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 |
|---|---|---|---|---|---|
CosyVerif/library | src/cosy/methods/user.lua | 1 | 12497 | return function (loader)
local Methods = {}
local Configuration = loader.load "cosy.configuration"
local Email = loader.load "cosy.email"
local I18n = loader.load "cosy.i18n"
local Parameters = loader.load "cosy.parameters"
local Password = loader.load "cosy.password"
local Token = loader.load "cosy.token"
local Json = loader.require "cjson".new ()
local Time = loader.require "socket".gettime
Configuration.load {
"cosy.nginx",
"cosy.methods",
"cosy.parameters",
"cosy.server",
}
local i18n = I18n.load {
"cosy.methods",
"cosy.server",
"cosy.library",
"cosy.parameters",
}
i18n._locale = Configuration.locale
function Methods.create (request, store, try_only)
Parameters.check (store, request, {
required = {
identifier = Parameters.user.new_identifier,
password = Parameters.password.checked,
email = Parameters.user.new_email,
tos_digest = Parameters.tos.digest,
locale = Parameters.locale,
},
optional = {
captcha = Parameters.captcha,
ip = Parameters.ip,
administration = Parameters.token.administration,
},
})
local email = store / "email" + request.email
email.identifier = request.identifier
if request.locale == nil then
request.locale = Configuration.locale
end
local user = store / "data" + request.identifier
user.checked = false
user.email = request.email
user.identifier = request.identifier
user.lastseen = Time ()
user.locale = request.locale
user.password = Password.hash (request.password)
user.tos_digest = request.tos_digest
user.reputation = Configuration.reputation.initial
user.status = "active"
user.type = "user"
local info = store / "info"
info ["#user"] = (info ["#user"] or 0) + 1
if not Configuration.dev_mode
and (request.captcha == nil or request.captcha == "")
and not request.administration then
error {
_ = i18n ["captcha:missing"],
key = "captcha"
}
end
if try_only then
return true
end
-- Captcha validation must be done only once,
-- so it must be __after__ the `try_only`.`
if request.captcha then
if not Configuration.dev_mode then
local url = "https://www.google.com/recaptcha/api/siteverify"
local body = "secret=" .. Configuration.recaptcha.private_key
.. "&response=" .. request.captcha
.. "&remoteip=" .. request.ip
local response, status = loader.request (url, body)
assert (status == 200)
response = Json.decode (response)
assert (response)
if not response.success then
error {
_ = i18n ["captcha:failure"],
}
end
end
elseif not request.administration then
error {
_ = i18n ["method:administration-only"],
}
end
Email.send {
locale = user.locale,
from = {
_ = i18n ["user:create:from"],
name = Configuration.http.hostname,
email = Configuration.server.email,
},
to = {
_ = i18n ["user:create:to"],
name = user.identifier,
email = user.email,
},
subject = {
_ = i18n ["user:create:subject"],
servername = Configuration.http.hostname,
identifier = user.identifier,
},
body = {
_ = i18n ["user:create:body"],
identifier = user.identifier,
token = Token.validation (user),
},
}
return {
authentication = Token.authentication (user),
}
end
function Methods.send_validation (request, store, try_only)
Parameters.check (store, request, {
required = {
authentication = Parameters.token.authentication,
},
})
local user = request.authentication.user
if try_only then
return true
end
Email.send {
locale = user.locale,
from = {
_ = i18n ["user:update:from"],
name = Configuration.http.hostname,
email = Configuration.server.email,
},
to = {
_ = i18n ["user:update:to"],
name = user.identifier,
email = user.email,
},
subject = {
_ = i18n ["user:update:subject"],
servername = Configuration.http.hostname,
identifier = user.identifier,
},
body = {
_ = i18n ["user:update:body"],
host = Configuration.http.hostname,
identifier = user.identifier,
token = Token.validation (user),
},
}
end
function Methods.validate (request, store)
Parameters.check (store, request, {
required = {
authentication = Parameters.token.authentication,
},
})
request.authentication.user.checked = true
end
function Methods.authenticate (request, store)
local ok, err = pcall (function ()
Parameters.check (store, request, {
required = {
user = Parameters.user.active,
password = Parameters.password,
},
})
end)
if not ok then
if request.__DESCRIBE then
error (err)
else
error {
_ = i18n ["user:authenticate:failure"],
}
end
end
local user = request.user
local verified = Password.verify (request.password, user.password)
if not verified then
error {
_ = i18n ["user:authenticate:failure"],
}
end
if type (verified) == "string" then
user.password = verified
end
user.lastseen = Time ()
return {
authentication = Token.authentication (user),
}
end
function Methods.authentified_as (request, store)
Parameters.check (store, request, {
optional = {
authentication = Parameters.token.authentication,
},
})
return {
identifier = request.authentication
and request.authentication.user.identifier
or nil,
}
end
function Methods.update (request, store, try_only)
Parameters.check (store, request, {
required = {
authentication = Parameters.token.authentication,
},
optional = {
avatar = Parameters.avatar,
email = Parameters.user.new_email,
homepage = Parameters.homepage,
locale = Parameters.locale,
name = Parameters.name,
organization = Parameters.organization,
password = Parameters.password.checked,
position = Parameters.position,
},
})
local user = request.authentication.user
if request.email then
local methods = loader.load "cosy.methods"
local oldemail = store / "email" / user.email
local newemail = store / "email" + request.email
newemail.identifier = oldemail.identifier
local _ = store / "email" - user.email
user.email = request.email
user.checked = false
methods.user.send_validation ({
authentication = Token.authentication (user),
try_only = try_only,
}, store)
end
if request.password then
user.password = Password.hash (request.password)
end
if request.position then
user.position = {
address = request.position.address,
latitude = request.position.latitude,
longitude = request.position.longitude,
}
end
if request.avatar then
user.avatar = {
full = request.avatar.normal,
icon = request.avatar.icon,
ascii = request.avatar.ascii,
}
end
for _, key in ipairs { "name", "homepage", "organization", "locale" } do
if request [key] then
user [key] = request [key]
end
end
return {
avatar = user.avatar,
checked = user.checked,
email = user.email,
homepage = user.homepage,
lastseen = user.lastseen,
locale = user.locale,
name = user.name,
organization = user.organization,
position = user.position,
identifier = user.identifier,
authentication = Token.authentication (user)
}
end
function Methods.information (request, store)
Parameters.check (store, request, {
required = {
user = Parameters.user,
},
})
local user = request.user
return {
avatar = user.avatar,
homepage = user.homepage,
name = user.name,
organization = user.organization,
position = user.position,
identifier = user.identifier,
}
end
function Methods.recover (request, store, try_only)
Parameters.check (store, request, {
required = {
validation = Parameters.token.validation,
password = Parameters.password.checked,
},
})
local user = request.validation.user
local token = Token.authentication (user)
local methods = loader.load "cosy.methods"
methods.user.update ({
user = token,
password = request.password,
try_only = try_only,
}, store)
return {
authentication = token,
}
end
function Methods.reset (request, store, try_only)
Parameters.check (store, request, {
required = {
email = Parameters.email,
},
})
local email = store / "email" / request.email
if email then
return
end
local user = store / "data" / email.identifier
if not user or user.type ~= "user" then
return
end
user.password = ""
if try_only then
return
end
Email.send {
locale = user.locale,
from = {
_ = i18n ["user:reset:from"],
name = Configuration.http.hostname,
email = Configuration.server.email,
},
to = {
_ = i18n ["user:reset:to"],
name = user.identifier,
email = user.email,
},
subject = {
_ = i18n ["user:reset:subject"],
servername = Configuration.http.hostname,
identifier = user.identifier,
},
body = {
_ = i18n ["user:reset:body"],
identifier = user.identifier,
validation = Token.validation (user),
},
}
end
function Methods.suspend (request, store)
Parameters.check (store, request, {
required = {
authentication = Parameters.token.authentication,
user = Parameters.user.active,
},
})
local origin = request.authentication.user
local user = request.user
if origin.identifier == user.identifier then
error {
_ = i18n ["user:suspend:self"],
}
end
local reputation = Configuration.reputation.suspend
if origin.reputation < reputation then
error {
_ = i18n ["user:suspend:not-enough"],
owned = origin.reputation,
required = reputation
}
end
origin.reputation = origin.reputation - reputation
user.status = "suspended"
end
function Methods.release (request, store)
Parameters.check (store, request, {
required = {
authentication = Parameters.token.authentication,
user = Parameters.user.suspended,
},
})
local origin = request.authentication.user
local user = request.user
if origin.identifier == user.identifier then
error {
_ = i18n ["user:release:self"],
}
end
local reputation = Configuration.reputation.release
if origin.reputation < reputation then
error {
_ = i18n ["user:suspend:not-enough"],
owned = origin.reputation,
required = reputation
}
end
origin.reputation = origin.reputation - reputation
user.status = "active"
end
function Methods.delete (request, store)
Parameters.check (store, request, {
required = {
authentication = Parameters.token.authentication,
},
})
local user = request.authentication.user
local _ = store / "email" - user.email
local _ = store / "data" - user.identifier
local info = store / "info"
info ["#user"] = info ["#user"] - 1
end
return Methods
end
| mit |
ncoe/rosetta | Extra_primes/Lua/extra.lua | 1 | 1617 | function next_prime_digit_number(n)
if n == 0 then
return 2
end
local r = n % 10
if r == 2 then
return n + 1
end
if r == 3 or r == 5 then
return n + 2
end
return 2 + next_prime_digit_number(math.floor(n / 10)) * 10
end
function is_prime(n)
if n < 2 then
return false
end
if n % 2 == 0 then
return n == 2
end
if n % 3 == 0 then
return n == 3
end
if n % 5 == 0 then
return n == 5
end
local wheel = { 4, 2, 4, 2, 4, 6, 2, 6 }
local p = 7
while true do
for w = 1, #wheel do
if p * p > n then
return true
end
if n % p == 0 then
return false
end
p = p + wheel[w]
end
end
end
function digit_sum(n)
local sum = 0
while n > 0 do
sum = sum + n % 10
n = math.floor(n / 10)
end
return sum
end
local limit1 = 10000
local limit2 = 1000000000
local last = 10
local p = 0
local n = 0
local extra_primes = {}
print("Extra primes under " .. limit1 .. ":")
while true do
p = next_prime_digit_number(p)
if p >= limit2 then
break
end
if is_prime(digit_sum(p)) and is_prime(p) then
n = n + 1
if p < limit1 then
print(string.format("%2d: %d", n, p))
end
extra_primes[n % last] = p
end
end
print(string.format("\nLast %d extra primes under %d:", last, limit2))
local i = last - 1
while i >= 0 do
print(string.format("%d: %d", n - i, extra_primes[(n - i) % last]))
i = i - 1
end
| mit |
nodemcu/nodemcu-firmware | lua_modules/ds3231/ds3231-web.lua | 7 | 1339 | local ds3231 = require('ds3231')
-- ESP-01 GPIO Mapping
local gpio0, gpio2 = 3, 4
local port = 80
local days = {
[1] = "Sunday",
[2] = "Monday",
[3] = "Tuesday",
[4] = "Wednesday",
[5] = "Thursday",
[6] = "Friday",
[7] = "Saturday"
}
local months = {
[1] = "January",
[2] = "Febuary",
[3] = "March",
[4] = "April",
[5] = "May",
[6] = "June",
[7] = "July",
[8] = "August",
[9] = "September",
[10] = "October",
[11] = "November",
[12] = "December"
}
do
i2c.setup(0, gpio0, gpio2, i2c.SLOW) -- call i2c.setup() only once
local srv = net.createServer(net.TCP)
srv:listen(port, function(conn)
local second, minute, hour, day, date, month, year = ds3231.getTime()
local prettyTime = string.format("%s, %s %s %s %s:%s:%s",
days[day], date, months[month], year, hour, minute, second)
conn:send("HTTP/1.1 200 OK\nContent-Type: text/html\nRefresh: 5\n\n" ..
"<!DOCTYPE HTML>" ..
"<html><body>" ..
"<b>ESP8266</b></br>" ..
"Time and Date: " .. prettyTime .. "<br>" ..
"Node ChipID : " .. node.chipid() .. "<br>" ..
"Node MAC : " .. wifi.sta.getmac() .. "<br>" ..
"Node Heap : " .. node.heap() .. "<br>" ..
"Timer Ticks : " .. tmr.now() .. "<br>" ..
"</html></body>")
conn:on("sent",function(sck) sck:close() end)
end)
end
| mit |
zynjec/darkstar | scripts/zones/Port_Windurst/npcs/Kususu.lua | 12 | 1113 | -----------------------------------
-- Area: Port Windurst
-- NPC: Kususu
-- 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 =
{
4641, 1165, 1, -- Diaga
4662, 7025, 1, -- Stoneskin
4664, 837, 1, -- Slow
4610, 585, 2, -- Cure II
4636, 140, 2, -- Banish
4646, 1165, 2, -- Banishga
4661, 2097, 2, -- Blink
4609, 61, 3, -- Cure
4615, 1363, 3, -- Curaga
4622, 180, 3, -- Poisona
4623, 324, 3, -- Paralyna
4624, 990, 3, -- Blindna
4631, 82, 3, -- Dia
4651, 219, 3, -- Protect
4656, 1584, 3, -- Shell
4663, 360, 3, -- Aquaveil
}
player:showText(npc, ID.text.KUSUSU_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 |
darklost/quick-ng | cocos/scripting/lua-bindings/auto/api/LayerMultiplex.lua | 7 | 1408 |
--------------------------------
-- @module LayerMultiplex
-- @extend Layer
-- @parent_module cc
--------------------------------
-- release the current layer and switches to another layer indexed by n.<br>
-- The current (old) layer will be removed from it's parent with 'cleanup=true'.<br>
-- param n The layer indexed by n will display.
-- @function [parent=#LayerMultiplex] switchToAndReleaseMe
-- @param self
-- @param #int n
-- @return LayerMultiplex#LayerMultiplex self (return value: cc.LayerMultiplex)
--------------------------------
-- Add a certain layer to LayerMultiplex.<br>
-- param layer A layer need to be added to the LayerMultiplex.
-- @function [parent=#LayerMultiplex] addLayer
-- @param self
-- @param #cc.Layer layer
-- @return LayerMultiplex#LayerMultiplex self (return value: cc.LayerMultiplex)
--------------------------------
-- Switches to a certain layer indexed by n.<br>
-- The current (old) layer will be removed from it's parent with 'cleanup=true'.<br>
-- param n The layer indexed by n will display.
-- @function [parent=#LayerMultiplex] switchTo
-- @param self
-- @param #int n
-- @return LayerMultiplex#LayerMultiplex self (return value: cc.LayerMultiplex)
--------------------------------
--
-- @function [parent=#LayerMultiplex] getDescription
-- @param self
-- @return string#string ret (return value: string)
return nil
| mit |
seem-sky/ph-open | libs/scripting/lua/script/AudioEngine.lua | 21 | 2392 | --Encapsulate SimpleAudioEngine to AudioEngine,Play music and sound effects.
local M = {}
local sharedEngine = SimpleAudioEngine:sharedEngine()
function M.stopAllEffects()
sharedEngine:stopAllEffects()
end
function M.getMusicVolume()
return sharedEngine:getBackgroundMusicVolume()
end
function M.isMusicPlaying()
return sharedEngine:isBackgroundMusicPlaying()
end
function M.getEffectsVolume()
return sharedEngine:getEffectsVolume()
end
function M.setMusicVolume(volume)
sharedEngine:setBackgroundMusicVolume(volume)
end
function M.stopEffect(handle)
sharedEngine:stopEffect(handle)
end
function M.stopMusic(isReleaseData)
local releaseDataValue = false
if nil ~= isReleaseData then
releaseDataValue = isReleaseData
end
sharedEngine:stopBackgroundMusic(releaseDataValue)
end
function M.playMusic(filename, isLoop)
local loopValue = false
if nil ~= isLoop then
loopValue = isLoop
end
sharedEngine:playBackgroundMusic(filename, loopValue)
end
function M.pauseAllEffects()
sharedEngine:pauseAllEffects()
end
function M.preloadMusic(filename)
sharedEngine:preloadBackgroundMusic(filename)
end
function M.resumeMusic()
sharedEngine:resumeBackgroundMusic()
end
function M.playEffect(filename, isLoop)
local loopValue = false
if nil ~= isLoop then
loopValue = isLoop
end
return sharedEngine:playEffect(filename, loopValue)
end
function M.rewindMusic()
sharedEngine:rewindBackgroundMusic()
end
function M.willPlayMusic()
return sharedEngine:willPlayBackgroundMusic()
end
function M.unloadEffect(filename)
sharedEngine:unloadEffect(filename)
end
function M.preloadEffect(filename)
sharedEngine:preloadEffect(filename)
end
function M.setEffectsVolume(volume)
sharedEngine:setEffectsVolume(volume)
end
function M.pauseEffect(handle)
sharedEngine:pauseEffect(handle)
end
function M.resumeAllEffects(handle)
sharedEngine:resumeAllEffects()
end
function M.pauseMusic()
sharedEngine:pauseBackgroundMusic()
end
function M.resumeEffect(handle)
sharedEngine:resumeEffect(handle)
end
local modename = "AudioEngine"
local proxy = {}
local mt = {
__index = M,
__newindex = function (t ,k ,v)
print("attemp to update a read-only table")
end
}
setmetatable(proxy,mt)
_G[modename] = proxy
package.loaded[modename] = proxy
| mit |
Colettechan/darkstar | scripts/zones/Norg/npcs/Quntsu-Nointsu.lua | 27 | 2965 | -----------------------------------
-- Area: Norg
-- NPC: Quntsu-Nointsu
-- Title Change NPC
-- @pos -67 -1 34 252
-----------------------------------
require("scripts/globals/titles");
local title2 = { HONORARY_DOCTORATE_MAJORING_IN_TONBERRIES , BUSHIDO_BLADE , BLACK_MARKETEER , CRACKER_OF_THE_SECRET_CODE ,
LOOKS_SUBLIME_IN_A_SUBLIGAR , LOOKS_GOOD_IN_LEGGINGS , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }
local title3 = { APPRENTICE_SOMMELIER , TREASUREHOUSE_RANSACKER , HEIR_OF_THE_GREAT_WATER , PARAGON_OF_SAMURAI_EXCELLENCE ,
PARAGON_OF_NINJA_EXCELLENCE , GUIDER_OF_SOULS_TO_THE_SANCTUARY , BEARER_OF_BONDS_BEYOND_TIME , FRIEND_OF_THE_OPOOPOS ,
PENTACIDE_PERPETRATOR , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }
local title4 = { BEARER_OF_THE_WISEWOMANS_HOPE , BEARER_OF_THE_EIGHT_PRAYERS , LIGHTWEAVER , DESTROYER_OF_ANTIQUITY , SEALER_OF_THE_PORTAL_OF_THE_GODS ,
BURIER_OF_THE_ILLUSION , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }
local title5 = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }
local title6 = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }
local title7 = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x03F3,npcUtil.genTmask(player,title2),npcUtil.genTmask(player,title3),npcUtil.genTmask(player,title4),npcUtil.genTmask(player,title5),npcUtil.genTmask(player,title6),npcUtil.genTmask(player,title7),1 ,player:getGil());
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==0x03F3) then
if (option > 0 and option <29) then
if (player:delGil(200)) then
player:setTitle( title2[option] )
end
elseif (option > 256 and option <285) then
if (player:delGil(300)) then
player:setTitle( title3[option - 256] )
end
elseif (option > 512 and option < 541) then
if (player:delGil(400)) then
player:setTitle( title4[option - 512] )
end
end
end
end; | gpl-3.0 |
Colettechan/darkstar | scripts/zones/Wajaom_Woodlands/npcs/_1f1.lua | 13 | 1097 | -----------------------------------
-- Area: Wajaom Woodlands
-- NPC: Engraved Tablet
-- @pos -64 -11 -641 51
-----------------------------------
require("scripts/globals/keyitems");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:hasKeyItem(SICKLEMOON_SALT)) then
player:startEvent(0x0202);
else
player:startEvent(0x0204);
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 == 0x0202 and option == 1) then
player:delKeyItem(SICKLEMOON_SALT);
end
end; | gpl-3.0 |
shamangary/DeepCD | main/train/fun_DeepCD_2S.lua | 1 | 11296 | require 'nn'
require '../utils.lua'
require 'image'
require 'optim'
require './DistanceRatioCriterion_allW.lua'
require 'cudnn'
require 'cutorch'
require 'cunn'
require './allWeightedMSECriterion.lua'
require './DataDependentModule.lua'
local matio = require 'matio'
des_type = arg[1]
if des_type == 'rb' then
dim1 = tonumber(arg[2])
bits2 = tonumber(arg[3])
elseif des_type == 'bb' then
bits1 = tonumber(arg[2])
bits2 = tonumber(arg[3])
end
w_com = tonumber(arg[4])
ws_lead = tonumber(arg[5])
ws_pro = tonumber(arg[6])
name = arg[7]
if arg[8] == 'true' then
isDDM = true
elseif arg[8] == 'false' then
isDDM = false
end
DDM_LR = tonumber(arg[9])
pT = {
--dim1 = 128,
--bits2 = 256,
--w_com= 1.41,
--ws_lead = 1,
--ws_pro = 5,
scal_sigmoid = 100,
isNorm = true,
--isSTN = false,
--name = 'liberty',
batch_size = 128,
num_triplets = 1280000,
max_epoch = 100
}
if des_type == 'rb' then
pT.dim1 = dim1
pT.bits2 = bits2
elseif des_type == 'bb' then
pT.bits1 = bits1
pT.bits2 = bits2
end
pT.w_com = w_com
pT.ws_lead = ws_lead
pT.ws_pro = ws_pro
pT.name = name
pT.isDDM = isDDM
pT.DDM_LR = DDM_LR
-- optim parameters
optimState = {
learningRate = 0.1,
weightDecay = 1e-4,
momentum = 0.9,
learningRateDecay = 1e-6
}
pT.optimState = optimState
if pT.isDDM then
addName = 'DDM_'
else
addName = ''
end
if des_type == 'rb' then
folder_name = './train_epoch/DeepCD_2S_'..addName..pT.dim1..'dim1_'..pT.bits2..'bits2_'..pT.name
elseif des_type == 'bb' then
folder_name = './train_epoch/DeepCD_2S_'..addName..pT.bits1..'bits1_'..pT.bits2..'bits2_'..pT.name
end
print(pT)
os.execute("mkdir -p " .. folder_name)
if pT.isDDM then
os.execute("mkdir -p " .. folder_name.."/DDM_vec/")
end
torch.save(folder_name..'/ParaTable_DeepCD_2S_'..addName..pT.name..'.t7',pT)
------------------------------------------------------------------------------------------------
-- number of threads
torch.setnumthreads(13)
-- read training data, save mu and sigma & normalize
traind = read_brown_data('./UBCdataset/'..pT.name)
stats = get_stats(traind)
print(stats)
if pT.isNorm then
norm_data(traind,stats)
end
print("==> read the dataset")
-- generate random triplets for training data
training_triplets = generate_triplets(traind, pT.num_triplets)
print("==> created the tests")
------------------------------------------------------------------------------------------------
if des_type == 'rb' then
paths.dofile('../models/model_DeepCD_2stream.lua')
elseif des_type == 'bb' then
paths.dofile('../models/model_DeepCD_2S_binary_binary.lua')
end
model1 = createModel(pT)
model1:training()
-- clone the other two networks in the triplet
model2 = model1:clone('weight', 'bias','gradWeight','gradBias')
model3 = model1:clone('weight', 'bias','gradWeight','gradBias')
-- add them to a parallel table
prl = nn.ParallelTable()
prl:add(model1)
prl:add(model2)
prl:add(model3)
prl:cuda()
------------------------------------------------------------------------------------------------
mlp= nn.Sequential()
mlp:add(prl)
-- get feature distances
cc = nn.ConcatTable()
-- feats 1 with 2 leading
cnn_left1_lead = nn.Sequential()
cnnneg1_dist_lead = nn.ConcatTable()
a_neg1_lead = nn.Sequential()
a_neg1_lead:add(nn.SelectTable(1))
a_neg1_lead:add(nn.SelectTable(1))
b_neg1_lead = nn.Sequential()
b_neg1_lead:add(nn.SelectTable(2))
b_neg1_lead:add(nn.SelectTable(1))
cnnneg1_dist_lead:add(a_neg1_lead)
cnnneg1_dist_lead:add(b_neg1_lead)
cnn_left1_lead:add(cnnneg1_dist_lead)
cnn_left1_lead:add(nn.PairwiseDistance(2))
cnn_left1_lead:add(nn.View(pT.batch_size ,1))
cnn_left1_lead:cuda()
cc:add(cnn_left1_lead)
-- feats 1 with 2 completing
cnn_left1_com = nn.Sequential()
cnnneg1_dist_com = nn.ConcatTable()
a_neg1_com = nn.Sequential()
a_neg1_com:add(nn.SelectTable(1))
a_neg1_com:add(nn.SelectTable(2))
b_neg1_com = nn.Sequential()
b_neg1_com:add(nn.SelectTable(2))
b_neg1_com:add(nn.SelectTable(2))
cnnneg1_dist_com:add(a_neg1_com)
cnnneg1_dist_com:add(b_neg1_com)
cnn_left1_com:add(cnnneg1_dist_com)
cnn_left1_com:add(nn.PairwiseDistance(2))
cnn_left1_com:add(nn.View(pT.batch_size ,1))
cnn_left1_com:cuda()
cc:add(cnn_left1_com)
-- feats 2 with 3 leading
cnn_left2_lead = nn.Sequential()
cnnneg2_dist_lead = nn.ConcatTable()
a_neg2_lead = nn.Sequential()
a_neg2_lead:add(nn.SelectTable(2))
a_neg2_lead:add(nn.SelectTable(1))
b_neg2_lead = nn.Sequential()
b_neg2_lead:add(nn.SelectTable(3))
b_neg2_lead:add(nn.SelectTable(1))
cnnneg2_dist_lead:add(a_neg2_lead)
cnnneg2_dist_lead:add(b_neg2_lead)
cnn_left2_lead:add(cnnneg2_dist_lead)
cnn_left2_lead:add(nn.PairwiseDistance(2))
cnn_left2_lead:add(nn.View(pT.batch_size,1))
cnn_left2_lead:cuda()
cc:add(cnn_left2_lead)
-- feats 2 with 3 completing
cnn_left2_com = nn.Sequential()
cnnneg2_dist_com = nn.ConcatTable()
a_neg2_com = nn.Sequential()
a_neg2_com:add(nn.SelectTable(2))
a_neg2_com:add(nn.SelectTable(2))
b_neg2_com = nn.Sequential()
b_neg2_com:add(nn.SelectTable(3))
b_neg2_com:add(nn.SelectTable(2))
cnnneg2_dist_com:add(a_neg2_com)
cnnneg2_dist_com:add(b_neg2_com)
cnn_left2_com:add(cnnneg2_dist_com)
cnn_left2_com:add(nn.PairwiseDistance(2))
cnn_left2_com:add(nn.View(pT.batch_size ,1))
cnn_left2_com:cuda()
cc:add(cnn_left2_com)
-- feats 1 with 3 leading
cnn_right_lead = nn.Sequential()
cnnpos_dist_lead = nn.ConcatTable()
a_pos_lead = nn.Sequential()
a_pos_lead:add(nn.SelectTable(1))
a_pos_lead:add(nn.SelectTable(1))
b_pos_lead = nn.Sequential()
b_pos_lead:add(nn.SelectTable(3))
b_pos_lead:add(nn.SelectTable(1))
cnnpos_dist_lead:add(a_pos_lead)
cnnpos_dist_lead:add(b_pos_lead)
cnn_right_lead:add(cnnpos_dist_lead)
cnn_right_lead:add(nn.PairwiseDistance(2))
cnn_right_lead:add(nn.View(pT.batch_size ,1))
cnn_right_lead:cuda()
cc:add(cnn_right_lead)
-- feats 1 with 3 completing
cnn_right_com = nn.Sequential()
cnnpos_dist_com = nn.ConcatTable()
a_pos_com = nn.Sequential()
a_pos_com:add(nn.SelectTable(1))
a_pos_com:add(nn.SelectTable(2))
b_pos_com = nn.Sequential()
b_pos_com:add(nn.SelectTable(3))
b_pos_com:add(nn.SelectTable(2))
cnnpos_dist_com:add(a_pos_com)
cnnpos_dist_com:add(b_pos_com)
cnn_right_com:add(cnnpos_dist_com)
cnn_right_com:add(nn.PairwiseDistance(2))
cnn_right_com:add(nn.View(pT.batch_size ,1))
cnn_right_com:cuda()
cc:add(cnn_right_com)
cc:cuda()
mlp:add(cc)
------------------------------------------------------------------------------------------------
last_layer = nn.ConcatTable()
-- select leading min negative distance inside the triplet
mined_neg = nn.Sequential()
mining_layer = nn.ConcatTable()
mining_layer:add(nn.SelectTable(1))
mining_layer:add(nn.SelectTable(3))
mined_neg:add(mining_layer)
mined_neg:add(nn.JoinTable(2))
mined_neg:add(nn.Min(2))
mined_neg:add(nn.View(pT.batch_size ,1))
last_layer:add(mined_neg)
-- add leading positive distance
pos_layer = nn.Sequential()
pos_layer:add(nn.SelectTable(5))
pos_layer:add(nn.View(pT.batch_size ,1))
last_layer:add(pos_layer)
------------------------------------------------------------------------------------------------
a_DDM = nn.Identity()
output_layer_DDM = nn.Linear(pT.batch_size*2,pT.batch_size)
output_layer_DDM.weight:fill(0)
output_layer_DDM.bias:fill(1)
b_DDM = nn.Sequential():add(nn.Reshape(pT.batch_size*2,false)):add(output_layer_DDM):add(nn.Sigmoid())
DDM_ct = nn.ConcatTable():add(a_DDM:clone()):add(b_DDM:clone())
DDM_layer = nn.Sequential():add(DDM_ct):add(nn.DataDependentModule(pT.DDM_LR))
------------------------------------------------------------------------------------------------
--add neg1 (real,binary) distance
neg1_RB_layer = nn.Sequential()
temp_neg1_RB = nn.ConcatTable()
S1_neg1 = nn.Sequential()
S1_neg1:add(nn.SelectTable(1))
S2_neg1 = nn.Sequential()
S2_neg1:add(nn.SelectTable(2))
temp_neg1_RB:add(S1_neg1)
temp_neg1_RB:add(S2_neg1)
neg1_RB_layer:add(temp_neg1_RB)
if pT.isDDM then
neg1_RB_layer:add(nn.JoinTable(2))
neg1_RB_layer:add(DDM_layer)
neg1_RB_layer:add(nn.SplitTable(2))
end
neg1_RB_layer:add(nn.CMulTable())
neg1_RB_layer:add(nn.Sqrt())
neg1_RB_layer:add(nn.View(pT.batch_size ,1))
neg1_RB_layer:cuda()
last_layer:add(neg1_RB_layer)
--add neg2 (real,binary) distance
neg2_RB_layer = nn.Sequential()
temp_neg2_RB = nn.ConcatTable()
S1_neg2 = nn.Sequential()
S1_neg2:add(nn.SelectTable(3))
S2_neg2 = nn.Sequential()
S2_neg2:add(nn.SelectTable(4))
temp_neg2_RB:add(S1_neg2)
temp_neg2_RB:add(S2_neg2 )
neg2_RB_layer:add(temp_neg2_RB)
if pT.isDDM then
neg2_RB_layer:add(nn.JoinTable(2))
neg2_RB_layer:add(DDM_layer)
neg2_RB_layer:add(nn.SplitTable(2))
end
neg2_RB_layer:add(nn.CMulTable())
neg2_RB_layer:add(nn.Sqrt())
neg2_RB_layer:add(nn.View(pT.batch_size ,1))
neg2_RB_layer:cuda()
last_layer:add(neg2_RB_layer)
--add pos (real,binary) distance
pos_RB_layer = nn.Sequential()
temp_pos_RB = nn.ConcatTable()
S1_pos = nn.Sequential()
S1_pos:add(nn.SelectTable(5))
S2_pos = nn.Sequential()
S2_pos:add(nn.SelectTable(6))
temp_pos_RB:add(S1_pos)
temp_pos_RB:add(S2_pos)
pos_RB_layer:add(temp_pos_RB)
pos_RB_layer:add(nn.CMulTable())
pos_RB_layer:add(nn.Sqrt())
pos_RB_layer:add(nn.View(pT.batch_size ,1))
pos_RB_layer:cuda()
last_layer:add(pos_RB_layer)
------------------------------------------------------------------------------------------------
mlp:add(last_layer)
mlp:add(nn.JoinTable(2))
mlp:cuda()
------------------------------------------------------------------------------------------------
-- setup the criterion: ratio of min-negative to positive
epoch = 1
x=torch.zeros(pT.batch_size,1,32,32):cuda()
y=torch.zeros(pT.batch_size,1,32,32):cuda()
z=torch.zeros(pT.batch_size,1,32,32):cuda()
parameters, gradParameters = mlp:getParameters()
-- main training loop
Loss = torch.zeros(1,pT.max_epoch)
w = torch.zeros(128,5)
w[{{},{1,2}}]:fill(pT.ws_lead)
w[{{},{3,5}}]:fill(pT.ws_pro)
crit=nn.DistanceRatioCriterion_allW(w):cuda()
for epoch=epoch, pT.max_epoch do
Gerr = 0
shuffle = torch.randperm(pT.num_triplets)
nbatches = pT.num_triplets/pT.batch_size
for k=1,nbatches-1 do
xlua.progress(k+1, nbatches)
s = shuffle[{ {k*pT.batch_size,k*pT.batch_size+pT.batch_size} }]
for i=1,pT.batch_size do
x[i] = traind.patches32[training_triplets[s[i]][1]]
y[i] = traind.patches32[training_triplets[s[i]][2]]
z[i] = traind.patches32[training_triplets[s[i]][3]]
end
local feval = function(f)
if f ~= parameters then parameters:copy(f) end
gradParameters:zero()
inputs = {x,y,z}
local outputs = mlp:forward(inputs)
local f = crit:forward(outputs, 1)
Gerr = Gerr+f
local df_do = crit:backward(outputs)
mlp:backward(inputs, df_do)
return f,gradParameters
end
optim.sgd(feval, parameters, optimState)
end
loss = Gerr/nbatches
Loss[{{1},{epoch}}] = loss
if pT.isDDM then
print(DDM_vec)
matio.save(folder_name..'/DDM_vec/DDM_vec_epoch'..epoch..'.mat',{DDM_vec=DDM_vec:double()})
end
print('==> epoch '..epoch)
print(loss)
print('')
--remain = math.fmod(epoch,3)
--if epoch == 1 or remain ==0 then
net_save = mlp:get(1):get(1):clone()
torch.save(folder_name..'/NET_DeepCD_2S_'..addName..pT.name..'_epoch'..epoch..'.t7',net_save:clearState())
--end
end
torch.save(folder_name..'/Loss_DeepCD_2S_'..addName..pT.name..'.t7',Loss)
| mit |
Vadavim/jsr-darkstar | scripts/zones/LaLoff_Amphitheater/npcs/qm1_2.lua | 17 | 2450 | -----------------------------------
-- Area: LaLoff_Amphitheater
-- NPC: Shimmering Circle (BCNM Entrances)
-------------------------------------
package.loaded["scripts/zones/LaLoff_Amphitheater/TextIDs"] = nil;
package.loaded["scripts/globals/bcnm"] = nil;
-------------------------------------
require("scripts/globals/bcnm");
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
require("scripts/globals/missions");
require("scripts/zones/LaLoff_Amphitheater/TextIDs");
-- Death cutscenes:
-- player:startEvent(0x7d01,1,instance:getFastestTime(),1,instance:getTimeInside(),1,0,0); -- hume
-- player:startEvent(0x7d01,1,instance:getFastestTime(),1,instance:getTimeInside(),1,1,0); -- taru
-- player:startEvent(0x7d01,1,instance:getFastestTime(),1,instance:getTimeInside(),1,2,0); -- mithra
-- player:startEvent(0x7d01,1,instance:getFastestTime(),1,instance:getTimeInside(),1,3,0); -- elvaan
-- player:startEvent(0x7d01,1,instance:getFastestTime(),1,instance:getTimeInside(),1,4,0); -- galka
-- player:startEvent(0x7d01,1,instance:getFastestTime(),1,instance:getTimeInside(),1,5,0); -- divine might
-- param 1: entrance #
-- param 2: fastest time
-- param 3: unknown
-- param 4: clear time
-- param 5: zoneid
-- param 6: exit cs (0-4 AA, 5 DM, 6-10 neo AA, 11 neo DM)
-- param 7: skip (0 - no skip, 1 - prompt, 2 - force)
-- param 8: 0
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (TradeBCNM(player,player:getZoneID(),trade,npc)) then
return;
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (EventTriggerBCNM(player,npc)) then
return;
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("onUpdate CSID: %u",csid);
-- printf("onUpdate RESULT: %u",option);
if (EventUpdateBCNM(player,csid,option,2)) then
return;
end
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("onFinish CSID: %u",csid);
-- printf("onFinish RESULT: %u",option);
if (EventFinishBCNM(player,csid,option)) then
return;
end
end; | gpl-3.0 |
dani-sj/telecreed | plugins/stats.lua | 56 | 3988 | 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() == 'nod32' 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 /nod32 ")
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] == "nod32" 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) (nod32)",-- Put everything you like :)
"^[!/]([Tt]nod32)"-- Put everything you like :)
},
run = run
}
end
| gpl-2.0 |
aleksijuvani/premake-core | modules/gmake2/tests/test_gmake2_linking.lua | 2 | 5886 | --
-- test_gmake2_linking.lua
-- Validate the link step generation for makefiles.
-- (c) 2016-2017 Jason Perkins, Blizzard Entertainment and the Premake project
--
local suite = test.declare("gmake2_linking")
local p = premake
local gmake2 = p.modules.gmake2
local project = p.project
--
-- Setup and teardown
--
local wks, prj
function suite.setup()
_OS = "linux"
wks, prj = test.createWorkspace()
end
local function prepare(calls)
local cfg = test.getconfig(prj, "Debug")
local toolset = p.tools.gcc
p.callarray(gmake2.cpp, calls, cfg, toolset)
end
--
-- Check link command for a shared C++ library.
--
function suite.links_onCppSharedLib()
kind "SharedLib"
prepare { "ldFlags", "linkCmd" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -shared -Wl,-soname=libMyProject.so -s
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
]]
end
function suite.links_onMacOSXCppSharedLib()
_OS = "macosx"
kind "SharedLib"
prepare { "ldFlags", "linkCmd" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -dynamiclib -Wl,-install_name,@rpath/libMyProject.dylib -Wl,-x
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
]]
end
--
-- Check link command for a shared C library.
--
function suite.links_onCSharedLib()
language "C"
kind "SharedLib"
prepare { "ldFlags", "linkCmd" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -shared -Wl,-soname=libMyProject.so -s
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
]]
end
--
-- Check link command for a static library.
--
function suite.links_onStaticLib()
kind "StaticLib"
prepare { "ldFlags", "linkCmd" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -s
LINKCMD = $(AR) -rcs "$@" $(OBJECTS)
]]
end
--
-- Check link command for the Utility kind.
--
-- Utility projects should only run custom commands, and perform no linking.
--
function suite.links_onUtility()
kind "Utility"
prepare { "linkCmd" }
test.capture [[
LINKCMD =
]]
end
--
-- Check link command for a Mac OS X universal static library.
--
function suite.links_onMacUniversalStaticLib()
architecture "universal"
kind "StaticLib"
prepare { "ldFlags", "linkCmd" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -s
LINKCMD = libtool -o "$@" $(OBJECTS)
]]
end
--
-- Check a linking to a sibling static library.
--
function suite.links_onSiblingStaticLib()
links "MyProject2"
test.createproject(wks)
kind "StaticLib"
location "build"
prepare { "ldFlags", "libs", "ldDeps" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -s
LIBS += build/bin/Debug/libMyProject2.a
LDDEPS += build/bin/Debug/libMyProject2.a
]]
end
--
-- Check a linking to a sibling shared library.
--
function suite.links_onSiblingSharedLib()
links "MyProject2"
test.createproject(wks)
kind "SharedLib"
location "build"
prepare { "ldFlags", "libs", "ldDeps" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -s
LIBS += build/bin/Debug/libMyProject2.so
LDDEPS += build/bin/Debug/libMyProject2.so
]]
end
--
-- Check a linking to a sibling shared library using -l and -L.
--
function suite.links_onSiblingSharedLib()
links "MyProject2"
flags { "RelativeLinks" }
test.createproject(wks)
kind "SharedLib"
location "build"
prepare { "ldFlags", "libs", "ldDeps" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -Lbuild/bin/Debug -Wl,-rpath,'$$ORIGIN/../../build/bin/Debug' -s
LIBS += -lMyProject2
LDDEPS += build/bin/Debug/libMyProject2.so
]]
end
function suite.links_onMacOSXSiblingSharedLib()
_OS = "macosx"
links "MyProject2"
flags { "RelativeLinks" }
test.createproject(wks)
kind "SharedLib"
location "build"
prepare { "ldFlags", "libs", "ldDeps" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -Lbuild/bin/Debug -Wl,-rpath,'@loader_path/../../build/bin/Debug' -Wl,-x
LIBS += -lMyProject2
LDDEPS += build/bin/Debug/libMyProject2.dylib
]]
end
--
-- Check a linking multiple siblings.
--
function suite.links_onMultipleSiblingStaticLib()
links "MyProject2"
links "MyProject3"
test.createproject(wks)
kind "StaticLib"
location "build"
test.createproject(wks)
kind "StaticLib"
location "build"
prepare { "ldFlags", "libs", "ldDeps" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -s
LIBS += build/bin/Debug/libMyProject2.a build/bin/Debug/libMyProject3.a
LDDEPS += build/bin/Debug/libMyProject2.a build/bin/Debug/libMyProject3.a
]]
end
--
-- Check a linking multiple siblings with link groups enabled.
--
function suite.links_onSiblingStaticLibWithLinkGroups()
links "MyProject2"
links "MyProject3"
linkgroups "On"
test.createproject(wks)
kind "StaticLib"
location "build"
test.createproject(wks)
kind "StaticLib"
location "build"
prepare { "ldFlags", "libs", "ldDeps" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -s
LIBS += -Wl,--start-group build/bin/Debug/libMyProject2.a build/bin/Debug/libMyProject3.a -Wl,--end-group
LDDEPS += build/bin/Debug/libMyProject2.a build/bin/Debug/libMyProject3.a
]]
end
--
-- When referencing an external library via a path, the directory
-- should be added to the library search paths, and the library
-- itself included via an -l flag.
--
function suite.onExternalLibraryWithPath()
location "MyProject"
links { "libs/SomeLib" }
prepare { "ldFlags", "libs" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -L../libs -s
LIBS += -lSomeLib
]]
end
--
-- When referencing an external library with a period in the
-- file name make sure it appears correctly in the LIBS
-- directive. Currently the period and everything after it
-- is stripped
--
function suite.onExternalLibraryWithPath()
location "MyProject"
links { "libs/SomeLib-1.1" }
prepare { "libs", }
test.capture [[
LIBS += -lSomeLib-1.1
]]
end
| bsd-3-clause |
Colettechan/darkstar | scripts/globals/items/slice_of_giant_sheep_meat.lua | 18 | 1350 | -----------------------------------------
-- ID: 4372
-- Item: slice_of_giant_sheep_meat
-- Food Effect: 5Min, Galka only
-----------------------------------------
-- Strength 2
-- Intelligence -4
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:getRace() ~= 8) then
result = 247;
end
if (target:getMod(MOD_EAT_RAW_MEAT) == 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,4372);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_STR, 2);
target:addMod(MOD_INT, -4);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_STR, 2);
target:delMod(MOD_INT, -4);
end;
| gpl-3.0 |
reaperrr/OpenRA | mods/ra/maps/allies-04/allies04-AI.lua | 7 | 7111 | --[[
Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
This file is part of OpenRA, which is free software. It is made
available to you under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version. For more
information, see COPYING.
]]
IdlingUnits = { }
Yaks = { }
AttackGroupSizes =
{
easy = 6,
normal = 8,
hard = 10,
tough = 12
}
AttackDelays =
{
easy = { DateTime.Seconds(4), DateTime.Seconds(9) },
normal = { DateTime.Seconds(2), DateTime.Seconds(7) },
hard = { DateTime.Seconds(1), DateTime.Seconds(5) },
tough = { DateTime.Seconds(1), DateTime.Seconds(5) }
}
AttackRallyPoints =
{
{ SovietRally1.Location, SovietRally3.Location, SovietRally5.Location, SovietRally4.Location, SovietRally13.Location, PlayerBase.Location },
{ SovietRally7.Location, SovietRally10.Location, PlayerBase.Location },
{ SovietRally1.Location, SovietRally3.Location, SovietRally5.Location, SovietRally4.Location, SovietRally12.Location, PlayerBase.Location },
{ SovietRally7.Location, ParadropPoint1.Location, PlayerBase.Location },
{ SovietRally8.Location, SovietRally9.Location, ParadropPoint1.Location, PlayerBase.Location, }
}
SovietInfantryTypes = { "e1", "e1", "e2" }
SovietVehicleTypes = { "3tnk", "3tnk", "3tnk", "ftrk", "ftrk", "apc" }
SovietAircraftType = { "yak" }
AttackOnGoing = false
HoldProduction = false
HarvesterKilled = false
Powr1 = { name = "powr", pos = CPos.New(47, 21), prize = 500, exists = true }
Barr = { name = "barr", pos = CPos.New(53, 26), prize = 400, exists = true }
Proc = { name = "proc", pos = CPos.New(54, 21), prize = 1400, exists = true }
Weap = { name = "weap", pos = CPos.New(48, 28), prize = 2000, exists = true }
Powr2 = { name = "powr", pos = CPos.New(51, 21), prize = 500, exists = true }
Powr3 = { name = "powr", pos = CPos.New(46, 25), prize = 500, exists = true }
Powr4 = { name = "powr", pos = CPos.New(49, 21), prize = 500, exists = true }
Ftur1 = { name = "powr", pos = CPos.New(56, 27), prize = 600, exists = true }
Ftur2 = { name = "powr", pos = CPos.New(51, 32), prize = 600, exists = true }
Ftur3 = { name = "powr", pos = CPos.New(54, 30), prize = 600, exists = true }
Afld1 = { name = "afld", pos = CPos.New(43, 23), prize = 500, exists = true }
Afld2 = { name = "afld", pos = CPos.New(43, 21), prize = 500, exists = true }
BaseBuildings = { Powr1, Barr, Proc, Weap, Powr2, Powr3, Powr4, Ftur1, Ftur2, Ftur3, Afld1, Afld2 }
InitialBase = { Barracks, Refinery, PowerPlant1, PowerPlant2, PowerPlant3, PowerPlant4, Warfactory, Flametur1, Flametur2, Flametur3, Airfield1, Airfield2 }
BuildBase = function()
if Conyard.IsDead or Conyard.Owner ~= ussr then
return
elseif Harvester.IsDead and ussr.Resources <= 299 then
return
end
for i,v in ipairs(BaseBuildings) do
if not v.exists then
BuildBuilding(v)
return
end
end
Trigger.AfterDelay(DateTime.Seconds(10), BuildBase)
end
BuildBuilding = function(building)
Trigger.AfterDelay(Actor.BuildTime(building.name), function()
local actor = Actor.Create(building.name, true, { Owner = ussr, Location = building.pos })
ussr.Cash = ussr.Cash - building.prize
building.exists = true
Trigger.OnKilled(actor, function() building.exists = false end)
Trigger.OnDamaged(actor, function(building)
if building.Owner == ussr and building.Health < building.MaxHealth * 3/4 then
building.StartBuildingRepairs()
DefendActor(actor)
end
end)
Trigger.AfterDelay(DateTime.Seconds(10), BuildBase)
end)
end
SetupAttackGroup = function()
local units = { }
for i = 0, AttackGroupSize, 1 do
if #IdlingUnits == 0 then
return units
end
local number = Utils.RandomInteger(1, #IdlingUnits)
if IdlingUnits[number] and not IdlingUnits[number].IsDead then
units[i] = IdlingUnits[number]
table.remove(IdlingUnits, number)
end
end
return units
end
SendAttack = function()
if Attacking then
return
end
Attacking = true
HoldProduction = true
local units = SetupAttackGroup()
local path = Utils.Random(AttackRallyPoints)
Utils.Do(units, function(unit)
unit.Patrol(path)
IdleHunt(unit)
end)
Trigger.OnAllRemovedFromWorld(units, function()
Attacking = false
HoldProduction = false
end)
end
ProtectHarvester = function(unit)
DefendActor(unit)
Trigger.OnKilled(unit, function() HarvesterKilled = true end)
end
DefendActor = function(unit)
Trigger.OnDamaged(unit, function(self, attacker)
if AttackOnGoing then
return
end
AttackOnGoing = true
local Guards = SetupAttackGroup()
if #Guards <= 0 then
AttackOnGoing = false
return
end
Utils.Do(Guards, function(unit)
if not self.IsDead then
unit.AttackMove(self.Location)
end
IdleHunt(unit)
end)
Trigger.OnAllRemovedFromWorld(Guards, function() AttackOnGoing = false end)
end)
end
InitAIUnits = function()
IdlingUnits = ussr.GetGroundAttackers()
DefendActor(Conyard)
for i,v in ipairs(InitialBase) do
DefendActor(v)
Trigger.OnDamaged(v, function(building)
if building.Owner == ussr and building.Health < building.MaxHealth * 3/4 then
building.StartBuildingRepairs()
end
end)
Trigger.OnKilled(v, function()
BaseBuildings[i].exists = false
end)
end
end
ProduceInfantry = function()
if HoldProduction then
Trigger.AfterDelay(DateTime.Minutes(1), ProduceInfantry)
return
end
-- See AttackDelay in WorldLoaded
local delay = Utils.RandomInteger(AttackDelay[1], AttackDelay[2])
local toBuild = { Utils.Random(SovietInfantryTypes) }
ussr.Build(toBuild, function(unit)
IdlingUnits[#IdlingUnits + 1] = unit[1]
Trigger.AfterDelay(delay, ProduceInfantry)
-- See AttackGroupSize in WorldLoaded
if #IdlingUnits >= (AttackGroupSize * 2.5) then
SendAttack()
end
end)
end
ProduceVehicles = function()
if HoldProduction then
Trigger.AfterDelay(DateTime.Minutes(1), ProduceVehicles)
return
end
-- See AttackDelay in WorldLoaded
local delay = Utils.RandomInteger(AttackDelay[1], AttackDelay[2])
if HarvesterKilled then
ussr.Build({ "harv" }, function(harv)
ProtectHarvester(harv[1])
HarvesterKilled = false
Trigger.AfterDelay(delay, ProduceVehicles)
end)
else
local toBuild = { Utils.Random(SovietVehicleTypes) }
ussr.Build(toBuild, function(unit)
IdlingUnits[#IdlingUnits + 1] = unit[1]
Trigger.AfterDelay(delay, ProduceVehicles)
-- See AttackGroupSize in WorldLoaded
if #IdlingUnits >= (AttackGroupSize * 2.5) then
SendAttack()
end
end)
end
end
ProduceAircraft = function()
ussr.Build(SovietAircraftType, function(units)
local yak = units[1]
Yaks[#Yaks + 1] = yak
Trigger.OnKilled(yak, ProduceAircraft)
if #Yaks == 1 then
Trigger.AfterDelay(DateTime.Minutes(1), ProduceAircraft)
end
InitializeAttackAircraft(yak, player)
end)
end
ActivateAI = function()
InitAIUnits()
ProtectHarvester(Harvester)
AttackDelay = AttackDelays[Difficulty]
AttackGroupSize = AttackGroupSizes[Difficulty]
Trigger.AfterDelay(DateTime.Seconds(10), function()
ProduceInfantry()
ProduceVehicles()
ProduceAircraft()
end)
end
| gpl-3.0 |
lcf8858/Sample_Lua | frameworks/cocos2d-x/cocos/scripting/lua-bindings/script/network/DeprecatedNetworkFunc.lua | 39 | 1074 | --tip
local function deprecatedTip(old_name,new_name)
print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********")
end
--functions of WebSocket will be deprecated begin
local targetPlatform = CCApplication:getInstance():getTargetPlatform()
if (kTargetIphone == targetPlatform) or (kTargetIpad == targetPlatform) or (kTargetAndroid == targetPlatform) or (kTargetWindows == targetPlatform) then
local WebSocketDeprecated = { }
function WebSocketDeprecated.sendTextMsg(self, string)
deprecatedTip("WebSocket:sendTextMsg","WebSocket:sendString")
return self:sendString(string)
end
WebSocket.sendTextMsg = WebSocketDeprecated.sendTextMsg
function WebSocketDeprecated.sendBinaryMsg(self, table,tablesize)
deprecatedTip("WebSocket:sendBinaryMsg","WebSocket:sendString")
string.char(unpack(table))
return self:sendString(string.char(unpack(table)))
end
WebSocket.sendBinaryMsg = WebSocketDeprecated.sendBinaryMsg
end
--functions of WebSocket will be deprecated end
| mit |
Vadavim/jsr-darkstar | scripts/zones/Caedarva_Mire/npcs/qm12.lua | 14 | 2040 | -----------------------------------
-- Area: Caedarva Mire
-- NPC: ???
-- @pos 456.993 -7.000 -270.815 79
-----------------------------------
package.loaded["scripts/zones/Caedarva_Mire/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/globals/settings");
require("scripts/zones/Caedarva_Mire/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local notMeantToBeProg = player:getVar("notmeanttobeCS");
if (notMeantToBeProg == 1) then
player:startEvent(0x0010);
elseif (player:getQuestStatus(AHT_URHGAN,NOT_MEANT_TO_BE) == QUEST_ACCEPTED and notMeantToBeProg == 3) then
player:startEvent(0x0011);
elseif (player:getVar("notmeanttobeMoshdahnKilled") == 1 and player:getVar("notmeanttobeLamia27Killed") == 1) then
player:startEvent(0x0012);
else
player:messageSpecial(NOTHING_HAPPENS);
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 == 0x0010) then
player:setVar("notmeanttobeCS",2);
elseif (csid == 0x0011) then
if (GetMobAction(17101149) == 0 and GetMobAction(17101148) == 0) then
SpawnMob(17101149):updateClaim(player);
SpawnMob(17101148):updateClaim(player);
end
elseif (csid == 0x0012) then
player:setVar("notmeanttobeMoshdahnKilled",0);
player:setVar("notmeanttobeLamia27Killed",0);
player:setVar("notmeanttobeCS",5);
end
end;
| gpl-3.0 |
pando85/telegram-bot | plugins/boobs.lua | 731 | 1601 | do
-- Recursive function
local function getRandomButts(attempt)
attempt = attempt or 0
attempt = attempt + 1
local res,status = http.request("http://api.obutts.ru/noise/1")
if status ~= 200 then return nil end
local data = json:decode(res)[1]
-- The OpenBoobs API sometimes returns an empty array
if not data and attempt <= 3 then
print('Cannot get that butts, trying another one...')
return getRandomButts(attempt)
end
return 'http://media.obutts.ru/' .. data.preview
end
local function getRandomBoobs(attempt)
attempt = attempt or 0
attempt = attempt + 1
local res,status = http.request("http://api.oboobs.ru/noise/1")
if status ~= 200 then return nil end
local data = json:decode(res)[1]
-- The OpenBoobs API sometimes returns an empty array
if not data and attempt < 10 then
print('Cannot get that boobs, trying another one...')
return getRandomBoobs(attempt)
end
return 'http://media.oboobs.ru/' .. data.preview
end
local function run(msg, matches)
local url = nil
if matches[1] == "!boobs" then
url = getRandomBoobs()
end
if matches[1] == "!butts" then
url = getRandomButts()
end
if url ~= nil then
local receiver = get_receiver(msg)
send_photo_from_url(receiver, url)
else
return 'Error getting boobs/butts for you, please try again later.'
end
end
return {
description = "Gets a random boobs or butts pic",
usage = {
"!boobs: Get a boobs NSFW image. 🔞",
"!butts: Get a butts NSFW image. 🔞"
},
patterns = {
"^!boobs$",
"^!butts$"
},
run = run
}
end
| gpl-2.0 |
aleksijuvani/premake-core | modules/vstudio/vs200x_vcproj.lua | 1 | 35359 | --
-- vs200x_vcproj.lua
-- Generate a Visual Studio 2005-2008 C/C++ project.
-- Copyright (c) Jason Perkins and the Premake project
--
local p = premake
p.vstudio.vc200x = {}
local m = p.vstudio.vc200x
local vstudio = p.vstudio
local context = p.context
local project = p.project
local config = p.config
local fileconfig = p.fileconfig
m.elements = {}
---
-- Generate a Visual Studio 200x C++ or Makefile project.
---
m.elements.project = function(prj)
return {
m.xmlElement,
m.visualStudioProject,
m.platforms,
m.toolFiles,
m.configurations,
m.references,
m.files,
m.globals
}
end
function m.generate(prj)
p.indent("\t")
p.callArray(m.elements.project, prj)
p.pop('</VisualStudioProject>')
p.w()
end
---
-- Write the opening <VisualStudioProject> element of the project file.
-- In this case, the call list is for XML attributes rather than elements.
---
m.elements.visualStudioProject = function(prj)
return {
m.projectType,
m.version,
m.projectName,
m.projectGUID,
m.rootNamespace,
m.keyword,
m.targetFrameworkVersion
}
end
function m.visualStudioProject(prj)
p.push('<VisualStudioProject')
p.callArray(m.elements.visualStudioProject, prj)
p.w('>')
end
---
-- Write out the <Configurations> element group, enumerating each of the
-- configuration-architecture pairings.
---
function m.configurations(prj)
p.push('<Configurations>')
-- Visual Studio requires each configuration to be paired up with each
-- architecture, even if the pairing doesn't make any sense (i.e. Win32
-- DLL DCRT|PS3). Start by building a map between configurations and
-- their Visual Studio names. I will use this to determine which
-- pairings are "real", and which need to be synthesized.
local mapping = {}
for cfg in project.eachconfig(prj) do
local name = vstudio.projectConfig(cfg)
mapping[cfg] = name
mapping[name] = cfg
end
-- Now enumerate each configuration and architecture pairing
for cfg in project.eachconfig(prj) do
for i, arch in ipairs(architectures) do
local target
-- Generate a Visual Studio name from this pairing and see if
-- it matches. If so, I can go ahead and output the markup for
-- this configuration.
local testName = vstudio.projectConfig(cfg, arch)
if testName == mapping[cfg] then
target = cfg
-- Okay, this pairing doesn't match this configuration. Check
-- the mapping to see if it matches some *other* configuration.
-- If it does, I can ignore it as it will getting written on
-- another pass through the loop. If it does not, then this is
-- one of those fake configurations that I have to synthesize.
elseif not mapping[testName] then
target = { fake = true }
end
-- If I'm not ignoring this pairing, output the result now
if target then
m.configuration(target, testName)
m.tools(target)
p.pop('</Configuration>')
end
end
end
p.pop('</Configurations>')
end
---
-- Write out the <Configuration> element, describing a specific Premake
-- build configuration/platform pairing.
---
m.elements.configuration = function(cfg)
if cfg.fake then
return {
m.intermediateDirectory,
m.configurationType
}
else
return {
m.outputDirectory,
m.intermediateDirectory,
m.configurationType,
m.useOfMFC,
m.characterSet,
m.managedExtensions,
}
end
end
function m.configuration(cfg, name)
p.push('<Configuration')
p.w('Name="%s"', name)
p.callArray(m.elements.configuration, cfg)
p.w('>')
end
---
-- Return the list of tools required to build a specific configuration.
-- Each tool gets represented by an XML element in the project file, all
-- of which are implemented farther down in this file.
--
-- @param cfg
-- The configuration being written.
---
m.elements.tools = function(cfg)
if vstudio.isMakefile(cfg) and not cfg.fake then
return {
m.VCNMakeTool
}
end
if cfg.system == p.XBOX360 then
return {
m.VCPreBuildEventTool,
m.VCCustomBuildTool,
m.VCXMLDataGeneratorTool,
m.VCWebServiceProxyGeneratorTool,
m.VCMIDLTool,
m.VCCLCompilerTool,
m.VCManagedResourceCompilerTool,
m.VCResourceCompilerTool,
m.VCPreLinkEventTool,
m.VCLinkerTool,
m.VCALinkTool,
m.VCX360ImageTool,
m.VCBscMakeTool,
m.VCX360DeploymentTool,
m.VCPostBuildEventTool,
m.DebuggerTool,
}
else
return {
m.VCPreBuildEventTool,
m.VCCustomBuildTool,
m.VCXMLDataGeneratorTool,
m.VCWebServiceProxyGeneratorTool,
m.VCMIDLTool,
m.VCCLCompilerTool,
m.VCManagedResourceCompilerTool,
m.VCResourceCompilerTool,
m.VCPreLinkEventTool,
m.VCLinkerTool,
m.VCALinkTool,
m.VCManifestTool,
m.VCXDCMakeTool,
m.VCBscMakeTool,
m.VCFxCopTool,
m.VCAppVerifierTool,
m.VCPostBuildEventTool,
}
end
end
function m.tools(cfg)
p.callArray(m.elements.tools, cfg, config.toolset(cfg))
end
---
-- Write out the <References> element group.
---
m.elements.references = function(prj)
return {
m.assemblyReferences,
m.projectReferences,
}
end
function m.references(prj)
p.push('<References>')
p.callArray(m.elements.references, prj)
p.pop('</References>')
end
---
-- Write out the <Files> element group.
---
function m.files(prj)
local tr = m.filesSorted(prj)
p.push('<Files>')
p.tree.traverse(tr, {
onbranchenter = m.filesFilterStart,
onbranchexit = m.filesFilterEnd,
onleaf = m.filesFile,
}, false)
p.pop('</Files>')
end
function m.filesSorted(prj)
-- Fetch the source tree, sorted how Visual Studio likes it: alpha
-- sorted, with any leading ../ sequences ignored. At the top level
-- of the tree, files go after folders, otherwise before.
return project.getsourcetree(prj, function(a,b)
local istop = (a.parent.parent == nil)
local aSortName = a.name
local bSortName = b.name
-- Only file nodes have a relpath field; folder nodes do not
if a.relpath then
if not b.relpath then
return not istop
end
aSortName = a.relpath:gsub("%.%.%/", "")
end
if b.relpath then
if not a.relpath then
return istop
end
bSortName = b.relpath:gsub("%.%.%/", "")
end
return aSortName < bSortName
end)
end
function m.filesFilterStart(node)
p.push('<Filter')
p.w('Name="%s"', node.name)
p.w('>')
end
function m.filesFilterEnd(node)
p.pop('</Filter>')
end
function m.filesFile(node)
p.push('<File')
p.w('RelativePath="%s"', path.translate(node.relpath))
p.w('>')
local prj = node.project
for cfg in project.eachconfig(prj) do
m.fileConfiguration(cfg, node)
end
p.pop('</File>')
end
m.elements.fileConfigurationAttributes = function(filecfg)
return {
m.excludedFromBuild,
}
end
function m.fileConfiguration(cfg, node)
local filecfg = fileconfig.getconfig(node, cfg)
-- Generate the individual sections of the file configuration
-- element and capture the results to a buffer. I will only
-- write the file configuration if the buffers are not empty.
local configAttribs = p.capture(function ()
p.push()
p.callArray(m.elements.fileConfigurationAttributes, filecfg)
p.pop()
end)
local compilerAttribs = p.capture(function ()
p.push()
m.VCCLCompilerTool(filecfg)
p.pop()
end)
-- lines() > 3 skips empty <Tool Name="VCCLCompiler" /> elements
if #configAttribs > 0 or compilerAttribs:lines() > 3 then
p.push('<FileConfiguration')
p.w('Name="%s"', vstudio.projectConfig(cfg))
if #configAttribs > 0 then
p.outln(configAttribs)
end
p.w('>')
p.outln(compilerAttribs)
p.pop('</FileConfiguration>')
end
end
---
-- I don't do anything with globals yet, but here it is if you want to
-- extend it.
---
m.elements.globals = function(prj)
return {}
end
function m.globals(prj)
p.push('<Globals>')
p.callArray(m.elements.globals, prj)
p.pop('</Globals>')
end
---------------------------------------------------------------------------
--
-- Handlers for the individual tool sections of the project.
--
-- There is a lot of repetition here; most of these tools are just
-- placeholders for modules to override as needed.
--
---------------------------------------------------------------------------
---
-- The implementation of a "normal" tool. Writes the opening tool element
-- and name attribute, calls the corresponding function list, and then
-- closes the element.
--
-- @param name
-- The name of the tool, e.g. "VCCustomBuildTool".
-- @param ...
-- Any additional arguments required by the call list.
---
function m.VCTool(name, cfg, ...)
p.push('<Tool')
local nameFunc = m[name .. "Name"]
local callFunc = m.elements[name]
if nameFunc then
name = nameFunc(cfg, ...)
end
p.w('Name="%s"', name)
if cfg and not cfg.fake then
p.callArray(callFunc, cfg, ...)
end
p.pop('/>')
end
------------
m.elements.DebuggerTool = function(cfg)
return {}
end
function m.DebuggerTool(cfg)
p.push('<DebuggerTool')
p.pop('/>')
end
------------
m.elements.VCALinkTool = function(cfg)
return {}
end
function m.VCALinkTool(cfg)
m.VCTool("VCALinkTool", cfg)
end
------------
m.elements.VCAppVerifierTool = function(cfg)
return {}
end
function m.VCAppVerifierTool(cfg)
if cfg.kind ~= p.STATICLIB then
m.VCTool("VCAppVerifierTool", cfg)
end
end
------------
m.elements.VCBscMakeTool = function(cfg)
return {}
end
function m.VCBscMakeTool(cfg)
m.VCTool("VCBscMakeTool", cfg)
end
------------
m.elements.VCCLCompilerTool = function(cfg, toolset)
if not toolset then
-- not a custom tool, use the standard set of attributes
return {
m.customBuildTool,
m.objectFile,
m.additionalCompilerOptions,
m.optimization,
m.additionalIncludeDirectories,
m.wholeProgramOptimization,
m.preprocessorDefinitions,
m.undefinePreprocessorDefinitions,
m.minimalRebuild,
m.basicRuntimeChecks,
m.bufferSecurityCheck,
m.stringPooling,
m.exceptionHandling,
m.runtimeLibrary,
m.enableFunctionLevelLinking,
m.enableEnhancedInstructionSet,
m.floatingPointModel,
m.runtimeTypeInfo,
m.treatWChar_tAsBuiltInType,
m.usePrecompiledHeader,
m.programDataBaseFileName,
m.warningLevel,
m.warnAsError,
m.detect64BitPortabilityProblems,
m.debugInformationFormat,
m.compileAs,
m.disableSpecificWarnings,
m.forcedIncludeFiles,
m.omitDefaultLib,
}
else
-- custom tool, use subset of attributes
return {
m.additionalExternalCompilerOptions,
m.additionalIncludeDirectories,
m.preprocessorDefinitions,
m.undefinePreprocessorDefinitions,
m.usePrecompiledHeader,
m.programDataBaseFileName,
m.debugInformationFormat,
m.compileAs,
m.forcedIncludeFiles,
}
end
end
function m.VCCLCompilerToolName(cfg)
local prjcfg, filecfg = config.normalize(cfg)
if filecfg and fileconfig.hasCustomBuildRule(filecfg) then
return "VCCustomBuildTool"
elseif prjcfg and prjcfg.system == p.XBOX360 then
return "VCCLX360CompilerTool"
else
return "VCCLCompilerTool"
end
end
function m.VCCLCompilerTool(cfg, toolset)
m.VCTool("VCCLCompilerTool", cfg, toolset)
end
------------
m.elements.VCCustomBuildTool = function(cfg)
return {}
end
function m.VCCustomBuildTool(cfg)
m.VCTool("VCCustomBuildTool", cfg)
end
------------
m.elements.VCFxCopTool = function(cfg)
return {}
end
function m.VCFxCopTool(cfg)
m.VCTool("VCFxCopTool", cfg)
end
------------
m.elements.VCLinkerTool = function(cfg, toolset)
if cfg.kind ~= p.STATICLIB then
return {
m.linkLibraryDependencies,
m.ignoreImportLibrary,
m.additionalLinkerOptions,
m.additionalDependencies,
m.outputFile,
m.linkIncremental,
m.additionalLibraryDirectories,
m.moduleDefinitionFile,
m.generateManifest,
m.generateDebugInformation,
m.programDatabaseFile,
m.subSystem,
m.largeAddressAware,
m.optimizeReferences,
m.enableCOMDATFolding,
m.entryPointSymbol,
m.importLibrary,
m.targetMachine,
}
else
return {
m.additionalLinkerOptions,
m.additionalDependencies,
m.outputFile,
m.additionalLibraryDirectories,
}
end
end
function m.VCLinkerToolName(cfg)
if cfg.kind == p.STATICLIB then
return "VCLibrarianTool"
elseif cfg.system == p.XBOX360 then
return "VCX360LinkerTool"
else
return "VCLinkerTool"
end
end
function m.VCLinkerTool(cfg, toolset)
m.VCTool("VCLinkerTool", cfg, toolset)
end
------------
m.elements.VCManagedResourceCompilerTool = function(cfg)
return {}
end
function m.VCManagedResourceCompilerTool(cfg)
m.VCTool("VCManagedResourceCompilerTool", cfg)
end
------------
m.elements.VCManifestTool = function(cfg)
return {
m.additionalManifestFiles,
}
end
function m.VCManifestTool(cfg)
if cfg.kind ~= p.STATICLIB then
m.VCTool("VCManifestTool", cfg)
end
end
------------
m.elements.VCMIDLTool = function(cfg)
return {
m.targetEnvironment
}
end
function m.VCMIDLTool(cfg)
m.VCTool("VCMIDLTool", cfg)
end
------------
m.elements.VCNMakeTool = function(cfg)
return {
m.buildCommandLine,
m.reBuildCommandLine,
m.cleanCommandLine,
m.output,
m.preprocessorDefinitions,
m.undefinePreprocessorDefinitions,
m.includeSearchPath,
m.forcedIncludes,
m.assemblySearchPath,
m.forcedUsingAssemblies,
m.compileAsManaged,
}
end
function m.VCNMakeTool(cfg)
m.VCTool("VCNMakeTool", cfg)
end
------------
m.elements.VCBuildTool = function(cfg, stage)
return {
m.commandLine,
}
end
function m.VCBuildToolName(cfg, stage)
return "VC" .. stage .. "EventTool"
end
function m.VCPreBuildEventTool(cfg)
m.VCTool("VCBuildTool", cfg, "PreBuild")
end
function m.VCPreLinkEventTool(cfg)
m.VCTool("VCBuildTool", cfg, "PreLink")
end
function m.VCPostBuildEventTool(cfg)
m.VCTool("VCBuildTool", cfg, "PostBuild")
end
------------
m.elements.VCResourceCompilerTool = function(cfg)
return {
m.additionalResourceOptions,
m.resourcePreprocessorDefinitions,
m.additionalResourceIncludeDirectories,
m.culture,
}
end
function m.VCResourceCompilerTool(cfg)
m.VCTool("VCResourceCompilerTool", cfg)
end
------------
m.elements.VCWebServiceProxyGeneratorTool = function(cfg)
return {}
end
function m.VCWebServiceProxyGeneratorTool(cfg)
m.VCTool("VCWebServiceProxyGeneratorTool", cfg)
end
------------
m.elements.VCX360DeploymentTool = function(cfg)
return {
m.deploymentType,
m.additionalDeploymentOptions,
}
end
function m.VCX360DeploymentTool(cfg)
m.VCTool("VCX360DeploymentTool", cfg)
end
------------
m.elements.VCX360ImageTool = function(cfg)
return {
m.additionalImageOptions,
m.outputFileName,
}
end
function m.VCX360ImageTool(cfg)
m.VCTool("VCX360ImageTool", cfg)
end
------------
m.elements.VCXDCMakeTool = function(cfg)
return {}
end
function m.VCXDCMakeTool(cfg)
m.VCTool("VCXDCMakeTool", cfg)
end
------------
m.elements.VCXMLDataGeneratorTool = function(cfg)
return {}
end
function m.VCXMLDataGeneratorTool(cfg)
m.VCTool("VCXMLDataGeneratorTool", cfg)
end
---------------------------------------------------------------------------
--
-- Support functions
--
---------------------------------------------------------------------------
--
-- Return the debugging symbol level for a configuration.
--
function m.symbols(cfg)
if not (cfg.symbols == p.ON) then
return 0
elseif cfg.debugformat == "c7" then
return 1
else
-- Edit-and-continue doesn't work for some configurations
if cfg.editandcontinue == p.OFF or
config.isOptimizedBuild(cfg) or
cfg.clr ~= p.OFF or
cfg.architecture == p.X86_64
then
return 3
else
return 4
end
end
end
---------------------------------------------------------------------------
--
-- Handlers for individual project elements
--
---------------------------------------------------------------------------
function m.additionalCompilerOptions(cfg)
local opts = cfg.buildoptions
if cfg.flags.MultiProcessorCompile then
table.insert(opts, "/MP")
end
if #opts > 0 then
p.x('AdditionalOptions="%s"', table.concat(opts, " "))
end
end
function m.additionalDependencies(cfg, toolset)
if #cfg.links == 0 then return end
local ex = vstudio.needsExplicitLink(cfg)
local links
if not toolset then
links = vstudio.getLinks(cfg, ex)
for i, link in ipairs(links) do
if link:find(" ", 1, true) then
link = '"' .. link .. '"'
end
links[i] = path.translate(link)
end
else
links = path.translate(toolset.getlinks(cfg, not ex))
end
if #links > 0 then
p.x('AdditionalDependencies="%s"', table.concat(links, " "))
end
end
function m.additionalDeploymentOptions(cfg)
if #cfg.deploymentoptions > 0 then
p.x('AdditionalOptions="%s"', table.concat(cfg.deploymentoptions, " "))
end
end
function m.additionalExternalCompilerOptions(cfg, toolset)
local buildoptions = table.join(toolset.getcxxflags(cfg), cfg.buildoptions)
if not cfg.flags.NoPCH and cfg.pchheader then
table.insert(buildoptions, '--use_pch="$(IntDir)/$(TargetName).pch"')
end
if #buildoptions > 0 then
p.x('AdditionalOptions="%s"', table.concat(buildoptions, " "))
end
end
function m.additionalImageOptions(cfg)
if #cfg.imageoptions > 0 then
p.x('AdditionalOptions="%s"', table.concat(cfg.imageoptions, " "))
end
end
function m.additionalIncludeDirectories(cfg)
if #cfg.includedirs > 0 then
local dirs = vstudio.path(cfg, cfg.includedirs)
p.x('AdditionalIncludeDirectories="%s"', table.concat(dirs, ";"))
end
end
function m.additionalLibraryDirectories(cfg)
if #cfg.libdirs > 0 then
local dirs = vstudio.path(cfg, cfg.libdirs)
p.x('AdditionalLibraryDirectories="%s"', table.concat(dirs, ";"))
end
end
function m.additionalLinkerOptions(cfg, toolset)
local flags
if toolset then
flags = table.join(toolset.getldflags(cfg), cfg.linkoptions)
else
flags = cfg.linkoptions
end
if #flags > 0 then
p.x('AdditionalOptions="%s"', table.concat(flags, " "))
end
end
function m.additionalManifestFiles(cfg)
local manifests = {}
for i, fname in ipairs(cfg.files) do
if path.getextension(fname) == ".manifest" then
table.insert(manifests, project.getrelative(cfg.project, fname))
end
end
if #manifests > 0 then
p.x('AdditionalManifestFiles="%s"', table.concat(manifests, ";"))
end
end
function m.additionalResourceIncludeDirectories(cfg)
local dirs = table.join(cfg.includedirs, cfg.resincludedirs)
if #dirs > 0 then
dirs = vstudio.path(cfg, dirs)
p.x('AdditionalIncludeDirectories="%s"', table.concat(dirs, ";"))
end
end
function m.additionalResourceOptions(cfg)
if #cfg.resoptions > 0 then
p.x('AdditionalOptions="%s"', table.concat(cfg.resoptions, " "))
end
end
function m.assemblyReferences(prj)
-- Visual Studio doesn't support per-config references
local cfg = project.getfirstconfig(prj)
local refs = config.getlinks(cfg, "system", "fullpath", "managed")
table.foreachi(refs, function(value)
p.push('<AssemblyReference')
p.x('RelativePath="%s"', path.translate(value))
p.pop('/>')
end)
end
function m.assemblySearchPath(cfg)
p.w('AssemblySearchPath=""')
end
function m.basicRuntimeChecks(cfg)
local cfg, filecfg = config.normalize(cfg)
if not filecfg
and not config.isOptimizedBuild(cfg)
and cfg.clr == p.OFF
and not cfg.flags.NoRuntimeChecks
then
p.w('BasicRuntimeChecks="3"')
end
end
function m.bufferSecurityCheck(cfg)
if cfg.flags.NoBufferSecurityCheck then
p.w('BufferSecurityCheck="false"')
end
end
function m.buildCommandLine(cfg)
local cmds = os.translateCommandsAndPaths(cfg.buildcommands, cfg.project.basedir, cfg.project.location)
p.x('BuildCommandLine="%s"', table.concat(cmds, "\r\n"))
end
function m.characterSet(cfg)
if not vstudio.isMakefile(cfg) then
p.w('CharacterSet="%s"', iif(cfg.characterset == p.MBCS, 2, 1))
end
end
function m.cleanCommandLine(cfg)
local cmds = os.translateCommandsAndPaths(cfg.cleancommands, cfg.project.basedir, cfg.project.location)
cmds = table.concat(cmds, "\r\n")
p.x('CleanCommandLine="%s"', cmds)
end
function m.commandLine(cfg, stage)
local field = stage:lower()
local steps = cfg[field .. "commands"]
local msg = cfg[field .. "message"]
if #steps > 0 then
if msg then
p.x('Description="%s"', msg)
end
steps = os.translateCommandsAndPaths(steps, cfg.project.basedir, cfg.project.location)
p.x('CommandLine="%s"', table.implode(steps, "", "", "\r\n"))
end
end
function m.compileAs(cfg, toolset)
local cfg, filecfg = config.normalize(cfg)
local c = p.languages.isc(cfg.language)
if filecfg then
if path.iscfile(filecfg.name) ~= c then
if path.iscppfile(filecfg.name) then
local value = iif(c, 2, 1)
p.w('CompileAs="%s"', value)
end
end
else
local compileAs
if toolset then
compileAs = "0"
elseif c then
compileAs = "1"
end
if compileAs then
p.w('CompileAs="%s"', compileAs)
end
end
end
function m.disableSpecificWarnings(cfg)
if #cfg.disablewarnings > 0 then
p.x('DisableSpecificWarnings="%s"', table.concat(cfg.disablewarnings, ";"))
end
end
function m.compileAsManaged(cfg)
p.w('CompileAsManaged=""')
end
function m.configurationType(cfg)
local cfgtypes = {
Makefile = 0,
None = 0,
SharedLib = 2,
StaticLib = 4,
}
p.w('ConfigurationType="%s"', cfgtypes[cfg.kind] or 1)
end
function m.culture(cfg)
local value = vstudio.cultureForLocale(cfg.locale)
if value then
p.w('Culture="%d"', value)
end
end
function m.customBuildTool(cfg)
local cfg, filecfg = config.normalize(cfg)
if filecfg and fileconfig.hasCustomBuildRule(filecfg) then
local cmds = os.translateCommandsAndPaths(filecfg.buildcommands, filecfg.project.basedir, filecfg.project.location)
p.x('CommandLine="%s"', table.concat(cmds,'\r\n'))
local outputs = project.getrelative(filecfg.project, filecfg.buildoutputs)
p.x('Outputs="%s"', table.concat(outputs, ';'))
if filecfg.buildinputs and #filecfg.buildinputs > 0 then
local inputs = project.getrelative(filecfg.project, filecfg.buildinputs)
p.x('AdditionalDependencies="%s"', table.concat(inputs, ';'))
end
end
end
function m.debugInformationFormat(cfg, toolset)
local prjcfg, filecfg = config.normalize(cfg)
if not filecfg then
local fmt = iif(toolset, "0", m.symbols(cfg))
p.w('DebugInformationFormat="%s"', fmt)
end
end
function m.deploymentType(cfg)
p.w('DeploymentType="0"')
end
function m.detect64BitPortabilityProblems(cfg)
local prjcfg, filecfg = config.normalize(cfg)
if _ACTION < "vs2008" and cfg.clr == p.OFF and cfg.warnings ~= p.OFF and not filecfg then
p.w('Detect64BitPortabilityProblems="%s"', tostring(not cfg.flags.No64BitChecks))
end
end
function m.enableCOMDATFolding(cfg, toolset)
if config.isOptimizedBuild(cfg) and not toolset then
p.w('EnableCOMDATFolding="2"')
end
end
function m.largeAddressAware(cfg)
if (cfg.largeaddressaware == true) then
p.w('LargeAddressAware="2"')
end
end
function m.enableEnhancedInstructionSet(cfg)
local map = { SSE = "1", SSE2 = "2" }
local value = map[cfg.vectorextensions]
if value and cfg.system ~= "Xbox360" and cfg.architecture ~= "x86_64" then
p.w('EnableEnhancedInstructionSet="%d"', value)
end
end
function m.enableFunctionLevelLinking(cfg)
local cfg, filecfg = config.normalize(cfg)
if not filecfg then
p.w('EnableFunctionLevelLinking="true"')
end
end
function m.entryPointSymbol(cfg, toolset)
if cfg.entrypoint then
p.w('EntryPointSymbol="%s"', cfg.entrypoint)
end
end
function m.exceptionHandling(cfg)
if cfg.exceptionhandling == p.OFF then
p.w('ExceptionHandling="%s"', iif(_ACTION < "vs2005", "FALSE", 0))
elseif cfg.exceptionhandling == "SEH" and _ACTION > "vs2003" then
p.w('ExceptionHandling="2"')
end
end
function m.excludedFromBuild(filecfg)
if not filecfg or filecfg.flags.ExcludeFromBuild then
p.w('ExcludedFromBuild="true"')
end
end
function m.floatingPointModel(cfg)
local map = { Strict = "1", Fast = "2" }
local value = map[cfg.floatingpoint]
if value then
p.w('FloatingPointModel="%d"', value)
end
end
function m.forcedIncludeFiles(cfg)
if #cfg.forceincludes > 0 then
local includes = vstudio.path(cfg, cfg.forceincludes)
p.w('ForcedIncludeFiles="%s"', table.concat(includes, ';'))
end
if #cfg.forceusings > 0 then
local usings = vstudio.path(cfg, cfg.forceusings)
p.w('ForcedUsingFiles="%s"', table.concat(usings, ';'))
end
end
function m.forcedIncludes(cfg)
p.w('ForcedIncludes=""')
end
function m.forcedUsingAssemblies(cfg)
p.w('ForcedUsingAssemblies=""')
end
function m.keyword(prj)
local windows, managed, makefile
for cfg in project.eachconfig(prj) do
if cfg.system == p.WINDOWS then windows = true end
if cfg.clr ~= p.OFF then managed = true end
if vstudio.isMakefile(cfg) then makefile = true end
end
if windows then
local keyword = "Win32Proj"
if managed then
keyword = "ManagedCProj"
end
if makefile then
keyword = "MakeFileProj"
end
p.w('Keyword="%s"', keyword)
end
end
function m.generateDebugInformation(cfg, toolset)
if not toolset then
p.w('GenerateDebugInformation="%s"', tostring(m.symbols(cfg) ~= 0))
end
end
function m.generateManifest(cfg, toolset)
if cfg.flags.NoManifest or toolset then
p.w('GenerateManifest="false"')
end
end
function m.ignoreImportLibrary(cfg, toolset)
if cfg.flags.NoImportLib and not toolset then
p.w('IgnoreImportLibrary="true"')
end
end
function m.importLibrary(cfg, toolset)
if cfg.kind == p.SHAREDLIB and not toolset then
local implibdir = cfg.linktarget.abspath
-- I can't actually stop the import lib, but I can hide it in the objects directory
if cfg.flags.NoImportLib then
implibdir = path.join(cfg.objdir, path.getname(implibdir))
end
implibdir = vstudio.path(cfg, implibdir)
p.x('ImportLibrary="%s"', implibdir)
end
end
function m.includeSearchPath(cfg)
p.w('IncludeSearchPath=""')
end
function m.intermediateDirectory(cfg)
local objdir
if not cfg.fake then
objdir = vstudio.path(cfg, cfg.objdir)
else
objdir = "$(PlatformName)\\$(ConfigurationName)"
end
p.x('IntermediateDirectory="%s"', objdir)
end
function m.linkIncremental(cfg, toolset)
local value
if not toolset then
value = iif(config.canLinkIncremental(cfg) , 2, 1)
else
value = 0
end
p.w('LinkIncremental="%s"', value)
end
function m.linkLibraryDependencies(cfg, toolset)
if vstudio.needsExplicitLink(cfg) and not toolset then
p.w('LinkLibraryDependencies="false"')
end
end
function m.managedExtensions(cfg)
if cfg.clr ~= p.OFF then
p.w('ManagedExtensions="1"')
end
end
function m.minimalRebuild(cfg)
if config.isDebugBuild(cfg) and
cfg.debugformat ~= "c7" and
not cfg.flags.NoMinimalRebuild and
cfg.clr == p.OFF and
not cfg.flags.MultiProcessorCompile
then
p.w('MinimalRebuild="true"')
end
end
function m.moduleDefinitionFile(cfg, toolset)
if not toolset then
local deffile = config.findfile(cfg, ".def")
if deffile then
p.w('ModuleDefinitionFile="%s"', deffile)
end
end
end
function m.objectFile(cfg)
local cfg, filecfg = config.normalize(cfg)
if filecfg and path.iscppfile(filecfg.name) then
if filecfg.objname ~= path.getbasename(filecfg.abspath) then
p.x('ObjectFile="$(IntDir)\\%s.obj"', filecfg.objname)
end
end
end
function m.omitDefaultLib(cfg)
if cfg.flags.OmitDefaultLibrary then
p.w('OmitDefaultLibName="true"')
end
end
function m.omitFramePointers(cfg)
if cfg.flags.NoFramePointer then
p.w('OmitFramePointers="true"')
end
end
function m.optimization(cfg)
local map = { Off=0, On=3, Debug=0, Full=3, Size=1, Speed=2 }
local value = map[cfg.optimize]
if value or not cfg.abspath then
p.w('Optimization="%s"', value or 0)
end
end
function m.optimizeReferences(cfg, toolset)
if config.isOptimizedBuild(cfg) and not toolset then
p.w('OptimizeReferences="2"')
end
end
function m.output(cfg)
p.w('Output="$(OutDir)%s"', cfg.buildtarget.name)
end
function m.outputDirectory(cfg)
local outdir = project.getrelative(cfg.project, cfg.buildtarget.directory)
p.x('OutputDirectory="%s"', path.translate(outdir))
end
function m.outputFile(cfg)
p.x('OutputFile="$(OutDir)\\%s"', cfg.buildtarget.name)
end
function m.outputFileName(cfg)
if cfg.imagepath ~= nil then
p.x('OutputFileName="%s"', path.translate(cfg.imagepath))
end
end
function m.platforms(prj)
architectures = {}
for cfg in project.eachconfig(prj) do
local arch = vstudio.archFromConfig(cfg, true)
if not table.contains(architectures, arch) then
table.insert(architectures, arch)
end
end
p.push('<Platforms>')
table.foreachi(architectures, function(arch)
p.push('<Platform')
p.w('Name="%s"', arch)
p.pop('/>')
end)
p.pop('</Platforms>')
end
function m.preprocessorDefinitions(cfg)
if #cfg.defines > 0 or vstudio.isMakefile(cfg) then
p.x('PreprocessorDefinitions="%s"', table.concat(cfg.defines, ";"))
end
end
function m.undefinePreprocessorDefinitions(cfg)
if #cfg.undefines > 0 then
p.x('UndefinePreprocessorDefinitions="%s"', table.concat(cfg.undefines, ";"))
end
end
function m.programDatabaseFile(cfg, toolset)
if toolset then
p.w('ProgramDatabaseFile=""')
end
end
function m.programDataBaseFileName(cfg, toolset)
if toolset then
p.w('ProgramDataBaseFileName=""')
end
end
function m.projectGUID(prj)
p.w('ProjectGUID="{%s}"', prj.uuid)
end
function m.projectName(prj)
p.x('Name="%s"', prj.name)
end
function m.projectReferences(prj)
local deps = project.getdependencies(prj)
if #deps > 0 then
-- This is a little odd: Visual Studio wants the "relative path to project"
-- to be relative to the *workspace*, rather than the project doing the
-- referencing. Which, in theory, would break if the project is included
-- in more than one workspace. But that's how they do it.
for i, dep in ipairs(deps) do
local relpath = vstudio.path(prj.workspace, vstudio.projectfile(dep))
-- Visual Studio wants the path to start with ./ or ../
if not relpath:startswith(".") then
relpath = ".\\" .. relpath
end
p.push('<ProjectReference')
p.w('ReferencedProjectIdentifier="{%s}"', dep.uuid)
p.w('RelativePathToProject="%s"', relpath)
p.pop('/>')
end
end
end
function m.projectType(prj)
p.w('ProjectType="Visual C++"')
end
function m.reBuildCommandLine(cfg)
commands = table.concat(cfg.rebuildcommands, "\r\n")
p.x('ReBuildCommandLine="%s"', commands)
end
function m.resourcePreprocessorDefinitions(cfg)
local defs = table.join(cfg.defines, cfg.resdefines)
if #defs > 0 then
p.x('PreprocessorDefinitions="%s"', table.concat(defs, ";"))
end
end
function m.rootNamespace(prj)
local hasWindows = project.hasConfig(prj, function(cfg)
return cfg.system == p.WINDOWS
end)
-- Technically, this should be skipped for pure makefile projects that
-- do not contain any empty configurations. But I need to figure out a
-- a good way to check the empty configuration bit first.
if hasWindows and _ACTION > "vs2003" then
p.x('RootNamespace="%s"', prj.name)
end
end
function m.runtimeLibrary(cfg)
local cfg, filecfg = config.normalize(cfg)
if not filecfg then
local runtimes = {
StaticRelease = 0,
StaticDebug = 1,
SharedRelease = 2,
SharedDebug = 3,
}
local runtime = config.getruntime(cfg)
if runtime then
p.w('RuntimeLibrary="%s"', runtimes[runtime])
else
-- TODO: this path should probably be omitted and left for default
-- ...but I can't really test this, so I'm a leave it how I found it
p.w('RuntimeLibrary="%s"', iif(config.isDebugBuild(cfg), 3, 2))
end
end
end
function m.runtimeTypeInfo(cfg)
if cfg.rtti == p.OFF and cfg.clr == p.OFF then
p.w('RuntimeTypeInfo="false"')
elseif cfg.rtti == p.ON then
p.w('RuntimeTypeInfo="true"')
end
end
function m.stringPooling(cfg)
if config.isOptimizedBuild(cfg) then
p.w('StringPooling="true"')
end
end
function m.subSystem(cfg, toolset)
if not toolset then
p.w('SubSystem="%s"', iif(cfg.kind == "ConsoleApp", 1, 2))
end
end
function m.targetEnvironment(cfg)
if cfg.architecture == "x86_64" then
p.w('TargetEnvironment="3"')
end
end
function m.targetFrameworkVersion(prj)
local windows, makefile
for cfg in project.eachconfig(prj) do
if cfg.system == p.WINDOWS then windows = true end
if vstudio.isMakefile(cfg) then makefile = true end
end
local version = 0
if makefile or not windows then
version = 196613
end
p.w('TargetFrameworkVersion="%d"', version)
end
function m.targetMachine(cfg, toolset)
if not toolset then
p.w('TargetMachine="%d"', iif(cfg.architecture == "x86_64", 17, 1))
end
end
function m.toolFiles(prj)
if _ACTION > "vs2003" then
p.w('<ToolFiles>')
p.w('</ToolFiles>')
end
end
function m.treatWChar_tAsBuiltInType(cfg)
local map = { On = "true", Off = "false" }
local value = map[cfg.nativewchar]
if value then
p.w('TreatWChar_tAsBuiltInType="%s"', value)
end
end
function m.useOfMFC(cfg)
if (cfg.flags.MFC) then
p.w('UseOfMFC="%d"', iif(cfg.staticruntime == "On", 1, 2))
end
end
function m.usePrecompiledHeader(cfg)
local prj, file = config.normalize(cfg)
if file then
if prj.pchsource == file.abspath and
not prj.flags.NoPCH and
prj.system == p.WINDOWS
then
p.w('UsePrecompiledHeader="1"')
elseif file.flags.NoPCH then
p.w('UsePrecompiledHeader="0"')
end
else
if not prj.flags.NoPCH and prj.pchheader then
p.w('UsePrecompiledHeader="%s"', iif(_ACTION < "vs2005", 3, 2))
p.x('PrecompiledHeaderThrough="%s"', prj.pchheader)
else
p.w('UsePrecompiledHeader="%s"', iif(_ACTION > "vs2003" or prj.flags.NoPCH, 0, 2))
end
end
end
function m.version(prj)
local map = {
vs2002 = '7.0',
vs2003 = '7.1',
vs2005 = '8.0',
vs2008 = '9.0'
}
p.w('Version="%s0"', map[_ACTION])
end
function m.warnAsError(cfg)
if cfg.flags.FatalCompileWarnings and cfg.warnings ~= p.OFF then
p.w('WarnAsError="true"')
end
end
function m.warningLevel(cfg)
local prjcfg, filecfg = config.normalize(cfg)
local level
if cfg.warnings == p.OFF then
level = "0"
elseif cfg.warnings == "Extra" then
level = "4"
elseif not filecfg then
level = "3"
end
if level then
p.w('WarningLevel="%s"', level)
end
end
function m.wholeProgramOptimization(cfg)
if cfg.flags.LinkTimeOptimization then
p.x('WholeProgramOptimization="true"')
end
end
function m.xmlElement()
p.w('<?xml version="1.0" encoding="Windows-1252"?>')
end
| bsd-3-clause |
Vadavim/jsr-darkstar | scripts/zones/Windurst_Woods/npcs/Retto-Marutto.lua | 27 | 1193 | -----------------------------------
-- Area: Windurst Woods
-- NPC: Retto-Marutto
-- Guild Merchant NPC: Bonecrafting Guild
-- @pos -6.142 -6.55 -132.639 241
-----------------------------------
package.loaded["scripts/zones/Windurst_Woods/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/shop");
require("scripts/zones/Windurst_Woods/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:sendGuild(5142,8,23,3)) then
player:showText(npc,RETTO_MARUTTO_DIALOG);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
zynjec/darkstar | scripts/globals/abilities/pets/knockout.lua | 14 | 1429 | ---------------------------------------------------
-- Knockout
---------------------------------------------------
require("scripts/globals/status")
require("scripts/globals/settings")
require("scripts/globals/automatonweaponskills")
---------------------------------------------------
function onMobSkillCheck(target, automaton, skill)
local master = automaton:getMaster()
return master:countEffect(dsp.effect.WIND_MANEUVER)
end
function onPetAbility(target, automaton, skill, master, action)
local params = {
numHits = 1,
atkmulti = 1,
accBonus = 50,
weaponType = dsp.skill.CLUB,
ftp100 = 4.0,
ftp200 = 5.0,
ftp300 = 5.5,
acc100 = 0.0,
acc200 = 0.0,
acc300 = 0.0,
str_wsc = 0.0,
dex_wsc = 0.0,
vit_wsc = 0.0,
agi_wsc = 0.0,
int_wsc = 0.0,
mnd_wsc = 0.0,
chr_wsc = 0.0
}
if USE_ADOULIN_WEAPON_SKILL_CHANGES then
params.agi_wsc = 1.0
params.ftp100 = 6.0
params.ftp200 = 8.5
params.ftp300 = 11.0
end
local damage = doAutoPhysicalWeaponskill(automaton, target, 0, skill:getTP(), true, action, false, params, skill, action)
if damage > 0 then
if not target:hasStatusEffect(dsp.effect.EVASION_DOWN) then
target:addStatusEffect(dsp.effect.EVASION_DOWN, 10, 0, 30)
end
end
return damage
end
| gpl-3.0 |
Colettechan/darkstar | scripts/globals/items/holy_maul_+1.lua | 41 | 1077 | -----------------------------------------
-- ID: 17114
-- Item: Holy Maul +1
-- Additional Effect: Light Damage
-----------------------------------------
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------
-- onAdditionalEffect Action
-----------------------------------
function onAdditionalEffect(player,target,damage)
local chance = 10;
if (math.random(0,99) >= chance) then
return 0,0,0;
else
local dmg = math.random(7,21);
local params = {};
params.bonusmab = 0;
params.includemab = false;
dmg = addBonusesAbility(player, ELE_LIGHT, target, dmg, params);
dmg = dmg * applyResistanceAddEffect(player,target,ELE_LIGHT,0);
dmg = adjustForTarget(target,dmg,ELE_LIGHT);
dmg = finalMagicNonSpellAdjustments(player,target,ELE_LIGHT,dmg);
local message = MSGBASIC_ADD_EFFECT_DMG;
if (dmg < 0) then
message = MSGBASIC_ADD_EFFECT_HEAL;
end
return SUBEFFECT_LIGHT_DAMAGE,message,dmg;
end
end; | gpl-3.0 |
zeromq/lzmq | src/lua/lzmq/ffi/api.lua | 1 | 27283 | --
-- Author: Alexey Melnichuk <mimir@newmail.ru>
--
-- Copyright (C) 2013-2017 Alexey Melnichuk <mimir@newmail.ru>
--
-- Licensed according to the included 'LICENCE' document
--
-- This file is part of lua-lzqm library.
--
local ffi = require "ffi"
local IS_WINDOWS = (ffi.os:lower() == 'windows') or
(package.config:sub(1,1) == '\\')
local function orequire(...)
local err = ""
for _, name in ipairs{...} do
local ok, mod = pcall(require, name)
if ok then return mod, name end
err = err .. "\n" .. mod
end
error(err)
end
local function oload(t)
local err = ""
for _, name in ipairs(t) do
local ok, mod = pcall(ffi.load, name)
if ok then return mod, name end
err = err .. "\n" .. mod
end
error(err)
end
local bit = orequire("bit32", "bit")
local zlibs if IS_WINDOWS then
zlibs = {
"zmq", "libzmq",
"zmq4", "libzmq4",
"zmq3", "libzmq3",
}
else
zlibs = {
"zmq", "libzmq",
"zmq.so.5", "libzmq.so.5",
"zmq.so.4", "libzmq.so.4",
"zmq.so.3", "libzmq.so.3",
"/usr/local/lib/libzmq.so",
"/usr/local/lib/libzmq.so.5",
"/usr/local/lib/libzmq.so.4",
"/usr/local/lib/libzmq.so.3",
}
end
local ok, libzmq3 = pcall( oload, zlibs )
if not ok then
if pcall( require, "lzmq" ) then -- jus to load libzmq3
libzmq3 = oload( zlibs )
else error(libzmq3) end
end
local aint_t = ffi.typeof("int[1]")
local aint16_t = ffi.typeof("int16_t[1]")
local auint16_t = ffi.typeof("uint16_t[1]")
local aint32_t = ffi.typeof("int32_t[1]")
local auint32_t = ffi.typeof("uint32_t[1]")
local aint64_t = ffi.typeof("int64_t[1]")
local auint64_t = ffi.typeof("uint64_t[1]")
local asize_t = ffi.typeof("size_t[1]")
local vla_char_t = ffi.typeof("char[?]")
local pvoid_t = ffi.typeof("void*")
local pchar_t = ffi.typeof("char*")
local uintptr_t = ffi.typeof("uintptr_t")
local NULL = ffi.cast(pvoid_t, 0)
local int16_size = ffi.sizeof("int16_t")
local int32_size = ffi.sizeof("int32_t")
local ptr_size = ffi.sizeof(pvoid_t)
local fd_t, afd_t
if IS_WINDOWS and ffi.arch == 'x64' then
fd_t, afd_t = "uint64_t", auint64_t
else
fd_t, afd_t = "int", aint_t
end
local fd_size = ffi.sizeof(fd_t)
-- !Note! this allocator could return same buffer more then once.
-- So you can not use this function to allocate 2 different buffers.
local function create_tmp_allocator(array_size, array_type)
assert(type(array_size) == "number")
assert(array_size > 0)
if type(array_type) == 'string' then
array_type = ffi.typeof(array_type)
else
array_type = array_type or vla_char_t
end
local buffer
return function(len)
if len <= array_size then
if not buffer then
buffer = ffi.new(array_type, array_size)
end
return buffer
end
return ffi.new(array_type, len)
end
end
local header = [[
void zmq_version (int *major, int *minor, int *patch);
]]
ffi.cdef(header)
local _M = {}
-- zmq_version
do
function _M.zmq_version()
local major, minor, patch = ffi.new(aint_t, 0), ffi.new(aint_t, 0), ffi.new(aint_t, 0)
libzmq3.zmq_version(major, minor, patch)
return major[0], minor[0], patch[0]
end
end
local ZMQ_VERSION_MAJOR, ZMQ_VERSION_MINOR, ZMQ_VERSION_PATCH = _M.zmq_version()
assert(
((ZMQ_VERSION_MAJOR == 3) and (ZMQ_VERSION_MINOR >= 2)) or (ZMQ_VERSION_MAJOR == 4),
"Unsupported ZMQ version: " .. ZMQ_VERSION_MAJOR .. "." .. ZMQ_VERSION_MINOR .. "." .. ZMQ_VERSION_PATCH
)
-- >=
local is_zmq_ge = function (major, minor, patch)
if ZMQ_VERSION_MAJOR < major then return false end
if ZMQ_VERSION_MAJOR > major then return true end
if ZMQ_VERSION_MINOR < minor then return false end
if ZMQ_VERSION_MINOR > minor then return true end
if ZMQ_VERSION_PATCH < patch then return false end
return true
end
if is_zmq_ge(4, 1, 1) then
header = [[
typedef struct zmq_msg_t {unsigned char _ [64];} zmq_msg_t;
]]
ffi.cdef(header)
elseif is_zmq_ge(4, 1, 0) then
header = [[
typedef struct zmq_msg_t {unsigned char _ [48];} zmq_msg_t;
]]
ffi.cdef(header)
else
header = [[
typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
]]
ffi.cdef(header)
end
header = [[
int zmq_errno (void);
const char *zmq_strerror (int errnum);
void *zmq_ctx_new (void);
int zmq_ctx_term (void *context);
int zmq_ctx_destroy (void *context);
int zmq_ctx_shutdown (void *context);
int zmq_ctx_set (void *context, int option, int optval);
int zmq_ctx_get (void *context, int option);
void *zmq_socket (void *, int type);
int zmq_close (void *s);
int zmq_setsockopt (void *s, int option, const void *optval, size_t optvallen);
int zmq_getsockopt (void *s, int option, void *optval, size_t *optvallen);
int zmq_bind (void *s, const char *addr);
int zmq_connect (void *s, const char *addr);
int zmq_unbind (void *s, const char *addr);
int zmq_disconnect (void *s, const char *addr);
int zmq_send (void *s, const void *buf, size_t len, int flags);
int zmq_recv (void *s, void *buf, size_t len, int flags);
int zmq_socket_monitor (void *s, const char *addr, int events);
int zmq_sendmsg (void *s, zmq_msg_t *msg, int flags);
int zmq_recvmsg (void *s, zmq_msg_t *msg, int flags);
int zmq_msg_init (zmq_msg_t *msg);
int zmq_msg_init_size (zmq_msg_t *msg, size_t size);
void *zmq_msg_data (zmq_msg_t *msg);
size_t zmq_msg_size (zmq_msg_t *msg);
int zmq_msg_close (zmq_msg_t *msg);
int zmq_msg_send (zmq_msg_t *msg, void *s, int flags);
int zmq_msg_recv (zmq_msg_t *msg, void *s, int flags);
int zmq_msg_move (zmq_msg_t *dest, zmq_msg_t *src);
int zmq_msg_copy (zmq_msg_t *dest, zmq_msg_t *src);
int zmq_msg_more (zmq_msg_t *msg);
int zmq_msg_get (zmq_msg_t *msg, int option);
int zmq_msg_set (zmq_msg_t *msg, int option, int optval);
]]
ffi.cdef(header)
if is_zmq_ge(4, 1, 0) then
ffi.cdef[[
const char *zmq_msg_gets (zmq_msg_t *msg, const char *property);
]]
end
header = [[
typedef struct {
void *socket;
]] .. fd_t .. [[ fd;
short events;
short revents;
} zmq_pollitem_t;
int zmq_poll (zmq_pollitem_t *items, int nitems, long timeout);
]]
ffi.cdef(header)
header = [[
int zmq_has (const char *capability);
]]
ffi.cdef(header)
header = [[
int zmq_proxy (void *frontend, void *backend, void *capture);
int zmq_device (int type, void *frontend, void *backend);
int zmq_proxy_steerable (void *frontend, void *backend, void *capture, void *control);
]]
ffi.cdef(header)
header = [[
char *zmq_z85_encode (char *dest, const char *data, size_t size);
char *zmq_z85_decode (char *dest, const char *string);
int zmq_curve_keypair (char *z85_public_key, char *z85_secret_key);
int zmq_curve_public (char *z85_public_key, const char *z85_secret_key);
]]
ffi.cdef(header)
header = [[
void *zmq_stopwatch_start (void);
unsigned long zmq_stopwatch_stop (void *watch_);
]]
ffi.cdef(header)
local zmq_msg_t = ffi.typeof("zmq_msg_t")
local vla_pollitem_t = ffi.typeof("zmq_pollitem_t[?]")
local zmq_pollitem_t = ffi.typeof("zmq_pollitem_t")
local pollitem_size = ffi.sizeof(zmq_pollitem_t)
local function ptrtoint(ptr)
return tonumber(ffi.cast(uintptr_t, ptr))
end
local function inttoptr(val)
return ffi.cast(pvoid_t, ffi.cast(uintptr_t, val))
end
local ptrtostr, strtoptr do
local void_array = ffi.new("void*[1]")
local char_ptr = ffi.cast(pchar_t, void_array)
ptrtostr = function (ptr)
void_array[0] = ptr
return ffi.string(char_ptr, ptr_size)
end
strtoptr = function (str)
if type(str) == 'string' then
assert(#str == ptr_size)
ffi.copy(char_ptr, str, ptr_size)
return void_array[0]
end
-- we can support also lightuserdata
assert(type(str) == 'userdata')
return ffi.cast(pvoid_t, str)
end
end
local serialize_ptr, deserialize_ptr = ptrtostr, strtoptr
local function pget(lib, elem)
local ok, err = pcall(function()
local m = lib[elem]
if nil ~= m then return m end
error("not found")
end)
if ok then return err end
return nil, err
end
-- zmq_errno, zmq_strerror, zmq_poll, zmq_device, zmq_proxy, zmq_has
do
function _M.zmq_errno()
return libzmq3.zmq_errno()
end
function _M.zmq_strerror(errnum)
local str = libzmq3.zmq_strerror (errnum);
return ffi.string(str)
end
function _M.zmq_poll(items, nitems, timeout)
return libzmq3.zmq_poll(items, nitems, timeout)
end
function _M.zmq_device(dtype, frontend, backend)
return libzmq3.zmq_device(dtype, frontend, backend)
end
function _M.zmq_proxy(frontend, backend, capture)
return libzmq3.zmq_proxy(frontend, backend, capture)
end
if pget(libzmq3, "zmq_proxy_steerable") then
function _M.zmq_proxy_steerable(frontend, backend, capture, control)
return libzmq3.zmq_proxy_steerable(frontend, backend, capture, control)
end
end
if pget(libzmq3, "zmq_has") then
function _M.zmq_has(capability)
local v = libzmq3.zmq_has(capability)
if v == 1 then return true end
return false
end
end
end
-- zmq_ctx_new, zmq_ctx_term, zmq_ctx_get, zmq_ctx_set
do
function _M.zmq_ctx_new()
local ctx = libzmq3.zmq_ctx_new()
ffi.gc(ctx, _M.zmq_ctx_term)
return ctx
end
if pget(libzmq3, "zmq_ctx_shutdown") then
function _M.zmq_ctx_shutdown(ctx)
return libzmq3.zmq_ctx_shutdown(ctx)
end
end
if pget(libzmq3, "zmq_ctx_term") then
function _M.zmq_ctx_term(ctx)
return libzmq3.zmq_ctx_term(ffi.gc(ctx, nil))
end
else
function _M.zmq_ctx_term(ctx)
libzmq3.zmq_ctx_destroy(ffi.gc(ctx, nil))
end
end
function _M.zmq_ctx_get(ctx, option)
return libzmq3.zmq_ctx_get(ctx, option)
end
function _M.zmq_ctx_set(ctx, option, value)
return libzmq3.zmq_ctx_set(ctx, option, value)
end
end
-- zmq_send, zmq_recv, zmq_sendmsg, zmq_recvmsg,
-- zmq_socket, zmq_close, zmq_connect, zmq_bind, zmq_unbind, zmq_disconnect,
-- zmq_skt_setopt_int, zmq_skt_setopt_i64, zmq_skt_setopt_u64, zmq_skt_setopt_str,
-- zmq_skt_getopt_int, zmq_skt_getopt_i64, zmq_skt_getopt_u64, zmq_skt_getopt_str
-- zmq_socket_monitor
do
function _M.zmq_socket(ctx, stype)
local skt = libzmq3.zmq_socket(ctx, stype)
if NULL == skt then return nil end
ffi.gc(skt, _M.zmq_close)
return skt
end
function _M.zmq_close(skt)
return libzmq3.zmq_close(ffi.gc(skt,nil))
end
local function gen_setopt_int(t, ct)
return function (skt, option, optval)
local size = ffi.sizeof(t)
local val = ffi.new(ct, optval)
return libzmq3.zmq_setsockopt(skt, option, val, size)
end
end
local function gen_getopt_int(t, ct)
return function (skt, option)
local size = ffi.new(asize_t, ffi.sizeof(t))
local val = ffi.new(ct, 0)
if -1 ~= libzmq3.zmq_getsockopt(skt, option, val, size) then
return val[0]
end
return
end
end
_M.zmq_skt_setopt_int = gen_setopt_int("int", aint_t )
_M.zmq_skt_setopt_i64 = gen_setopt_int("int64_t", aint64_t )
_M.zmq_skt_setopt_u64 = gen_setopt_int("uint64_t", auint64_t)
function _M.zmq_skt_setopt_str(skt, option, optval)
return libzmq3.zmq_setsockopt(skt, option, optval, #optval)
end
_M.zmq_skt_getopt_int = gen_getopt_int("int", aint_t )
_M.zmq_skt_getopt_fdt = gen_getopt_int(fd_t, afd_t )
_M.zmq_skt_getopt_i64 = gen_getopt_int("int64_t", aint64_t )
_M.zmq_skt_getopt_u64 = gen_getopt_int("uint64_t", auint64_t)
function _M.zmq_skt_getopt_str(skt, option)
local len = 255
local val = ffi.new(vla_char_t, len)
local size = ffi.new(asize_t, len)
if -1 ~= libzmq3.zmq_getsockopt(skt, option, val, size) then
if size[0] > 0 then
return ffi.string(val, size[0] - 1)
end
return ""
end
return
end
function _M.zmq_skt_getopt_identity_fd(skt, option, id)
local buffer_len = 255
assert(#id <= buffer_len, "identity too big")
local size = ffi.new(asize_t, #id)
local buffer = ffi.new(vla_char_t, buffer_len)
local val = ffi.new(afd_t, 0)
ffi.copy(buffer, id)
if -1 ~= libzmq3.zmq_getsockopt(skt, option, buffer, size) then
ffi.copy(val, buffer, fd_size)
return val[0]
end
end
function _M.zmq_connect(skt, addr)
return libzmq3.zmq_connect(skt, addr)
end
function _M.zmq_bind(skt, addr)
return libzmq3.zmq_bind(skt, addr)
end
function _M.zmq_unbind(skt, addr)
return libzmq3.zmq_unbind(skt, addr)
end
function _M.zmq_disconnect(skt, addr)
return libzmq3.zmq_disconnect(skt, addr)
end
function _M.zmq_send(skt, data, flags)
return libzmq3.zmq_send(skt, data, #data, flags or 0)
end
function _M.zmq_recv(skt, len, flags)
local buf = ffi.new(vla_char_t, len)
local flen = libzmq3.zmq_recv(skt, buf, len, flags or 0)
if flen < 0 then return end
if len > flen then len = flen end
return ffi.string(buf, len), flen
end
function _M.zmq_sendmsg(skt, msg, flags)
return libzmq3.zmq_sendmsg(skt, msg, flags)
end
function _M.zmq_recvmsg(skt, msg, flags)
return libzmq3.zmq_recvmsg(skt, msg, flags)
end
function _M.zmq_socket_monitor(skt, addr, events)
return libzmq3.zmq_socket_monitor(skt, addr, events)
end
end
-- zmq_msg_init, zmq_msg_init_size, zmq_msg_data, zmq_msg_size, zmq_msg_get,
-- zmq_msg_set, zmq_msg_move, zmq_msg_copy, zmq_msg_set_data, zmq_msg_get_data,
-- zmq_msg_init_string, zmq_msg_recv, zmq_msg_send, zmq_msg_more, zmq_msg_gets
do -- message
function _M.zmq_msg_init(msg)
msg = msg or ffi.new(zmq_msg_t)
if 0 == libzmq3.zmq_msg_init(msg) then
return msg
end
return
end
function _M.zmq_msg_init_size(msg, len)
if not len then msg, len = nil, msg end
local msg = msg or ffi.new(zmq_msg_t)
if 0 == libzmq3.zmq_msg_init_size(msg, len) then
return msg
end
return
end
function _M.zmq_msg_data(msg, pos)
local ptr = libzmq3.zmq_msg_data(msg)
pos = pos or 0
if pos == 0 then return ptr end
ptr = ffi.cast(pchar_t, ptr) + pos
return ffi.cast(pvoid_t, ptr)
end
function _M.zmq_msg_size(msg)
return libzmq3.zmq_msg_size(msg)
end
function _M.zmq_msg_close(msg)
libzmq3.zmq_msg_close(msg)
end
local function get_msg_copy(copy)
return function (dest, src)
local new = false
if not src then
new, src = true, dest
dest = _M.zmq_msg_init()
if not dest then return end
end
local ret = copy(dest, src)
if ret == -1 then
if new then _M.zmq_msg_close(dest) end
return
end
return dest
end
end
_M.zmq_msg_move = get_msg_copy(libzmq3.zmq_msg_move)
_M.zmq_msg_copy = get_msg_copy(libzmq3.zmq_msg_copy)
function _M.zmq_msg_set_data(msg, str)
ffi.copy(_M.zmq_msg_data(msg), str)
end
function _M.zmq_msg_get_data(msg)
return ffi.string(_M.zmq_msg_data(msg), _M.zmq_msg_size(msg))
end
function _M.zmq_msg_init_string(str)
local msg = _M.zmq_msg_init_size(#str)
_M.zmq_msg_set_data(msg, str)
return msg
end
function _M.zmq_msg_recv(msg, skt, flags)
return libzmq3.zmq_msg_recv(msg, skt, flags or 0)
end
function _M.zmq_msg_send(msg, skt, flags)
return libzmq3.zmq_msg_send(msg, skt, flags or 0)
end
function _M.zmq_msg_more(msg)
return libzmq3.zmq_msg_more(msg)
end
function _M.zmq_msg_get(msg, option)
return libzmq3.zmq_msg_get(msg, option)
end
function _M.zmq_msg_set(msg, option, optval)
return libzmq3.zmq_msg_set(msg, option, optval)
end
if pget(libzmq3, "zmq_msg_gets") then
function _M.zmq_msg_gets(msg, option)
local value = libzmq3.zmq_msg_gets(msg, option)
if value == NULL then return end
return ffi.string(value)
end
end
end
-- zmq_z85_encode, zmq_z85_decode
if pget(libzmq3, "zmq_z85_encode") then
-- we alloc buffers for CURVE encoded key size
local alloc_z85_buff = create_tmp_allocator(41)
function _M.zmq_z85_encode(data)
local len = math.floor(#data * 1.25 + 1.0001)
local buf = alloc_z85_buff(len)
local ret = libzmq3.zmq_z85_encode(buf, data, #data)
if ret == NULL then error("size of the block must be divisible by 4") end
return ffi.string(buf, len - 1)
end
function _M.zmq_z85_decode(data)
local len = math.floor(#data * 0.8 + 0.0001)
local buf = alloc_z85_buff(len)
local ret = libzmq3.zmq_z85_decode(buf, data)
if ret == NULL then error("size of the block must be divisible by 5") end
return ffi.string(buf, len)
end
end
-- zmq_curve_keypair
if pget(libzmq3, "zmq_curve_keypair") then
function _M.zmq_curve_keypair(as_binary)
local public_key = ffi.new(vla_char_t, 41)
local secret_key = ffi.new(vla_char_t, 41)
local ret = libzmq3.zmq_curve_keypair(public_key, secret_key)
if ret == -1 then return -1 end
if not as_binary then
return ffi.string(public_key, 40), ffi.string(secret_key, 40)
end
local public_key_bin = ffi.new(vla_char_t, 32)
local secret_key_bin = ffi.new(vla_char_t, 32)
libzmq3.zmq_z85_decode(public_key_bin, public_key)
libzmq3.zmq_z85_decode(secret_key_bin, secret_key)
return ffi.string(public_key_bin, 32), ffi.string(secret_key_bin, 32)
end
end
-- zmq_curve_public
if pget(libzmq3, "zmq_curve_public") then
function _M.zmq_curve_public(secret_key, as_binary)
local public_key = ffi.new(vla_char_t, 41)
local ret = libzmq3.zmq_curve_public(public_key, secret_key)
if ret == -1 then return -1 end
if not as_binary then
return ffi.string(public_key, 40)
end
local public_key_bin = ffi.new(vla_char_t, 32)
libzmq3.zmq_z85_decode(public_key_bin, public_key)
return ffi.string(public_key_bin, 32)
end
end
-- zmq_recv_event
do
local msg = ffi.new(zmq_msg_t)
if ZMQ_VERSION_MAJOR == 3 then
local header = [[
typedef struct {
int event;
union {
struct {
char *addr;
int fd;
} connected;
struct {
char *addr;
int err;
} connect_delayed;
struct {
char *addr;
int interval;
} connect_retried;
struct {
char *addr;
int fd;
} listening;
struct {
char *addr;
int err;
} bind_failed;
struct {
char *addr;
int fd;
} accepted;
struct {
char *addr;
int err;
} accept_failed;
struct {
char *addr;
int fd;
} closed;
struct {
char *addr;
int err;
} close_failed;
struct {
char *addr;
int fd;
} disconnected;
} data;
} zmq_event_t;
]]
ffi.cdef(header)
local zmq_event_t = ffi.typeof("zmq_event_t")
local event_size = ffi.sizeof(zmq_event_t)
local event = ffi.new(zmq_event_t)
function _M.zmq_recv_event(skt, flags)
local msg = _M.zmq_msg_init(msg)
if not msg then return end
local ret = _M.zmq_msg_recv(msg, skt, flags)
if ret == -1 then
_M.zmq_msg_close(msg)
return
end
assert(_M.zmq_msg_size(msg) >= event_size)
assert(_M.zmq_msg_more(msg) == 0)
ffi.copy(event, _M.zmq_msg_data(msg), event_size)
local addr
if event.data.connected.addr ~= NULL then
addr = ffi.string(event.data.connected.addr)
end
_M.zmq_msg_close(msg)
return event.event, event.data.connected.fd, addr
end
else
local event = ffi.new(auint16_t)
local value = ffi.new(aint32_t)
function _M.zmq_recv_event(skt, flags)
local msg = _M.zmq_msg_init(msg)
if not msg then return end
local ret = _M.zmq_msg_recv(msg, skt, flags)
if ret == -1 then
_M.zmq_msg_close(msg)
return
end
-- assert(_M.zmq_msg_more(msg) ~= 0)
local buf = ffi.cast(pchar_t, _M.zmq_msg_data(msg))
assert(_M.zmq_msg_size(msg) == (int16_size + int32_size))
ffi.copy(event, buf, int16_size)
ffi.copy(value, buf + int16_size, int32_size)
ret = _M.zmq_msg_recv(msg, skt, _M.FLAGS.ZMQ_DONTWAIT)
if ret == -1 then
_M.zmq_msg_close(msg)
return
end
local addr = _M.zmq_msg_get_data(msg)
_M.zmq_msg_close(msg)
-- assert(_M.zmq_msg_more(msg) == 0)
return event[0], value[0], addr
end
end
end
-- zmq_stopwatch_start, zmq_stopwatch_stop
do
function _M.zmq_stopwatch_start()
return libzmq3.zmq_stopwatch_start()
end
function _M.zmq_stopwatch_stop(watch)
return tonumber(libzmq3.zmq_stopwatch_stop(watch))
end
end
_M.ERRORS = require"lzmq.ffi.error"
local ERRORS_MNEMO = {}
for k,v in pairs(_M.ERRORS) do ERRORS_MNEMO[v] = k end
function _M.zmq_mnemoerror(errno)
return ERRORS_MNEMO[errno] or "UNKNOWN"
end
do -- const
local unpack = unpack or table.unpack
local function O(opt)
local t = {}
for k, v in pairs(opt) do
if type(k) == "string" then
t[k] = v
elseif is_zmq_ge(unpack(k)) then
for name, val in pairs(v) do
t[name] = val
end
end
end
return t
end
_M.CONTEXT_OPTIONS = O{
ZMQ_IO_THREADS = 1;
ZMQ_MAX_SOCKETS = 2;
[{4,1,0}] = {
ZMQ_SOCKET_LIMIT = 3;
ZMQ_THREAD_PRIORITY = 3;
ZMQ_THREAD_SCHED_POLICY = 4;
};
[{4,2,2}] = {
ZMQ_MAX_MSGSZ = 5
};
}
_M.SOCKET_OPTIONS = O{
ZMQ_AFFINITY = {4 , "RW", "u64"};
ZMQ_IDENTITY = {5 , "RW", "str"};
ZMQ_SUBSCRIBE = {6 , "WO", "str_arr"};
ZMQ_UNSUBSCRIBE = {7 , "WO", "str_arr"};
ZMQ_RATE = {8 , "RW", "int"};
ZMQ_RECOVERY_IVL = {9 , "RW", "int"};
ZMQ_SNDBUF = {11, "RW", "int"};
ZMQ_RCVBUF = {12, "RW", "int"};
ZMQ_RCVMORE = {13, "RO", "int"};
ZMQ_FD = {14, "RO", "fdt"};
ZMQ_EVENTS = {15, "RO", "int"};
ZMQ_TYPE = {16, "RO", "int"};
ZMQ_LINGER = {17, "RW", "int"};
ZMQ_RECONNECT_IVL = {18, "RW", "int"};
ZMQ_BACKLOG = {19, "RW", "int"};
ZMQ_RECONNECT_IVL_MAX = {21, "RW", "int"};
ZMQ_MAXMSGSIZE = {22, "RW", "i64"};
ZMQ_SNDHWM = {23, "RW", "int"};
ZMQ_RCVHWM = {24, "RW", "int"};
ZMQ_MULTICAST_HOPS = {25, "RW", "int"};
ZMQ_RCVTIMEO = {27, "RW", "int"};
ZMQ_SNDTIMEO = {28, "RW", "int"};
ZMQ_IPV4ONLY = {31, "RW", "int"};
ZMQ_LAST_ENDPOINT = {32, "RO", "str"};
ZMQ_ROUTER_MANDATORY = {33, "WO", "int"};
ZMQ_TCP_KEEPALIVE = {34, "RW", "int"};
ZMQ_TCP_KEEPALIVE_CNT = {35, "RW", "int"};
ZMQ_TCP_KEEPALIVE_IDLE = {36, "RW", "int"};
ZMQ_TCP_KEEPALIVE_INTVL = {37, "RW", "int"};
ZMQ_TCP_ACCEPT_FILTER = {38, "WO", "str_arr"};
ZMQ_DELAY_ATTACH_ON_CONNECT = {39, "RW", "int"};
ZMQ_IMMEDIATE = {39, "RW", "int"};
ZMQ_XPUB_VERBOSE = {40, "RW", "int"};
[{4,0,0}] = {
ZMQ_ROUTER_RAW = {41, "RW", "int"};
ZMQ_IPV6 = {42, "RW", "int"},
ZMQ_MECHANISM = {43, "RO", "int"},
ZMQ_PLAIN_SERVER = {44, "RW", "int"},
ZMQ_PLAIN_USERNAME = {45, "RW", "str"},
ZMQ_PLAIN_PASSWORD = {46, "RW", "str"},
ZMQ_CURVE_SERVER = {47, "RW", "int"},
ZMQ_CURVE_PUBLICKEY = {48, "RW", "str"},
ZMQ_CURVE_SECRETKEY = {49, "RW", "str"},
ZMQ_CURVE_SERVERKEY = {50, "RW", "str"},
ZMQ_PROBE_ROUTER = {51, "WO", "int"},
ZMQ_REQ_CORRELATE = {52, "WO", "int"},
ZMQ_REQ_RELAXED = {53, "WO", "int"},
ZMQ_CONFLATE = {54, "WO", "int"},
ZMQ_ZAP_DOMAIN = {55, "RW", "str"},
};
[{4,1,0}] = {
ZMQ_ROUTER_HANDOVER = {56, "WO", "int"},
ZMQ_TOS = {57, "RW", "int"},
ZMQ_IPC_FILTER_PID = {58, "WO", "int"}, --@fixme use pid_t
ZMQ_IPC_FILTER_UID = {59, "WO", "int"}, --@fixme use uid_t
ZMQ_IPC_FILTER_GID = {60, "WO", "int"}, --@fixme use gid_t
ZMQ_CONNECT_RID = {61, "WO", "str"},
ZMQ_GSSAPI_SERVER = {62, "RW", "int"},
ZMQ_GSSAPI_PRINCIPAL = {63, "RW", "str"},
ZMQ_GSSAPI_SERVICE_PRINCIPAL = {64, "RW", "str"},
ZMQ_GSSAPI_PLAINTEXT = {65, "RW", "str"},
ZMQ_HANDSHAKE_IVL = {66, "RW", "int"},
-- ZMQ_IDENTITY_FD = {67, "RO", "fdt"},
ZMQ_SOCKS_PROXY = {68, "RW", "str"},
};
[{4,1,1}] = {
ZMQ_XPUB_NODROP = {69, "WO", "int"},
};
[{4,2,0}] = {
ZMQ_BLOCKY = {70, "RW", "int"},
ZMQ_XPUB_MANUAL = {71, "WO", "int"},
ZMQ_XPUB_WELCOME_MSG = {72, "WO", "str"},
};
[{4,2,2}] = {
ZMQ_STREAM_NOTIFY = {73, "WO", "int"},
ZMQ_INVERT_MATCHING = {74, "RW", "int"},
ZMQ_HEARTBEAT_IVL = {75, "WO", "int"},
ZMQ_HEARTBEAT_TTL = {76, "WO", "int"},
ZMQ_HEARTBEAT_TIMEOUT = {77, "WO", "int"},
ZMQ_XPUB_VERBOSER = {78, "WO", "int"},
ZMQ_CONNECT_TIMEOUT = {79, "RW", "int"},
ZMQ_TCP_MAXRT = {80, "RW", "int"},
ZMQ_THREAD_SAFE = {81, "RO", "int"},
ZMQ_MULTICAST_MAXTPDU = {84, "RW", "int"},
ZMQ_VMCI_BUFFER_SIZE = {85, "RW", "u64"},
ZMQ_VMCI_BUFFER_MIN_SIZE = {86, "RW", "u64"},
ZMQ_VMCI_BUFFER_MAX_SIZE = {87, "RW", "u64"},
ZMQ_VMCI_CONNECT_TIMEOUT = {88, "RW", "int"},
ZMQ_USE_FD = {89, "RW", "fdt"},
};
}
_M.MESSAGE_OPTIONS = O{
ZMQ_MORE = {1, "RO"};
[{4,0,6}] = {
ZMQ_SRCFD = {2, "RO"};
ZMQ_SHARED = {3, "RO"};
};
}
_M.SOCKET_TYPES = O{
ZMQ_PAIR = 0;
ZMQ_PUB = 1;
ZMQ_SUB = 2;
ZMQ_REQ = 3;
ZMQ_REP = 4;
ZMQ_DEALER = 5;
ZMQ_ROUTER = 6;
ZMQ_PULL = 7;
ZMQ_PUSH = 8;
ZMQ_XPUB = 9;
ZMQ_XSUB = 10;
[{4,0,0}] = {
ZMQ_STREAM = 11;
};
}
_M.FLAGS = {
ZMQ_DONTWAIT = 1;
ZMQ_SNDMORE = 2;
ZMQ_POLLIN = 1;
ZMQ_POLLOUT = 2;
ZMQ_POLLERR = 4;
}
_M.DEVICE = {
ZMQ_STREAMER = 1;
ZMQ_FORWARDER = 2;
ZMQ_QUEUE = 3;
}
_M.SECURITY_MECHANISM = {
ZMQ_NULL = 0;
ZMQ_PLAIN = 1;
ZMQ_CURVE = 2;
}
_M.EVENTS = O{
ZMQ_EVENT_CONNECTED = 1;
ZMQ_EVENT_CONNECT_DELAYED = 2;
ZMQ_EVENT_CONNECT_RETRIED = 4;
ZMQ_EVENT_LISTENING = 8;
ZMQ_EVENT_BIND_FAILED = 16;
ZMQ_EVENT_ACCEPTED = 32;
ZMQ_EVENT_ACCEPT_FAILED = 64;
ZMQ_EVENT_CLOSED = 128;
ZMQ_EVENT_CLOSE_FAILED = 256;
ZMQ_EVENT_DISCONNECTED = 512;
[{4,0,0}] = {
ZMQ_EVENT_MONITOR_STOPPED = 1024;
};
}
do local ZMQ_EVENT_ALL = 0
for _, v in pairs(_M.EVENTS) do
ZMQ_EVENT_ALL = ZMQ_EVENT_ALL + v
end
_M.EVENTS.ZMQ_EVENT_ALL = ZMQ_EVENT_ALL
end
if is_zmq_ge(4, 2, 0) then
_M.SOCKET_OPTIONS.ZMQ_IDENTITY_FD = nil
end
end
_M.inttoptr = inttoptr
_M.ptrtoint = ptrtoint
_M.strtoptr = strtoptr
_M.ptrtostr = ptrtostr
_M.serialize_ptr = serialize_ptr
_M.deserialize_ptr = deserialize_ptr
_M.vla_pollitem_t = vla_pollitem_t
_M.zmq_pollitem_t = zmq_pollitem_t
_M.zmq_msg_t = zmq_msg_t
_M.NULL = NULL
_M.bit = bit
_M.ZMQ_VERSION_MAJOR, _M.ZMQ_VERSION_MINOR, _M.ZMQ_VERSION_PATCH =
ZMQ_VERSION_MAJOR, ZMQ_VERSION_MINOR, ZMQ_VERSION_PATCH
return _M
| mit |
Akamaru/Mikubot | plugins/get.lua | 1 | 1122 | local function get_value(msg, var_name)
local hash = get_redis_hash(msg, 'variables')
if hash then
local value = redis:hget(hash, var_name)
if not value then
return'Nicht gefunden, benutze "!get", um alle Variablen aufzulisten.'
else
return var_name..' = '..value
end
end
end
local function list_variables(msg)
local hash = get_redis_hash(msg, 'variables')
if hash then
print('Getting variable from redis hash '..hash)
local names = redis:hkeys(hash)
local text = ''
for i=1, #names do
variables = get_value(msg, names[i])
text = text..variables.."\n"
end
if text == '' or text == nil then
return 'Keine Variablen vorhanden!'
else
return text
end
end
end
local function run(msg, matches)
if matches[2] then
return get_value(msg, matches[2])
else
return list_variables(msg)
end
end
return {
description = "Bekommt Variablen, die mit !set gesetzt wurden",
usage = {
"#get: Gibt alle Variablen aus",
"#get (Variable): Gibt die Variable aus."
},
patterns = {
"^(#get) (.+)$",
"^#get$"
},
run = run
} | gpl-2.0 |
JarnoVgr/InfectedWars | entities/entities/tripmine/init.lua | 1 | 3005 | --[[-----------------------------------------------------------------------------
* 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.
-----------------------------------------------------------------------------]]
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include('shared.lua')
/*---------------------------------------------------------
Name: Initialize
---------------------------------------------------------*/
function ENT:Initialize()
self.Entity:DrawShadow( false )
self.Entity:SetModel( "models/weapons/w_eq_smokegrenade.mdl" )
self.Entity:PhysicsInit( SOLID_VPHYSICS )
self.Entity:SetCollisionGroup( COLLISION_GROUP_DEBRIS )
self.Entity:SetTrigger( true )
end
function ENT:Think()
if self.LockPos then
self.Entity:SetPos(self.LockPos)
self.Entity:SetAngles(self.LockAngle)
end
if ( self.AlarmTimer && self.AlarmTimer < CurTime() ) then
self.AlarmTimer = nil
end
if ( self.NotifyTimer && self.NotifyTimer < CurTime() ) then
self.NotifyTimer = nil
end
end
function ENT:StartTripmineMode( hitpos, forward )
if (hitpos) then self.Entity:SetPos( hitpos ) end
self.Entity:SetAngles( forward:Angle() + Angle( 90, 0, 0 ) )
self.LockPos = self.Entity:GetPos()
self.LockAngle = self.Entity:GetAngles()
local trace = {}
trace.start = self.Entity:GetPos()
trace.endpos = self.Entity:GetPos() + (forward * 4096)
trace.filter = self.Entity
trace.mask = MASK_NPCWORLDSTATIC
local tr = util.TraceLine( trace )
local ent = ents.Create( "triplaser" )
ent:SetAngles(self.Entity:GetAngles())
ent:SetPos( self.Entity:LocalToWorld( Vector( 0, 0, 1) ) )
ent:Spawn()
ent:Activate()
ent:GetTable():SetEndPos( tr.HitPos )
ent:SetParent( self.Entity )
ent:SetOwner( self.Entity )
self.Laser = ent
local effectdata = EffectData()
effectdata:SetOrigin( self.Entity:GetPos() )
effectdata:SetNormal( forward )
effectdata:SetMagnitude( 1 )
effectdata:SetScale( 1 )
effectdata:SetRadius( 1 )
util.Effect( "Sparks", effectdata )
end
function ENT:Alarm()
if ( self.AlarmTimer ) then return end
self.AlarmTimer = CurTime() + 0.90
self.Entity:EmitSound( Sound("npc/attack_helicopter/aheli_damaged_alarm1.wav", 100, 400) )
end
function ENT:Notify()
if ( self.NotifyTimer ) then return end
self.NotifyTimer = CurTime() + 0.90
self.Entity:EmitSound( Sound("npc/scanner/combat_scan2.wav", 200, 120) )
end
/*---------------------------------------------------------
Name: UpdateTransmitState
Desc: Set the transmit state
---------------------------------------------------------*/
function ENT:UpdateTransmitState()
return TRANSMIT_ALWAYS
end
| mit |
zynjec/darkstar | scripts/zones/Windurst_Woods/npcs/Umumu.lua | 9 | 2411 | -----------------------------------
-- Area: Windurst Woods
-- NPC: Umumu
-- Involved In Quest: Making Headlines
-- !pos 32.575 -5.250 141.372 241
-----------------------------------
local ID = require("scripts/zones/Windurst_Woods/IDs")
require("scripts/globals/quests")
require("scripts/globals/titles")
-----------------------------------
function onTrade(player,npc,trade)
end
function onTrigger(player,npc)
function testflag(set,flag)
return (set % (2*flag) >= flag)
end
local MakingHeadlines = player:getQuestStatus(WINDURST,dsp.quest.id.windurst.MAKING_HEADLINES)
local WildcatWindurst = player:getCharVar("WildcatWindurst")
if player:getQuestStatus(WINDURST,dsp.quest.id.windurst.LURE_OF_THE_WILDCAT) == QUEST_ACCEPTED and not player:getMaskBit(WildcatWindurst,3) then
player:startEvent(731)
elseif MakingHeadlines == 1 then
local prog = player:getCharVar("QuestMakingHeadlines_var")
-- Variable to track if player has talked to 4 NPCs and a door
-- 1 = Kyume
-- 2 = Yujuju
-- 4 = Hiwom
-- 8 = Umumu
-- 16 = Mahogany Door
if testflag(tonumber(prog),16) then
player:startEvent(383) -- Advised to go to Naiko
elseif not testflag(tonumber(prog),8) then
player:startEvent(381) -- Get scoop and asked to validate
else
player:startEvent(382) -- Reminded to validate
end
elseif MakingHeadlines == 2 then
local rand = math.random(1,3)
if rand == 1 then
player:startEvent(385) -- Conversation after quest completed
elseif rand == 2 then
player:startEvent(386) -- Conversation after quest completed
elseif rand == 3 then
player:startEvent(414) -- Standard Conversation
end
else
player:startEvent(414) -- Standard Conversation
end
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
if csid == 381 then
local prog = player:getCharVar("QuestMakingHeadlines_var")
player:addKeyItem(dsp.ki.WINDURST_WOODS_SCOOP)
player:messageSpecial(ID.text.KEYITEM_OBTAINED,dsp.ki.WINDURST_WOODS_SCOOP)
player:setCharVar("QuestMakingHeadlines_var",prog+8)
elseif csid == 731 then
player:setMaskBit(player:getCharVar("WildcatWindurst"),"WildcatWindurst",3,true)
end
end
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/items/serving_of_salmon_roe.lua | 18 | 1326 | -----------------------------------------
-- ID: 5218
-- Item: serving_of_salmon_roe
-- Food Effect: 30Min, All Races
-----------------------------------------
-- Health 8
-- Magic 8
-- Dexterity 2
-- Mind -1
-----------------------------------------
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,5218);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 8);
target:addMod(MOD_MP, 8);
target:addMod(MOD_DEX, 2);
target:addMod(MOD_MND, -1);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 8);
target:delMod(MOD_MP, 8);
target:delMod(MOD_DEX, 2);
target:delMod(MOD_MND, -1);
end;
| gpl-3.0 |
vimfung/LuaScriptCore | Source/iOS_OSX/LuaScriptCoreTests-iOS/coroutine.lua | 1 | 1399 | function Resume(func)
coroutine.resume(func)
end
function Test()
logic = coroutine.create(function()
while true do
value = GetValue() --返回function?
print ("------ value = ", value);
r, g, b = GetPixel(1000, 1200) --返回1000, 1200
print ("------ r, g, b = ", r, g, b);
coroutine.yield()
end
end)
Resume(logic);
end
function TestModuleFunc()
local tfunc = coroutine.create(function()
local str = TestModule();
print (str);
coroutine.yield()
end)
coroutine.resume(tfunc);
end
function TestClassFunc()
local tfunc = coroutine.create(function()
print ("+++++++++++++");
local p = Person();
print (p);
p:speak("i am vim");
p = Person:createPerson();
print (p);
p.name = "vim";
print (p.name);
Person:printPersonName(p);
coroutine.yield()
end)
coroutine.resume(tfunc);
end
function TestClassImportFunc()
local tfunc = coroutine.create(function()
print(Person, NativePerson);
local p = NativePerson:createPerson();
print(p);
p.name = "abc"
p:speak('Hello World!');
coroutine.yield()
end)
coroutine.resume(tfunc);
end
Test();
TestModuleFunc();
TestClassFunc();
TestClassImportFunc();
| apache-2.0 |
CosyVerif/library | src/cosy/webclient/init.lua | 1 | 3153 | return function (loader)
local I18n = loader.load "cosy.i18n"
local Layer = loader.require "layeredata"
local MT = {}
local Webclient = setmetatable ({
shown = {},
}, MT)
local function replace (t)
if type (t) ~= "table" then
return t
elseif t._ then
return t.message
else
for k, v in pairs (t) do
t [k] = replace (v)
end
return t
end
end
function MT.__call (_, f, ...)
local args = { ... }
loader.scheduler.addthread (function ()
xpcall (function ()
return f (table.unpack (args))
end, function (err)
print ("error:", err)
print (debug.traceback ())
end)
end)
end
function Webclient.jQuery (key)
return Webclient.window:jQuery (key)
end
function Webclient.show (component)
local where = component.where
local data = component.data
local i18n = component.i18n
local template = component.template
local container = Webclient.jQuery ("#" .. where)
local shown = Webclient.shown [where]
if data then
data.locale = Webclient.locale
end
local replacer = setmetatable ({}, {
__index = function (_, key)
if I18n.defines (i18n, key) then
return i18n [key] % {}
elseif data [key] then
return tostring (data [key])
else
return nil
end
end
})
if shown and shown ~= loader.scheduler.running () then
loader.scheduler.removethread (shown)
end
Webclient.shown [where] = loader.scheduler.running ()
container:html (template % replacer)
end
function Webclient.template (name)
local url = "/template/" .. name
local result, err = loader.request (url, true)
if not result then
error (err)
end
return result
end
function Webclient.tojs (t)
if type (t) ~= "table" then
return t
elseif #t ~= 0 then
local result = Webclient.js.new (Webclient.window.Array)
for i = 1, #t do
result [result.length] = Webclient.tojs (t [i])
end
return result
else
local result = Webclient.js.new (Webclient.window.Object)
for k, v in pairs (t) do
assert (type (k) == "string")
result [k] = Webclient.tojs (v)
end
return result
end
end
function Webclient.init ()
local Value = loader.load "cosy.value"
Webclient.library = loader.load "cosy.library"
Webclient.storage = Webclient.window.sessionStorage
local data = Webclient.storage:getItem "cosy:client"
Webclient.data = Layer.new {
name = "webclient",
data = data ~= loader.js.null and Value.decode (data) or {},
}
Webclient.client = assert (Webclient.library.connect (Webclient.origin, Webclient.data))
end
Webclient.js = loader.js
Webclient.window = loader.js.global
Webclient.document = loader.js.global.document
Webclient.navigator = loader.js.global.navigator
Webclient.locale = loader.js.global.navigator.language
Webclient.origin = loader.js.global.location.origin
return Webclient
end
| mit |
zynjec/darkstar | scripts/zones/Windurst_Woods/npcs/Kyaa_Taali.lua | 12 | 1245 | -----------------------------------
-- Area: Windurst Woods
-- NPC: Kyaa Taali
-- Type: Bonecraft Image Support
-- !pos -10.470 -6.25 -141.700 241
-----------------------------------
local ID = require("scripts/zones/Windurst_Woods/IDs")
require("scripts/globals/crafting")
require("scripts/globals/status")
-----------------------------------
function onTrade(player,npc,trade)
end
function onTrigger(player,npc)
local guildMember = isGuildMember(player,2)
local SkillCap = getCraftSkillCap(player,dsp.skill.BONECRAFT)
local SkillLevel = player:getSkillLevel(dsp.skill.BONECRAFT)
if guildMember == 1 then
if not player:hasStatusEffect(dsp.effect.BONECRAFT_IMAGERY) then
player:startEvent(10020,SkillCap,SkillLevel,2,509,player:getGil(),0,0,0)
else
player:startEvent(10020,SkillCap,SkillLevel,2,511,player:getGil(),7147,0,0)
end
else
player:startEvent(10020) -- Standard Dialogue
end
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
if csid == 10020 and option == 1 then
player:messageSpecial(ID.text.IMAGE_SUPPORT,0,6,2)
player:addStatusEffect(dsp.effect.BONECRAFT_IMAGERY,1,0,120)
end
end | gpl-3.0 |
Colettechan/darkstar | scripts/globals/items/serving_of_herb_quus.lua | 18 | 1383 | -----------------------------------------
-- ID: 4559
-- Item: serving_of_herb_quus
-- Food Effect: 180Min, All Races
-----------------------------------------
-- Dexterity 1
-- Mind -1
-- Ranged ACC % 7
-- Ranged ACC Cap 10
-----------------------------------------
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,4559);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_DEX, 1);
target:addMod(MOD_MND, -1);
target:addMod(MOD_FOOD_RACCP, 7);
target:addMod(MOD_FOOD_RACC_CAP, 10);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_DEX, 1);
target:delMod(MOD_MND, -1);
target:delMod(MOD_FOOD_RACCP, 7);
target:delMod(MOD_FOOD_RACC_CAP, 10);
end;
| gpl-3.0 |
kickstandproject/asterisk-testsuite-temporary | tests/apps/queues/macro_gosub_test/test.lua | 5 | 2314 | function manager_setup(a)
local m,err = a:manager_connect()
if not m then
fail("error connecting to asterisk: " .. err)
end
local login = ast.manager.action.login()
if not login then
fail("Failed to create manager login action")
end
local r = m(login)
if not r then
fail("error logging in to the manager: " .. err)
end
if r["Response"] ~= "Success" then
fail("error authenticating: " .. r["Message"])
end
return m
end
function primary(event)
if event["Variable"] == "MACROVAR" then
if event["Value"] == "primarymacro" then
passmacro = true
end
end
if event["Variable"] == "GOSUBVAR" then
if event["Value"] == "primarygosub" then
passgosub = true
end
end
end
function secondary(event)
if event["Variable"] == "MACROVAR" then
if event["Value"] == "secondarymacro" then
passmacro = true
end
end
if event["Variable"] == "GOSUBVAR" then
if event["Value"] == "secondarygosub" then
passgosub = true
end
end
end
function test_call(exten, man, handler)
passmacro = false
passgosub = false
local orig = ast.manager.action:new("Originate")
man:register_event("VarSet", handler)
orig["Channel"] = "Local/" .. exten .."@test_context/n"
orig["Application"] = "Wait"
orig["Data"] = "3"
local res,err = man(orig)
if not res then
fail("Error originating call: " .. err)
end
if res["Response"] ~= "Success" then
fail("Failure response from Originate: " .. res["Message"])
end
--When the originate returns, we know that the member
--has answered the call, but we can't guarantee that
--the macro or gosub has actually run, so sleep for a
--sec for safety's sake
posix.sleep(1)
res, err = man:pump_messages()
if not res then
fail("Error pumping messages: " .. err)
end
man:process_events()
man:unregister_event("VarSet", handler)
if not passmacro then
fail("Did not get expected macro variable set")
end
if not passgosub then
fail("Did not get expected gosub variable set")
end
end
instance = ast.new()
instance:load_config("configs/ast1/extensions.conf")
instance:load_config("configs/ast1/queues.conf")
instance:generate_manager_conf()
instance:spawn()
man = manager_setup(instance)
test_call("test1", man, primary)
test_call("test2", man, secondary)
logoff = ast.manager.action.logoff()
man(logoff)
instance:term_or_kill()
| gpl-2.0 |
Vadavim/jsr-darkstar | scripts/zones/Mordion_Gaol/Zone.lua | 5 | 1417 | -----------------------------------
--
-- Zone: Mordion_Gaol
--
-----------------------------------
require("scripts/globals/settings");
package.loaded["scripts/zones/Mordion_Gaol/TextIDs"] = nil;
require("scripts/zones/Mordion_Gaol/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
end;
-----------------------------------
-- onConquestUpdate
-----------------------------------
function onConquestUpdate(zone, updatetype)
local players = zone:getPlayers();
for name, player in pairs(players) do
conquestUpdate(zone, player, updatetype, CONQUEST_BASE);
end
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/zones/Windurst_Waters_[S]/npcs/Dallus-Mallus.lua | 13 | 1074 | -----------------------------------
-- Area: Windurst Waters (S)
-- NPC: Dallus-Mallus
-- Type: Campaign Intel Advisor
-- @zone: 94
-- @pos -13.666 -2 26.180
--
-- 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(0x0143);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/globals/items/plate_of_beef_paella_+1.lua | 18 | 1474 | -----------------------------------------
-- ID: 5973
-- Item: Plate of Beef Paella +1
-- Food Effect: 4 Hrs, All Races
-----------------------------------------
-- HP 45
-- Strength 6
-- Attack % 19 Cap 95
-- Undead Killer 6
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,14400,5973);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 45);
target:addMod(MOD_STR, 6);
target:addMod(MOD_FOOD_ATTP, 19);
target:addMod(MOD_FOOD_ATT_CAP, 95);
target:addMod(MOD_UNDEAD_KILLER, 6);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 45);
target:delMod(MOD_STR, 6);
target:delMod(MOD_FOOD_ATTP, 19);
target:delMod(MOD_FOOD_ATT_CAP, 95);
target:delMod(MOD_UNDEAD_KILLER, 6);
end;
| gpl-3.0 |
zynjec/darkstar | scripts/globals/items/tonosama_rice_ball.lua | 11 | 1150 | -----------------------------------------
-- ID: 4277
-- Item: Tonosama Rice Ball
-- Food Effect: 30Min, All Races
-----------------------------------------
-- HP +15
-- Dex +3
-- Vit +3
-- Chr +3
-- Effect with enhancing equipment (Note: these are latents on gear with the effect)
-- Atk +50
-- Def +30
-- Double Attack +1%
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if target:hasStatusEffect(dsp.effect.FOOD) or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) then
result = dsp.msg.basic.IS_FULL
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,1800,4277)
end
function onEffectGain(target, effect)
target:addMod(dsp.mod.HP, 15)
target:addMod(dsp.mod.DEX, 3)
target:addMod(dsp.mod.VIT, 3)
target:addMod(dsp.mod.CHR, 3)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.HP, 15)
target:delMod(dsp.mod.DEX, 3)
target:delMod(dsp.mod.VIT, 3)
target:delMod(dsp.mod.CHR, 3)
end | gpl-3.0 |
zynjec/darkstar | scripts/globals/items/loaf_of_hobgoblin_bread.lua | 11 | 1070 | -----------------------------------------
-- ID: 4328
-- Item: loaf_of_hobgoblin_bread
-- Food Effect: 60Min, All Races
-----------------------------------------
-- Health 10
-- Vitality 3
-- Charisma -7
-- Health Regen While Healing 2
-----------------------------------------
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,3600,4328)
end
function onEffectGain(target, effect)
target:addMod(dsp.mod.HP, 10)
target:addMod(dsp.mod.VIT, 3)
target:addMod(dsp.mod.CHR, -7)
target:addMod(dsp.mod.HPHEAL, 2)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.HP, 10)
target:delMod(dsp.mod.VIT, 3)
target:delMod(dsp.mod.CHR, -7)
target:delMod(dsp.mod.HPHEAL, 2)
end
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Windurst_Waters/npcs/Yung_Yaam.lua | 14 | 1769 | -----------------------------------
-- Area: Windurst Waters
-- NPC: Yung Yaam
-- Involved In Quest: Wondering Minstrel
-- Working 100%
-- @zone = 238
-- @pos = -63 -4 27
-----------------------------------
package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/zones/Windurst_Waters/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
--player:addFame(WINDURST,100)
wonderingstatus = player:getQuestStatus(WINDURST,WONDERING_MINSTREL);
fame = player:getFameLevel(WINDURST)
if (wonderingstatus <= 1 and fame >= 5) then
player:startEvent(0x027d); -- WONDERING_MINSTREL: Quest Available / Quest Accepted
elseif (wonderingstatus == QUEST_COMPLETED and player:needToZone()) then
player:startEvent(0x0283); -- WONDERING_MINSTREL: Quest After
else
player:startEvent(0x0261); -- Standard Conversation
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 |
Gh0stblade/OpenTomb | scripts/audio/sample_override.lua | 3 | 9006 | -- OPENTOMB SAMPLE OVERRIDE SCRIPT
-- by noname, June 2014
--------------------------------------------------------------------------------
-- This script allows to override native sound effects from level files or
-- MAIN.SFX file with custom samples. Note that you can specify it on a
-- per-game basis only, and generally, it is needed for first two games which
-- used low-quality samples. You won't need to replace samples for late games
-- (like TR3, TR4 or TR5), since they already have high-quality samples.
--------------------------------------------------------------------------------
print("Sample remapper script loaded");
tr1_sound = {};
tr1_sound[000] = {sample = 0, count = 004};
tr1_sound[001] = {sample = 4, count = 001};
tr1_sound[002] = {sample = 5, count = 001};
tr1_sound[003] = {sample = 6, count = 001};
tr1_sound[004] = {sample = 7, count = 001};
tr1_sound[005] = {sample = 8, count = 001};
tr1_sound[006] = {sample = 9, count = 001};
tr1_sound[007] = {sample = 10, count = 001};
tr1_sound[008] = {sample = 11, count = 001};
tr1_sound[009] = {sample = 12, count = 001};
tr1_sound[010] = {sample = 13, count = 002};
tr1_sound[011] = {sample = 15, count = 001};
tr1_sound[012] = {sample = 16, count = 001};
tr1_sound[013] = {sample = 17, count = 001};
tr1_sound[014] = {sample = 18, count = 002};
tr1_sound[016] = {sample = 20, count = 001};
tr1_sound[018] = {sample = 21, count = 001};
tr1_sound[019] = {sample = 22, count = 002};
tr1_sound[020] = {sample = 24, count = 001};
tr1_sound[022] = {sample = 25, count = 002};
tr1_sound[024] = {sample = 27, count = 001};
tr1_sound[025] = {sample = 28, count = 002};
tr1_sound[026] = {sample = 30, count = 001};
tr1_sound[027] = {sample = 31, count = 002};
tr1_sound[028] = {sample = 33, count = 002};
tr1_sound[029] = {sample = 35, count = 001};
tr1_sound[030] = {sample = 36, count = 001};
tr1_sound[031] = {sample = 37, count = 002};
tr1_sound[032] = {sample = 39, count = 001};
tr1_sound[033] = {sample = 40, count = 001};
tr1_sound[034] = {sample = 41, count = 001};
tr1_sound[035] = {sample = 42, count = 001};
tr1_sound[036] = {sample = 43, count = 001};
tr1_sound[037] = {sample = 44, count = 001};
tr1_sound[038] = {sample = 45, count = 001};
tr1_sound[039] = {sample = 46, count = 001};
tr1_sound[040] = {sample = 47, count = 001};
tr1_sound[041] = {sample = 48, count = 001};
tr1_sound[042] = {sample = 49, count = 001};
tr1_sound[043] = {sample = 50, count = 001};
tr1_sound[044] = {sample = 51, count = 001};
tr1_sound[045] = {sample = 52, count = 001};
tr1_sound[046] = {sample = 53, count = 001};
tr1_sound[047] = {sample = 54, count = 003};
tr1_sound[048] = {sample = 57, count = 001};
tr1_sound[050] = {sample = 58, count = 001};
tr1_sound[051] = {sample = 59, count = 001};
tr1_sound[052] = {sample = 60, count = 001};
tr1_sound[053] = {sample = 61, count = 001};
tr1_sound[054] = {sample = 62, count = 001};
tr1_sound[055] = {sample = 63, count = 001};
tr1_sound[056] = {sample = 64, count = 001};
tr1_sound[057] = {sample = 65, count = 001};
tr1_sound[058] = {sample = 66, count = 001};
tr1_sound[059] = {sample = 67, count = 001};
tr1_sound[060] = {sample = 68, count = 001};
tr1_sound[061] = {sample = 69, count = 001};
tr1_sound[063] = {sample = 70, count = 001};
tr1_sound[064] = {sample = 71, count = 001};
tr1_sound[065] = {sample = 72, count = 001};
tr1_sound[066] = {sample = 73, count = 001};
tr1_sound[067] = {sample = 74, count = 001};
tr1_sound[068] = {sample = 75, count = 001};
tr1_sound[069] = {sample = 76, count = 001};
tr1_sound[070] = {sample = 77, count = 001};
tr1_sound[071] = {sample = 78, count = 001};
tr1_sound[072] = {sample = 79, count = 001};
tr1_sound[073] = {sample = 80, count = 001};
tr1_sound[074] = {sample = 81, count = 001};
tr1_sound[075] = {sample = 82, count = 002};
tr1_sound[076] = {sample = 84, count = 001};
tr1_sound[077] = {sample = 85, count = 001};
tr1_sound[078] = {sample = 86, count = 001};
tr1_sound[079] = {sample = 87, count = 001};
tr1_sound[080] = {sample = 88, count = 001};
tr1_sound[081] = {sample = 89, count = 001};
tr1_sound[082] = {sample = 90, count = 001};
tr1_sound[083] = {sample = 91, count = 001};
tr1_sound[084] = {sample = 92, count = 001};
tr1_sound[085] = {sample = 93, count = 001};
tr1_sound[086] = {sample = 94, count = 002};
tr1_sound[087] = {sample = 96, count = 001};
tr1_sound[088] = {sample = 97, count = 001};
tr1_sound[089] = {sample = 98, count = 001};
tr1_sound[090] = {sample = 99, count = 001};
tr1_sound[091] = {sample = 100, count = 001};
tr1_sound[092] = {sample = 101, count = 001};
tr1_sound[093] = {sample = 102, count = 002};
tr1_sound[094] = {sample = 104, count = 001};
tr1_sound[095] = {sample = 105, count = 001};
tr1_sound[096] = {sample = 106, count = 001};
tr1_sound[097] = {sample = 107, count = 001};
tr1_sound[098] = {sample = 108, count = 001};
tr1_sound[099] = {sample = 109, count = 001};
tr1_sound[100] = {sample = 110, count = 001};
tr1_sound[101] = {sample = 111, count = 004};
tr1_sound[102] = {sample = 115, count = 001};
tr1_sound[103] = {sample = 116, count = 001};
tr1_sound[104] = {sample = 117, count = 001};
tr1_sound[108] = {sample = 118, count = 001};
tr1_sound[109] = {sample = 119, count = 001};
tr1_sound[110] = {sample = 120, count = 001};
tr1_sound[111] = {sample = 121, count = 001};
tr1_sound[112] = {sample = 122, count = 001};
tr1_sound[113] = {sample = 123, count = 001};
tr1_sound[114] = {sample = 124, count = 001};
tr1_sound[115] = {sample = 125, count = 001};
tr1_sound[116] = {sample = 126, count = 001};
tr1_sound[117] = {sample = 127, count = 001};
tr1_sound[118] = {sample = 128, count = 001};
tr1_sound[119] = {sample = 129, count = 001};
tr1_sound[120] = {sample = 130, count = 002};
tr1_sound[121] = {sample = 132, count = 001};
tr1_sound[122] = {sample = 133, count = 001};
tr1_sound[123] = {sample = 134, count = 001};
tr1_sound[124] = {sample = 135, count = 001};
tr1_sound[125] = {sample = 136, count = 001};
tr1_sound[126] = {sample = 137, count = 004};
tr1_sound[127] = {sample = 141, count = 001};
tr1_sound[128] = {sample = 142, count = 001};
tr1_sound[129] = {sample = 143, count = 001};
tr1_sound[130] = {sample = 144, count = 001};
tr1_sound[131] = {sample = 145, count = 001};
tr1_sound[132] = {sample = 146, count = 001};
tr1_sound[133] = {sample = 147, count = 001};
tr1_sound[134] = {sample = 148, count = 001};
tr1_sound[135] = {sample = 149, count = 001};
tr1_sound[136] = {sample = 150, count = 001};
tr1_sound[137] = {sample = 151, count = 001};
tr1_sound[138] = {sample = 152, count = 001};
tr1_sound[139] = {sample = 153, count = 001};
tr1_sound[140] = {sample = 154, count = 001};
tr1_sound[141] = {sample = 155, count = 001};
tr1_sound[142] = {sample = 156, count = 001};
tr1_sound[143] = {sample = 157, count = 004};
tr1_sound[144] = {sample = 161, count = 001};
tr1_sound[145] = {sample = 162, count = 001};
tr1_sound[146] = {sample = 163, count = 001};
tr1_sound[147] = {sample = 164, count = 001};
tr1_sound[148] = {sample = 165, count = 001};
tr1_sound[149] = {sample = 166, count = 001};
tr1_sound[150] = {sample = 167, count = 001};
tr1_sound[151] = {sample = 168, count = 001};
tr1_sound[152] = {sample = 169, count = 001};
tr1_sound[153] = {sample = 170, count = 001};
tr1_sound[154] = {sample = 171, count = 001};
tr1_sound[155] = {sample = 172, count = 001};
tr1_sound[156] = {sample = 173, count = 001};
tr1_sound[157] = {sample = 174, count = 001};
tr1_sound[158] = {sample = 175, count = 001};
tr1_sound[159] = {sample = 176, count = 001};
tr1_sound[160] = {sample = 177, count = 001};
tr1_sound[161] = {sample = 178, count = 001};
tr1_sound[162] = {sample = 179, count = 001};
tr1_sound[163] = {sample = 180, count = 001};
tr1_sound[164] = {sample = 181, count = 001};
tr1_sound[165] = {sample = 182, count = 001};
tr1_sound[166] = {sample = 183, count = 001};
tr1_sound[167] = {sample = 184, count = 001};
tr1_sound[168] = {sample = 185, count = 001};
tr1_sound[169] = {sample = 186, count = 001};
tr1_sound[170] = {sample = 187, count = 001};
tr1_sound[171] = {sample = 188, count = 001};
tr1_sound[172] = {sample = 189, count = 001};
tr_sound_info = {};
tr_sound_info[0] = { num_samples = 195,
num_sounds = 165,
sample_name_mask = "data/tr1/samples/SFX_%04d.wav",
sample_table = tr1_sound };
function getOverridedSample(ver, level_id, sound_id)
if((tr_sound_info[ver] ~= nil) and (tr_sound_info[ver].sample_table[sound_id] ~= nil)) then
return tr_sound_info[ver].sample_table[sound_id].sample, tr_sound_info[ver].sample_table[sound_id].count;
else
return -1, -1;
end
end;
function getOverridedSamplesInfo(ver)
if(tr_sound_info[ver] ~= nil) then
return tr_sound_info[ver].num_samples, tr_sound_info[ver].num_sounds, tr_sound_info[ver].sample_name_mask;
else
return -1, -1, "NONE";
end;
end; | lgpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Port_Windurst/npcs/Janshura-Rashura.lua | 14 | 2913 | -----------------------------------
-- Area: Port Windurst
-- NPC: Janshura Rashura
-- Starts Windurst Missions
-- @pos -227 -8 184 240
-----------------------------------
package.loaded["scripts/zones/Port_Windurst/TextIDs"] = nil;
package.loaded["scripts/globals/missions"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/missions");
require("scripts/zones/Port_Windurst/TextIDs");
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getNation() ~= NATION_WINDURST) then
player:startEvent(0x0047); -- for other nation
else
CurrentMission = player:getCurrentMission(WINDURST);
MissionStatus = player:getVar("MissionStatus");
pRank = player:getRank();
cs, p, offset = getMissionOffset(player,3,CurrentMission,MissionStatus);
if (CurrentMission <= 15 and (cs ~= 0 or offset ~= 0 or (CurrentMission == 0 and offset == 0))) then
if (cs == 0) then
player:showText(npc,ORIGINAL_MISSION_OFFSET + offset); -- dialog after accepting mission
else
player:startEvent(cs,p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8]);
end
elseif (CurrentMission ~= 255) then
player:startEvent(0x004c);
elseif (player:hasCompletedMission(WINDURST,THE_HORUTOTO_RUINS_EXPERIMENT) == false) then
player:startEvent(0x0053);
elseif (player:hasCompletedMission(WINDURST,THE_HEART_OF_THE_MATTER) == false) then
player:startEvent(0x0068);
elseif (player:hasCompletedMission(WINDURST,THE_PRICE_OF_PEACE) == false) then
player:startEvent(0x006d);
elseif (player:hasKeyItem(MESSAGE_TO_JEUNO_WINDURST)) then
player:startEvent(0x00a3);
else
flagMission, repeatMission = getMissionMask(player);
player:startEvent(0x004e,flagMission,0,0,0,STAR_CRESTED_SUMMONS,repeatMission);
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);
finishMissionTimeline(player,3,csid,option);
if (csid == 0x0076 and option == 1) then
player:addTitle(NEW_BEST_OF_THE_WEST_RECRUIT);
elseif (csid == 0x004e and (option == 12 or option == 15)) then
player:addKeyItem(STAR_CRESTED_SUMMONS);
player:messageSpecial(KEYITEM_OBTAINED,STAR_CRESTED_SUMMONS);
end
end; | gpl-3.0 |
Colettechan/darkstar | scripts/zones/Kuftal_Tunnel/npcs/qm5.lua | 13 | 1458 | -----------------------------------
-- Area: Kuftal Tunnel
-- NPC: ???
-- Involved in Mission: Bastok 8-2
-----------------------------------
package.loaded["scripts/zones/Kuftal_Tunnel/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/keyitems");
require("scripts/globals/missions");
require("scripts/zones/Kuftal_Tunnel/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local missionStatus = player:getVar("MissionStatus");
if (player:getCurrentMission(BASTOK) == ENTER_THE_TALEKEEPER and missionStatus == 1) then
player:startEvent(0x00c);
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);
if (option == 0) then
if (csid == 0x00c) then
player:setVar("MissionStatus",2);
player:messageSpecial(FELL);
end
end
end; | gpl-3.0 |
adminomega/extreme | plugins/get.lua | 613 | 1067 | local function get_variables_hash(msg)
if msg.to.type == 'chat' then
return 'chat:'..msg.to.id..':variables'
end
if msg.to.type == 'user' then
return 'user:'..msg.from.id..':variables'
end
end
local function list_variables(msg)
local hash = get_variables_hash(msg)
if hash then
local names = redis:hkeys(hash)
local text = ''
for i=1, #names do
text = text..names[i]..'\n'
end
return text
end
end
local function get_value(msg, var_name)
local hash = get_variables_hash(msg)
if hash then
local value = redis:hget(hash, var_name)
if not value then
return'Not found, use "!get" to list variables'
else
return var_name..' => '..value
end
end
end
local function run(msg, matches)
if matches[2] then
return get_value(msg, matches[2])
else
return list_variables(msg)
end
end
return {
description = "Retrieves variables saved with !set",
usage = "!get (value_name): Returns the value_name value.",
patterns = {
"^(!get) (.+)$",
"^!get$"
},
run = run
}
| gpl-2.0 |
Vadavim/jsr-darkstar | scripts/zones/Nashmau/npcs/Fhe_Maksojha.lua | 14 | 2276 | -----------------------------------
-- Area: Nashmau
-- NPC: Fhe Maksojha
-- Type: Standard NPC
-- @pos 19.084 -7 71.287 53
-----------------------------------
package.loaded["scripts/zones/Nashmau/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/globals/settings");
require("scripts/zones/Nashmau/TextIDs");
-----------------------------------
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local notmeanttobe = player:getQuestStatus(AHT_URHGAN,NOT_MEANT_TO_BE);
local notMeantToBeProg = player:getVar("notmeanttobeCS");
if (notmeanttobe == QUEST_AVAILABLE) then
player:startEvent(0x0125);
elseif (notMeantToBeProg == 1) then
player:startEvent(0x0127);
elseif (notMeantToBeProg == 2) then
player:startEvent(0x0126);
elseif (notMeantToBeProg == 3) then
player:startEvent(0x0128);
elseif (notMeantToBeProg == 5) then
player:startEvent(0x0129);
elseif (notmeanttobe == QUEST_COMPLETED) then
player:startEvent(0x012a);
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 == 0x0125) then
player:setVar("notmeanttobeCS",1);
player:addQuest(AHT_URHGAN,NOT_MEANT_TO_BE);
elseif (csid == 0x0126) then
player:setVar("notmeanttobeCS",3);
elseif (csid == 0x0129) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINEDX,2187,3);
else
player:setVar("notmeanttobeCS",0);
player:addItem(2187,3);
player:messageSpecial(ITEM_OBTAINEDX,2187,3);
player:completeQuest(AHT_URHGAN,NOT_MEANT_TO_BE);
end
end
end;
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Gustav_Tunnel/mobs/Antares.lua | 14 | 1024 | ----------------------------------
-- Area: Gustav Tunnel
-- MOB: Antares
-- Note: Place holder Amikiri
-----------------------------------
require("scripts/globals/groundsofvalor");
require("scripts/zones/Gustav_Tunnel/MobIDs");
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
checkGoVregime(player,mob,768,2);
end;
-----------------------------------
-- onMobDespawn
-----------------------------------
function onMobDespawn(mob)
local mobID = mob:getID();
if (Amikiri_PH[mobID] ~= nil) then
local ToD = GetServerVariable("[POP]Amikiri");
if (ToD <= os.time(t) and GetMobAction(Amikiri) == 0) then
if (math.random(1,20) == 5) then
UpdateNMSpawnPoint(Amikiri);
GetMobByID(Amikiri):setRespawnTime(GetMobRespawnTime(mobID));
SetServerVariable("[PH]Amikiri", mobID);
DeterMob(mobID, true);
end
end
end
end;
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/items/serving_of_bavarois.lua | 18 | 1192 | -----------------------------------------
-- ID: 5729
-- Item: serving_of_bavarois
-- Food Effect: 3Hrs, All Races
-----------------------------------------
-- HP 20
-- Intelligence 3
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,10800,5729);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 20);
target:addMod(MOD_INT, 3);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 20);
target:delMod(MOD_INT, 3);
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/globals/items/serving_of_bavarois.lua | 18 | 1192 | -----------------------------------------
-- ID: 5729
-- Item: serving_of_bavarois
-- Food Effect: 3Hrs, All Races
-----------------------------------------
-- HP 20
-- Intelligence 3
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,10800,5729);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 20);
target:addMod(MOD_INT, 3);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 20);
target:delMod(MOD_INT, 3);
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/globals/mobskills/Bilgestorm.lua | 30 | 1415 | ---------------------------------------------
-- Bilgestorm
--
-- Description: Deals damage in an area of effect. Additional effect: Lowers attack, accuracy, and defense
-- Type: Physical
-- Utsusemi/Blink absorb: Wipes shadows
-- Range: Unknown
-- Notes: Only used at low health.*Experienced the use at 75%*
---------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------
function onMobSkillCheck(target,mob,skill)
if(mob:getFamily() == 316) then
local mobSkin = mob:getModelId();
if (mobSkin == 1839) then
return 0;
else
return 1;
end
end
return 0;
end;
function onMobWeaponSkill(target, mob, skill)
local power = math.random(20,25);
MobPhysicalStatusEffectMove(mob, target, skill, EFFECT_ACCURACY_DOWN, power, 0, 60);
MobPhysicalStatusEffectMove(mob, target, skill, EFFECT_ATTACK_DOWN, power, 0, 60);
MobPhysicalStatusEffectMove(mob, target, skill, EFFECT_DEFENSE_DOWN, power, 0, 60);
local numhits = 1;
local accmod = 1;
local dmgmod = 2;
local info = MobPhysicalMove(mob,target,skill,numhits,accmod,dmgmod,TP_NO_EFFECT);
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_PHYSICAL,MOBPARAM_BLUNT,MOBPARAM_WIPE_SHADOWS);
target:delHP(dmg);
return dmg;
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/zones/Meriphataud_Mountains/npcs/Buliame_RK.lua | 13 | 3350 | -----------------------------------
-- Area: Meriphataud Mountains
-- NPC: Buliame, R.K.
-- Type: Border Conquest Guards
-- @pos -120.393 -25.822 -592.604 119
-----------------------------------
package.loaded["scripts/zones/Meriphataud_Mountains/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/conquest");
require("scripts/zones/Meriphataud_Mountains/TextIDs");
local guardnation = SANDORIA; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno
local guardtype = 4; -- 1: city, 2: foreign, 3: outpost, 4: border
local region = ARAGONEU;
local csid = 0x7ffa;
-----------------------------------
-- 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 |
zynjec/darkstar | scripts/zones/Aht_Urhgan_Whitegate/npcs/Rodin-Comidin.lua | 11 | 1290 | -----------------------------------
-- Area: Aht Urhgan Whitegate
-- NPC: Rodin-Comidin
-- Standard Info NPC
-- Involved in Missions: TOAU-41
-- !pos 17.205 -5.999 51.161 50
-----------------------------------
require("scripts/globals/keyitems")
require("scripts/globals/missions")
require("scripts/globals/npc_util")
local ID = require("scripts/zones/Aht_Urhgan_Whitegate/IDs")
-----------------------------------
function onTrade(player,npc,trade)
end
function onTrigger(player,npc)
if player:getCurrentMission(TOAU) == dsp.mission.id.toau.PATH_OF_DARKNESS and player:hasKeyItem(dsp.ki.NYZUL_ISLE_ROUTE) == false then
player:startEvent(3141,0,0,0,0,0,0,0,0,0)
elseif player:getCurrentMission(TOAU) == dsp.mission.id.toau.LIGHT_OF_JUDGMENT then
player:startEvent(3137,0,0,0,0,0,0,0,0,0)
else
player:startEvent(665)
end
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
if csid == 3137 then
npcUtil.giveKeyItem(player, dsp.ki.NYZUL_ISLE_ROUTE)
player:completeMission(TOAU,dsp.mission.id.toau.LIGHT_OF_JUDGMENT)
player:addMission(TOAU,dsp.mission.id.toau.PATH_OF_DARKNESS)
elseif csid == 3141 then
npcUtil.giveKeyItem(player, dsp.ki.NYZUL_ISLE_ROUTE)
end
end | gpl-3.0 |
zynjec/darkstar | scripts/zones/Arrapago_Reef/mobs/Medusa.lua | 11 | 2583 | -----------------------------------
-- Area: Arrapago Reef
-- NM: Medusa
-- !pos -458 -20 458
-- TODO: resists, attack/def boosts
-----------------------------------
local ID = require("scripts/zones/Arrapago_Reef/IDs")
mixins = {require("scripts/mixins/job_special")}
require("scripts/globals/titles")
require("scripts/globals/status")
-----------------------------------
function onMobSpawn(mob)
dsp.mix.jobSpecial.config(mob, {
chance = 75, -- "Is possible that she will not use Eagle Eye Shot at all." (guessing 75 percent)
specials =
{
{id = dsp.jsa.EES_LAMIA, hpp = math.random(5, 99)},
},
})
end
function onMobEngaged(mob, target)
target:showText(mob, ID.text.MEDUSA_ENGAGE)
for i = ID.mob.MEDUSA + 1, ID.mob.MEDUSA + 4 do
SpawnMob(i):updateEnmity(target)
end
end
function onMobFight(mob, target)
if (mob:getBattleTime() % 60 < 2 and mob:getBattleTime() > 10) then
if (not GetMobByID(ID.mob.MEDUSA + 1):isSpawned()) then
GetMobByID(ID.mob.MEDUSA + 1):setSpawn(mob:getXPos()+math.random(1,5), mob:getYPos(), mob:getZPos()+math.random(1,5))
SpawnMob(ID.mob.MEDUSA + 1):updateEnmity(target)
elseif (not GetMobByID(ID.mob.MEDUSA + 2):isSpawned()) then
GetMobByID(ID.mob.MEDUSA + 2):setSpawn(mob:getXPos()+math.random(1,5), mob:getYPos(), mob:getZPos()+math.random(1,5))
SpawnMob(ID.mob.MEDUSA + 2):updateEnmity(target)
elseif (not GetMobByID(ID.mob.MEDUSA + 3):isSpawned()) then
GetMobByID(ID.mob.MEDUSA + 3):setSpawn(mob:getXPos()+math.random(1,5), mob:getYPos(), mob:getZPos()+math.random(1,5))
SpawnMob(ID.mob.MEDUSA + 3):updateEnmity(target)
elseif (not GetMobByID(ID.mob.MEDUSA + 4):isSpawned()) then
GetMobByID(ID.mob.MEDUSA + 4):setSpawn(mob:getXPos()+math.random(1,5), mob:getYPos(), mob:getZPos()+math.random(1,5))
SpawnMob(ID.mob.MEDUSA + 4):updateEnmity(target)
end
end
for i = ID.mob.MEDUSA + 1, ID.mob.MEDUSA + 4 do
local pet = GetMobByID(i)
if (pet:getCurrentAction() == dsp.act.ROAMING) then
pet:updateEnmity(target)
end
end
end
function onMobDisengage(mob)
for i = 1,4 do DespawnMob(ID.mob.MEDUSA + i) end
end
function onMobDeath(mob, player, isKiller)
player:showText(mob, ID.text.MEDUSA_DEATH)
player:addTitle(dsp.title.GORGONSTONE_SUNDERER)
for i = 1,4 do DespawnMob(ID.mob.MEDUSA + i) end
end
function onMobDespawn(mob)
for i = 1,4 do DespawnMob(ID.mob.MEDUSA + i) end
end | gpl-3.0 |
stein2013/torch7 | Tensor.lua | 57 | 16339 | -- additional methods for Storage
local Storage = {}
-- additional methods for Tensor
local Tensor = {}
-- types
local types = {'Byte', 'Char', 'Short', 'Int', 'Long', 'Float', 'Double'}
-- Lua 5.2 compatibility
local log10 = math.log10 or function(x) return math.log(x, 10) end
-- tostring() functions for Tensor and Storage
local function Storage__printformat(self)
if self:size() == 0 then
return "", nil, 0
end
local intMode = true
local type = torch.typename(self)
-- if type == 'torch.FloatStorage' or type == 'torch.DoubleStorage' then
for i=1,self:size() do
if self[i] ~= math.ceil(self[i]) then
intMode = false
break
end
end
-- end
local tensor = torch.DoubleTensor(torch.DoubleStorage(self:size()):copy(self), 1, self:size()):abs()
local expMin = tensor:min()
if expMin ~= 0 then
expMin = math.floor(log10(expMin)) + 1
else
expMin = 1
end
local expMax = tensor:max()
if expMax ~= 0 then
expMax = math.floor(log10(expMax)) + 1
else
expMax = 1
end
local format
local scale
local sz
if intMode then
if expMax > 9 then
format = "%11.4e"
sz = 11
else
format = "%SZd"
sz = expMax + 1
end
else
if expMax-expMin > 4 then
format = "%SZ.4e"
sz = 11
if math.abs(expMax) > 99 or math.abs(expMin) > 99 then
sz = sz + 1
end
else
if expMax > 5 or expMax < 0 then
format = "%SZ.4f"
sz = 7
scale = math.pow(10, expMax-1)
else
format = "%SZ.4f"
if expMax == 0 then
sz = 7
else
sz = expMax+6
end
end
end
end
format = string.gsub(format, 'SZ', sz)
if scale == 1 then
scale = nil
end
return format, scale, sz
end
function Storage.__tostring__(self)
local strt = {'\n'}
local format,scale = Storage__printformat(self)
if format:sub(2,4) == 'nan' then format = '%f' end
if scale then
table.insert(strt, string.format('%g', scale) .. ' *\n')
for i = 1,self:size() do
table.insert(strt, string.format(format, self[i]/scale) .. '\n')
end
else
for i = 1,self:size() do
table.insert(strt, string.format(format, self[i]) .. '\n')
end
end
table.insert(strt, '[' .. torch.typename(self) .. ' of size ' .. self:size() .. ']\n')
local str = table.concat(strt)
return str
end
for _,type in ipairs(types) do
local metatable = torch.getmetatable('torch.' .. type .. 'Storage')
for funcname, func in pairs(Storage) do
rawset(metatable, funcname, func)
end
end
local function Tensor__printMatrix(self, indent)
local format,scale,sz = Storage__printformat(self:storage())
if format:sub(2,4) == 'nan' then format = '%f' end
-- print('format = ' .. format)
scale = scale or 1
indent = indent or ''
local strt = {indent}
local nColumnPerLine = math.floor((80-#indent)/(sz+1))
-- print('sz = ' .. sz .. ' and nColumnPerLine = ' .. nColumnPerLine)
local firstColumn = 1
local lastColumn = -1
while firstColumn <= self:size(2) do
if firstColumn + nColumnPerLine - 1 <= self:size(2) then
lastColumn = firstColumn + nColumnPerLine - 1
else
lastColumn = self:size(2)
end
if nColumnPerLine < self:size(2) then
if firstColumn ~= 1 then
table.insert(strt, '\n')
end
table.insert(strt, 'Columns ' .. firstColumn .. ' to ' .. lastColumn .. '\n' .. indent)
end
if scale ~= 1 then
table.insert(strt, string.format('%g', scale) .. ' *\n ' .. indent)
end
for l=1,self:size(1) do
local row = self:select(1, l)
for c=firstColumn,lastColumn do
table.insert(strt, string.format(format, row[c]/scale))
if c == lastColumn then
table.insert(strt, '\n')
if l~=self:size(1) then
if scale ~= 1 then
table.insert(strt, indent .. ' ')
else
table.insert(strt, indent)
end
end
else
table.insert(strt, ' ')
end
end
end
firstColumn = lastColumn + 1
end
local str = table.concat(strt)
return str
end
local function Tensor__printTensor(self)
local counter = torch.LongStorage(self:nDimension()-2)
local strt = {''}
local finished
counter:fill(1)
counter[1] = 0
while true do
for i=1,self:nDimension()-2 do
counter[i] = counter[i] + 1
if counter[i] > self:size(i) then
if i == self:nDimension()-2 then
finished = true
break
end
counter[i] = 1
else
break
end
end
if finished then
break
end
-- print(counter)
if #strt > 1 then
table.insert(strt, '\n')
end
table.insert(strt, '(')
local tensor = self
for i=1,self:nDimension()-2 do
tensor = tensor:select(1, counter[i])
table.insert(strt, counter[i] .. ',')
end
table.insert(strt, '.,.) = \n')
table.insert(strt, Tensor__printMatrix(tensor, ' '))
end
local str = table.concat(strt)
return str
end
function Tensor.__tostring__(self)
local str = '\n'
local strt = {''}
if self:nDimension() == 0 then
table.insert(strt, '[' .. torch.typename(self) .. ' with no dimension]\n')
else
local tensor = torch.DoubleTensor():resize(self:size()):copy(self)
if tensor:nDimension() == 1 then
local format,scale,sz = Storage__printformat(tensor:storage())
if format:sub(2,4) == 'nan' then format = '%f' end
if scale then
table.insert(strt, string.format('%g', scale) .. ' *\n')
for i = 1,tensor:size(1) do
table.insert(strt, string.format(format, tensor[i]/scale) .. '\n')
end
else
for i = 1,tensor:size(1) do
table.insert(strt, string.format(format, tensor[i]) .. '\n')
end
end
table.insert(strt, '[' .. torch.typename(self) .. ' of size ' .. tensor:size(1) .. ']\n')
elseif tensor:nDimension() == 2 then
table.insert(strt, Tensor__printMatrix(tensor))
table.insert(strt, '[' .. torch.typename(self) .. ' of size ' .. tensor:size(1) .. 'x' .. tensor:size(2) .. ']\n')
else
table.insert(strt, Tensor__printTensor(tensor))
table.insert(strt, '[' .. torch.typename(self) .. ' of size ')
for i=1,tensor:nDimension() do
table.insert(strt, tensor:size(i))
if i ~= tensor:nDimension() then
table.insert(strt, 'x')
end
end
table.insert(strt, ']\n')
end
end
local str = table.concat(strt)
return str
end
function Tensor.type(self,type)
local current = torch.typename(self)
if not type then return current end
if type ~= current then
local new = torch.getmetatable(type).new()
if self:nElement() > 0 then
new:resize(self:size()):copy(self)
end
return new
else
return self
end
end
function Tensor.typeAs(self,tensor)
return self:type(tensor:type())
end
function Tensor.byte(self)
return self:type('torch.ByteTensor')
end
function Tensor.char(self)
return self:type('torch.CharTensor')
end
function Tensor.short(self)
return self:type('torch.ShortTensor')
end
function Tensor.int(self)
return self:type('torch.IntTensor')
end
function Tensor.long(self)
return self:type('torch.LongTensor')
end
function Tensor.float(self)
return self:type('torch.FloatTensor')
end
function Tensor.double(self)
return self:type('torch.DoubleTensor')
end
function Tensor.real(self)
return self:type(torch.getdefaulttensortype())
end
function Tensor.expand(result,tensor,...)
-- get sizes
local sizes = {...}
local t = torch.type(tensor)
if (t == 'number' or t == 'torch.LongStorage') then
table.insert(sizes,1,tensor)
tensor = result
result = tensor.new()
end
-- check type
local size
if torch.type(sizes[1])=='torch.LongStorage' then
size = sizes[1]
else
size = torch.LongStorage(#sizes)
for i,s in ipairs(sizes) do
size[i] = s
end
end
-- get dimensions
local tensor_dim = tensor:dim()
local tensor_stride = tensor:stride()
local tensor_size = tensor:size()
-- check nb of dimensions
if #size ~= tensor:dim() then
error('the number of dimensions provided must equal tensor:dim()')
end
-- create a new geometry for tensor:
for i = 1,tensor_dim do
if tensor_size[i] == 1 then
tensor_size[i] = size[i]
tensor_stride[i] = 0
elseif tensor_size[i] ~= size[i] then
error('incorrect size: only supporting singleton expansion (size=1)')
end
end
-- create new view, with singleton expansion:
result:set(tensor:storage(), tensor:storageOffset(),
tensor_size, tensor_stride)
return result
end
torch.expand = Tensor.expand
function Tensor.expandAs(result,tensor,template)
if template then
return result:expand(tensor,template:size())
end
return result:expand(tensor:size())
end
torch.expandAs = Tensor.expandAs
function Tensor.repeatTensor(result,tensor,...)
-- get sizes
local sizes = {...}
local t = torch.type(tensor)
if (t == 'number' or t == 'torch.LongStorage') then
table.insert(sizes,1,tensor)
tensor = result
result = tensor.new()
end
-- if not contiguous, then force the tensor to be contiguous
if not tensor:isContiguous() then tensor = tensor:clone() end
-- check type
local size
if torch.type(sizes[1])=='torch.LongStorage' then
size = sizes[1]
else
size = torch.LongStorage(#sizes)
for i,s in ipairs(sizes) do
size[i] = s
end
end
if size:size() < tensor:dim() then
error('Number of dimensions of repeat dims can not be smaller than number of dimensions of tensor')
end
local xtensor = tensor.new():set(tensor)
local xsize = xtensor:size():totable()
for i=1,size:size()-tensor:dim() do
table.insert(xsize,1,1)
end
size = torch.DoubleTensor(xsize):cmul(torch.DoubleTensor(size:totable())):long():storage()
xtensor:resize(torch.LongStorage(xsize))
result:resize(size)
local urtensor = result.new(result)
for i=1,xtensor:dim() do
urtensor = urtensor:unfold(i,xtensor:size(i),xtensor:size(i))
end
for i=1,urtensor:dim()-xtensor:dim() do
table.insert(xsize,1,1)
end
xtensor:resize(torch.LongStorage(xsize))
local xxtensor = xtensor:expandAs(urtensor)
urtensor:copy(xxtensor)
return result
end
torch.repeatTensor = Tensor.repeatTensor
--- One of the size elements can be -1,
--- a new LongStorage is then returned.
--- The length of the unspecified dimension
--- is infered from the number of remaining elements.
local function specifyFully(size, nElements)
local nCoveredElements = 1
local remainingDim = nil
local sizes = size:totable()
for i = 1, #sizes do
local wantedDimSize = sizes[i]
if wantedDimSize == -1 then
if remainingDim then
error("Only one of torch.view dimensions can be -1.")
end
remainingDim = i
else
nCoveredElements = nCoveredElements * wantedDimSize
end
end
if not remainingDim then
return size
end
assert(nElements % nCoveredElements == 0, "The number of covered elements is not a multiple of all elements.")
local copy = torch.LongStorage(sizes)
copy[remainingDim] = nElements / nCoveredElements
return copy
end
-- TODO : This should be implemented in TH and and wrapped.
function Tensor.view(result, src, ...)
local size = ...
local view, tensor
local function istensor(tensor)
return torch.typename(tensor) and torch.typename(tensor):find('torch.*Tensor')
end
local function isstorage(storage)
return torch.typename(storage) and torch.typename(storage) == 'torch.LongStorage'
end
if istensor(result) and istensor(src) and type(size) == 'number' then
size = torch.LongStorage{...}
view = result
tensor = src
elseif istensor(result) and istensor(src) and isstorage(size) then
size = size
view = result
tensor = src
elseif istensor(result) and isstorage(src) and size == nil then
size = src
tensor = result
view = tensor.new()
elseif istensor(result) and type(src) == 'number' then
size = {...}
table.insert(size,1,src)
size = torch.LongStorage(size)
tensor = result
view = tensor.new()
else
local t1 = 'torch.Tensor, torch.Tensor, number [, number ]*'
local t2 = 'torch.Tensor, torch.Tensor, torch.LongStorage'
local t3 = 'torch.Tensor, torch.LongStorage'
local t4 = 'torch.Tensor, number [, number ]*'
error(string.format('torch.view, expected (%s) or\n (%s) or\n (%s)\n or (%s)', t1, t2, t3, t4))
end
local origNElement = tensor:nElement()
size = specifyFully(size, origNElement)
assert(tensor:isContiguous(), "expecting a contiguous tensor")
view:set(tensor:storage(), tensor:storageOffset(), size)
if view:nElement() ~= origNElement then
local inputSize = table.concat(tensor:size():totable(), "x")
local outputSize = table.concat(size:totable(), "x")
error(string.format("Wrong size for view. Input size: %s. Output size: %s",
inputSize, outputSize))
end
return view
end
torch.view = Tensor.view
function Tensor.viewAs(result, src, template)
if template and torch.typename(template) then
return result:view(src, template:size())
elseif template == nil then
template = src
src = result
result = src.new()
return result:view(src, template:size())
else
local t1 = 'torch.Tensor, torch.Tensor, torch.LongStorage'
local t2 = 'torch.Tensor, torch.LongStorage'
error(string.format('expecting (%s) or (%s)', t1, t2))
end
end
torch.viewAs = Tensor.viewAs
function Tensor.split(result, tensor, splitSize, dim)
if torch.type(result) ~= 'table' then
dim = splitSize
splitSize = tensor
tensor = result
result = {}
else
-- empty existing result table before using it
for k,v in pairs(result) do
result[k] = nil
end
end
dim = dim or 1
local start = 1
while start <= tensor:size(dim) do
local size = math.min(splitSize, tensor:size(dim) - start + 1)
local split = tensor:narrow(dim, start, size)
table.insert(result, split)
start = start + size
end
return result
end
torch.split = Tensor.split
function Tensor.chunk(result, tensor, nChunk, dim)
if torch.type(result) ~= 'table' then
dim = nChunk
nChunk = tensor
tensor = result
result = {}
end
dim = dim or 1
local splitSize = math.ceil(tensor:size(dim)/nChunk)
return torch.split(result, tensor, splitSize, dim)
end
torch.chunk = Tensor.chunk
function Tensor.totable(tensor)
local result = {}
if tensor:dim() == 1 then
tensor:apply(function(i) table.insert(result, i) end)
else
for i = 1, tensor:size(1) do
table.insert(result, tensor[i]:totable())
end
end
return result
end
torch.totable = Tensor.totable
function Tensor.permute(tensor, ...)
local perm = {...}
local nDims = tensor:dim()
assert(#perm == nDims, 'Invalid permutation')
local j
for i, p in ipairs(perm) do
if p ~= i and p ~= 0 then
j = i
repeat
assert(0 < perm[j] and perm[j] <= nDims, 'Invalid permutation')
tensor = tensor:transpose(j, perm[j])
j, perm[j] = perm[j], 0
until perm[j] == i
perm[j] = j
end
end
return tensor
end
torch.permute = Tensor.permute
for _,type in ipairs(types) do
local metatable = torch.getmetatable('torch.' .. type .. 'Tensor')
for funcname, func in pairs(Tensor) do
rawset(metatable, funcname, func)
end
end
| bsd-3-clause |
Vadavim/jsr-darkstar | scripts/zones/Riverne-Site_A01/Zone.lua | 15 | 1963 | -----------------------------------
--
-- Zone: Riverne-Site_A01
--
-----------------------------------
package.loaded["scripts/zones/Riverne-Site_A01/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Riverne-Site_A01/TextIDs");
require("scripts/globals/status");
require("scripts/globals/settings");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
SetServerVariable("Heliodromos_ToD", (os.time() + math.random((43200), (54000))));
SetServerVariable("[NM]Carmine_Dobsonflies_Killed", 0);
end;
-----------------------------------
-- onConquestUpdate
-----------------------------------
function onConquestUpdate(zone, updatetype)
local players = zone:getPlayers();
for name, player in pairs(players) do
conquestUpdate(zone, player, updatetype, CONQUEST_BASE);
end
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then
player:setPos(732.55,-32.5,-506.544,90); -- {R}
end
-- ZONE LEVEL RESTRICTION
if (ENABLE_COP_ZONE_CAP == 1) then
player:addStatusEffect(EFFECT_LEVEL_RESTRICTION,40,0,0);
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 |
Colettechan/darkstar | scripts/zones/Dynamis-Xarcabard/mobs/Duke_Scox.lua | 23 | 1566 | -----------------------------------
-- Area: Dynamis Xarcabard
-- MOB: Duke Scox
-----------------------------------
require("scripts/globals/dynamis");
require("scripts/zones/Dynamis-Xarcabard/TextIDs");
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
end;
-----------------------------------
-- onMobFight Action
-----------------------------------
function onMobFight(mob,target)
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
local Animate_Trigger = GetServerVariable("[DynaXarcabard]Boss_Trigger");
if (mob:isInBattlefieldList() == false) then
mob:addInBattlefieldList();
Animate_Trigger = Animate_Trigger + 1024;
SetServerVariable("[DynaXarcabard]Boss_Trigger",Animate_Trigger);
if (Animate_Trigger == 32767) then
SpawnMob(17330911); -- 142
SpawnMob(17330912); -- 143
SpawnMob(17330177); -- Dynamis Lord
GetMobByID(17330183):setSpawn(-364,-35.661,17.254); -- Set Ying and Yang's spawn points to their initial spawn point.
GetMobByID(17330184):setSpawn(-364,-35.974,24.254);
SpawnMob(17330183);
SpawnMob(17330184);
activateAnimatedWeapon(); -- Change subanim of all animated weapon
end
end
if (Animate_Trigger == 32767) then
player:messageSpecial(PRISON_OF_SOULS_HAS_SET_FREE);
end
end; | gpl-3.0 |
Colettechan/darkstar | scripts/globals/items/shall_shell.lua | 18 | 1327 | -----------------------------------------
-- ID: 4484
-- Item: shall_shell
-- Food Effect: 5Min, Mithra only
-----------------------------------------
-- Dexterity -5
-- Vitality 4
-- Defense % 16.4
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:getRace() ~= 7) then
result = 247;
elseif (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,4484);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_DEX, -5);
target:addMod(MOD_VIT, 4);
target:addMod(MOD_DEFP, 16.4);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_DEX, -5);
target:delMod(MOD_VIT, 4);
target:delMod(MOD_DEFP, 16.4);
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/zones/Windurst_Walls/npcs/Ojha_Rhawash.lua | 26 | 3747 | -----------------------------------
-- Area: Windurst Walls
-- NPC: Ojha Rhawash
-- Starts and Finishes Quest: Flower Child
-- @zone 239
-- @pos -209 0 -134
-----------------------------------
package.loaded["scripts/zones/Windurst_Walls/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Windurst_Walls/TextIDs");
require("scripts/globals/settings");
require("scripts/globals/quests");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
count = trade:getItemCount();
gil = trade:getGil();
itemQuality = 0;
if (trade:getItemCount() == 1 and trade:getGil() == 0) then
if (trade:hasItemQty(956,1)) then -- Lilac
itemQuality = 2;
elseif (trade:hasItemQty(957,1) or -- Amaryllis
trade:hasItemQty(2554,1) or -- Asphodel
trade:hasItemQty(948,1) or -- Carnation
trade:hasItemQty(1120,1) or -- Casablanca
trade:hasItemQty(1413,1) or -- Cattleya
trade:hasItemQty(636,1) or -- Chamomile
trade:hasItemQty(959,1) or -- Dahlia
trade:hasItemQty(835,1) or -- Flax Flower
trade:hasItemQty(2507,1) or -- Lycopodium Flower
trade:hasItemQty(958,1) or -- Marguerite
trade:hasItemQty(1412,1) or -- Olive Flower
trade:hasItemQty(938,1) or -- Papaka Grass
trade:hasItemQty(1411,1) or -- Phalaenopsis
trade:hasItemQty(949,1) or -- Rain Lily
trade:hasItemQty(941,1) or -- Red Rose
trade:hasItemQty(1725,1) or -- Snow Lily
trade:hasItemQty(1410,1) or -- Sweet William
trade:hasItemQty(950,1) or -- Tahrongi Cactus
trade:hasItemQty(2960,1) or -- Water Lily
trade:hasItemQty(951,1)) then -- Wijnruit
itemQuality = 1;
end
end
FlowerChild = player:getQuestStatus(WINDURST,FLOWER_CHILD);
if (itemQuality == 2) then
if (FlowerChild == QUEST_COMPLETED) then
player:startEvent(0x2710, 0, 239, 4);
else
player:startEvent(0x2710, 0, 239, 2);
end
elseif (itemQuality == 1) then
if (FlowerChild == QUEST_COMPLETED) then
player:startEvent(0x2710, 0, 239, 5);
elseif (FlowerChild == QUEST_ACCEPTED) then
player:startEvent(0x2710, 0, 239, 3);
else
player:startEvent(0x2710, 0, 239, 1);
end
else
player:startEvent(0x2710, 0, 239, 0);
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x2710, 0, 239, 10);
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 == 0x2710 and option == 3002) then
player:tradeComplete();
player:completeQuest(WINDURST,FLOWER_CHILD);
player:addFame(WINDURST,120);
player:moghouseFlag(4);
player:messageSpecial(MOGHOUSE_EXIT);
elseif (csid == 0x2710 and option == 1) then
player:tradeComplete();
player:addQuest(WINDURST,FLOWER_CHILD);
end
end; | gpl-3.0 |
Colettechan/darkstar | scripts/zones/Jugner_Forest_[S]/npcs/Larkin_CA.lua | 13 | 1045 | -----------------------------------
-- Area: Jugner Forest (S)
-- NPC: Larkin, C.A.
-- Type: Campaign Arbiter
-- @pos 50.217 -1.769 51.095 82
-----------------------------------
package.loaded["scripts/zones/Jugner_Forest_[S]/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Jugner_Forest_[S]/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x01c5);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/zones/Valley_of_Sorrows/mobs/Adamantoise.lua | 5 | 1529 | -----------------------------------
-- Area: Valley of Sorrows
-- HNM: Adamantoise
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/status");
-----------------------------------
-- onMobInitialize
-----------------------------------
function onMobInitialize(mob)
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
player:addTitle(TORTOISE_TORTURER);
end;
-----------------------------------
-- onMobDespawn
-----------------------------------
function onMobDespawn(mob)
local Adamantoise = mob:getID();
local Aspidochelone = mob:getID()+1;
local ToD = GetServerVariable("[POP]Aspidochelone");
local kills = GetServerVariable("[PH]Aspidochelone");
local popNow = (math.random(1,5) == 3 or kills > 6);
if (LandKingSystem_HQ ~= 1 and ToD <= os.time(t) and popNow == true) then
-- 0 = timed spawn, 1 = force pop only, 2 = BOTH
if (LandKingSystem_NQ == 0) then
DeterMob(Adamantoise, true);
end
DeterMob(Aspidochelone, false);
UpdateNMSpawnPoint(Aspidochelone);
GetMobByID(Aspidochelone):setRespawnTime(math.random(75600,86400));
else
if (LandKingSystem_NQ ~= 1) then
UpdateNMSpawnPoint(Adamantoise);
mob:setRespawnTime(math.random(75600,86400));
SetServerVariable("[PH]Aspidochelone", kills + 1);
end
end
end; | gpl-3.0 |
LedeDBProxy/resurgence | hscale-0.2/test/luaUnit/optivo/common/utilsTest.lua | 2 | 2102 | --[[
Copyright (C) 2008 optivo GmbH
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--]]
--- Unit tests.
--
-- @author $Author: peter.romianowski $
-- @release $Date: 2008-04-08 16:05:25 +0200 (Di, 08 Apr 2008) $ $Rev: 23 $
require('luaunit')
local utils = require("optivo.common.utils")
TestUtils = {}
function TestUtils:setUp()
end
function TestUtils:testConvertTableToString()
assertEquals("key = value", utils.convertTableToString({["key"] = "value"}))
assertEquals(
"key1 = value1\nkey2 = value2",
utils.convertTableToString({
["key1"] = "value1",
["key2"] = "value2"
})
)
local complexTable =
{
["key1"] = "value1",
["key2"] = {
["key2_1"] = "value2_1",
["key2_2"] = {
["key3_1"] = "value3_1",
["key3_2"] = "value3_2"
}
}
}
assertEquals(
"key1 = value1\nkey2 = {\n key2_1 = value2_1\n key2_2 = {\n key3_2 = value3_2\n key3_1 = value3_1\n }\n}",
utils.convertTableToString(complexTable, 2)
)
assertEquals(
"key1 = value1\nkey2 = {\n key2_1 = value2_1\n key2_2 = [... more table data ...]\n}",
utils.convertTableToString(complexTable, 1)
)
end
function TestUtils:testSimpleChecksum()
assertEquals(448, utils.calculateSimpleChecksum("test"))
assertEquals(48, utils.calculateSimpleChecksum("test", 200))
end | gpl-2.0 |
Colettechan/darkstar | scripts/globals/spells/cura_iii.lua | 36 | 4123 | -----------------------------------------
-- Spell: Cura III
-- Restores hp in area of effect. Self target only
-- From what I understand, Cura III's base potency is the same as Cure III's.
-- With Afflatus Misery Bonus, it can be as potent as a Curaga IV
-- Modeled after our cure_iii.lua, which was modeled after the below reference
-- 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)
if (caster:getID() ~= target:getID()) then
return MSGBASIC_CANNOT_PERFORM_TARG;
else
return 0;
end;
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 = 130;
if (USE_OLD_CURE_FORMULA == true) then
power = getCurePowerOld(caster);
rate = 1;
constant = 70;
if (power > 300) then
rate = 15.6666;
constant = 180.43;
elseif (power > 180) then
rate = 2;
constant = 115;
end
else
power = getCurePower(caster);
if (power < 125) then
divisor = 2.2
constant = 130;
basepower = 70;
elseif (power < 200) then
divisor = 75/65;
constant = 155;
basepower = 125;
elseif (power < 300) then
divisor = 2.5;
constant = 220;
basepower = 200;
elseif (power < 700) then
divisor = 5;
constant = 260;
basepower = 300;
else
divisor = 999999;
constant = 340;
basepower = 0;
end
end
if (USE_OLD_CURE_FORMULA == true) then
basecure = getBaseCure(power,divisor,constant);
else
basecure = getBaseCure(power,divisor,constant,basepower);
end
--Apply Afflatus Misery Bonus to the Result
if (caster:hasStatusEffect(EFFECT_AFFLATUS_MISERY)) then
if (caster:getID() == target:getID()) then -- Let's use a local var to hold the power of Misery so the boost is applied to all targets,
caster:setLocalVar("Misery_Power", caster:getMod(MOD_AFFLATUS_MISERY));
end;
local misery = caster:getLocalVar("Misery_Power");
--THIS IS LARELY SEMI-EDUCATED GUESSWORK. THERE IS NOT A
--LOT OF CONCRETE INFO OUT THERE ON CURA THAT I COULD FIND
--Not very much documentation for Cura II known at all.
--As with Cura, the Afflatus Misery bonus can boost this spell up
--to roughly the level of a Curaga 4. For Cura II vs Curaga III,
--this is document at ~375HP, 15HP less than the cap of 390HP. So
--for Cura II, i'll go with 15 less than the cap of Curaga IV (690): 675
--So with lack of available formula documentation, I'll go with that.
--printf("BEFORE AFFLATUS MISERY BONUS: %d", basecure);
basecure = basecure + misery;
if (basecure > 675) then
basecure = 675;
end
--printf("AFTER AFFLATUS MISERY BONUS: %d", basecure);
--Afflatus Misery Mod Gets Used Up
caster:setMod(MOD_AFFLATUS_MISERY, 0);
end
final = getCureFinal(caster,spell,basecure,minCure,false);
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:addHP(final);
target:wakeUp();
--Enmity for Cura III is fixed, so its CE/VE is set in the SQL and not calculated with updateEnmityFromCure
spell:setMsg(367);
return final;
end; | gpl-3.0 |
pedja1/aNmap | dSploit/jni/nmap/nselib/ftp.lua | 5 | 2150 | ---
-- FTP functions.
--
-- @copyright Same as Nmap--See http://nmap.org/book/man-legal.html
local comm = require "comm"
local stdnse = require "stdnse"
local string = require "string"
_ENV = stdnse.module("ftp", stdnse.seeall)
local ERROR_MESSAGES = {
["EOF"] = "connection closed",
["TIMEOUT"] = "connection timeout",
["ERROR"] = "failed to receive data"
}
--- Connects to the FTP server based on the provided options.
--
-- @param host The host table
-- @param port The port table
-- @param opts The connection option table, possible options:
-- timeout: generic timeout value
-- recv_before: receive data before returning
-- @return socket The socket descriptor, or nil on errors
-- @return response The response received on success and when
-- the recv_before is set, or the error message on failures.
connect = function(host, port, opts)
local socket, _, _, ret = comm.tryssl(host, port, '', opts)
if not socket then
return socket, (ERROR_MESSAGES[ret] or 'unspecified error')
end
return socket, ret
end
---
-- Read an FTP reply and return the numeric code and the message. See RFC 959,
-- section 4.2.
-- @param buffer should have been created with
-- <code>stdnse.make_buffer(socket, "\r?\n")</code>.
-- @return numeric code or <code>nil</code>.
-- @return text reply or error message.
function read_reply(buffer)
local readline
local line, err
local code, message
local _, p, tmp
line, err = buffer()
if not line then
return line, err
end
-- Single-line response?
code, message = string.match(line, "^(%d%d%d) (.*)$")
if code then
return tonumber(code), message
end
-- Multi-line response?
_, p, code, message = string.find(line, "^(%d%d%d)%-(.*)$")
if p then
while true do
line, err = buffer()
if not line then
return line, err
end
tmp = string.match(line, "^%d%d%d (.*)$")
if tmp then
message = message .. "\n" .. tmp
break
end
message = message .. "\n" .. line
end
return tonumber(code), message
end
return nil, string.format("Unparseable response: %q", line)
end
return _ENV;
| gpl-3.0 |
Colettechan/darkstar | scripts/zones/Metalworks/npcs/Olaf.lua | 13 | 1174 | -----------------------------------
-- Area: Metalworks
-- NPC: Olaf
-- Standard Merchant NPC
-----------------------------------
package.loaded["scripts/zones/Metalworks/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/shop");
require("scripts/zones/Metalworks/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,OLAF_SHOP_DIALOG);
stock = {0x4360,46836,2, -- Arquebus
0x43BC,90,3, -- Bullet
0x03A0,463,3} -- Bomb Ash
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/globals/weaponskills/scourge.lua | 19 | 2229 | -----------------------------------
-- Scourge
-- Great Sword weapon skill
-- Skill level: N/A
-- Additional effect: temporarily improves params.critical hit rate.
-- params.critical hit rate boost duration is based on TP when the weapon skill is used. 100% TP will give 20 seconds of params.critical hit rate boost; this scales linearly to 60 seconds of params.critical hit rate boost at 300% TP. 5 TP = 1 Second of Aftermath.
-- Parses show the params.critical hit rate increase from the Scourge Aftermath is between 10% and 15%.
-- This weapon skill is only available with the stage 5 relic Great Sword Ragnarok or within Dynamis with the stage 4 Valhalla.
-- Aligned with the Light Gorget & Flame Gorget.
-- Aligned with the Light Belt & Flame Belt.
-- Element: None
-- Modifiers: STR:40% ; VIT:40%
-- 100%TP 200%TP 300%TP
-- 3.00 3.00 3.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 = 1;
params.ftp100 = 3; params.ftp200 = 3; params.ftp300 = 3;
params.str_wsc = 0.0; 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.4;
params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0;
params.canCrit = false;
params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0;
params.atkmulti = 1;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.str_wsc = 0.4; params.vit_wsc = 0.4; params.mnd_wsc = 0.0; params.chr_wsc = 0.0;
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, tp, primary, action, taChar, params);
-- TODO: Whoever codes those level 85 weapons with the latent that grants this WS needs to code a check to not give the aftermath effect.
if (damage > 0) then
local amDuration = 20 * math.floor(tp/1000);
player:addStatusEffect(EFFECT_AFTERMATH, 5, 0, amDuration, 0, 2);
end
return tpHits, extraHits, criticalHit, damage;
end | gpl-3.0 |
tsdfsetatata/xserver | config/server/NpcTalkTable.lua | 1 | 16696 | local NpcTalkTable = {
[156000001] = {
['ID'] = 156000001, --索引
['NpcId'] = 152007014, --怪物\NPCID
['Type'] = 1, --说话类别
['EventNum1'] = 0, --参数1
['EventNum2'] = {5} --参数2
},
[156000002] = {
['ID'] = 156000002,
['NpcId'] = 151000004,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111300101}
},
[156000003] = {
['ID'] = 156000003,
['NpcId'] = 151000004,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {50}
},
[156000004] = {
['ID'] = 156000004,
['NpcId'] = 151001020,
['Type'] = 3,
['EventNum1'] = 1,
['EventNum2'] = {0}
},
[156000005] = {
['ID'] = 156000005,
['NpcId'] = 151001020,
['Type'] = 3,
['EventNum1'] = 2,
['EventNum2'] = {0}
},
[156000006] = {
['ID'] = 156000006,
['NpcId'] = 152030024,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {2}
},
[156000007] = {
['ID'] = 156000007,
['NpcId'] = 152030025,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {5,5,5,5,9}
},
[156000008] = {
['ID'] = 156000008,
['NpcId'] = 152030027,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {7,5,5,5,11}
},
[156000009] = {
['ID'] = 156000009,
['NpcId'] = 151002031,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111500414}
},
[156000010] = {
['ID'] = 156000010,
['NpcId'] = 151002032,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111500414}
},
[156000011] = {
['ID'] = 156000011,
['NpcId'] = 151002033,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111500413}
},
[156000012] = {
['ID'] = 156000012,
['NpcId'] = 151002034,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111500401}
},
[156000013] = {
['ID'] = 156000013,
['NpcId'] = 151002035,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111500401}
},
[156000014] = {
['ID'] = 156000014,
['NpcId'] = 151002036,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111500402}
},
[156000015] = {
['ID'] = 156000015,
['NpcId'] = 152000061,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {2,2,2}
},
[156000016] = {
['ID'] = 156000016,
['NpcId'] = 151005001,
['Type'] = 3,
['EventNum1'] = 1,
['EventNum2'] = {0}
},
[156000017] = {
['ID'] = 156000017,
['NpcId'] = 151005001,
['Type'] = 3,
['EventNum1'] = 2,
['EventNum2'] = {0}
},
[156000018] = {
['ID'] = 156000018,
['NpcId'] = 151005001,
['Type'] = 3,
['EventNum1'] = 3,
['EventNum2'] = {0}
},
[156000019] = {
['ID'] = 156000019,
['NpcId'] = 151005001,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {99}
},
[156000020] = {
['ID'] = 156000020,
['NpcId'] = 151005001,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {50}
},
[156000021] = {
['ID'] = 156000021,
['NpcId'] = 151005001,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {10}
},
[156000022] = {
['ID'] = 156000022,
['NpcId'] = 151005044,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {99}
},
[156000023] = {
['ID'] = 156000023,
['NpcId'] = 151005045,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {99}
},
[156000024] = {
['ID'] = 156000024,
['NpcId'] = 151005027,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {99}
},
[156000025] = {
['ID'] = 156000025,
['NpcId'] = 151005027,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {50}
},
[156000026] = {
['ID'] = 156000026,
['NpcId'] = 151005027,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {10}
},
[156000027] = {
['ID'] = 156000027,
['NpcId'] = 151005021,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {99}
},
[156000028] = {
['ID'] = 156000028,
['NpcId'] = 151005021,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {50}
},
[156000029] = {
['ID'] = 156000029,
['NpcId'] = 151005021,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {10}
},
[156000030] = {
['ID'] = 156000030,
['NpcId'] = 151005008,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {99}
},
[156000031] = {
['ID'] = 156000031,
['NpcId'] = 151005011,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {99}
},
[156000032] = {
['ID'] = 156000032,
['NpcId'] = 151005014,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {99}
},
[156000033] = {
['ID'] = 156000033,
['NpcId'] = 151005017,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {99}
},
[156000034] = {
['ID'] = 156000034,
['NpcId'] = 151002012,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111300104}
},
[156000035] = {
['ID'] = 156000035,
['NpcId'] = 151002013,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111300702}
},
[156000036] = {
['ID'] = 156000036,
['NpcId'] = 151002014,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111500436}
},
[156000037] = {
['ID'] = 156000037,
['NpcId'] = 151002018,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111500438}
},
[156000038] = {
['ID'] = 156000038,
['NpcId'] = 151002017,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111500440}
},
[156000039] = {
['ID'] = 156000039,
['NpcId'] = 151002016,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111500439}
},
[156000040] = {
['ID'] = 156000040,
['NpcId'] = 151002037,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111300501}
},
[156000041] = {
['ID'] = 156000041,
['NpcId'] = 151002037,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111300502}
},
[156000042] = {
['ID'] = 156000042,
['NpcId'] = 152013055,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {2}
},
[156000043] = {
['ID'] = 156000043,
['NpcId'] = 151004010,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111300104}
},
[156000044] = {
['ID'] = 156000044,
['NpcId'] = 151004010,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111300103}
},
[156000045] = {
['ID'] = 156000045,
['NpcId'] = 151004010,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111300102}
},
[156000046] = {
['ID'] = 156000046,
['NpcId'] = 151005055,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {51}
},
[156000047] = {
['ID'] = 156000047,
['NpcId'] = 151005056,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {51}
},
[156000048] = {
['ID'] = 156000048,
['NpcId'] = 151005057,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {81}
},
[156000049] = {
['ID'] = 156000049,
['NpcId'] = 151005057,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {51}
},
[156000050] = {
['ID'] = 156000050,
['NpcId'] = 151005057,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {21}
},
[156000051] = {
['ID'] = 156000051,
['NpcId'] = 151004018,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111500505}
},
[156000052] = {
['ID'] = 156000052,
['NpcId'] = 151005081,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {10}
},
[156000053] = {
['ID'] = 156000053,
['NpcId'] = 151005082,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {10}
},
[156000054] = {
['ID'] = 156000054,
['NpcId'] = 151005083,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {10}
},
[156000055] = {
['ID'] = 156000055,
['NpcId'] = 151005084,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {10}
},
[156000056] = {
['ID'] = 156000056,
['NpcId'] = 151004019,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {2,3}
},
[156000057] = {
['ID'] = 156000057,
['NpcId'] = 151007010,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111300703}
},
[156000058] = {
['ID'] = 156000058,
['NpcId'] = 151007011,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111304702}
},
[152000001] = {
['ID'] = 152000001,
['NpcId'] = 152030005,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {2}
},
[152000002] = {
['ID'] = 152000002,
['NpcId'] = 152030018,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {5}
},
[152000003] = {
['ID'] = 152000003,
['NpcId'] = 152030020,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {8}
},
[152000004] = {
['ID'] = 152000004,
['NpcId'] = 152030019,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {11}
},
[152000005] = {
['ID'] = 152000005,
['NpcId'] = 152030042,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {3,3,3,3}
},
[152000006] = {
['ID'] = 152000006,
['NpcId'] = 152040160,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {1,3,3}
},
[152000007] = {
['ID'] = 152000007,
['NpcId'] = 152040161,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {3,3,3,3}
},
[151000001] = {
['ID'] = 151000001,
['NpcId'] = 151004036,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111500514}
},
[151000002] = {
['ID'] = 151000002,
['NpcId'] = 151004037,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111500525}
},
[151000003] = {
['ID'] = 151000003,
['NpcId'] = 151004038,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111500526}
},
[151000004] = {
['ID'] = 151000004,
['NpcId'] = 151004039,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111500504}
},
[151000005] = {
['ID'] = 151000005,
['NpcId'] = 151004040,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111500532}
},
[151000006] = {
['ID'] = 151000006,
['NpcId'] = 151004033,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111500505}
},
[151000007] = {
['ID'] = 151000007,
['NpcId'] = 151004034,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111500505}
},
[151000008] = {
['ID'] = 151000008,
['NpcId'] = 151004035,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111500505}
},
[151000009] = {
['ID'] = 151000009,
['NpcId'] = 152030040,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {3,3}
},
[151000021] = {
['ID'] = 151000021,
['NpcId'] = 151077002,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111400025}
},
[151000022] = {
['ID'] = 151000022,
['NpcId'] = 151077018,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111300703}
},
[151000023] = {
['ID'] = 151000023,
['NpcId'] = 151077011,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111300101}
},
[151000024] = {
['ID'] = 151000024,
['NpcId'] = 151077013,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111400025}
},
[151000025] = {
['ID'] = 151000025,
['NpcId'] = 151077017,
['Type'] = 2,
['EventNum1'] = 1,
['EventNum2'] = {111300703}
},
[151000026] = {
['ID'] = 151000026,
['NpcId'] = 151077017,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {50}
},
[152100001] = {
['ID'] = 152100001,
['NpcId'] = 152140245,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {2}
},
[152100002] = {
['ID'] = 152100002,
['NpcId'] = 152140246,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {2}
},
[152100003] = {
['ID'] = 152100003,
['NpcId'] = 152140247,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {2}
},
[152100004] = {
['ID'] = 152100004,
['NpcId'] = 151077047,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {90,60,30}
},
[152100005] = {
['ID'] = 152100005,
['NpcId'] = 152140250,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {2}
},
[152100006] = {
['ID'] = 152100006,
['NpcId'] = 152140251,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {2}
},
[152100007] = {
['ID'] = 152100007,
['NpcId'] = 152140252,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {2}
},
[152100008] = {
['ID'] = 152100008,
['NpcId'] = 152030021,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {3}
},
[152100009] = {
['ID'] = 152100009,
['NpcId'] = 152031001,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {6}
},
[152100010] = {
['ID'] = 152100010,
['NpcId'] = 152031002,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {7}
},
[152100011] = {
['ID'] = 152100011,
['NpcId'] = 152031003,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {5,10}
},
[152100012] = {
['ID'] = 152100012,
['NpcId'] = 152031004,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {3,8}
},
[152100013] = {
['ID'] = 152100013,
['NpcId'] = 152031005,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {4,9}
},
[152100014] = {
['ID'] = 152100014,
['NpcId'] = 152031006,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {10,10}
},
[152100015] = {
['ID'] = 152100015,
['NpcId'] = 152031007,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {8,8}
},
[152100016] = {
['ID'] = 152100016,
['NpcId'] = 152031008,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {9,9}
},
[152100017] = {
['ID'] = 152100017,
['NpcId'] = 152031011,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {5,10}
},
[152100018] = {
['ID'] = 152100018,
['NpcId'] = 152031012,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {5,8,10}
},
[152100019] = {
['ID'] = 152100019,
['NpcId'] = 152031012,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {5,5,10}
},
[152100020] = {
['ID'] = 152100020,
['NpcId'] = 152030001,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {5}
},
[152100024] = {
['ID'] = 152100024,
['NpcId'] = 152140263,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {4}
},
[152100025] = {
['ID'] = 152100025,
['NpcId'] = 152140262,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {4}
},
[152100026] = {
['ID'] = 152100026,
['NpcId'] = 151077045,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {50}
},
[152100027] = {
['ID'] = 152100027,
['NpcId'] = 151077044,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {90}
},
[152100028] = {
['ID'] = 152100028,
['NpcId'] = 152040020,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {5}
},
[152100029] = {
['ID'] = 152100029,
['NpcId'] = 152040021,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {5}
},
[152100031] = {
['ID'] = 152100031,
['NpcId'] = 151077110,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {90,50}
},
[152100032] = {
['ID'] = 152100032,
['NpcId'] = 152031045,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {3}
},
[152100033] = {
['ID'] = 152100033,
['NpcId'] = 151077112,
['Type'] = 2,
['EventNum1'] = 2,
['EventNum2'] = {90,50}
},
[152100034] = {
['ID'] = 152100034,
['NpcId'] = 152031060,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {1}
},
[152100035] = {
['ID'] = 152100035,
['NpcId'] = 152031055,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {1}
},
[152100036] = {
['ID'] = 152100036,
['NpcId'] = 151002001,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {1}
},
[152100037] = {
['ID'] = 152100037,
['NpcId'] = 151002002,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {2}
},
[152100038] = {
['ID'] = 152100038,
['NpcId'] = 151002003,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {3}
},
[152100039] = {
['ID'] = 152100039,
['NpcId'] = 151002004,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {4}
},
[152100040] = {
['ID'] = 152100040,
['NpcId'] = 151002005,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {1}
},
[152100041] = {
['ID'] = 152100041,
['NpcId'] = 151002006,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {2}
},
[152100042] = {
['ID'] = 152100042,
['NpcId'] = 151002007,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {3}
},
[152100043] = {
['ID'] = 152100043,
['NpcId'] = 151002008,
['Type'] = 1,
['EventNum1'] = 0,
['EventNum2'] = {2}
},
[152100044] = {
['ID'] = 152100044,
['NpcId'] = 151006036,
['Type'] = 1,
['EventNum1'] = 2,
['EventNum2'] = {90,50}
}
}
return NpcTalkTable
| gpl-3.0 |
zynjec/darkstar | scripts/zones/West_Ronfaure/npcs/Palcomondau.lua | 9 | 12838 | -----------------------------------
-- Area: West Ronfaure
-- NPC: Palcomondau
-- Type: Patrol
-- !pos -349.796 -45.345 344.733 100
-----------------------------------
local ID = require("scripts/zones/West_Ronfaure/IDs")
require("scripts/globals/pathfind")
-----------------------------------
local path =
{
-373.096863, -45.742077, 340.182159,
-361.441864, -46.052444, 340.367371,
-360.358276, -46.063702, 340.457428,
-359.297211, -46.093231, 340.693817,
-358.264465, -46.285988, 341.032928,
-357.301941, -45.966343, 341.412994,
-356.365295, -45.641331, 341.804657,
-353.933533, -45.161453, 342.873901,
-346.744659, -45.006634, 346.113251,
-345.843506, -44.973419, 346.716309,
-345.138519, -44.939915, 347.540436,
-344.564056, -44.925575, 348.463470,
-344.069366, -44.945713, 349.431824,
-343.621704, -45.004826, 350.421936,
-343.194946, -45.062874, 351.421173,
-342.118958, -45.391632, 354.047485,
-334.448578, -44.964996, 373.198242,
-333.936615, -45.028484, 374.152283,
-333.189636, -45.068111, 374.939209,
-332.252838, -45.073158, 375.488129,
-331.241516, -45.065205, 375.888031,
-330.207855, -45.043056, 376.226532,
-329.165100, -45.022049, 376.536011,
-328.118622, -45.000935, 376.832428,
-323.437805, -45.726982, 378.101166,
-305.333038, -49.030193, 382.936646,
-304.308228, -49.435581, 383.130188,
-303.259979, -49.765697, 383.194305,
-302.209290, -50.104950, 383.175659,
-301.161774, -50.446033, 383.117767,
-300.114624, -50.787590, 383.041473,
-298.422943, -51.390713, 382.898590,
-281.798126, -56.178822, 381.370544,
-280.718414, -56.161697, 381.241425,
-279.641785, -56.142433, 381.087341,
-278.567627, -56.121262, 380.917938,
-261.485809, -55.875919, 378.010284,
-260.404205, -55.893314, 377.898254,
-259.317078, -55.908813, 377.861389,
-258.229248, -55.923473, 377.879669,
-257.142151, -55.938625, 377.919037,
-254.834976, -55.888081, 378.032623,
-224.857941, -56.603645, 379.721832,
-194.892044, -59.911034, 381.416382,
-178.437729, -61.500011, 382.347656, -- report?
-179.524124, -61.500011, 382.285919,
-209.530518, -58.837189, 380.588806,
-239.543137, -56.145073, 378.891602,
-257.769012, -55.930656, 377.861328,
-258.856445, -55.915405, 377.839905,
-259.943420, -55.900009, 377.884918,
-261.025116, -55.882565, 377.999329,
-262.102173, -55.864536, 378.151794,
-263.193237, -55.845242, 378.320587,
-279.088043, -56.134182, 381.021332,
-280.165344, -56.153133, 381.172882,
-281.246033, -56.168983, 381.299683,
-282.302917, -56.181866, 381.408691,
-301.977173, -50.175457, 383.230652,
-302.993134, -49.847698, 383.246735,
-303.998260, -49.580284, 383.147003,
-305.083649, -49.109840, 382.933411,
-306.061432, -48.755005, 382.706818,
-307.152679, -48.355675, 382.435608,
-327.497711, -45.027401, 377.016663,
-328.548553, -45.009663, 376.735291,
-331.569672, -45.071396, 375.927429,
-332.566711, -45.084835, 375.500153,
-333.347351, -45.055779, 374.749634,
-333.952423, -44.990082, 373.848999,
-334.454071, -44.958176, 372.884399,
-334.909607, -44.930862, 371.896698,
-335.338989, -44.939476, 370.897034,
-336.319305, -45.033978, 368.508484,
-344.092773, -44.934128, 349.103394,
-344.599304, -44.920494, 348.142578,
-345.289124, -44.948330, 347.305328,
-346.152740, -44.981884, 346.646881,
-347.087494, -45.014847, 346.091278,
-348.052368, -45.047348, 345.589172,
-349.030975, -45.039383, 345.114044,
-350.016052, -45.036438, 344.652252,
-357.274414, -45.947830, 341.359833,
-358.277222, -46.126381, 340.958984,
-359.326965, -46.091412, 340.679291,
-360.404205, -46.072746, 340.529785,
-361.488525, -46.061684, 340.441284,
-362.575226, -46.055046, 340.388184,
-363.662323, -46.050694, 340.353088,
-367.288086, -45.562141, 340.276978,
-397.408386, -46.031933, 339.796722,
-427.522491, -45.366581, 339.319641,
-457.651947, -45.910805, 338.841827,
-463.498932, -45.831551, 338.757111,
-464.580750, -45.752060, 338.776215,
-465.656433, -45.603558, 338.822693,
-467.953491, -45.463387, 338.967407,
-494.403381, -45.661190, 340.958710,
-495.442017, -45.667831, 341.254303,
-496.256042, -45.713417, 341.966400,
-496.865723, -45.720673, 342.866852,
-497.385132, -45.755371, 343.821838,
-498.376312, -45.856812, 345.908539,
-498.820007, -45.996841, 346.899353,
-499.174530, -46.197227, 347.923767,
-499.352539, -46.093906, 348.989563,
-499.416016, -46.074814, 350.073944,
-499.423279, -46.070366, 351.161072,
-499.397400, -46.084679, 352.248505,
-499.358795, -46.133957, 353.335815,
-498.771545, -46.025249, 365.000885,
-498.687347, -45.804886, 366.615082,
-498.166779, -45.846115, 376.640106,
-498.109924, -45.862961, 377.726410,
-497.697968, -45.951462, 385.738007,
-497.694122, -46.004673, 386.825317,
-497.737915, -46.056293, 387.912231,
-497.809082, -46.020039, 388.997162,
-498.192322, -46.074364, 393.595886,
-499.513733, -47.018887, 408.449036,
-499.682556, -47.223618, 409.509949,
-499.959503, -47.415245, 410.549194,
-500.307434, -47.595810, 411.566589,
-500.686859, -48.017868, 412.545349,
-501.077026, -48.478256, 413.506836,
-501.873901, -49.394321, 415.425659,
-502.207245, -49.737534, 416.425812,
-502.382660, -50.058594, 417.464630,
-502.406891, -50.394829, 418.516327,
-502.342438, -50.724243, 419.565948,
-502.251190, -51.088074, 420.607056,
-502.139435, -51.460213, 421.645935,
-501.954468, -52.022106, 423.198792,
-500.171021, -55.784023, 437.153931,
-500.033447, -56.010731, 438.356873,
-499.879120, -56.021641, 439.981689,
-499.679840, -55.963177, 442.392639,
-499.790558, -55.536102, 443.497894,
-500.205383, -55.237358, 444.453308,
-500.785736, -55.148598, 445.369598,
-501.427277, -55.099243, 446.246521,
-502.103760, -55.051254, 447.097015,
-502.791046, -55.003696, 447.939423,
-503.574524, -55.015862, 448.879730,
-510.872284, -55.089428, 457.484222,
-511.691742, -55.159729, 458.188812,
-512.678040, -55.280975, 458.628448,
-513.720825, -55.419674, 458.910309,
-514.785461, -55.554832, 459.097260,
-515.851929, -55.741619, 459.240265,
-516.923096, -55.906597, 459.366913,
-517.998413, -56.087105, 459.482513,
-521.921387, -56.035919, 459.879913,
-522.965271, -55.886223, 460.131927,
-523.947327, -55.785652, 460.568665,
-524.886719, -55.581245, 461.082581,
-525.805237, -55.438984, 461.645203,
-526.824829, -55.279068, 462.300720,
-531.560181, -54.945484, 465.464722,
-532.406555, -54.961479, 466.143524,
-533.060120, -54.995003, 467.010559,
-533.618408, -55.030079, 467.943695,
-534.158691, -55.026203, 468.887848,
-538.343323, -55.609158, 476.336639,
-538.852539, -55.920918, 477.273773,
-539.335510, -56.089600, 478.277985,
-539.767029, -56.035652, 479.274902,
-540.283997, -56.042004, 480.532135,
-544.975769, -55.047729, 492.510040,
-545.471375, -55.034317, 493.475891,
-546.206604, -55.009632, 494.270599,
-547.121643, -54.949020, 494.853882,
-548.100342, -54.921333, 495.329163,
-549.105103, -54.930302, 495.747131,
-550.121033, -54.979893, 496.133270,
-551.140991, -55.035213, 496.507385,
-556.089600, -55.924522, 498.256134,
-557.125793, -56.028824, 498.568329,
-558.182983, -56.208153, 498.806641,
-559.256592, -56.133862, 498.981354,
-560.335327, -56.116646, 499.118896,
-562.091736, -56.104050, 499.314911,
-574.530396, -56.559124, 500.553680,
-575.606262, -56.603722, 500.706024,
-576.649963, -56.813107, 500.963989,
-577.670288, -57.037365, 501.291138,
-578.679321, -57.266209, 501.647278,
-579.683105, -57.510010, 502.019379,
-581.321777, -57.800549, 502.643463,
-608.199463, -60.061394, 513.086548, -- turn around
-607.195618, -59.956524, 512.696411,
-579.141602, -57.367210, 501.788940,
-578.157959, -57.136345, 501.407318,
-577.150146, -56.915344, 501.086304,
-576.116089, -56.711021, 500.848358,
-575.049622, -56.572414, 500.676178,
-573.971497, -56.540531, 500.535004,
-572.891418, -56.511803, 500.410767,
-571.541260, -56.454227, 500.267334,
-559.917480, -56.117676, 499.110870,
-558.841248, -56.137356, 498.953400,
-557.782593, -56.166878, 498.714447,
-556.750061, -55.982758, 498.415985,
-555.608704, -55.807209, 498.053894,
-553.104614, -55.239231, 497.204651,
-547.725464, -54.925472, 495.326019,
-546.765625, -54.984024, 494.821899,
-546.022339, -55.011047, 494.032928,
-545.445923, -55.024132, 493.110931,
-544.951660, -55.061985, 492.142212,
-544.503357, -55.055382, 491.151031,
-544.083557, -55.041119, 490.147827,
-543.675354, -55.021049, 489.139801,
-540.065735, -56.014805, 479.933258,
-539.634155, -56.052246, 478.935516,
-539.166565, -56.161896, 477.960266,
-538.697327, -55.847233, 477.044403,
-538.208557, -55.557598, 476.136658,
-537.436646, -55.298710, 474.733032,
-533.392761, -55.013466, 467.513885,
-532.726868, -54.979912, 466.657013,
-531.930054, -54.948929, 465.917389,
-531.075134, -54.949390, 465.244354,
-530.197693, -54.950920, 464.600464,
-529.308838, -54.990524, 463.974792,
-525.172791, -55.543240, 461.159485,
-524.214478, -55.720425, 460.668243,
-523.196838, -55.850220, 460.304413,
-522.141357, -56.015007, 460.066986,
-521.068726, -56.020702, 459.886475,
-519.991577, -56.039570, 459.735687,
-518.911011, -56.055336, 459.609558,
-517.433777, -55.982838, 459.449738,
-513.966614, -55.460213, 459.099396,
-512.921997, -55.323360, 458.849701,
-512.001587, -55.181244, 458.291351,
-511.179230, -55.105251, 457.583893,
-510.412476, -55.032543, 456.816132,
-509.680267, -54.958725, 456.014191,
-508.602783, -54.942749, 454.788452,
-500.669189, -55.143158, 445.473999,
-500.128296, -55.247131, 444.541412,
-499.898651, -55.518276, 443.507935,
-499.821869, -55.910942, 442.468292,
-499.832764, -56.027439, 441.384308,
-499.881256, -56.021374, 440.297485,
-499.962463, -56.011227, 439.212982,
-500.072205, -56.031265, 438.133789,
-500.329163, -55.395157, 435.970062,
-502.441742, -50.690495, 419.476440,
-502.485474, -50.371307, 418.460999,
-502.368835, -50.054039, 417.447144,
-502.131531, -49.750740, 416.450317,
-501.775696, -49.393009, 415.406342,
-501.394318, -48.913757, 414.410278,
-500.999023, -48.445408, 413.431396,
-500.303253, -47.637516, 411.756561,
-499.980103, -47.454823, 410.747284,
-499.763947, -47.256901, 409.705627,
-499.603699, -47.051754, 408.654358,
-499.474274, -46.886150, 407.591583,
-499.360931, -46.714558, 406.528320,
-497.842590, -45.999271, 389.667542,
-497.735077, -46.047218, 388.312012,
-497.702972, -46.022728, 387.226166,
-497.717407, -45.968018, 386.140686,
-497.752014, -45.910450, 385.054596,
-498.532532, -45.704178, 369.587616,
-498.589294, -45.753151, 368.501129,
-499.547089, -46.040310, 350.040375,
-499.412354, -46.078503, 348.964417,
-499.099609, -46.221172, 347.926239,
-498.741913, -46.030338, 346.926208,
-498.351959, -45.860306, 345.923828,
-497.941467, -45.805256, 344.918884,
-497.518524, -45.751751, 343.918427,
-497.074768, -45.707314, 342.926636,
-496.434631, -45.690395, 342.056549,
-495.518555, -45.685642, 341.481903,
-494.478638, -45.677624, 341.169525,
-493.406281, -45.681431, 340.990509,
-492.333801, -46.148170, 340.858154,
-491.272858, -45.972626, 340.751801,
-490.196564, -45.903652, 340.655212,
-466.653748, -45.466057, 338.859863,
-465.575256, -45.615093, 338.803314,
-464.496521, -45.763508, 338.779785,
-463.410126, -45.832458, 338.774506,
-433.375122, -45.735828, 339.226624,
-403.243805, -46.015915, 339.704468,
}
function onSpawn(npc)
npc:initNpcAi()
npc:setPos(dsp.path.first(path))
onPath(npc)
end
function onPath(npc)
if npc:atPoint(dsp.path.get(path, 45)) then
GetNPCByID(npc:getID() + 3):showText(npc, ID.text.PALCOMONDAU_REPORT)
-- small delay after path finish
npc:wait(8000)
end
dsp.path.patrol(npc, path)
end
function onTrade(player, npc, trade)
end
function onTrigger(player, npc)
player:showText(npc, ID.text.PALCOMONDAU_DIALOG)
--npc:wait(1500)
end
function onEventUpdate(player, csid, option)
end
function onEventFinish(player, csid, option)
end
| gpl-3.0 |
Colettechan/darkstar | scripts/zones/Beadeaux/npcs/_43b.lua | 13 | 1745 | -----------------------------------
-- Area: Beadeaux
-- NPC: Jail Door
-- Involved in Quests: The Rescue
-- @pos 56 0.1 -23 147
-----------------------------------
package.loaded["scripts/zones/Beadeaux/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/quests");
require("scripts/globals/keyitems");
require("scripts/zones/Beadeaux/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:getQuestStatus(OTHER_AREAS,THE_RESCUE) == QUEST_ACCEPTED and player:hasKeyItem(TRADERS_SACK) == false) then
if (trade:hasItemQty(495,1) == true and trade:getItemCount() == 1) then
player:startEvent(0x03e8);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getQuestStatus(OTHER_AREAS,THE_RESCUE) == QUEST_ACCEPTED and player:hasKeyItem(TRADERS_SACK) == false) then
player:messageSpecial(LOCKED_DOOR_QUADAV_HAS_KEY);
else
player:messageSpecial(NOTHING_OUT_OF_ORDINARY);
end
return 1;
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x03e8) then
player:addKeyItem(TRADERS_SACK);
player:messageSpecial(KEYITEM_OBTAINED,TRADERS_SACK);
end
end;
| gpl-3.0 |
pedja1/aNmap | dSploit/jni/nmap/nselib/vuzedht.lua | 3 | 17077 | ---
-- A Vuze DHT protocol implementation based on the following documentation:
-- o http://wiki.vuze.com/w/Distributed_hash_table
--
-- It currently supports the PING and FIND_NODE requests and parses the
-- responses. The following main classes are used by the library:
--
-- o Request - the request class containing all of the request classes. It
-- currently contains the Header, PING and FIND_NODE classes.
--
-- o Response - the response class containing all of the response classes. It
-- currently contains the Header, PING, FIND_NODE and ERROR
-- class.
--
-- o Session - a class containing "session state" such as the transaction- and
-- instance ID's.
--
-- o Helper - The helper class that serves as the main interface between
-- scripts and the library.
--
-- @author "Patrik Karlsson <patrik@cqure.net>"
--
local bin = require "bin"
local ipOps = require "ipOps"
local math = require "math"
local nmap = require "nmap"
local os = require "os"
local stdnse = require "stdnse"
local string = require "string"
local table = require "table"
local openssl = stdnse.silent_require "openssl"
_ENV = stdnse.module("vuzedht", stdnse.seeall)
Request = {
Actions = {
ACTION_PING = 1024,
FIND_NODE = 1028,
},
-- The request Header class shared by all Requests classes
Header = {
-- Creates a new Header instance
-- @param action number containing the request action
-- @param session instance of Session
-- @return o new instance of Header
new = function(self, action, session)
local o = {
conn_id = string.char(255) .. openssl.rand_pseudo_bytes(7),
-- we need to handle this one like this, due to a bug in nsedoc
-- it used to be action = action, but that breaks parsing
["action"] = action,
trans_id = session:getTransactionId(),
proto_version = 0x32,
vendor_id = 0,
network_id = 0,
local_proto_version = 0x32,
address = session:getAddress(),
port = session:getPort(),
instance_id = session:getInstanceId(),
time = os.time(),
}
setmetatable(o, self)
self.__index = self
return o
end,
-- Converts the header to a string
__tostring = function(self)
local lhost = ipOps.todword(self.address)
return bin.pack( ">AIICCICCISIL", self.conn_id, self.action, self.trans_id,
self.proto_version, self.vendor_id, self.network_id, self.local_proto_version,
4, lhost, self.port, self.instance_id, self.time )
end,
},
-- The PING Request class
Ping = {
-- Creates a new Ping instance
-- @param session instance of Session
-- @return o new instance of Ping
new = function(self, session)
local o = {
header = Request.Header:new(Request.Actions.ACTION_PING, session)
}
setmetatable(o, self)
self.__index = self
return o
end,
-- Converts a Ping Request to a string
__tostring = function(self)
return tostring(self.header)
end,
},
-- The FIND_NODES Request class
FindNode = {
-- Creates a new FindNode instance
-- @param session instance of Session
-- @return o new instance of FindNode
new = function(self, session)
local o = {
header = Request.Header:new(Request.Actions.FIND_NODE, session),
id_length = 20,
node_id = '\xA7' .. openssl.rand_pseudo_bytes(19),
status = 0xFFFFFFFF,
dht_size = 0,
}
setmetatable(o, self)
self.__index = self
return o
end,
-- Converts a FindNode Request to a string
__tostring = function(self)
local data = tostring(self.header)
data = data .. bin.pack(">CAII", self.id_length, self.node_id, self.status, self.dht_size)
return data
end,
}
}
Response = {
-- A table of currently supported Actions (Responses)
-- It's used in the fromString method to determine which class to create.
Actions = {
ACTION_PING = 1025,
FIND_NODE = 1029,
ERROR = 1032,
},
-- Creates an address record based on received data
-- @param data containing an address record [C][I|H][S] where
-- [C] is the length of the address (4 or 16)
-- [I|H] is the address as a dword or hex string
-- [S] is the port number as a short
-- @return o Address instance on success, nil on failure
Address = {
new = function(self, data)
local o = { data = data }
setmetatable(o, self)
self.__index = self
if ( o:parse() ) then
return o
end
end,
-- Parses the received data
-- @return true on success, false on failure
parse = function(self)
local pos, addr_len = bin.unpack("C", self.data)
if ( addr_len == 4 ) then
self.length = 4 + 2 + 1
pos, self.ip = bin.unpack("<I", self.data, pos)
self.ip = ipOps.fromdword(self.ip)
elseif( addr_len == 16 ) then
self.length = 16 + 2 + 1
pos, self.ip = bin.unpack("H16", self.data, pos)
else
stdnse.print_debug("Unknown address type (length: %d)", addr_len)
return false, "Unknown address type"
end
pos, self.port = bin.unpack(">S", self.data, pos)
return true
end
},
-- The response header, present in all packets
Header = {
Vendors = {
[0] = "Azureus",
[1] = "ShareNet",
[255] = "Unknown", -- to be honest, we report all except 0 and 1 as unknown
},
Networks = {
[0] = "Stable",
[1] = "CVS"
},
-- Creates a new Header instance
-- @param data string containing the received data
-- @return o instance of Header
new = function(self, data)
local o = { data = data }
setmetatable(o, self)
self.__index = self
o:parse()
return o
end,
-- parses the header
parse = function(self)
local pos
pos, self.action, self.trans_id, self.conn_id,
self.proto_version, self.vendor_id, self.network_id,
self.instance_id = bin.unpack(">IIH8CCII", self.data)
end,
-- Converts the header to a suitable string representation
__tostring = function(self)
local result = {}
table.insert(result, ("Transaction id: %d"):format(self.trans_id))
table.insert(result, ("Connection id: 0x%s"):format(self.conn_id))
table.insert(result, ("Protocol version: %d"):format(self.proto_version))
table.insert(result, ("Vendor id: %s (%d)"):format(
Response.Header.Vendors[self.vendor_id] or "Unknown", self.vendor_id))
table.insert(result, ("Network id: %s (%d)"):format(
Response.Header.Networks[self.network_id] or "Unknown", self.network_id))
table.insert(result, ("Instance id: %d"):format(self.instance_id))
return stdnse.format_output(true, result)
end,
},
-- The PING response
PING = {
-- Creates a new instance of PING
-- @param data string containing the received data
-- @return o new PING instance
new = function(self, data)
local o = {
header = Response.Header:new(data)
}
setmetatable(o, self)
self.__index = self
return o
end,
-- Creates a new PING instance based on received data
-- @param data string containing received data
-- @return status true on success, false on failure
-- @return new instance of PING on success, error message on failure
fromString = function(data)
local ping = Response.PING:new(data)
if ( ping ) then
return true, ping
end
return false, "Failed to parse PING response"
end,
-- Converts the PING response to a response suitable for script output
-- @return result formatted script output
__tostring = function(self)
return tostring(self.header)
end,
},
-- A class to process the response from a FIND_NODE query
FIND_NODE = {
-- Creates a new FIND_NODE instance
-- @param data string containing the received data
-- @return o new instance of FIND_NODE
new = function(self, data)
local o = {
header = Response.Header:new(data),
data = data:sub(27)
}
setmetatable(o, self)
self.__index = self
o:parse()
return o
end,
-- Parses the FIND_NODE response
parse = function(self)
local pos
pos, self.spoof_id, self.node_type, self.dht_size,
self.network_coords = bin.unpack(">IIIH20", self.data)
local contact_count
pos, contact_count = bin.unpack("C", self.data, pos)
self.contacts = {}
for i=1, contact_count do
local contact, addr_len, address = {}
pos, contact.type, contact.proto_version, addr_len = bin.unpack("CCC", self.data, pos)
if ( addr_len == 4 ) then
pos, address = bin.unpack("<I", self.data, pos)
contact.address = ipOps.fromdword(address)
elseif ( addr_len == 16 ) then
pos, contact.address = bin.unpack("H16", self.data, pos)
end
pos, contact.port = bin.unpack(">S", self.data, pos)
table.insert(self.contacts, contact)
end
end,
-- Creates a new instance of FIND_NODE based on received data
-- @param data string containing received data
-- @return status true on success, false on failure
-- @return new instance of FIND_NODE on success, error message on failure
fromString = function(data)
local find = Response.FIND_NODE:new(data)
if ( find.header.proto_version < 13 ) then
stdnse.print_debug("ERROR: Unsupported version %d", find.header.proto_version)
return false
end
return true, find
end,
-- Convert the FIND_NODE response to formatted string data, suitable
-- for script output.
-- @return string with formatted FIND_NODE data
__tostring = function(self)
if ( not(self.contacts) ) then
return ""
end
local result = {}
for _, contact in ipairs(self.contacts) do
table.insert(result, ("%s:%d"):format(contact.address, contact.port))
end
return stdnse.format_output(true, result)
end
},
-- The ERROR action
ERROR = {
-- Creates a new ERROR instance based on received socket data
-- @return o new ERROR instance on success, nil on failure
new = function(self, data)
local o = {
header = Response.Header:new(data),
data = data:sub(27)
}
setmetatable(o, self)
self.__index = self
if ( o:parse() ) then
return o
end
end,
-- parses the received data and attempts to create an ERROR response
-- @return true on success, false on failure
parse = function(self)
local pos, err_type = bin.unpack(">I", self.data)
if ( 1 == err_type ) then
self.addr = Response.Address:new(self.data:sub(5))
return true
end
return false
end,
-- creates a new ERROR instance based on the received data
-- @return true on success, false on failure
fromString = function(data)
local err = Response.ERROR:new(data)
if ( err ) then
return true, err
end
return false
end,
-- Converts the ERROR action to a formatted response
-- @return string containing the formatted response
__tostring = function(self)
return ("Wrong address, expected: %s"):format(self.addr.ip)
end,
},
-- creates a suitable Response class based on the Action received
-- @return true on success, false on failure
-- @return response instance of suitable Response class on success,
-- err string error message if status is false
fromString = function(data)
local pos, action = bin.unpack(">I", data)
if ( action == Response.Actions.ACTION_PING ) then
return Response.PING.fromString(data)
elseif ( action == Response.Actions.FIND_NODE ) then
return Response.FIND_NODE.fromString(data)
elseif ( action == Response.Actions.ERROR ) then
return Response.ERROR.fromString(data)
end
stdnse.print_debug("ERROR: Unknown response received from server")
return false, "Failed to parse response"
end,
}
-- The Session
Session = {
-- Creates a new Session instance to keep track on some of the protocol
-- stuff, such as transaction- and instance- identities.
-- @param address the local address to pass in the requests to the server
-- this could be either the local address or the IP of the router
-- depending on if NAT is used or not.
-- @param port the local port to pass in the requests to the server
-- @return o new instance of Session
new = function(self, address, port)
local o = {
trans_id = math.random(12345678),
instance_id = math.random(12345678),
address = address,
port = port,
}
setmetatable(o, self)
self.__index = self
return o
end,
-- Gets the next transaction ID
-- @return trans_id number
getTransactionId = function(self)
self.trans_id = self.trans_id + 1
return self.trans_id
end,
-- Gets the next instance ID
-- @return instance_id number
getInstanceId = function(self)
self.instance_id = self.instance_id + 1
return self.instance_id
end,
-- Gets the stored local address used to create the session
-- @return string containing the IP passed to the session
getAddress = function(self)
return self.address
end,
-- Get the stored local port used to create the session
-- @return number containing the local port
getPort = function(self)
return self.port
end
}
-- The Helper class, used as main interface between the scripts and the library
Helper = {
-- Creates a new instance of the Helper class
-- @param host table as passed to the action method
-- @param port table as passed to the action method
-- @param lhost [optional] used if an alternate local address is to be
-- passed in the requests to the remote node (ie. NAT is in play).
-- @param lport [optional] used if an alternate port is to be passed in
-- the requests to the remote node.
-- @return o new instance of Helper
new = function(self, host, port, lhost, lport)
local o = {
host = host,
port = port,
lhost = lhost,
lport = lport
}
setmetatable(o, self)
self.__index = self
math.randomseed(os.time())
return o
end,
-- Connects to the remote Vuze Node
-- @return true on success, false on failure
-- @return err string error message if status is false
connect = function(self)
local lhost = self.lhost or stdnse.get_script_args('vuzedht.lhost')
local lport = self.lport or stdnse.get_script_args('vuzedht.lport')
self.socket = nmap.new_socket()
if ( lport ) then
self.socket:bind(nil, lport)
end
local status, err = self.socket:connect(self.host, self.port)
if ( not(status) ) then
return false, "Failed to connect to server"
end
if ( not(lhost) or not(lport) ) then
local status, lh, lp, _, _ = self.socket:get_info()
if ( not(status) ) then
return false, "Failed to get socket information"
end
lhost = lhost or lh
lport = lport or lp
end
self.session = Session:new(lhost, lport)
return true
end,
-- Sends a Vuze PING request to the server and parses the response
-- @return status true on success, false on failure
-- @return response PING response instance on success,
-- err string containing the error message on failure
ping = function(self)
local ping = Request.Ping:new(self.session)
local status, err = self.socket:send(tostring(ping))
if ( not(status) ) then
return false, "Failed to send PING request to server"
end
local data
status, data = self.socket:receive()
if ( not(status) ) then
return false, "Failed to receive PING response from server"
end
local response
status, response = Response.fromString(data)
if ( not(status) ) then
return false, "Failed to parse PING response from server"
end
return true, response
end,
-- Requests a list of known nodes by sending the FIND_NODES request
-- to the remote node and parses the response.
-- @return status true on success, false on failure
-- @return response FIND_NODE response instance on success
-- err string containing the error message on failure
findNodes = function(self)
local find = Request.FindNode:new(self.session)
local status, err = self.socket:send(tostring(find))
if ( not(status) ) then
return false, "Failed to send FIND_NODE request to server"
end
local data
status, data = self.socket:receive()
local response
status, response = Response.fromString(data)
if ( not(status) ) then
return false, "Failed to parse FIND_NODE response from server"
end
return true, response
end,
-- Closes the socket connect to the remote node
close = function(self)
self.socket:close()
end,
}
return _ENV;
| gpl-3.0 |
zynjec/darkstar | scripts/zones/Norg/npcs/Ranemaud.lua | 9 | 3367 | -----------------------------------
-- Area: Norg
-- NPC: Ranemaud
-- Involved in Quest: Forge Your Destiny, The Sacred Katana
-- !pos 15 0 23 252
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/quests");
local ID = require("scripts/zones/Norg/IDs");
-----------------------------------
function onTrade(player,npc,trade)
local questItem = player:getCharVar("ForgeYourDestiny_Event");
local checkItem = testflag(tonumber(questItem),0x02);
if (checkItem == true) then
if (trade:hasItemQty(738,1) and trade:hasItemQty(737,2) and trade:getItemCount() == 3) then
player:startEvent(43,0,0,738,737); -- Platinum Ore, Gold Ore
end
end
if (player:getQuestStatus(OUTLANDS,dsp.quest.id.outlands.THE_SACRED_KATANA) == QUEST_ACCEPTED and player:hasItem(17809) == false) then
if (trade:getGil() == 30000 and trade:getItemCount() == 1 and player:getFreeSlotsCount() >= 1) then
player:startEvent(145);
end
end
end;
-----------------------------------
-- Event Check
-----------------------------------
function testflag(set,flag)
return (set % (2*flag) >= flag)
end;
function onTrigger(player,npc)
local swordTimer = player:getCharVar("ForgeYourDestiny_timer")
if (player:getQuestStatus(OUTLANDS,dsp.quest.id.outlands.FORGE_YOUR_DESTINY) == QUEST_ACCEPTED and swordTimer == 0) then
if (player:hasItem(1153)) then
player:startEvent(48,1153); -- Sacred Branch
elseif (player:hasItem(1198) == false) then
local questItem = player:getCharVar("ForgeYourDestiny_Event");
local checkItem = testflag(tonumber(questItem),0x02);
if (checkItem == false) then
player:startEvent(40,1153,1198); -- Sacred Branch, Sacred Sprig
elseif (checkItem == true) then
player:startEvent(42,0,0,738,737); -- Platinum Ore, Gold Ore
end
elseif (player:hasItem(1198)) then -- Sacred Sprig
player:startEvent(41);
end
elseif (player:getQuestStatus(OUTLANDS,dsp.quest.id.outlands.THE_SACRED_KATANA) == QUEST_ACCEPTED and player:hasItem(17809) == false) then
player:startEvent(144);
else
player:startEvent(68);
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
local questItem = player:getCharVar("ForgeYourDestiny_Event");
if (csid == 40) then
if (player:getFreeSlotsCount(0) >= 1) then
player:addItem(1198);
player:messageSpecial(ID.text.ITEM_OBTAINED, 1198); -- Sacred Sprig
player:setCharVar("ForgeYourDestiny_Event",questItem + 0x02);
else
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED, 1151); -- Oriental Steel
end
elseif (csid == 43) then
if (player:getFreeSlotsCount(0) >= 1) then
player:tradeComplete();
player:addItem(1198);
player:messageSpecial(ID.text.ITEM_OBTAINED, 1198); -- Sacred Sprig
else
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED, 1198); -- Sacred Sprig
end
elseif (csid == 145) then
player:tradeComplete();
player:addItem(17809);
player:messageSpecial(ID.text.ITEM_OBTAINED,17809); -- Mumeito
end
end; | gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Windurst_Woods/npcs/Etsa_Rhuyuli.lua | 14 | 1474 | -----------------------------------
-- Area: Windurst Woods
-- NPC: Etsa Rhuyuli
-- Type: Standard NPC
-- @pos 62.482 -8.499 -139.836 241
-----------------------------------
package.loaded["scripts/zones/Windurst_Woods/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/zones/Windurst_Woods/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local WildcatWindurst = player:getVar("WildcatWindurst");
if (player:getQuestStatus(WINDURST,LURE_OF_THE_WILDCAT_WINDURST) == QUEST_ACCEPTED and player:getMaskBit(WildcatWindurst,1) == false) then
player:startEvent(0x02de);
else
player:startEvent(0x01a6);
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 == 0x02de) then
player:setMaskBit(player:getVar("WildcatWindurst"),"WildcatWindurst",1,true);
end
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/zones/Temenos/mobs/Goblin_Slaughterman.lua | 23 | 1065 | -----------------------------------
-- Area: Temenos N T
-- NPC: Goblin_Slaughterman
-----------------------------------
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)
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
local mobID = mob:getID();
-- print(mobID);
local mobX = mob:getXPos();
local mobY = mob:getYPos();
local mobZ = mob:getZPos();
if (mobID ==16928773) then
GetNPCByID(16928768+18):setPos(330,70,468);
GetNPCByID(16928768+18):setStatus(STATUS_NORMAL);
elseif (mobID ==16928772) then
GetNPCByID(16928770+450):setStatus(STATUS_NORMAL);
end
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/globals/items/kalamar.lua | 18 | 1307 | -----------------------------------------
-- ID: 5448
-- Item: Kalamar
-- Food Effect: 5Min, Mithra only
-----------------------------------------
-- Dexterity 3
-- Mind -5
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
result = 0
if (target:getRace() ~= 7) then
result = 247;
end
if (target:getMod(MOD_EAT_RAW_FISH) == 1) then
result = 0;
end
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,300,5448);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_DEX, 3);
target:addMod(MOD_MND, -5);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_DEX, 3);
target:delMod(MOD_MND, -5);
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/zones/Mhaura/npcs/Phoochuchu.lua | 13 | 1542 | -----------------------------------
-- Area: Mhaura
-- NPC: Phoochuchu
-- Involved in Quest: A Thief in Norg!?
-- @pos -4 -4 69 249
-----------------------------------
package.loaded["scripts/zones/Mhaura/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/zones/Mhaura/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getQuestStatus(OUTLANDS,A_THIEF_IN_NORG) == QUEST_ACCEPTED) then
local aThiefinNorgCS = player:getVar("aThiefinNorgCS");
if (aThiefinNorgCS == 2) then
player:startEvent(0x012d);
elseif (aThiefinNorgCS == 3) then
player:startEvent(0x012f);
elseif (aThiefinNorgCS >= 4) then
player:startEvent(0x012e);
end
else
player:startEvent(0x012c);
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 == 0x012d) then
player:setVar("aThiefinNorgCS",3);
end
end; | gpl-3.0 |
darklost/quick-ng | cocos/scripting/lua-bindings/auto/api/ComAttribute.lua | 19 | 2639 |
--------------------------------
-- @module ComAttribute
-- @extend Component
-- @parent_module ccs
--------------------------------
--
-- @function [parent=#ComAttribute] getFloat
-- @param self
-- @param #string key
-- @param #float def
-- @return float#float ret (return value: float)
--------------------------------
--
-- @function [parent=#ComAttribute] getString
-- @param self
-- @param #string key
-- @param #string def
-- @return string#string ret (return value: string)
--------------------------------
--
-- @function [parent=#ComAttribute] setFloat
-- @param self
-- @param #string key
-- @param #float value
-- @return ComAttribute#ComAttribute self (return value: ccs.ComAttribute)
--------------------------------
--
-- @function [parent=#ComAttribute] setString
-- @param self
-- @param #string key
-- @param #string value
-- @return ComAttribute#ComAttribute self (return value: ccs.ComAttribute)
--------------------------------
--
-- @function [parent=#ComAttribute] getBool
-- @param self
-- @param #string key
-- @param #bool def
-- @return bool#bool ret (return value: bool)
--------------------------------
--
-- @function [parent=#ComAttribute] setInt
-- @param self
-- @param #string key
-- @param #int value
-- @return ComAttribute#ComAttribute self (return value: ccs.ComAttribute)
--------------------------------
--
-- @function [parent=#ComAttribute] parse
-- @param self
-- @param #string jsonFile
-- @return bool#bool ret (return value: bool)
--------------------------------
--
-- @function [parent=#ComAttribute] getInt
-- @param self
-- @param #string key
-- @param #int def
-- @return int#int ret (return value: int)
--------------------------------
--
-- @function [parent=#ComAttribute] setBool
-- @param self
-- @param #string key
-- @param #bool value
-- @return ComAttribute#ComAttribute self (return value: ccs.ComAttribute)
--------------------------------
--
-- @function [parent=#ComAttribute] create
-- @param self
-- @return ComAttribute#ComAttribute ret (return value: ccs.ComAttribute)
--------------------------------
--
-- @function [parent=#ComAttribute] createInstance
-- @param self
-- @return Ref#Ref ret (return value: cc.Ref)
--------------------------------
--
-- @function [parent=#ComAttribute] init
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
--
-- @function [parent=#ComAttribute] serialize
-- @param self
-- @param #void r
-- @return bool#bool ret (return value: bool)
return nil
| mit |
Vadavim/jsr-darkstar | scripts/zones/Valkurm_Dunes/npcs/Fighting_Ant_IM.lua | 14 | 3326 | -----------------------------------
-- Area: Valkurm Dunes
-- NPC: Fighting Ant, I.M.
-- Border Conquest Guards
-- @pos 908.245 -1.171 -411.504 103
-----------------------------------
package.loaded["scripts/zones/Valkurm_Dunes/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/conquest");
require("scripts/zones/Valkurm_Dunes/TextIDs");
local guardnation = NATION_BASTOK; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno
local guardtype = 4; -- 1: city, 2: foreign, 3: outpost, 4: border
local region = ZULKHEIM;
local csid = 0x7ff8;
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
tradeConquestGuard(player,npc,trade,guardnation,guardtype);
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:hasKeyItem(getSupplyKey(region)) and player:getNation() == guardnation) then
if (supplyRunFresh(player) == 1) then
player:startEvent(csid,16,0,0,0,1,0,0,255); -- you have brought us supplies !
else
player:showText(npc, CONQUEST - 1); -- "Hmm... These supplies you have brought us are too old to be of any use."
player:delKeyItem(getSupplyKey(region));
player:messageSpecial(KEYITEM_OBTAINED + 1, getSupplyKey(region));
player:setVar("supplyQuest_region",0);
end
else
local arg1 = getArg1(guardnation, player) - 1;
if (arg1 >= 1792) then -- foreign, non-allied
player:startEvent(csid,1808,0,0,0,0,player:getRank(),0,0);
else -- citizen or allied
player:startEvent(csid,arg1,0,0x3F0000,0,0,getArg6(player),0,0);
end
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("OPTION: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("OPTION: %u",option);
if (option == 1) then
local duration = (player:getRank() + getNationRank(player:getNation()) + 3) * 3600;
player:delStatusEffect(EFFECT_SIGIL);
player:delStatusEffect(EFFECT_SANCTION);
player:delStatusEffect(EFFECT_SIGNET);
player:addStatusEffect(EFFECT_SIGNET,0,0,duration); -- Grant Signet
elseif (option == 2) then
player:delKeyItem(getSupplyKey(region));
player:addCP(supplyReward[region + 1])
player:messageSpecial(CONQUEST); -- "You've earned conquest points!"
if (hasOutpost(player, region+5) == 0) then
local supply_quests = 2^(region+5);
player:addNationTeleport(guardnation,supply_quests);
player:setVar("supplyQuest_region",0);
end
elseif (option == 4) then
if (player:delGil(giltosetHP(guardnation,player))) then
player:setHomePoint();
player:messageSpecial(CONQUEST + 94); -- "Your home point has been set."
else
player:messageSpecial(CONQUEST + 95); -- "You do not have enough gil to set your home point here."
end
end
end; | gpl-3.0 |
Colettechan/darkstar | scripts/zones/Bibiki_Bay/npcs/Warmachine.lua | 13 | 2034 | -----------------------------------
-- Area: Bibiki Bay
-- NPC: Warmachine
-- @zone 4
-- @pos -345.236 -3.188 -976.563 4
-----------------------------------
package.loaded["scripts/zones/Bibiki_Bay/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/keyitems");
require("scripts/zones/Bibiki_Bay/TextIDs");
require("scripts/globals/missions");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local ColoredDrop = 4258+math.random(0,7);
-- COP mission
if (player:getCurrentMission(COP) == THREE_PATHS and player:getVar("COP_Louverance_s_Path") == 2) then
player:startEvent(0x0021);
elseif (player:getCurrentMission(COP) == DAWN and player:getVar("COP_3-taru_story")== 1) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,ColoredDrop);
else
player:setVar("ColoredDrop",ColoredDrop);
player:startEvent(0x002B);
end
-- standard dialog
else
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 == 0x0021) then
player:setVar("COP_Louverance_s_Path",3);
elseif (csid == 0x002B) then
local ColoredDropID=player:getVar("ColoredDrop");
player:addItem(ColoredDropID);
player:messageSpecial(ITEM_OBTAINED,ColoredDropID);
player:setVar("COP_3-taru_story",2);
player:setVar("ColoredDrop",0);
end
end; | gpl-3.0 |
Colettechan/darkstar | scripts/globals/items/mithran_tomato.lua | 18 | 1180 | -----------------------------------------
-- ID: 4390
-- Item: mithran_tomato
-- Food Effect: 5Min, All Races
-----------------------------------------
-- Agility -3
-- Intelligence 1
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,300,4390);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_AGI, -3);
target:addMod(MOD_INT, 1);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_AGI, -3);
target:delMod(MOD_INT, 1);
end;
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/items/moogle_pie.lua | 18 | 1701 | -----------------------------------------
-- ID: 5561
-- Item: Moogle Pie
-- Food Effect: 3 Hrs, All Races
-----------------------------------------
-- HP 20
-- MP 20
-- Strength 1
-- Dexterity 1
-- Vitality 1
-- Agility 1
-- Intelligence 1
-- Mind 1
-- Charisma 1
-----------------------------------------
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,10800,5561);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 20);
target:addMod(MOD_MP, 20);
target:addMod(MOD_STR,1);
target:addMod(MOD_DEX, 1);
target:addMod(MOD_VIT,1);
target:addMod(MOD_AGI,1);
target:addMod(MOD_INT, 1);
target:addMod(MOD_MND,1);
target:addMod(MOD_CHR, 1);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 20);
target:delMod(MOD_MP, 20);
target:delMod(MOD_STR,1);
target:delMod(MOD_DEX, 1);
target:delMod(MOD_VIT,1);
target:delMod(MOD_AGI,1);
target:delMod(MOD_INT, 1);
target:delMod(MOD_MND,1);
target:delMod(MOD_CHR, 1);
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/globals/items/moogle_pie.lua | 18 | 1701 | -----------------------------------------
-- ID: 5561
-- Item: Moogle Pie
-- Food Effect: 3 Hrs, All Races
-----------------------------------------
-- HP 20
-- MP 20
-- Strength 1
-- Dexterity 1
-- Vitality 1
-- Agility 1
-- Intelligence 1
-- Mind 1
-- Charisma 1
-----------------------------------------
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,10800,5561);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 20);
target:addMod(MOD_MP, 20);
target:addMod(MOD_STR,1);
target:addMod(MOD_DEX, 1);
target:addMod(MOD_VIT,1);
target:addMod(MOD_AGI,1);
target:addMod(MOD_INT, 1);
target:addMod(MOD_MND,1);
target:addMod(MOD_CHR, 1);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 20);
target:delMod(MOD_MP, 20);
target:delMod(MOD_STR,1);
target:delMod(MOD_DEX, 1);
target:delMod(MOD_VIT,1);
target:delMod(MOD_AGI,1);
target:delMod(MOD_INT, 1);
target:delMod(MOD_MND,1);
target:delMod(MOD_CHR, 1);
end;
| gpl-3.0 |
anthrotype/sile | lua-libraries/std/tree.lua | 6 | 6900 | --[[--
Tree container.
Derived from @{std.container}, and inherits Container's metamethods.
Note that Functions listed below are only available from the Tree
prototype return by requiring this module, because Container objects
cannot have object methods.
@classmod std.tree
@see std.container
]]
local base = require "std.base"
local Container = require "std.container"
local List = require "std.list"
local func = require "std.functional"
local prototype = (require "std.object").prototype
local Tree -- forward declaration
--- Tree iterator which returns just numbered leaves, in order.
-- @function ileaves
-- @static
-- @tparam tree|table tr tree or tree-like table
-- @treturn function iterator function
-- @treturn tree|table the tree `tr`
local ileaves = base.ileaves
--- Tree iterator which returns just leaves.
-- @function leaves
-- @static
-- @tparam tree|table tr tree or tree-like table
-- @treturn function iterator function
-- @treturn tree|table the tree, `tr`
local leaves = base.leaves
--- Make a deep copy of a tree, including any metatables.
--
-- To make fast shallow copies, use @{std.table.clone}.
-- @tparam table|tree t table or tree to be cloned
-- @tparam boolean nometa if non-nil don't copy metatables
-- @treturn table|tree a deep copy of `t`
local function clone (t, nometa)
assert (type (t) == "table",
"bad argument #1 to 'clone' (table expected, got " .. type (t) .. ")")
local r = {}
if not nometa then
setmetatable (r, getmetatable (t))
end
local d = {[t] = r}
local function copy (o, x)
for i, v in pairs (x) do
if type (v) == "table" then
if not d[v] then
d[v] = {}
if not nometa then
setmetatable (d[v], getmetatable (v))
end
o[i] = copy (d[v], v)
else
o[i] = d[v]
end
else
o[i] = v
end
end
return o
end
return copy (r, t)
end
--- Tree iterator.
-- @tparam function it iterator function
-- @tparam tree|table tr tree or tree-like table
-- @treturn string type ("leaf", "branch" (pre-order) or "join" (post-order))
-- @treturn table path to node ({i\_1...i\_k})
-- @return node
local function _nodes (it, tr)
local p = {}
local function visit (n)
if type (n) == "table" then
coroutine.yield ("branch", p, n)
for i, v in it (n) do
table.insert (p, i)
visit (v)
table.remove (p)
end
coroutine.yield ("join", p, n)
else
coroutine.yield ("leaf", p, n)
end
end
return coroutine.wrap (visit), tr
end
--- Tree iterator over all nodes.
--
-- The returned iterator function performs a depth-first traversal of
-- `tr`, and at each node it returns `{node-type, tree-path, tree-node}`
-- where `node-type` is `branch`, `join` or `leaf`; `tree-path` is a
-- list of keys used to reach this node, and `tree-node` is the current
-- node.
--
-- Given a `tree` to represent:
--
-- + root
-- +-- node1
-- | +-- leaf1
-- | '-- leaf2
-- '-- leaf 3
--
-- tree = std.tree { std.tree { "leaf1", "leaf2"}, "leaf3" }
--
-- A series of calls to `tree.nodes` will return:
--
-- "branch", {}, {{"leaf1", "leaf2"}, "leaf3"}
-- "branch", {1}, {"leaf1", "leaf"2")
-- "leaf", {1,1}, "leaf1"
-- "leaf", {1,2}, "leaf2"
-- "join", {1}, {"leaf1", "leaf2"}
-- "leaf", {2}, "leaf3"
-- "join", {}, {{"leaf1", "leaf2"}, "leaf3"}
--
-- Note that the `tree-path` reuses the same table on each iteration, so
-- you must `table.clone` a copy if you want to take a snap-shot of the
-- current state of the `tree-path` list before the next iteration
-- changes it.
-- @tparam tree|table tr tree or tree-like table to iterate over
-- @treturn function iterator function
-- @treturn tree|table the tree, `tr`
-- @see inodes
local function nodes (tr)
assert (type (tr) == "table",
"bad argument #1 to 'nodes' (table expected, got " .. type (tr) .. ")")
return _nodes (pairs, tr)
end
--- Tree iterator over numbered nodes, in order.
--
-- The iterator function behaves like @{nodes}, but only traverses the
-- array part of the nodes of `tr`, ignoring any others.
-- @tparam tree|table tr tree to iterate over
-- @treturn function iterator function
-- @treturn tree|table the tree, `tr`
-- @see nodes
local function inodes (tr)
assert (type (tr) == "table",
"bad argument #1 to 'inodes' (table expected, got " .. type (tr) .. ")")
return _nodes (ipairs, tr)
end
--- Destructively deep-merge one tree into another.
-- @tparam tree|table t destination tree or table
-- @tparam tree|table u tree or table with nodes to merge
-- @treturn tree|table `t` with nodes from `u` merged in
-- @see std.table.merge
local function merge (t, u)
assert (type (t) == "table",
"bad argument #1 to 'merge' (table expected, got " .. type (t) .. ")")
assert (type (u) == "table",
"bad argument #2 to 'merge' (table expected, got " .. type (u) .. ")")
for ty, p, n in nodes (u) do
if ty == "leaf" then
t[p] = n
end
end
return t
end
--- @export
local _functions = {
clone = clone,
ileaves = ileaves,
inodes = inodes,
leaves = leaves,
merge = merge,
nodes = nodes,
}
--- Tree prototype object.
-- @table std.tree
-- @string[opt="Tree"] _type type of Tree, returned by
-- @{std.object.prototype}
-- @tfield[opt={}] table|function _init a table of field names, or
-- initialisation function, see @{std.object.__call}
-- @tfield nil|table _functions a table of module functions not copied
-- by @{std.object.__call}
Tree = Container {
-- Derived object type.
_type = "Tree",
--- Tree `__index` metamethod.
-- @function __index
-- @param i non-table, or list of keys `{i\_1 ... i\_n}`
-- @return `self[i]...[i\_n]` if i is a table, or `self[i]` otherwise
-- @todo the following doesn't treat list keys correctly
-- e.g. self[{{1, 2}, {3, 4}}], maybe flatten first?
__index = function (self, i)
if type (i) == "table" and #i > 0 then
return List.foldl (func.op["[]"], self, i)
else
return rawget (self, i)
end
end,
--- Tree `__newindex` metamethod.
--
-- Sets `self[i\_1]...[i\_n] = v` if i is a table, or `self[i] = v` otherwise
-- @function __newindex
-- @param i non-table, or list of keys `{i\_1 ... i\_n}`
-- @param v value
__newindex = function (self, i, v)
if type (i) == "table" then
for n = 1, #i - 1 do
if prototype (self[i[n]]) ~= "Tree" then
rawset (self, i[n], Tree {})
end
self = self[i[n]]
end
rawset (self, i[#i], v)
else
rawset (self, i, v)
end
end,
_functions = base.merge (_functions, {
-- backwards compatibility.
new = function (t) return Tree (t or {}) end,
}),
}
return Tree
| mit |
zynjec/darkstar | scripts/globals/items/bowl_of_jack-o-soup.lua | 11 | 1388 | -----------------------------------------
-- ID: 4522
-- Item: Bowl of Jack-o'-Soup
-- Food Effect: 240Min, All Races
-----------------------------------------
-- Health % 2 (cap 120)
-- Agility 3
-- Vitality -1
-- Health Regen While Healing 5
-- Ranged ACC % 8
-- Ranged ACC Cap 25
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if target:hasStatusEffect(dsp.effect.FOOD) or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) then
result = dsp.msg.basic.IS_FULL
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,14400,4522)
end
function onEffectGain(target, effect)
target:addMod(dsp.mod.FOOD_HPP, 2)
target:addMod(dsp.mod.FOOD_HP_CAP, 120)
target:addMod(dsp.mod.AGI, 3)
target:addMod(dsp.mod.VIT, -1)
target:addMod(dsp.mod.HPHEAL, 5)
target:addMod(dsp.mod.FOOD_RACCP, 8)
target:addMod(dsp.mod.FOOD_RACC_CAP, 25)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.FOOD_HPP, 2)
target:delMod(dsp.mod.FOOD_HP_CAP, 120)
target:delMod(dsp.mod.AGI, 3)
target:delMod(dsp.mod.VIT, -1)
target:delMod(dsp.mod.HPHEAL, 5)
target:delMod(dsp.mod.FOOD_RACCP, 8)
target:delMod(dsp.mod.FOOD_RACC_CAP, 25)
end
| gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/East_Ronfaure_[S]/npcs/qm5.lua | 29 | 1559 | -----------------------------------
-- Area: East Ronfaure [S]
-- NPC: qm5 "???"
-- Involved in Quests: Steamed Rams
-- @pos 380.015 -26.5 -22.525
-----------------------------------
package.loaded["scripts/zones/East_Ronfaure_[S]/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/keyitems");
require("scripts/globals/campaign");
require("scripts/zones/East_Ronfaure_[S]/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getQuestStatus(CRYSTAL_WAR,STEAMED_RAMS) == QUEST_ACCEPTED) then
if (player:hasKeyItem(OXIDIZED_PLATE)) then
player:messageSpecial(NOTHING_OUT_OF_ORDINARY);
else
player:startEvent(0x0003);
end
else
player:messageSpecial(NOTHING_OUT_OF_ORDINARY);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
-- print("CSID:",csid);
-- print("RESULT:",option);
if (csid == 0x0003) then
player:addKeyItem(OXIDIZED_PLATE);
player:messageSpecial(KEYITEM_OBTAINED,OXIDIZED_PLATE);
end
end; | gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Batallia_Downs_[S]/npcs/Cavernous_Maw.lua | 29 | 2133 | -----------------------------------
-- Area: Batallia Downs [S]
-- NPC: Cavernous Maw
-- @pos -48 0 435 84
-- Teleports Players to Batallia Downs
-----------------------------------
package.loaded["scripts/zones/Batallia_Downs_[S]/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/teleports");
require("scripts/globals/campaign");
require("scripts/zones/Batallia_Downs_[S]/TextIDs");
require("scripts/globals/titles");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getCurrentMission(WOTG) == BACK_TO_THE_BEGINNING and
(player:getQuestStatus(CRYSTAL_WAR, CLAWS_OF_THE_GRIFFON) == QUEST_COMPLETED or
player:getQuestStatus(CRYSTAL_WAR, THE_TIGRESS_STRIKES) == QUEST_COMPLETED or
player:getQuestStatus(CRYSTAL_WAR, FIRES_OF_DISCONTENT) == QUEST_COMPLETED)) then
player:startEvent(701);
elseif (hasMawActivated(player,0) == false) then
player:startEvent(100);
else
player:startEvent(101);
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 == 100 and option == 1) then
player:addNationTeleport(MAW,1);
toMaw(player,2);
elseif (csid == 101 and option == 1) then
toMaw(player,2);
elseif (csid == 701) then
player:completeMission(WOTG, BACK_TO_THE_BEGINNING);
player:addMission(WOTG, CAIT_SITH);
player:addTitle(CAIT_SITHS_ASSISTANT);
if (hasMawActivated(player,0) == false) then
player:addNationTeleport(MAW,1);
end
toMaw(player,2);
end
end; | gpl-3.0 |
Vadavim/jsr-darkstar | scripts/zones/Castle_Oztroja/Zone.lua | 19 | 1745 | -----------------------------------
--
-- Zone: Castle_Oztroja (151)
--
-----------------------------------
package.loaded["scripts/zones/Castle_Oztroja/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/zone");
require("scripts/zones/Castle_Oztroja/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
-- Yagudo Avatar
SetRespawnTime(17396134, 900, 10800);
UpdateTreasureSpawnPoint(17396206);
UpdateTreasureSpawnPoint(17396207);
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
player:setPos(-162.895,22.136,-139.923,2);
end
return cs;
end;
-----------------------------------
-- onConquestUpdate
-----------------------------------
function onConquestUpdate(zone, updatetype)
local players = zone:getPlayers();
for name, player in pairs(players) do
conquestUpdate(zone, player, updatetype, CONQUEST_BASE);
end
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end; | gpl-3.0 |
zynjec/darkstar | scripts/zones/Tavnazian_Safehold/npcs/Aligi-Kufongi.lua | 9 | 2270 | -----------------------------------
-- Area: Tavnazian Safehold
-- NPC: Aligi-Kufongi
-- Title Change NPC
-- !pos -23 -21 15 26
-----------------------------------
require("scripts/globals/titles")
-----------------------------------
local eventId = 342
local titleInfo =
{
{
cost = 200,
title =
{
dsp.title.TAVNAZIAN_SQUIRE,
dsp.title.PUTRID_PURVEYOR_OF_PUNGENT_PETALS,
dsp.title.MONARCH_LINN_PATROL_GUARD,
dsp.title.SIN_HUNTER_HUNTER,
dsp.title.DISCIPLE_OF_JUSTICE,
dsp.title.DYNAMIS_TAVNAZIA_INTERLOPER,
dsp.title.CONFRONTER_OF_NIGHTMARES,
},
},
{
cost = 300,
title =
{
dsp.title.DEAD_BODY,
dsp.title.FROZEN_DEAD_BODY,
dsp.title.DREAMBREAKER,
dsp.title.MIST_MELTER,
dsp.title.DELTA_ENFORCER,
dsp.title.OMEGA_OSTRACIZER,
dsp.title.ULTIMA_UNDERTAKER,
dsp.title.ULMIAS_SOULMATE,
dsp.title.TENZENS_ALLY,
dsp.title.COMPANION_OF_LOUVERANCE,
dsp.title.TRUE_COMPANION_OF_LOUVERANCE,
dsp.title.PRISHES_BUDDY,
dsp.title.NAGMOLADAS_UNDERLING,
dsp.title.ESHANTARLS_COMRADE_IN_ARMS,
dsp.title.THE_CHEBUKKIS_WORST_NIGHTMARE,
dsp.title.UNQUENCHABLE_LIGHT,
dsp.title.WARRIOR_OF_THE_CRYSTAL,
},
},
{
cost = 400,
title =
{
dsp.title.ANCIENT_FLAME_FOLLOWER,
dsp.title.TAVNAZIAN_TRAVELER,
dsp.title.TRANSIENT_DREAMER,
dsp.title.THE_LOST_ONE,
dsp.title.TREADER_OF_AN_ICY_PAST,
dsp.title.BRANDED_BY_LIGHTNING,
dsp.title.SEEKER_OF_THE_LIGHT,
dsp.title.AVERTER_OF_THE_APOCALYPSE,
dsp.title.BANISHER_OF_EMPTINESS,
dsp.title.BREAKER_OF_THE_CHAINS,
},
},
}
function onTrade(player,npc,trade)
end
function onTrigger(player,npc)
dsp.title.changerOnTrigger(player, eventId, titleInfo)
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
dsp.title.changerOnEventFinish(player, csid, option, eventId, titleInfo)
end | gpl-3.0 |
lcf8858/Sample_Lua | frameworks/cocos2d-x/tests/lua-tests/src/CocoStudioTest/CocoStudioSceneTest/TriggerCode/cons.lua | 10 | 1517 | local NodeInRect = class("NodeInRect")
NodeInRect._tag = -1
NodeInRect._origin = nil
NodeInRect._size = nil
function NodeInRect:ctor()
self._tag = -1
self._origin = nil
self._size = nil
self._origin = cc.p(0, 0)
self._size = cc.size(0, 0)
end
function NodeInRect:init()
return true
end
function NodeInRect:detect()
local node = ccs.SceneReader:getInstance():getNodeByTag(self._tag)
if nil ~= node and math.abs(node:getPositionX() - self._origin.x) <= self._size.width and math.abs(node:getPositionY() - self._origin.y) <= self._size.height then
return true
end
return false
end
function NodeInRect:serialize(value)
local dataItems = value["dataitems"]
if nil ~= dataItems then
local count = table.getn(dataItems)
for i = 1, count do
local subDict = dataItems[i]
local key = subDict["key"]
if key == "Tag" then
self._tag = subDict["value"]
elseif key == "originX" then
self._origin.x = subDict["value"]
elseif key == "originY" then
self._origin.y = subDict["value"]
elseif key == "sizeWidth" then
self._size.width = subDict["value"]
elseif key == "sizeHeight" then
self._size.height = subDict["value"]
end
end
end
end
function NodeInRect:removeAll()
print("NodeInRect::removeAll")
end
ccs.registerTriggerClass("NodeInRect",NodeInRect.new)
| mit |
Vadavim/jsr-darkstar | scripts/zones/Phomiuna_Aqueducts/npcs/qm4.lua | 14 | 1031 | -----------------------------------
-- Area: Phomiuna Aqueducts
-- NPC: qm4 (???)
-- Notes: Opens west door @ J-9
-- @pos 92.542 -25.907 26.548 27
-----------------------------------
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local DoorOffset = npc:getID() - 1;
if (GetNPCByID(DoorOffset):getAnimation() == 9) then
GetNPCByID(DoorOffset):openDoor(7); -- _0rj
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end; | gpl-3.0 |
Colettechan/darkstar | scripts/zones/Abyssea-Vunkerl/npcs/Cavernous_Maw.lua | 29 | 1194 | -----------------------------------
-- Area: Abyssea - Vunkerl
-- NPC: Cavernous Maw
-- @pos -360.000 -46.750 700.000 217
-- Notes: Teleports Players to Jugner Forest
-----------------------------------
package.loaded["scripts/zones/Abyssea-Vunkerl/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/zones/Abyssea-Vunkerl/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x00c8);
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 and option == 1) then
player:setPos(241,0.001,11,42,104);
end
end; | gpl-3.0 |
Vadavim/jsr-darkstar | scripts/globals/abilities/pets/zantetsuken.lua | 1 | 2159 | ---------------------------------------------------
-- Zantetsuken
---------------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
require("scripts/globals/magic");
require("scripts/globals/summon");
---------------------------------------------------
function onAbilityCheck(player, target, ability)
return 0,0;
end;
function onPetAbility(target, pet, skill, master)
local power = master:getMP() / master:getMaxMP();
master:setMP(0);
if (target:isNM()) then
local dmg = 0.1 * target:getHP() + 0.1 * target:getHP() * power;
if (dmg > 9999) then
dmg = 9999;
end
dmg = MobMagicalMove(pet,target,skill,dmg,ELE_DARK,1,TP_NO_EFFECT,0);
dmg = AvatarFinalAdjustments(dmg,pet,skill,target,MOBSKILL_MAGICAL,MOBPARAM_NONE,1);
target:delHP(dmg);
target:updateEnmityFromDamage(pet,dmg);
return dmg;
else
local chance = (100 * power) / skill:getTotalTargets();
if math.random(0,99) < chance and target:getAnimation() ~= 33 then
skill:setMsg(MSG_ENFEEB_IS);
target:delHP(target:getHP());
return EFFECT_KO;
else
skill:setMsg(282);
return 0;
end
end
-- if (target:isNM()) then
-- local dmg = 0.1 * target:getHP() + 0.1 * target:getHP() * power;
-- if (dmg > 9999) then
-- dmg = 9999;
-- end
-- dmg = MobMagicalMove(pet,target,skill,dmg,ELE_DARK,1,TP_NO_EFFECT,0);
-- dmg = AvatarFinalAdjustments(dmg,pet,skill,target,MOBSKILL_MAGICAL,MOBPARAM_NONE,1);
-- target:delHP(dmg);
-- target:updateEnmityFromDamage(pet,dmg);
-- return dmg;
-- else
-- local chance = (100 * power) / skill:getTotalTargets();
-- if math.random(0,99) < chance and target:getAnimation() ~= 33 then
-- skill:setMsg(MSG_ENFEEB_IS);
-- target:delHP(target:getHP());
-- return EFFECT_KO;
-- else
-- skill:setMsg(282);
-- return 0;
-- end
-- end
end | gpl-3.0 |
darklost/quick-ng | cocos/scripting/lua-bindings/auto/api/Text.lua | 7 | 7852 |
--------------------------------
-- @module Text
-- @extend Widget
-- @parent_module ccui
--------------------------------
-- Enable shadow for the label.<br>
-- todo support blur for shadow effect<br>
-- param shadowColor The color of shadow effect.<br>
-- param offset The offset of shadow effect.<br>
-- param blurRadius The blur radius of shadow effect.
-- @function [parent=#Text] enableShadow
-- @param self
-- @return Text#Text self (return value: ccui.Text)
--------------------------------
-- Gets the font size of label.<br>
-- return The font size.
-- @function [parent=#Text] getFontSize
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
--
-- @function [parent=#Text] getString
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @overload self, int
-- @overload self
-- @function [parent=#Text] disableEffect
-- @param self
-- @param #int effect
-- @return Text#Text self (return value: ccui.Text)
--------------------------------
-- Gets text color.<br>
-- return Text color.
-- @function [parent=#Text] getTextColor
-- @param self
-- @return color4b_table#color4b_table ret (return value: color4b_table)
--------------------------------
-- Sets text vertical alignment.<br>
-- param alignment vertical text alignment type
-- @function [parent=#Text] setTextVerticalAlignment
-- @param self
-- @param #int alignment
-- @return Text#Text self (return value: ccui.Text)
--------------------------------
-- Sets the font name of label.<br>
-- If you are trying to use a system font, you could just pass a font name<br>
-- If you are trying to use a TTF, you should pass a file path to the TTF file<br>
-- Usage:<br>
-- code<br>
-- create a system font UIText<br>
-- Text *text = Text::create("Hello", "Arial", 20);<br>
-- it will change the font to system font no matter the previous font type is TTF or system font<br>
-- text->setFontName("Marfelt");<br>
-- it will change the font to TTF font no matter the previous font type is TTF or system font<br>
-- text->setFontName("xxxx/xxx.ttf");<br>
-- endcode<br>
-- param name Font name.
-- @function [parent=#Text] setFontName
-- @param self
-- @param #string name
-- @return Text#Text self (return value: ccui.Text)
--------------------------------
-- Sets the touch scale enabled of label.<br>
-- param enabled Touch scale enabled of label.
-- @function [parent=#Text] setTouchScaleChangeEnabled
-- @param self
-- @param #bool enabled
-- @return Text#Text self (return value: ccui.Text)
--------------------------------
--
-- @function [parent=#Text] setString
-- @param self
-- @param #string text
-- @return Text#Text self (return value: ccui.Text)
--------------------------------
-- Gets the touch scale enabled of label.<br>
-- return Touch scale enabled of label.
-- @function [parent=#Text] isTouchScaleChangeEnabled
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- Gets the font name.<br>
-- return Font name.
-- @function [parent=#Text] getFontName
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- Sets the rendering size of the text, you should call this method<br>
-- along with calling `ignoreContentAdaptWithSize(false)`, otherwise the text area<br>
-- size is caculated by the real size of the text content.<br>
-- param size The text rendering area size.
-- @function [parent=#Text] setTextAreaSize
-- @param self
-- @param #size_table size
-- @return Text#Text self (return value: ccui.Text)
--------------------------------
-- Gets the string length of the label.<br>
-- Note: This length will be larger than the raw string length,<br>
-- if you want to get the raw string length,<br>
-- you should call this->getString().size() instead.<br>
-- return String length.
-- @function [parent=#Text] getStringLength
-- @param self
-- @return long#long ret (return value: long)
--------------------------------
-- Gets the render size in auto mode.<br>
-- return The size of render size in auto mode.
-- @function [parent=#Text] getAutoRenderSize
-- @param self
-- @return size_table#size_table ret (return value: size_table)
--------------------------------
-- Enable outline for the label.<br>
-- It only works on IOS and Android when you use System fonts.<br>
-- param outlineColor The color of outline.<br>
-- param outlineSize The size of outline.
-- @function [parent=#Text] enableOutline
-- @param self
-- @param #color4b_table outlineColor
-- @param #int outlineSize
-- @return Text#Text self (return value: ccui.Text)
--------------------------------
-- Gets the font type.<br>
-- return The font type.
-- @function [parent=#Text] getType
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- Gets text horizontal alignment.<br>
-- return Horizontal text alignment type
-- @function [parent=#Text] getTextHorizontalAlignment
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- Sets the font size of label.<br>
-- param size The font size.
-- @function [parent=#Text] setFontSize
-- @param self
-- @param #int size
-- @return Text#Text self (return value: ccui.Text)
--------------------------------
-- Sets text color.<br>
-- param color Text color.
-- @function [parent=#Text] setTextColor
-- @param self
-- @param #color4b_table color
-- @return Text#Text self (return value: ccui.Text)
--------------------------------
-- Only support for TTF.<br>
-- param glowColor The color of glow.
-- @function [parent=#Text] enableGlow
-- @param self
-- @param #color4b_table glowColor
-- @return Text#Text self (return value: ccui.Text)
--------------------------------
-- Gets text vertical alignment.<br>
-- return Vertical text alignment type
-- @function [parent=#Text] getTextVerticalAlignment
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- Return the text rendering area size.<br>
-- return The text rendering area size.
-- @function [parent=#Text] getTextAreaSize
-- @param self
-- @return size_table#size_table ret (return value: size_table)
--------------------------------
-- Sets text horizontal alignment.<br>
-- param alignment Horizontal text alignment type
-- @function [parent=#Text] setTextHorizontalAlignment
-- @param self
-- @param #int alignment
-- @return Text#Text self (return value: ccui.Text)
--------------------------------
-- @overload self, string, string, int
-- @overload self
-- @function [parent=#Text] create
-- @param self
-- @param #string textContent
-- @param #string fontName
-- @param #int fontSize
-- @return Text#Text ret (return value: ccui.Text)
--------------------------------
--
-- @function [parent=#Text] createInstance
-- @param self
-- @return Ref#Ref ret (return value: cc.Ref)
--------------------------------
--
-- @function [parent=#Text] getVirtualRenderer
-- @param self
-- @return Node#Node ret (return value: cc.Node)
--------------------------------
-- Returns the "class name" of widget.
-- @function [parent=#Text] getDescription
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
--
-- @function [parent=#Text] getVirtualRendererSize
-- @param self
-- @return size_table#size_table ret (return value: size_table)
--------------------------------
-- Default constructor.<br>
-- js ctor<br>
-- lua new
-- @function [parent=#Text] Text
-- @param self
-- @return Text#Text self (return value: ccui.Text)
return nil
| mit |
Vadavim/jsr-darkstar | scripts/globals/effects/aftermath.lua | 30 | 2749 | -----------------------------------
--
-- EFFECT_AFTERMATH
--
-----------------------------------
require("scripts/globals/status");
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
local power = effect:getPower();
if (effect:getSubPower() == 1) then
target:addMod(MOD_SUBTLE_BLOW,power);
elseif (effect:getSubPower() == 2) then
target:addMod(MOD_CRITHITRATE,power)
elseif (effect:getSubPower() == 3) then
target:addMod(MOD_REGEN,power)
elseif (effect:getSubPower() == 4) then
target:addMod(MOD_ATTP,power)
elseif (effect:getSubPower() == 5) then
target:addMod(MOD_DMG,power)
elseif (effect:getSubPower() == 6) then
target:addMod(MOD_HASTE_GEAR,power)
elseif (effect:getSubPower() == 7) then
target:addMod(MOD_SPIKES,5)
target:addMod(MOD_SPIKES_DMG,power)
elseif (effect:getSubPower() == 8) then
target:addMod(MOD_STORETP,power)
elseif (effect:getSubPower() == 9) then
target:addMod(MOD_ACC,power)
elseif (effect:getSubPower() == 10) then
target:addMod(MOD_REFRESH,power)
elseif (effect:getSubPower() == 11) then
target:addMod(MOD_ENMITY,power)
elseif (effect:getSubPower() == 12) then
target:addMod(MOD_RACC,power)
end
end;
-----------------------------------
-- onEffectTick Action
-----------------------------------
function onEffectTick(target,effect)
end;
-----------------------------------
-- onEffectLose Action
-----------------------------------
function onEffectLose(target,effect)
local power = effect:getPower();
if (effect:getSubPower() == 1) then
target:delMod(MOD_SUBTLE_BLOW,power);
elseif (effect:getSubPower() == 2) then
target:delMod(MOD_CRITHITRATE,power)
elseif (effect:getSubPower() == 3) then
target:delMod(MOD_REGEN,power)
elseif (effect:getSubPower() == 4) then
target:delMod(MOD_ATTP,power)
elseif (effect:getSubPower() == 5) then
target:delMod(MOD_DMG,power)
elseif (effect:getSubPower() == 6) then
target:delMod(MOD_HASTE_GEAR,power)
elseif (effect:getSubPower() == 7) then
target:delMod(MOD_SPIKES,5);
target:delMod(MOD_SPIKES_DMG,power)
elseif (effect:getSubPower() == 8) then
target:delMod(MOD_STORETP,power)
elseif (effect:getSubPower() == 9) then
target:delMod(MOD_ACC,power)
elseif (effect:getSubPower() == 10) then
target:delMod(MOD_REFRESH,power)
elseif (effect:getSubPower() == 11) then
target:delMod(MOD_ENMITY,power)
elseif (effect:getSubPower() == 12) then
target:delMod(MOD_RACC,power)
end
end; | gpl-3.0 |
zynjec/darkstar | scripts/zones/Mount_Zhayolm/mobs/Sarameya.lua | 11 | 2571 | -----------------------------------
-- Area: Mount Zhayolm
-- NM: Sarameya
-- !pos 322 -14 -581 61
-- Spawned with Buffalo Corpse: !additem 2583
-- Wiki: http://ffxiclopedia.wikia.com/wiki/Sarameya
-- TODO: PostAIRewrite: Code the Howl effect and gradual resists.
-----------------------------------
mixins = {require("scripts/mixins/rage")}
require("scripts/globals/status")
require("scripts/globals/magic")
require("scripts/globals/msg")
-----------------------------------
function onMobInitialize(mob)
mob:setMobMod(dsp.mobMod.GA_CHANCE, 50)
mob:setMobMod(dsp.mobMod.ADD_EFFECT, 1)
end
function onMobSpawn(mob)
mob:addMod(dsp.mod.MEVA, 95)
mob:addMod(dsp.mod.MDEF, 30)
mob:addMod(dsp.mod.SILENCERES, 20)
mob:addMod(dsp.mod.GRAVITYRES, 20)
mob:addMod(dsp.mod.LULLABYRES, 30)
mob:setLocalVar("[rage]timer", 3600) -- 60 minutes
end
function onMobRoam(mob)
end
function onMobFight(mob, target)
local hpp = mob:getHPP()
local useChainspell = false
if hpp < 90 and mob:getLocalVar("chainspell89") == 0 then
mob:setLocalVar("chainspell89", 1)
useChainspell = true
elseif hpp < 70 and mob:getLocalVar("chainspell69") == 0 then
mob:setLocalVar("chainspell69", 1)
useChainspell = true
elseif hpp < 50 and mob:getLocalVar("chainspell49") == 0 then
mob:setLocalVar("chainspell49", 1)
useChainspell = true
elseif hpp < 30 and mob:getLocalVar("chainspell29") == 0 then
mob:setLocalVar("chainspell29", 1)
useChainspell = true
elseif hpp < 10 and mob:getLocalVar("chainspell9") == 0 then
mob:setLocalVar("chainspell9", 1)
useChainspell = true
end
if useChainspell then
mob:useMobAbility(692) -- Chainspell
mob:setMobMod(dsp.mobMod.GA_CHANCE, 100)
end
-- Spams TP moves and -ga spells
if mob:hasStatusEffect(dsp.effect.CHAINSPELL) then
mob:setTP(2000)
else
if mob:getMobMod(dsp.mobMod.GA_CHANCE) == 100 then
mob:setMobMod(dsp.mobMod.GA_CHANCE, 50)
end
end
-- Regens 1% of his HP a tick with Blaze Spikes on
if mob:hasStatusEffect(dsp.effect.BLAZE_SPIKES) then
mob:setMod(dsp.mod.REGEN, math.floor(mob:getMaxHP()/100))
else
if mob:getMod(dsp.mod.REGEN) > 0 then
mob:setMod(dsp.mod.REGEN, 0)
end
end
end
function onAdditionalEffect(mob, target, damage)
return dsp.mob.onAddEffect(mob, target, damage, dsp.mob.ae.POISON, {chance = 40, power = 50})
end
function onMobDeath(mob, player, isKiller)
end
| gpl-3.0 |
zynjec/darkstar | scripts/zones/Aht_Urhgan_Whitegate/npcs/Hadayah.lua | 12 | 1163 | -----------------------------------
-- Area: Aht Urhgan Whitegate
-- NPC: Hadayah
-- Type: Alchemy Image Support
-- !pos -10.470 -6.25 -141.700 241
-----------------------------------
local ID = require("scripts/zones/Aht_Urhgan_Whitegate/IDs")
require("scripts/globals/status")
require("scripts/globals/crafting")
-----------------------------------
function onTrade(player,npc,trade)
end
function onTrigger(player,npc)
local guildMember = isGuildMember(player,1)
local SkillLevel = player:getSkillLevel(dsp.skill.ALCHEMY)
if guildMember == 1 then
if player:hasStatusEffect(dsp.effect.ALCHEMY_IMAGERY) == false then
player:startEvent(638,4,SkillLevel,1,511,187,0,7,2184)
else
player:startEvent(638,4,SkillLevel,1,511,5662,6955,7,2184)
end
else
player:startEvent(638,0,0,0,0,0,0,7,0) -- Standard Dialogue
end
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
if csid == 638 and option == 1 then
player:messageSpecial(ID.text.IMAGE_SUPPORT,0,7,1)
player:addStatusEffect(dsp.effect.ALCHEMY_IMAGERY,1,0,120)
end
end | gpl-3.0 |
syntafin/prosody-modules | mod_limit_auth/mod_limit_auth.lua | 31 | 1377 | -- mod_limit_auth
local st = require"util.stanza";
local new_throttle = require "util.throttle".create;
local period = math.max(module:get_option_number(module.name.."_period", 30), 0);
local max = math.max(module:get_option_number(module.name.."_max", 5), 1);
local tarpit_delay = module:get_option_number(module.name.."_tarpit_delay", nil);
if tarpit_delay then
local waiter = require "util.async".waiter;
local delay = tarpit_delay;
function tarpit_delay()
local wait, done = waiter();
module:add_timer(delay, done);
wait();
end
else
function tarpit_delay() end
end
local throttles = module:shared"throttles";
local reply = st.stanza("failure", { xmlns = "urn:ietf:params:xml:ns:xmpp-sasl" }):tag("temporary-auth-failure");
local function get_throttle(ip)
local throttle = throttles[ip];
if not throttle then
throttle = new_throttle(max, period);
throttles[ip] = throttle;
end
return throttle;
end
module:hook("stanza/urn:ietf:params:xml:ns:xmpp-sasl:auth", function (event)
local origin = event.origin;
if not get_throttle(origin.ip):peek(1) then
origin.log("warn", "Too many authentication attepmts for ip %s", origin.ip);
tarpit_delay();
origin.send(reply);
return true;
end
end, 10);
module:hook("authentication-failure", function (event)
get_throttle(event.session.ip):poll(1);
end);
-- TODO remove old throttles after some time
| mit |
Vadavim/jsr-darkstar | scripts/zones/Abyssea-Konschtat/Zone.lua | 33 | 1801 | -----------------------------------
--
-- Zone: Abyssea - Konschtat
--
-----------------------------------
-- Research
-- EventID 0x0400-0x0405 aura of boundless rage
-- EventID 0x0800-0x0883 The treasure chest will disappear is 180 seconds menu.
-- EventID 0x0884 Teleport?
-- EventID 0x0885 DEBUG Menu
-----------------------------------
package.loaded["scripts/zones/Abyssea-Konschtat/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/quests");
require("scripts/zones/Abyssea-Konschtat/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
-- Note: in retail even tractor lands you back at searing ward, will handle later.
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
player:setPos(153,-72,-840,140);
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 |
fraxken/Craftstudio-united | constructor.lua | 1 | 6564 | -- > New global variable for mt
TASK = false
SceneConstructor = false
UI = false
Core = false
FrameworkLoad = false
-- > Declare United global variable
United = {}
setmetatable(United,United)
United.ActiveModule = {}
-- > United Error core
United.Err = {}
do
local Err = United.Err
-- > Error metamethode
Err.__index = Err
Err.__call = function(mt,error,exit)
mt:Call(error,(exit or false))
end
Err.__tostring = function()
return "A error is print"
end
-- > Environnement Err
Err.OccuredError = 0
Err.AssetError = 0
setmetatable(Err,Err)
function Err:Call(error,exit)
Err.OccuredError = Err.OccuredError + 1
do local echo = print
echo(tostring(error))
end
if exit then CS.Exit() end
return false
end
end
-- > United Constructor
United.Constructor = {}
do
local Constructor = United.Constructor
-- > Constructor metamethode
Constructor.__index = Constructor
Constructor.__call = function(mt,constructorTable)
mt:LoadClass(constructorTable)
end
setmetatable(Constructor,Constructor)
-- > Function LoadClass
function Constructor:LoadClass(constructorTable)
local Framework = United
for i = 1 ,#constructorTable do
local mt = Framework[constructorTable[i]]
if mt ~= nil then
mt.Core()
Framework.ActiveModule[ #Framework.ActiveModule + 1 ] = constructorTable[i]
else
United.Err("Invalid core name : "..v.." Constructor dont find the core function",true)
end
end
self:BuildClass()
-- > Define new metamethode for United meta.
United.__call = function(mt)
mt.Core()
end
United.__index = United.Core
United.__newindex = United.Core
United.Constructor = nil
FrameworkLoad = true
collectgarbage("collect")
end
-- > Function BuildClass
function Constructor:BuildClass()
local activeClass = {}
local search = pairs
for k,_ in search(United) do
if k ~= "Err" and k ~= "ActiveModule" and k ~= "Constructor" and k ~= "Core" then
for _,v in search(United.ActiveModule) do
if k == v then
activeClass[#activeClass + 1] = v
end
end
end
end
do
local inactiveClass = {}
-- > Detect inactive class
for k,_ in search(United) do
if k ~= "Err" and k ~= "ActiveModule" and k ~= "Constructor" and k ~= "Core" then
inactiveClass[k] = false
for _,v in search(activeClass) do
if k == v then
inactiveClass[k] = true
end
end
end
end
-- > Destroy inactive class
for k,v in search(inactiveClass) do
if not v then
United[k] = nil
end
end
end
end
end
-- > United Core for gameScript
United.Core = {}
do
local Core = United.Core
-- > Mouse
Core.Mouse = {}
Core.Mouse.ToUnit = {x=0,y=0}
Core.Mouse.Focus = {x=0,y=0}
Core.Mouse.In = true
Core.Mouse.Move = true
-- > Other
Core.Index = nil
Core.TempMemory = {}
setmetatable(Core,Core)
-- > Vider la mémoire de variable global pre-instancier + Variable non core.
function Core:Out_Memory()
self.TempMemory = {}
if SceneConstructor ~= nil then
SceneConstructor:Out_Memory()
end
end
function Core:DestroyObject(gameObject)
local Craft = CS
Craft.Destroy( gameObject )
if SceneConstructor ~= nil then
SceneConstructor:ObjectDestroy(gameObject)
end
end
function Core:Update()
-- > Update Mouse value
do
local MousePos = CS.Input.GetMousePosition()
local MouseDelta = CS.Input.GetMouseDelta()
local ScreenSize = UI.Screen.Size or {CS.Screen.GetSize().x,CS.Screen.GetSize().y}
if MouseDelta.x ~= 0 or MouseDelta.y ~= 0 and self.Mouse.In then
self.Mouse.Move = true
else
self.Mouse.Move = false
end
if MousePos.x >= 0 and MousePos.x <= ScreenSize.x and MousePos.y >= 0 and MousePos.y <= ScreenSize.y then
if not self.Mouse.In then
self.Mouse.In = true
end
do
local PTU = UI.Screen.PTU or 16
local ScreenCenter = UI.Screen.Center or {x=0,y=0}
self.Mouse.ToUnit.x = MousePos.x * PTU
self.Mouse.ToUnit.y = MousePos.y * PTU
self.Mouse.Focus.x = self.Mouse.ToUnit.x - ScreenCenter.x
self.Mouse.Focus.y = -self.Mouse.ToUnit.y + ScreenCenter.y
end
else
if self.Mouse.In then
self.Mouse.In = false
end
end
end
local UnitedActiveModule = United.ActiveModule
local search = pairs
-- > While for update active module.
for _,v in search(UnitedActiveModule) do
if v == "UserInterface" then
UI:Update()
elseif v == "TaskCron" then
TASK:Update()
end
end
end
-- > Core metamethode
Core.__index = function(mt,k)
if FrameworkLoad then
local search = pairs
for a,b in search(mt.TempMemory) do
if a == k then
return b
end
end
end
rawget(mt,k)
end
Core.__call = function(mt)
mt:Update()
end
Core.__newindex = function(mt,k,v)
if FrameworkLoad then
rawset(mt.TempMemory,k,v)
print("Nouvelle variable hors Mémoire : "..tostring(k).." = "..tostring(v))
else
rawset(mt,k,v)
end
end
end
Core = United.Core
| gpl-3.0 |
AliKhodadad/wild-man | plugins/webshot.lua | 919 | 1473 | local helpers = require "OAuth.helpers"
local base = 'https://screenshotmachine.com/'
local url = base .. 'processor.php'
local function get_webshot_url(param)
local response_body = {}
local request_constructor = {
url = url,
method = "GET",
sink = ltn12.sink.table(response_body),
headers = {
referer = base,
dnt = "1",
origin = base,
["User-Agent"] = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36"
},
redirect = false
}
local arguments = {
urlparam = param,
size = "FULL"
}
request_constructor.url = url .. "?" .. helpers.url_encode_arguments(arguments)
local ok, response_code, response_headers, response_status_line = https.request(request_constructor)
if not ok or response_code ~= 200 then
return nil
end
local response = table.concat(response_body)
return string.match(response, "href='(.-)'")
end
local function run(msg, matches)
local find = get_webshot_url(matches[1])
if find then
local imgurl = base .. find
local receiver = get_receiver(msg)
send_photo_from_url(receiver, imgurl)
end
end
return {
description = "Send an screenshot of a website.",
usage = {
"!webshot [url]: Take an screenshot of the web and send it back to you."
},
patterns = {
"^!webshot (https?://[%w-_%.%?%.:/%+=&]+)$",
},
run = run
}
| gpl-2.0 |
Ali-2h/iranibot | plugins/webshot.lua | 919 | 1473 | local helpers = require "OAuth.helpers"
local base = 'https://screenshotmachine.com/'
local url = base .. 'processor.php'
local function get_webshot_url(param)
local response_body = {}
local request_constructor = {
url = url,
method = "GET",
sink = ltn12.sink.table(response_body),
headers = {
referer = base,
dnt = "1",
origin = base,
["User-Agent"] = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36"
},
redirect = false
}
local arguments = {
urlparam = param,
size = "FULL"
}
request_constructor.url = url .. "?" .. helpers.url_encode_arguments(arguments)
local ok, response_code, response_headers, response_status_line = https.request(request_constructor)
if not ok or response_code ~= 200 then
return nil
end
local response = table.concat(response_body)
return string.match(response, "href='(.-)'")
end
local function run(msg, matches)
local find = get_webshot_url(matches[1])
if find then
local imgurl = base .. find
local receiver = get_receiver(msg)
send_photo_from_url(receiver, imgurl)
end
end
return {
description = "Send an screenshot of a website.",
usage = {
"!webshot [url]: Take an screenshot of the web and send it back to you."
},
patterns = {
"^!webshot (https?://[%w-_%.%?%.:/%+=&]+)$",
},
run = run
}
| gpl-2.0 |
gmorishere/lsd | plugins/webshot.lua | 919 | 1473 | local helpers = require "OAuth.helpers"
local base = 'https://screenshotmachine.com/'
local url = base .. 'processor.php'
local function get_webshot_url(param)
local response_body = {}
local request_constructor = {
url = url,
method = "GET",
sink = ltn12.sink.table(response_body),
headers = {
referer = base,
dnt = "1",
origin = base,
["User-Agent"] = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36"
},
redirect = false
}
local arguments = {
urlparam = param,
size = "FULL"
}
request_constructor.url = url .. "?" .. helpers.url_encode_arguments(arguments)
local ok, response_code, response_headers, response_status_line = https.request(request_constructor)
if not ok or response_code ~= 200 then
return nil
end
local response = table.concat(response_body)
return string.match(response, "href='(.-)'")
end
local function run(msg, matches)
local find = get_webshot_url(matches[1])
if find then
local imgurl = base .. find
local receiver = get_receiver(msg)
send_photo_from_url(receiver, imgurl)
end
end
return {
description = "Send an screenshot of a website.",
usage = {
"!webshot [url]: Take an screenshot of the web and send it back to you."
},
patterns = {
"^!webshot (https?://[%w-_%.%?%.:/%+=&]+)$",
},
run = run
}
| gpl-2.0 |
shayanchabok555/shayan007 | plugins/webshot.lua | 919 | 1473 | local helpers = require "OAuth.helpers"
local base = 'https://screenshotmachine.com/'
local url = base .. 'processor.php'
local function get_webshot_url(param)
local response_body = {}
local request_constructor = {
url = url,
method = "GET",
sink = ltn12.sink.table(response_body),
headers = {
referer = base,
dnt = "1",
origin = base,
["User-Agent"] = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36"
},
redirect = false
}
local arguments = {
urlparam = param,
size = "FULL"
}
request_constructor.url = url .. "?" .. helpers.url_encode_arguments(arguments)
local ok, response_code, response_headers, response_status_line = https.request(request_constructor)
if not ok or response_code ~= 200 then
return nil
end
local response = table.concat(response_body)
return string.match(response, "href='(.-)'")
end
local function run(msg, matches)
local find = get_webshot_url(matches[1])
if find then
local imgurl = base .. find
local receiver = get_receiver(msg)
send_photo_from_url(receiver, imgurl)
end
end
return {
description = "Send an screenshot of a website.",
usage = {
"!webshot [url]: Take an screenshot of the web and send it back to you."
},
patterns = {
"^!webshot (https?://[%w-_%.%?%.:/%+=&]+)$",
},
run = run
}
| gpl-2.0 |
zynjec/darkstar | scripts/zones/Kazham/npcs/Popopp.lua | 9 | 2740 | -----------------------------------
-- Area: Kazham
-- NPC: Popopp
-- Standard Info NPC
-----------------------------------
function onTrade(player,npc,trade)
-- 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
local OpoOpoAndIStatus = player:getQuestStatus(OUTLANDS, dsp.quest.id.outlands.THE_OPO_OPO_AND_I);
local progress = player:getCharVar("OPO_OPO_PROGRESS");
local failed = player:getCharVar("OPO_OPO_FAILED");
local goodtrade = trade:hasItemQty(1158,1);
local badtrade = (trade:hasItemQty(483,1) or trade:hasItemQty(22,1) or trade:hasItemQty(1008,1) or trade:hasItemQty(1157,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 == 4 or failed == 5 then
if goodtrade then
player:startEvent(223);
elseif badtrade then
player:startEvent(233);
end
end
end
end;
function onTrigger(player,npc)
local OpoOpoAndIStatus = player:getQuestStatus(OUTLANDS, dsp.quest.id.outlands.THE_OPO_OPO_AND_I);
local progress = player:getCharVar("OPO_OPO_PROGRESS");
local failed = player:getCharVar("OPO_OPO_FAILED");
local retry = player:getCharVar("OPO_OPO_RETRY");
if (OpoOpoAndIStatus == QUEST_ACCEPTED) then
if retry >= 1 then -- has failed on future npc so disregard previous successful trade
player:startEvent(201);
elseif (progress == 4 or failed == 5) then
player:startEvent(210); -- asking for wandering bulb
elseif (progress >= 5 or failed >= 6) then
player:startEvent(246); -- happy with wandering bulb
end
else
player:startEvent(201);
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 223) then -- correct trade, onto next opo
if player:getCharVar("OPO_OPO_PROGRESS") == 4 then
player:tradeComplete();
player:setCharVar("OPO_OPO_PROGRESS",5);
player:setCharVar("OPO_OPO_FAILED",0);
else
player:setCharVar("OPO_OPO_FAILED",6);
end
elseif (csid == 233) then -- wrong trade, restart at first opo
player:setCharVar("OPO_OPO_FAILED",1);
player:setCharVar("OPO_OPO_RETRY",5);
end
end;
| gpl-3.0 |
Colettechan/darkstar | scripts/zones/Sea_Serpent_Grotto/mobs/Devil_Manta.lua | 4 | 1213 | -----------------------------------
-- Area: Sea Serpent Grotto
-- MOB: Devil Manta
-- Note: Place holder Charybdis
-----------------------------------
require("scripts/globals/groundsofvalor");
require("scripts/zones/Sea_Serpent_Grotto/MobIDs");
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
checkGoVregime(player,mob,810,2);
local mobID = mob:getID();
if (Charybdis_PH[mobID] ~= nil) then
local Charybdis_ToD = GetServerVariable("[POP]Charybdis");
if (Charybdis_ToD <= os.time(t) and GetMobAction(Charybdis) == 0 and math.random((1),(10)) == 10) then
UpdateNMSpawnPoint(Charybdis);
GetMobByID(Charybdis):setRespawnTime(GetMobRespawnTime(mobID));
SetServerVariable("[PH]Charybdis", mobID);
DeterMob(mobID, true);
else
local r = math.random(1,2);
if (mobID ~= Charybdis_PH[r]) then -- what is this?
DeterMob(mobID, true);
DeterMob(Charybdis_PH[r], false);
GetMobByID(Charybdis_PH[r]):setRespawnTime(GetMobRespawnTime(mobID));
end
end
end
end;
| gpl-3.0 |
zynjec/darkstar | scripts/globals/weaponskills/sunburst.lua | 10 | 1319 | -----------------------------------
-- Sunburst
-- Staff weapon skill
-- Skill Level: 150
-- Deals light or darkness elemental damage. Damage varies with TP.
-- Aligned with the Shadow Gorget & Aqua Gorget.
-- Aligned with the Shadow Belt & Aqua Belt.
-- Element: Light/Dark
-- Modifiers: : STR:40% MND:40%
-- 100%TP 200%TP 300%TP
-- 1.00 2.50 4.00
-----------------------------------
require("scripts/globals/magic")
require("scripts/globals/status")
require("scripts/globals/settings")
require("scripts/globals/weaponskills")
-----------------------------------
function onUseWeaponSkill(player, target, wsID, tp, primary, action, taChar)
local params = {}
params.ftp100 = 1 params.ftp200 = 2.5 params.ftp300 = 4
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.ele = dsp.magic.ele.DARK params.ele = dsp.magic.ele.LIGHT
params.skill = dsp.skill.STAFF
params.includemab = true
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.str_wsc = 0.4 params.mnd_wsc = 0.4
end
local damage, criticalHit, tpHits, extraHits = doMagicWeaponskill(player, target, wsID, params, tp, action, primary)
return tpHits, extraHits, criticalHit, damage
end
| gpl-3.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.