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
AlexandreCA/update
scripts/zones/Cloister_of_Gales/bcnms/sugar-coated_directive.lua
19
1709
---------------------------------------- -- Area: Cloister of Gales -- BCNM: Sugar Coated Directive (ASA-4) ---------------------------------------- package.loaded["scripts/zones/Cloister_of_Gales/TextIDs"] = nil; ---------------------------------------- require("scripts/globals/keyitems"); require("scripts/globals/quests"); require("scripts/zones/Cloister_of_Gales/TextIDs"); ---------------------------------------- -- After registering the BCNM via bcnmRegister(bcnmid) function onBcnmRegister(player,instance) end; -- Physically entering the BCNM via bcnmEnter(bcnmid) function onBcnmEnter(player,instance) end; -- Leaving the BCNM by every mean possible, given by the LeaveCode -- 1=Select Exit on circle -- 2=Winning the BC -- 3=Disconnected or warped out -- 4=Losing the BC -- via bcnmLeave(1) or bcnmLeave(2). LeaveCodes 3 and 4 are called -- from the core when a player disconnects or the time limit is up, etc function onBcnmLeave(player,instance,leavecode) -- print("leave code "..leavecode); if (leavecode == 2) then -- play end CS. Need time and battle id for record keeping + storage if (player:hasCompletedMission(ASA,SUGAR_COATED_DIRECTIVE)) then player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,4,1); else player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,4,0); end elseif (leavecode == 4) then player:startEvent(0x7d02); end end; function onEventUpdate(player,csid,option) -- print("bc update csid "..csid.." and option "..option); end; function onEventFinish(player,csid,option) -- print("bc finish csid "..csid.." and option "..option); if (csid == 0x7d01) then player:addExp(400); player:setVar("ASA4_Emerald","1"); end end;
gpl-3.0
incinirate/Riko4
scripts/home/demos/circ.lua
1
1892
--[[ Random fun little thing ... I don't even know Inspired by @egordorichev ]] local running = true gpu.clear() local w, h = gpu.width, gpu.height local gpp = dofile("/lib/gpp.lua") local sin = math.sin local timer = 0 local vel = 0 local off = 0 local loff = 0 local function update(dt) timer = timer + dt vel = 10 * sin(2 * timer) loff = off off = off + vel * dt end local function round(n) if n % 1 >= 0.5 then return n % 1 + 1 else return n % 1 end end local function cfunc(i, j) if round(i / (math.pi / 2)) % 2 == 0 then return 16 else if j % 2 == 0 then return 9 else return 8 end end end local function draw() for i = 1, 1499 do local x, y = math.random(1, w), math.random(1, h) gpu.drawPixel(x - 1, y, 1) gpu.drawPixel(x + 1, y, 1) gpu.drawPixel(x, y - 1, 1) gpu.drawPixel(x, y + 1, 1) end -- gpu.clear() for j = 1, 7 do for i = 0, 2 * math.pi, math.pi / 4 do local r = (sin((timer + j / 3) * 1.5) + 1.25) * (35 + j * 10) -- local cloff = loff * (j % 2 == 0 and 1 or -1) -- local coff = off * (j % 2 == 0 and 1 or -1) for k = math.min(off, loff), math.max(off, loff), 0.05 do local coff = k * (j % 2 == 0 and 1 or -1) gpp.fillEllipse(w / 2 + math.cos(coff + i) * r, h / 2 + math.sin(coff + i) * r, 10, 10, cfunc(i, j)) --math.floor((i + j) * 12) % 15 + 2) end end end gpu.swap() end local function event(e, ...) if e == "key" then local k = ... if k == "escape" then running = false end end end local eq = {} local last = os.clock() while running do while true do local a = {coroutine.yield()} if not a[1] then break end table.insert(eq, a) end while #eq > 0 do event(unpack(table.remove(eq, 1))) end update(os.clock() - last) last = os.clock() draw() end
mit
heptal/hammerspoon
extensions/osascript/init.lua
9
2774
--- === hs.osascript === --- --- Execute Open Scripting Architecture (OSA) code - AppleScript and JavaScript --- local module = require("hs.osascript.internal") -- private variables and methods ----------------------------------------- local processResults = function(ok, object, rawDescriptor) local descriptor if not ok then rawDescriptor = rawDescriptor:match("^{\n(.*)}$") descriptor = {} local lines = hs.fnutils.split(rawDescriptor, ";\n") lines = hs.fnutils.ifilter(lines, function(line) return line ~= "" end) for _, line in ipairs(lines) do local k, v = line:match('^%s*(%w+)%s=%s(.*)$') v = v:match('^"(.*)"$') or v:match("^'(.*)'$") or v descriptor[k] = tonumber(v) or v end else descriptor = rawDescriptor:match("^<NSAppleEventDescriptor: (.*)>$") end return ok, object, descriptor end -- Public interface ------------------------------------------------------ --- hs.osascript.applescript(source) -> bool, object, descriptor --- Function --- Runs AppleScript code --- --- Parameters: --- * source - A string containing some AppleScript code to execute --- --- Returns: --- * A boolean value indicating whether the code succeeded or not --- * An object containing the parsed output that can be any type, or nil if unsuccessful --- * If the code succeeded, the raw output of the code string. If the code failed, a table containing an error dictionary --- --- Notes: --- * Use hs.osascript._osascript(source, "AppleScript") if you always want the result as a string, even when a failure occurs module.applescript = function(source) local ok, object, descriptor = module._osascript(source, "AppleScript") return processResults(ok, object, descriptor) end --- hs.osascript.javascript(source) -> bool, object, descriptor --- Function --- Runs JavaScript code --- --- Parameters: --- * source - A string containing some JavaScript code to execute --- --- Returns: --- * A boolean value indicating whether the code succeeded or not --- * An object containing the parsed output that can be any type, or nil if unsuccessful --- * If the code succeeded, the raw output of the code string. If the code failed, a table containing an error dictionary --- --- Notes: --- * Use hs.osascript._osascript(source, "JavaScript") if you always want the result as a string, even when a failure occurs module.javascript = function(source) local ok, object, descriptor = module._osascript(source, "JavaScript") return processResults(ok, object, descriptor) end setmetatable(module, { __call = function(_, ...) return module.applescript(...) end }) -- Return Module Object -------------------------------------------------- return module
mit
AlexandreCA/darkstar
scripts/globals/spells/dragonfoe_mambo.lua
27
1611
----------------------------------------- -- Spell: Dragonfoe Mambo -- Grants evasion bonus to all members. ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnSpellCast ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) local sLvl = caster:getSkillLevel(SKILL_SNG); -- Gets skill level of Singing local iLvl = caster:getWeaponSkillLevel(SLOT_RANGED); -- Since nobody knows the evasion values for mambo, I'll just make shit up! (aka - same as madrigal) local power = 9; if (sLvl+iLvl > 130) then power = power + math.floor((sLvl+iLvl-130) / 18); end if (power >= 30) then power = 30; end local iBoost = caster:getMod(MOD_MAMBO_EFFECT) + caster:getMod(MOD_ALL_SONGS_EFFECT); if (iBoost > 0) then power = power + 1 + (iBoost-1)*4; end if (caster:hasStatusEffect(EFFECT_SOUL_VOICE)) then power = power * 2; elseif (caster:hasStatusEffect(EFFECT_MARCATO)) then power = power * 1.5; end caster:delStatusEffect(EFFECT_MARCATO); local duration = 120; duration = duration * ((iBoost * 0.1) + (caster:getMod(MOD_SONG_DURATION_BONUS)/100) + 1); if (caster:hasStatusEffect(EFFECT_TROUBADOUR)) then duration = duration * 2; end if not (target:addBardSong(caster,EFFECT_MAMBO,power,0,duration,caster:getID(), 0, 2)) then spell:setMsg(75); end return EFFECT_MAMBO; end;
gpl-3.0
AlexandreCA/update
scripts/zones/Castle_Zvahl_Keep_[S]/Zone.lua
28
1341
----------------------------------- -- -- Zone: Castle_Zvahl_Keep_[S] (155) -- ----------------------------------- package.loaded["scripts/zones/Castle_Zvahl_Keep_[S]/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/zones/Castle_Zvahl_Keep_[S]/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) local cs = -1; if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then player:setPos(-555.996,-71.691,60,255); 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
AlexandreCA/update
scripts/globals/weaponskills/blade_chi.lua
30
1380
----------------------------------- -- Blade Chi -- Katana weapon skill -- Skill Level: 150 -- Delivers a two-hit earth elemental attack. Damage varies with TP. -- Aligned with the Thunder Gorget & Light Gorget. -- Aligned with the Thunder Belt & Light Belt. -- Element: Earth -- Modifiers: STR:30% ; INT:30% -- 100%TP 200%TP 300%TP -- 1.00 1.00 1.00 ----------------------------------- require("scripts/globals/status"); require("scripts/globals/settings"); require("scripts/globals/weaponskills"); ----------------------------------- function onUseWeaponSkill(player, target, wsID) local params = {}; params.numHits = 2; params.ftp100 = 1; params.ftp200 = 1; params.ftp300 = 1; params.str_wsc = 0.3; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.3; params.mnd_wsc = 0.0; params.chr_wsc = 0.0; params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0; params.canCrit = false; params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0; params.atkmulti = 1; if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then params.ftp100 = 0.5; params.ftp200 = 0.75; params.ftp300 = 1; end local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, params); damage = damage * WEAPON_SKILL_POWER return tpHits, extraHits, criticalHit, damage; end
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Jugner_Forest_[S]/Zone.lua
12
1790
----------------------------------- -- -- Zone: Jugner_Forest_[S] (82) -- ----------------------------------- package.loaded["scripts/zones/Jugner_Forest_[S]/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/zones/Jugner_Forest_[S]/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) local cs = -1; if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then player:setPos(621.865,-6.665,300.264,149); end if (player:getQuestStatus(CRYSTAL_WAR,CLAWS_OF_THE_GRIFFON) == QUEST_ACCEPTED and player:getVar("ClawsOfGriffonProg") == 0) then cs = 0x00C8; elseif (player:getVar("roadToDivadomCS") == 1) then cs = 0x0069; end; return cs; end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x00C8) then player:setVar("ClawsOfGriffonProg",1); elseif (csid == 0x0069 ) then player:setVar("roadToDivadomCS", 2); end; end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Bastok_Mines/npcs/HomePoint#2.lua
27
1311
----------------------------------- -- Area: Bastok Mines -- NPC: HomePoint#2 -- @pos 118 1 -58 234 ----------------------------------- package.loaded["scripts/zones/Bastok_Mines/TextIDs"] = nil; package.loaded["scripts/globals/homepoint"] = nil; require("scripts/globals/settings"); require("scripts/zones/Bastok_Mines/TextIDs"); require("scripts/globals/homepoint"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) homepointMenu( player, 0x21fd, 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 == 0x21fd) then if (option == 1) then player:setHomePoint(); player:messageSpecial(HOMEPOINT_SET); else hpTeleport( player, option); end end end;
gpl-3.0
tartina/ardour
share/scripts/_channelstrip.lua
4
3883
ardour { ["type"] = "EditorAction", name = "Channel Strip Setup", license = "MIT", author = "Ardour Team", description = [[Add Compressor and EQ plugin to every selected track and if a bus name 'Reverb' exists post-fader reverb send]] } function factory (params) return function () -- helper functions function plugin_uri (proc) return proc:to_plugininsert():plugin(0):get_info().unique_id end function add_lv2_plugin (route, pluginname, position) local p = ARDOUR.LuaAPI.new_plugin (Session, pluginname, ARDOUR.PluginType.LV2, "") if not p:isnil () then route:add_processor_by_index (p, position, nil, true) end end function test_send_dest (send, route) local intsend = send:to_internalsend() if intsend:isnil () then return false end return intsend:target_route () == route end -- Test if there is a Bus named "Reverb" local reverb_bus = Session:route_by_name ("Reverb") if reverb_bus:isnil () or not reverb_bus:to_track ():isnil () then reverb_bus = nil; end -- Iterate over all selected Track/Bus -- http://manual.ardour.org/lua-scripting/class_reference/#ArdourUI:TrackSelection local sel = Editor:get_selection () for route in sel.tracks:routelist ():iter () do local have_eq = false local comp_pos = 0 local add_send = false -- skip master-bus if route:is_master() then goto next end -- iterate over all plugins on the route, -- check if a a-eq or a-comp is already present local i = 0; repeat local proc = route:nth_plugin (i) -- get Nth Ardour::Processor if (not proc:isnil()) and plugin_uri (proc) == "urn:ardour:a-eq" then have_eq = true; end if (not proc:isnil()) and (plugin_uri (proc) == "urn:ardour:a-comp" or plugin_uri (proc) == "urn:ardour:a-comp#stereo") then comp_pos = i + 1; -- remember position of compressor end i = i + 1 until proc:isnil() -- check if there is a send to the reverb bus if reverb_bus then add_send = true; i = 0; repeat local send = route:nth_send (i) -- get Nth Ardour::Send if not send:isnil() and test_send_dest (send, reverb_bus) then add_send = false end i = i + 1 until send:isnil() end -- plugins are inserted at the top (pos = 0). -- So they have to be added in reverse order: -- If the compressor is not yet present (comp_pos == 0), -- first add the EQ, and then the compressor before the EQ. -- Otherwise add the EQ after the compressor. if not have_eq then add_lv2_plugin (route, "urn:ardour:a-eq", comp_pos) end if comp_pos == 0 then if route:n_inputs ():n_audio () == 2 then add_lv2_plugin (route, "urn:ardour:a-comp#stereo", 0) else add_lv2_plugin (route, "urn:ardour:a-comp", 0) end end --add send to reverb bus, post-fader, just before the track's mains output. if add_send then Session:add_internal_send (reverb_bus, route:main_outs (), route) end ::next:: end end end function icon (params) return function (ctx, width, height, fg) function rnd (x) return math.floor (x + 0.5) end local wc = rnd (width * 0.5) - 0.5 local wl = wc - math.floor (width * .25) local wr = wc + math.floor (width * .25) local h0 = height * 0.2 local h1 = height * 0.8 local fw = math.floor (width * .1) local fl = rnd (height * .35) - 1 local fc = rnd (height * .65) - 1 local fr = rnd (height * .45) - 1 ctx:set_source_rgba (ARDOUR.LuaAPI.color_to_rgba (fg)) ctx:set_line_width (1) ctx:move_to (wl, h0) ctx:line_to (wl, h1) ctx:move_to (wc, h0) ctx:line_to (wc, h1) ctx:move_to (wr, h0) ctx:line_to (wr, h1) ctx:stroke () ctx:set_line_width (2) ctx:move_to (wl - fw, fl) ctx:line_to (wl + fw, fl) ctx:move_to (wc - fw, fc) ctx:line_to (wc + fw, fc) ctx:move_to (wr - fw, fr) ctx:line_to (wr + fw, fr) ctx:stroke () end end
gpl-2.0
AlexandreCA/darkstar
scripts/zones/Northern_San_dOria/npcs/Charmealaut.lua
13
1060
----------------------------------- -- Area: Northern San d'Oria -- NPC: Charmealaut -- Type: Merchant -- @zone: 231 -- @pos 0.000 -0.501 29.303 -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x0300); 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
AlexandreCA/update
scripts/zones/Southern_San_dOria_[S]/Zone.lua
12
2469
----------------------------------- -- -- Zone: Southern_San_dOria_[S] (80) -- ----------------------------------- package.loaded["scripts/zones/Southern_San_dOria_[S]/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/zones/Southern_San_dOria_[S]/TextIDs"); require("scripts/globals/quests"); require("scripts/globals/missions"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) local cs = -1; if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then player:setPos(103.978,-1,-47.951,158); end if (prevZone == 81) then if (player:getQuestStatus(CRYSTAL_WAR, KNOT_QUITE_THERE) == QUEST_ACCEPTED and player:getVar("KnotQuiteThere") == 2) then cs = 0x003E; elseif (player:getQuestStatus(CRYSTAL_WAR, DOWNWARD_HELIX) == QUEST_ACCEPTED and player:getVar("DownwardHelix") == 0) then cs = 0x0041; elseif (player:getCurrentMission(WOTG) == CAIT_SITH and (player:getQuestStatus(CRYSTAL_WAR, WRATH_OF_THE_GRIFFON) == QUEST_COMPLETED or player:getQuestStatus(CRYSTAL_WAR, A_MANIFEST_PROBLEM) == QUEST_COMPLETED or player:getQuestStatus(CRYSTAL_WAR, BURDEN_OF_SUSPICION) == QUEST_COMPLETED)) then cs = 0x0043; end end return cs; end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x003E) then player:setVar("KnotQuiteThere",3); elseif (csid == 0x0041) then player:setVar("DownwardHelix",1); elseif (csid == 0x0043) then player:completeMission(WOTG, CAIT_SITH); player:addMission(WOTG, THE_QUEEN_OF_THE_DANCE); end end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Selbina/npcs/Wenzel.lua
13
1052
---------------------------------- -- Area: Selbina -- NPC: Wenzel -- Type: Item Deliverer -- @pos 31.961 -14.661 57.997 248 ----------------------------------- package.loaded["scripts/zones/Selbina/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Selbina/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc, WENZEL_DELIVERY_DIALOG); player:openSendBox(); 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
niedzielski/premake-4.4-beta4
src/base/tree.lua
22
5157
-- -- tree.lua -- Functions for working with the source code tree. -- Copyright (c) 2009 Jason Perkins and the Premake project -- premake.tree = { } local tree = premake.tree -- -- Create a new tree. -- -- @param n -- The name of the tree, applied to the root node (optional). -- function premake.tree.new(n) local t = { name = n, children = { } } return t end -- -- Add a new node to the tree, or returns the current node if it already exists. -- -- @param tr -- The tree to contain the new node. -- @param p -- The path of the new node. -- @param onaddfunc -- A function to call when a new node is added to the tree. Receives the -- new node as an argument. -- @returns -- The new tree node. -- function premake.tree.add(tr, p, onaddfunc) -- Special case "." refers to the current node if p == "." then return tr end -- Look for the immediate parent for this new node, creating it if necessary. -- Recurses to create as much of the tree as necessary. local parentnode = tree.add(tr, path.getdirectory(p), onaddfunc) -- Another special case, ".." refers to the parent node and doesn't create anything local childname = path.getname(p) if childname == ".." then return parentnode end -- Create the child if necessary. If two children with the same name appear -- at the same level, make sure they have the same path to prevent conflicts -- i.e. ../Common and ../../Common can both appear at the top of the tree -- yet they have different paths (Bug #3016050) local childnode = parentnode.children[childname] if not childnode or childnode.path ~= p then childnode = tree.insert(parentnode, tree.new(childname)) childnode.path = p if onaddfunc then onaddfunc(childnode) end end return childnode end -- -- Insert one tree into another. -- -- @param parent -- The parent tree, to contain the child. -- @param child -- The child tree, to be inserted. -- function premake.tree.insert(parent, child) table.insert(parent.children, child) if child.name then parent.children[child.name] = child end child.parent = parent return child end -- -- Gets the node's relative path from it's parent. If the parent does not have -- a path set (it is the root or other container node) returns the full node path. -- -- @param node -- The node to query. -- function premake.tree.getlocalpath(node) if node.parent.path then return node.name elseif node.cfg then return node.cfg.name else return node.path end end -- -- Remove a node from a tree. -- -- @param node -- The node to remove. -- function premake.tree.remove(node) local children = node.parent.children for i = 1, #children do if children[i] == node then table.remove(children, i) end end node.children = {} end -- -- Sort the nodes of a tree in-place. -- -- @param tr -- The tree to sort. -- function premake.tree.sort(tr) tree.traverse(tr, { onnode = function(node) table.sort(node.children, function(a,b) return a.name < b.name end) end }, true) end -- -- Traverse a tree. -- -- @param t -- The tree to traverse. -- @param fn -- A collection of callback functions, which may contain any or all of the -- following entries. Entries are called in this order. -- -- onnode - called on each node encountered -- onbranchenter - called on branches, before processing children -- onbranch - called only on branch nodes -- onleaf - called only on leaf nodes -- onbranchexit - called on branches, after processing children -- -- Callbacks receive two arguments: the node being processed, and the -- current traversal depth. -- -- @param includeroot -- True to include the root node in the traversal, otherwise it will be skipped. -- @param initialdepth -- An optional starting value for the traversal depth; defaults to zero. -- function premake.tree.traverse(t, fn, includeroot, initialdepth) -- forward declare my handlers, which call each other local donode, dochildren -- process an individual node donode = function(node, fn, depth) if node.isremoved then return end if fn.onnode then fn.onnode(node, depth) end if #node.children > 0 then if fn.onbranchenter then fn.onbranchenter(node, depth) end if fn.onbranch then fn.onbranch(node, depth) end dochildren(node, fn, depth + 1) if fn.onbranchexit then fn.onbranchexit(node, depth) end else if fn.onleaf then fn.onleaf(node, depth) end end end -- this goofy iterator allows nodes to be removed during the traversal dochildren = function(parent, fn, depth) local i = 1 while i <= #parent.children do local node = parent.children[i] donode(node, fn, depth) if node == parent.children[i] then i = i + 1 end end end -- set a default initial traversal depth, if one wasn't set if not initialdepth then initialdepth = 0 end if includeroot then donode(t, fn, initialdepth) else dochildren(t, fn, initialdepth) end end
bsd-3-clause
AlexandreCA/darkstar
scripts/zones/Abyssea-Tahrongi/npcs/Cavernous_Maw.lua
29
1190
----------------------------------- -- Area: Abyssea - Tahrongi -- NPC: Cavernous Maw -- @pos -31.000, 47.000, -681.000 45 -- Teleports Players to Tahrongi Canyon ----------------------------------- package.loaded["scripts/zones/Abyssea-Tahrongi/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/zones/Abyssea-Tahrongi/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(-28,46,-680,76,117); end end;
gpl-3.0
nwf/openwrt-luci
modules/luci-base/luasrc/sys.lua
40
15171
-- Copyright 2008 Steven Barth <steven@midlink.org> -- Licensed to the public under the Apache License 2.0. local io = require "io" local os = require "os" local table = require "table" local nixio = require "nixio" local fs = require "nixio.fs" local uci = require "luci.model.uci" local luci = {} luci.util = require "luci.util" luci.ip = require "luci.ip" local tonumber, ipairs, pairs, pcall, type, next, setmetatable, require, select = tonumber, ipairs, pairs, pcall, type, next, setmetatable, require, select module "luci.sys" function call(...) return os.execute(...) / 256 end exec = luci.util.exec function mounts() local data = {} local k = {"fs", "blocks", "used", "available", "percent", "mountpoint"} local ps = luci.util.execi("df") if not ps then return else ps() end for line in ps do local row = {} local j = 1 for value in line:gmatch("[^%s]+") do row[k[j]] = value j = j + 1 end if row[k[1]] then -- this is a rather ugly workaround to cope with wrapped lines in -- the df output: -- -- /dev/scsi/host0/bus0/target0/lun0/part3 -- 114382024 93566472 15005244 86% /mnt/usb -- if not row[k[2]] then j = 2 line = ps() for value in line:gmatch("[^%s]+") do row[k[j]] = value j = j + 1 end end table.insert(data, row) end end return data end -- containing the whole environment is returned otherwise this function returns -- the corresponding string value for the given name or nil if no such variable -- exists. getenv = nixio.getenv function hostname(newname) if type(newname) == "string" and #newname > 0 then fs.writefile( "/proc/sys/kernel/hostname", newname ) return newname else return nixio.uname().nodename end end function httpget(url, stream, target) if not target then local source = stream and io.popen or luci.util.exec return source("wget -qO- '"..url:gsub("'", "").."'") else return os.execute("wget -qO '%s' '%s'" % {target:gsub("'", ""), url:gsub("'", "")}) end end function reboot() return os.execute("reboot >/dev/null 2>&1") end function syslog() return luci.util.exec("logread") end function dmesg() return luci.util.exec("dmesg") end function uniqueid(bytes) local rand = fs.readfile("/dev/urandom", bytes) return rand and nixio.bin.hexlify(rand) end function uptime() return nixio.sysinfo().uptime end net = {} -- The following fields are defined for arp entry objects: -- { "IP address", "HW address", "HW type", "Flags", "Mask", "Device" } function net.arptable(callback) local arp = (not callback) and {} or nil local e, r, v if fs.access("/proc/net/arp") then for e in io.lines("/proc/net/arp") do local r = { }, v for v in e:gmatch("%S+") do r[#r+1] = v end if r[1] ~= "IP" then local x = { ["IP address"] = r[1], ["HW type"] = r[2], ["Flags"] = r[3], ["HW address"] = r[4], ["Mask"] = r[5], ["Device"] = r[6] } if callback then callback(x) else arp = arp or { } arp[#arp+1] = x end end end end return arp end local function _nethints(what, callback) local _, k, e, mac, ip, name local cur = uci.cursor() local ifn = { } local hosts = { } local function _add(i, ...) local k = select(i, ...) if k then if not hosts[k] then hosts[k] = { } end hosts[k][1] = select(1, ...) or hosts[k][1] hosts[k][2] = select(2, ...) or hosts[k][2] hosts[k][3] = select(3, ...) or hosts[k][3] hosts[k][4] = select(4, ...) or hosts[k][4] end end if fs.access("/proc/net/arp") then for e in io.lines("/proc/net/arp") do ip, mac = e:match("^([%d%.]+)%s+%S+%s+%S+%s+([a-fA-F0-9:]+)%s+") if ip and mac then _add(what, mac:upper(), ip, nil, nil) end end end if fs.access("/etc/ethers") then for e in io.lines("/etc/ethers") do mac, ip = e:match("^([a-f0-9]%S+) (%S+)") if mac and ip then _add(what, mac:upper(), ip, nil, nil) end end end if fs.access("/var/dhcp.leases") then for e in io.lines("/var/dhcp.leases") do mac, ip, name = e:match("^%d+ (%S+) (%S+) (%S+)") if mac and ip then _add(what, mac:upper(), ip, nil, name ~= "*" and name) end end end cur:foreach("dhcp", "host", function(s) for mac in luci.util.imatch(s.mac) do _add(what, mac:upper(), s.ip, nil, s.name) end end) for _, e in ipairs(nixio.getifaddrs()) do if e.name ~= "lo" then ifn[e.name] = ifn[e.name] or { } if e.family == "packet" and e.addr and #e.addr == 17 then ifn[e.name][1] = e.addr:upper() elseif e.family == "inet" then ifn[e.name][2] = e.addr elseif e.family == "inet6" then ifn[e.name][3] = e.addr end end end for _, e in pairs(ifn) do if e[what] and (e[2] or e[3]) then _add(what, e[1], e[2], e[3], e[4]) end end for _, e in luci.util.kspairs(hosts) do callback(e[1], e[2], e[3], e[4]) end end -- Each entry contains the values in the following order: -- [ "mac", "name" ] function net.mac_hints(callback) if callback then _nethints(1, function(mac, v4, v6, name) name = name or nixio.getnameinfo(v4 or v6, nil, 100) or v4 if name and name ~= mac then callback(mac, name or nixio.getnameinfo(v4 or v6, nil, 100) or v4) end end) else local rv = { } _nethints(1, function(mac, v4, v6, name) name = name or nixio.getnameinfo(v4 or v6, nil, 100) or v4 if name and name ~= mac then rv[#rv+1] = { mac, name or nixio.getnameinfo(v4 or v6, nil, 100) or v4 } end end) return rv end end -- Each entry contains the values in the following order: -- [ "ip", "name" ] function net.ipv4_hints(callback) if callback then _nethints(2, function(mac, v4, v6, name) name = name or nixio.getnameinfo(v4, nil, 100) or mac if name and name ~= v4 then callback(v4, name) end end) else local rv = { } _nethints(2, function(mac, v4, v6, name) name = name or nixio.getnameinfo(v4, nil, 100) or mac if name and name ~= v4 then rv[#rv+1] = { v4, name } end end) return rv end end -- Each entry contains the values in the following order: -- [ "ip", "name" ] function net.ipv6_hints(callback) if callback then _nethints(3, function(mac, v4, v6, name) name = name or nixio.getnameinfo(v6, nil, 100) or mac if name and name ~= v6 then callback(v6, name) end end) else local rv = { } _nethints(3, function(mac, v4, v6, name) name = name or nixio.getnameinfo(v6, nil, 100) or mac if name and name ~= v6 then rv[#rv+1] = { v6, name } end end) return rv end end function net.conntrack(callback) local connt = {} if fs.access("/proc/net/nf_conntrack", "r") then for line in io.lines("/proc/net/nf_conntrack") do line = line:match "^(.-( [^ =]+=).-)%2" local entry, flags = _parse_mixed_record(line, " +") if flags[6] ~= "TIME_WAIT" then entry.layer3 = flags[1] entry.layer4 = flags[3] for i=1, #entry do entry[i] = nil end if callback then callback(entry) else connt[#connt+1] = entry end end end elseif fs.access("/proc/net/ip_conntrack", "r") then for line in io.lines("/proc/net/ip_conntrack") do line = line:match "^(.-( [^ =]+=).-)%2" local entry, flags = _parse_mixed_record(line, " +") if flags[4] ~= "TIME_WAIT" then entry.layer3 = "ipv4" entry.layer4 = flags[1] for i=1, #entry do entry[i] = nil end if callback then callback(entry) else connt[#connt+1] = entry end end end else return nil end return connt end function net.devices() local devs = {} for k, v in ipairs(nixio.getifaddrs()) do if v.family == "packet" then devs[#devs+1] = v.name end end return devs end function net.deviceinfo() local devs = {} for k, v in ipairs(nixio.getifaddrs()) do if v.family == "packet" then local d = v.data d[1] = d.rx_bytes d[2] = d.rx_packets d[3] = d.rx_errors d[4] = d.rx_dropped d[5] = 0 d[6] = 0 d[7] = 0 d[8] = d.multicast d[9] = d.tx_bytes d[10] = d.tx_packets d[11] = d.tx_errors d[12] = d.tx_dropped d[13] = 0 d[14] = d.collisions d[15] = 0 d[16] = 0 devs[v.name] = d end end return devs end -- The following fields are defined for route entry tables: -- { "dest", "gateway", "metric", "refcount", "usecount", "irtt", -- "flags", "device" } function net.routes(callback) local routes = { } for line in io.lines("/proc/net/route") do local dev, dst_ip, gateway, flags, refcnt, usecnt, metric, dst_mask, mtu, win, irtt = line:match( "([^%s]+)\t([A-F0-9]+)\t([A-F0-9]+)\t([A-F0-9]+)\t" .. "(%d+)\t(%d+)\t(%d+)\t([A-F0-9]+)\t(%d+)\t(%d+)\t(%d+)" ) if dev then gateway = luci.ip.Hex( gateway, 32, luci.ip.FAMILY_INET4 ) dst_mask = luci.ip.Hex( dst_mask, 32, luci.ip.FAMILY_INET4 ) dst_ip = luci.ip.Hex( dst_ip, dst_mask:prefix(dst_mask), luci.ip.FAMILY_INET4 ) local rt = { dest = dst_ip, gateway = gateway, metric = tonumber(metric), refcount = tonumber(refcnt), usecount = tonumber(usecnt), mtu = tonumber(mtu), window = tonumber(window), irtt = tonumber(irtt), flags = tonumber(flags, 16), device = dev } if callback then callback(rt) else routes[#routes+1] = rt end end end return routes end -- The following fields are defined for route entry tables: -- { "source", "dest", "nexthop", "metric", "refcount", "usecount", -- "flags", "device" } function net.routes6(callback) if fs.access("/proc/net/ipv6_route", "r") then local routes = { } for line in io.lines("/proc/net/ipv6_route") do local dst_ip, dst_prefix, src_ip, src_prefix, nexthop, metric, refcnt, usecnt, flags, dev = line:match( "([a-f0-9]+) ([a-f0-9]+) " .. "([a-f0-9]+) ([a-f0-9]+) " .. "([a-f0-9]+) ([a-f0-9]+) " .. "([a-f0-9]+) ([a-f0-9]+) " .. "([a-f0-9]+) +([^%s]+)" ) if dst_ip and dst_prefix and src_ip and src_prefix and nexthop and metric and refcnt and usecnt and flags and dev then src_ip = luci.ip.Hex( src_ip, tonumber(src_prefix, 16), luci.ip.FAMILY_INET6, false ) dst_ip = luci.ip.Hex( dst_ip, tonumber(dst_prefix, 16), luci.ip.FAMILY_INET6, false ) nexthop = luci.ip.Hex( nexthop, 128, luci.ip.FAMILY_INET6, false ) local rt = { source = src_ip, dest = dst_ip, nexthop = nexthop, metric = tonumber(metric, 16), refcount = tonumber(refcnt, 16), usecount = tonumber(usecnt, 16), flags = tonumber(flags, 16), device = dev, -- lua number is too small for storing the metric -- add a metric_raw field with the original content metric_raw = metric } if callback then callback(rt) else routes[#routes+1] = rt end end end return routes end end function net.pingtest(host) return os.execute("ping -c1 '"..host:gsub("'", '').."' >/dev/null 2>&1") end process = {} function process.info(key) local s = {uid = nixio.getuid(), gid = nixio.getgid()} return not key and s or s[key] end function process.list() local data = {} local k local ps = luci.util.execi("/bin/busybox top -bn1") if not ps then return end for line in ps do local pid, ppid, user, stat, vsz, mem, cpu, cmd = line:match( "^ *(%d+) +(%d+) +(%S.-%S) +([RSDZTW][W ][<N ]) +(%d+) +(%d+%%) +(%d+%%) +(.+)" ) local idx = tonumber(pid) if idx then data[idx] = { ['PID'] = pid, ['PPID'] = ppid, ['USER'] = user, ['STAT'] = stat, ['VSZ'] = vsz, ['%MEM'] = mem, ['%CPU'] = cpu, ['COMMAND'] = cmd } end end return data end function process.setgroup(gid) return nixio.setgid(gid) end function process.setuser(uid) return nixio.setuid(uid) end process.signal = nixio.kill user = {} -- { "uid", "gid", "name", "passwd", "dir", "shell", "gecos" } user.getuser = nixio.getpw function user.getpasswd(username) local pwe = nixio.getsp and nixio.getsp(username) or nixio.getpw(username) local pwh = pwe and (pwe.pwdp or pwe.passwd) if not pwh or #pwh < 1 or pwh == "!" or pwh == "x" then return nil, pwe else return pwh, pwe end end function user.checkpasswd(username, pass) local pwh, pwe = user.getpasswd(username) if pwe then return (pwh == nil or nixio.crypt(pass, pwh) == pwh) end return false end function user.setpasswd(username, password) if password then password = password:gsub("'", [['"'"']]) end if username then username = username:gsub("'", [['"'"']]) end return os.execute( "(echo '" .. password .. "'; sleep 1; echo '" .. password .. "') | " .. "passwd '" .. username .. "' >/dev/null 2>&1" ) end wifi = {} function wifi.getiwinfo(ifname) local stat, iwinfo = pcall(require, "iwinfo") if ifname then local c = 0 local u = uci.cursor_state() local d, n = ifname:match("^(%w+)%.network(%d+)") if d and n then ifname = d n = tonumber(n) u:foreach("wireless", "wifi-iface", function(s) if s.device == d then c = c + 1 if c == n then ifname = s.ifname or s.device return false end end end) elseif u:get("wireless", ifname) == "wifi-device" then u:foreach("wireless", "wifi-iface", function(s) if s.device == ifname and s.ifname then ifname = s.ifname return false end end) end local t = stat and iwinfo.type(ifname) local x = t and iwinfo[t] or { } return setmetatable({}, { __index = function(t, k) if k == "ifname" then return ifname elseif x[k] then return x[k](ifname) end end }) end end init = {} init.dir = "/etc/init.d/" function init.names() local names = { } for name in fs.glob(init.dir.."*") do names[#names+1] = fs.basename(name) end return names end function init.index(name) if fs.access(init.dir..name) then return call("env -i sh -c 'source %s%s enabled; exit ${START:-255}' >/dev/null" %{ init.dir, name }) end end local function init_action(action, name) if fs.access(init.dir..name) then return call("env -i %s%s %s >/dev/null" %{ init.dir, name, action }) end end function init.enabled(name) return (init_action("enabled", name) == 0) end function init.enable(name) return (init_action("enable", name) == 1) end function init.disable(name) return (init_action("disable", name) == 0) end function init.start(name) return (init_action("start", name) == 0) end function init.stop(name) return (init_action("stop", name) == 0) end -- Internal functions function _parse_mixed_record(cnt, delimiter) delimiter = delimiter or " " local data = {} local flags = {} for i, l in pairs(luci.util.split(luci.util.trim(cnt), "\n")) do for j, f in pairs(luci.util.split(luci.util.trim(l), delimiter, nil, true)) do local k, x, v = f:match('([^%s][^:=]*) *([:=]*) *"*([^\n"]*)"*') if k then if x == "" then table.insert(flags, k) else data[k] = v end end end end return data, flags end
apache-2.0
AlexandreCA/darkstar
scripts/globals/items/dish_of_spaghetti_pescatora_+1.lua
18
1656
----------------------------------------- -- ID: 5200 -- Item: dish_of_spaghetti_pescatora_+1 -- Food Effect: 60Min, All Races ----------------------------------------- -- Health % 15 -- Health Cap 160 -- Vitality 3 -- Mind -1 -- Defense % 22 -- Defense Cap 70 -- Store TP 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,3600,5200); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_FOOD_HPP, 15); target:addMod(MOD_FOOD_HP_CAP, 160); target:addMod(MOD_VIT, 3); target:addMod(MOD_MND, -1); target:addMod(MOD_FOOD_DEFP, 22); target:addMod(MOD_FOOD_DEF_CAP, 70); target:addMod(MOD_STORETP, 6); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_FOOD_HPP, 15); target:delMod(MOD_FOOD_HP_CAP, 160); target:delMod(MOD_VIT, 3); target:delMod(MOD_MND, -1); target:delMod(MOD_FOOD_DEFP, 22); target:delMod(MOD_FOOD_DEF_CAP, 70); target:delMod(MOD_STORETP, 6); end;
gpl-3.0
AlexandreCA/update
scripts/zones/The_Celestial_Nexus/mobs/Orbital.lua
18
2131
----------------------------------- -- Area: The Celestial Nexus -- NPC: Orbital -- Zilart Mission 16 BCNM Fight ----------------------------------- require("scripts/globals/titles"); require("scripts/globals/status"); require("scripts/globals/magic"); function onMobInitialize(mob) mob:addMod(MOD_REGAIN, 50); end ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) end; function onMobFight(mob, target) end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob,killer) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("updateCSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option,target) --printf("finishCSID: %u",csid); --printf("RESULT: %u",option); if (csid == 0x7d04) then if (GetMobByID(target:getID()-1):getName() == "Orbital") then DespawnMob(target:getID()); DespawnMob(target:getID()-1); DespawnMob(target:getID()-3); DespawnMob(target:getID()-4); mob = SpawnMob(target:getID()-2); mob:updateEnmity(player); --the "30 seconds of rest" you get before he attacks you, and making sure he teleports first in range mob:addStatusEffectEx(EFFECT_BIND, 0, 1, 0, 30); mob:addStatusEffectEx(EFFECT_SILENCE, 0, 1, 0, 40); else DespawnMob(target:getID()); DespawnMob(target:getID()+1); DespawnMob(target:getID()-2); DespawnMob(target:getID()-3); mob = SpawnMob(target:getID()-1); mob:updateEnmity(player); --the "30 seconds of rest" you get before he attacks you, and making sure he teleports first in range mob:addStatusEffectEx(EFFECT_BIND, 0, 1, 0, 30); mob:addStatusEffectEx(EFFECT_SILENCE, 0, 1, 0, 40); end end end;
gpl-3.0
AlexandreCA/update
scripts/globals/abilities/elemental_siphon.lua
11
2885
----------------------------------- -- Ability: Elemental Siphon -- Drains MP from your summoned spirit. -- Obtained: Summoner level 50 -- Recast Time: 5:00 -- Duration: Instant ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/pets"); require("scripts/globals/magic") require("scripts/globals/utils") ----------------------------------- -- onAbilityCheck ----------------------------------- function onAbilityCheck(player,target,ability) local pet = player:getPetID(); if (pet >= 0 and pet <= 7) then -- spirits return 0,0; else return MSGBASIC_UNABLE_TO_USE_JA,0; end end; ----------------------------------- -- onUseAbility ----------------------------------- function onUseAbility(player,target,ability) local spiritEle = player:getPetID() + 1; -- get the spirit's ID, then make it line up with element value for the day order. -- pet order: fire, ice, air, earth, thunder, water, light, dark -- day order: fire, earth, water, wind, ice, thunder, light, dark if (spiritEle == 2) then spiritEle = 5 elseif (spiritEle == 3) then spiritEle = 4 elseif (spiritEle == 4) then spiritEle = 2 elseif (spiritEle == 5) then spiritEle = 6 elseif (spiritEle == 6) then spiritEle = 3 end; local pEquipMods = player:getMod(MOD_ENHANCES_ELEMENTAL_SIPHON); local basePower = player:getSkillLevel(SKILL_SUM) + pEquipMods - 50; if (basePower < 0) then -- skill your summoning magic you lazy bastard ! basePower = 0; end; local weatherDayBonus = 1; local dayElement = VanadielDayElement(); local weather = player:getWeather(); -- Day bonus/penalty if (dayElement == dayStrong[spiritEle]) then weatherDayBonus = weatherDayBonus + 0.1; elseif (dayElement == dayWeak[spiritEle]) then weatherDayBonus = weatherDayBonus - 0.1; end -- Weather bonus/penalty if (weather == singleWeatherStrong[spiritEle]) then weatherDayBonus = weatherDayBonus + 0.1; elseif (weather == singleWeatherWeak[spiritEle]) then weatherDayBonus = weatherDayBonus - 0.1; elseif (weather == doubleWeatherStrong[spiritEle]) then weatherDayBonus = weatherDayBonus + 0.25; elseif (weather == doubleWeatherWeak[spiritEle]) then weatherDayBonus = weatherDayBonus - 0.25; end local power = math.floor(basePower * weatherDayBonus); local spirit = player:getPet(); power = utils.clamp(power, 0, spirit:getMP()); -- cap MP drained at spirit's MP power = utils.clamp(power, 0, player:getMaxMP() - player:getMP()); -- cap MP drained at the max MP - current MP spirit:delMP(power); return player:addMP(power); end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Caedarva_Mire/npcs/Nahshib.lua
15
2108
----------------------------------- -- Area: Caedarva Mire -- NPC: Nahshib -- Type: Assault -- @pos -274.334 -9.287 -64.255 79 ----------------------------------- package.loaded["scripts/zones/Caedarva_Mire/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Caedarva_Mire/TextIDs"); require("scripts/globals/missions"); require("scripts/globals/keyitems"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local IPpoint = player:getCurrency("imperial_standing"); if (player:getCurrentMission(TOAU) == IMMORTAL_SENTRIES) then if (player:hasKeyItem(SUPPLIES_PACKAGE)) then player:startEvent(5); elseif (player:getVar("AhtUrganStatus") == 1) then player:startEvent(6); end elseif (player:getCurrentMission(TOAU) >= PRESIDENT_SALAHEEM) then if (player:hasKeyItem(PERIQIA_ASSAULT_ORDERS) and player:hasKeyItem(ASSAULT_ARMBAND) == false) then player:startEvent(148,50,IPpoint); else player:startEvent(7); -- player:delKeyItem(ASSAULT_ARMBAND); end else player:startEvent(4); 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 == 5 and option == 1) then player:delKeyItem(SUPPLIES_PACKAGE); player:setVar("AhtUrganStatus",1); elseif (csid == 148 and option == 1) then player:delCurrency("imperial_standing", 50); player:addKeyItem(ASSAULT_ARMBAND); player:messageSpecial(KEYITEM_OBTAINED,ASSAULT_ARMBAND); end end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Sea_Serpent_Grotto/npcs/relic.lua
13
1861
----------------------------------- -- Area: Sea Serpent Grotto -- NPC: <this space intentionally left blank> -- @pos -356 14 -102 176 ----------------------------------- package.loaded["scripts/zones/Sea_Serpent_Grotto/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Sea_Serpent_Grotto/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- Working on correct relic, 4 items, Stage 4 item, Shard, Necropsyche, currencypiece if (player:getVar("RELIC_IN_PROGRESS") == 18311 and trade:getItemCount() == 4 and trade:hasItemQty(18311,1) and trade:hasItemQty(1579,1) and trade:hasItemQty(1589,1) and trade:hasItemQty(1457,1)) then player:startEvent(11,18312); end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:messageSpecial(NOTHING_OUT_OF_ORDINARY); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); if (csid == 11) then if (player:getFreeSlotsCount() < 2) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,18312); player:messageSpecial(FULL_INVENTORY_AFTER_TRADE,1456); else player:tradeComplete(); player:addItem(18312); player:addItem(1456,30); player:messageSpecial(ITEM_OBTAINED,18312); player:messageSpecial(ITEMS_OBTAINED,1456,30); player:setVar("RELIC_IN_PROGRESS",0); end end end;
gpl-3.0
samboy/Oblige
games/doom/fabs/exit/closet1.lua
1
1124
-- -- Exit closet -- PREFABS.Exit_closet1 = { file = "exit/closet1.wad" prob = 100 theme = "!tech" where = "seeds" seed_w = 1 seed_h = 1 deep = 16 over = -16 x_fit = "frame" y_fit = "top" } PREFABS.Exit_closet1_tech = { template = "Exit_closet1" theme = "tech" tex_STEP3 = "STEP1" tex_GRAYVINE = "COMPBLUE" tex_SW1VINE = "SW1BLUE" } ------- Exit-to-Secret --------------------------- PREFABS.Exit_closet1_secret = { template = "Exit_closet1" kind = "secret_exit" -- replace normal exit special with "exit to secret" special line_11 = 51 tex_GRAYVINE = "SP_HOT1" tex_SW1VINE = "SW1HOT" } ------- Trappy variation ------------------------- PREFABS.Exit_closet1_trap = { template = "Exit_closet1" map = "MAP02" prob = 30 theme = "!tech" style = "traps" seed_w = 1 seed_h = 2 } PREFABS.Exit_closet1_trap_tech = { template = "Exit_closet1" map = "MAP02" prob = 30 theme = "tech" style = "traps" seed_w = 1 seed_h = 2 tex_STEP3 = "STEP1" tex_GRAYVINE = "COMPBLUE" tex_SW1VINE = "SW1BLUE" }
gpl-2.0
AlexandreCA/update
scripts/zones/Lower_Jeuno/npcs/Kurou-Morou.lua
17
5313
----------------------------------- -- Area: Lower Jeuno -- Starts and Finishes Quest: Your Crystal Ball & Never to return -- @pos -4 -6 -28 245 ----------------------------------- package.loaded["scripts/zones/Lower_Jeuno/TextIDs"] = nil; package.loaded["scripts/globals/settings"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/titles"); require("scripts/globals/shop"); require("scripts/globals/quests"); require("scripts/zones/Lower_Jeuno/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if (player:getQuestStatus(JEUNO,YOUR_CRYSTAL_BALL) == QUEST_ACCEPTED and trade:getItemCount() == 1) then if (trade:hasItemQty(557,1) == true) then player:startEvent(0x00C0); -- CS for ahriman lens trade; Trading the lens to Kurou-Morou is optional elseif (trade:hasItemQty(556,1) == true) then player:startEvent(0x00C4); -- Trade divination sphere, finish quest end elseif (player:getQuestStatus(JEUNO,NEVER_TO_RETURN) == QUEST_ACCEPTED and trade:hasItemQty(12507,1) == true and trade:getItemCount() == 1) then player:startEvent(0x00Cb); -- Finish "Never to return" quest end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) printf("Ontrigger completed"); local YourCrystalBall = player:getQuestStatus(JEUNO,YOUR_CRYSTAL_BALL); local SearchingForTheRightWords = player:getQuestStatus(JEUNO,SEARCHING_FOR_THE_RIGHT_WORDS); local ACandlelightVigil = player:getQuestStatus(JEUNO,A_CANDLELIGHT_VIGIL); local RubbishDay = player:getQuestStatus(JEUNO,RUBBISH_DAY); local NeverToReturn = player:getQuestStatus(JEUNO,NEVER_TO_RETURN); local JFame = player:getFameLevel(JEUNO); local SearchingForWords_prereq = player:getVar("QuestSearchRightWords_prereq"); if (JFame >= 2 and YourCrystalBall == QUEST_AVAILABLE) then player:startEvent(0x00C2); -- Start "Your Crystal Ball" quest elseif (JFame >= 5 and YourCrystalBall == QUEST_COMPLETED and player:getQuestStatus(JEUNO,NEVER_TO_RETURN) == QUEST_AVAILABLE and player:getVar("QuestNeverToReturn_day") ~= VanadielDayOfTheYear()) then prog = player:getVar("QuestNeverToReturn_prog"); if (prog <= 2) then fortune = math.random(1,99); player:startEvent(0x00Cc,fortune); -- Required to get fortune read 3x on 3 diff game days before quest is kicked off elseif (prog == 3) then player:startEvent(0x00Ca); -- Start "Never to return" quest end --if searching for right words *prereq* CS has been activated elseif (SearchingForWords_prereq == 1) then player:startEvent(0x0026); elseif (player:getVar("QuestSearchRightWords_denied") == 1) then player:startEvent(0x0024); elseif (SearchingForTheRightWords == QUEST_ACCEPTED) then player:startEvent(0x0027); elseif (player:getVar("SearchingForRightWords_postcs") == -2) then player:startEvent(0x009a); elseif (SearchingForTheRightWords == QUEST_COMPLETED) then --final state, after all quests complete player:startEvent(0x0025); --conditions for searching for the right words elseif (ACandlelightVigil == QUEST_COMPLETED and RubbishDay == QUEST_COMPLETED and NeverToReturn == QUEST_COMPLETED and SearchingForTheRightWords == QUEST_AVAILABLE) then player:startEvent(0x0011); else player:startEvent(0x00C1); -- Standard 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); if (csid == 0x00C2 and option == 0) then player:addQuest(JEUNO,YOUR_CRYSTAL_BALL); elseif (csid == 0x00C4) then player:addTitle(FORTUNETELLER_IN_TRAINING); player:addFame(JEUNO, JEUNO_FAME*30); player:tradeComplete(trade); player:completeQuest(JEUNO,YOUR_CRYSTAL_BALL); elseif (csid == 0x00Cc and option == 0) then player:setVar("QuestNeverToReturn_prog", player:getVar("QuestNeverToReturn_prog") + 1); -- Keep track of how many times the players fortune has been read player:setVar("QuestNeverToReturn_day", VanadielDayOfTheYear()); -- new vanadiel day elseif (csid == 0x00Ca and option == 0) then player:addQuest(JEUNO,NEVER_TO_RETURN); player:setVar("QuestNeverToReturn_prog", 0); player:setVar("QuestNeverToReturn_day", 0); elseif (csid == 0x00Cb) then if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,13477); else player:addGil(GIL_RATE*1200); player:messageSpecial(GIL_OBTAINED,GIL_RATE*1200); player:addItem(13477); player:messageSpecial(ITEM_OBTAINED,13477); player:addFame(JEUNO, JEUNO_FAME*30); player:tradeComplete(trade); player:completeQuest(JEUNO,NEVER_TO_RETURN); end elseif (csid == 0x0011) then player:setVar("QuestSearchRightWords_prereq", 1); elseif (csid == 0x009a) then player:setVar("SearchingForRightWords_postcs", -1); end end;
gpl-3.0
AlexandreCA/update
scripts/zones/Temenos/mobs/Temenos_Weapon.lua
16
1289
----------------------------------- -- Area: Temenos Central 1floor -- NPC: Temenos_Weapon ----------------------------------- package.loaded["scripts/zones/Temenos/TextIDs"] = nil; ----------------------------------- require("scripts/globals/limbus"); require("scripts/zones/Temenos/TextIDs"); ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) end; ----------------------------------- -- onMobEngaged ----------------------------------- function onMobEngaged(mob,target) if (IsMobDead(16929048)==true) then mob:addStatusEffect(EFFECT_REGAIN,7,3,0); mob:addStatusEffect(EFFECT_REGEN,50,3,0); end end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob,killer) local mobX = mob:getXPos(); local mobY = mob:getYPos(); local mobZ = mob:getZPos(); if (IsMobDead(16929046)==true and IsMobDead(16929047)==true and IsMobDead(16929048)==true and IsMobDead(16929049)==true and IsMobDead(16929050)==true and IsMobDead(16929051)==true) then GetNPCByID(16928768+71):setPos(mobX,mobY,mobZ); GetNPCByID(16928768+71):setStatus(STATUS_NORMAL); GetNPCByID(16928770+471):setStatus(STATUS_NORMAL); end end;
gpl-3.0
AlexandreCA/update
scripts/zones/Hall_of_Transference/npcs/_0e0.lua
32
1340
----------------------------------- -- Area: Hall of Transference -- NPC: Cermet Gate - Holla -- @pos -219 -6 280 14 ----------------------------------- package.loaded["scripts/zones/Hall_of_Transference/TextIDs"] = nil; ----------------------------------- require("scripts/globals/missions"); require("scripts/zones/Hall_of_Transference/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:getCurrentMission(COP) > BELOW_THE_ARKS) then player:startEvent(0x0096); else player:messageSpecial(NO_RESPONSE_OFFSET+1); -- The door is firmly shut. 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 == 0x0096 and option == 1) then player:setPos(92.033, 0, 80.380, 255, 16); -- To Promyvion Holla {R} end end;
gpl-3.0
AlexandreCA/update
scripts/globals/items/plate_of_shrimp_sushi.lua
35
1552
----------------------------------------- -- ID: 5691 -- Item: plate_of_shrimp_sushi -- Food Effect: 30Min, All Races ----------------------------------------- -- Vitality 1 -- Defense 5 -- Accuracy % 11 -- Store TP 2 -- Triple Attack 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,5691); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_VIT, 1); target:addMod(MOD_DEF, 5); target:addMod(MOD_FOOD_ACCP, 11); target:addMod(MOD_FOOD_ACC_CAP, 999); target:addMod(MOD_STORETP, 2); target:addMod(MOD_TRIPLE_ATTACK, 1); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_VIT, 1); target:delMod(MOD_DEF, 5); target:delMod(MOD_FOOD_ACCP, 11); target:delMod(MOD_FOOD_ACC_CAP, 999); target:delMod(MOD_STORETP, 2); target:delMod(MOD_TRIPLE_ATTACK, 1); end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/AlTaieu/mobs/Absolute_Virtue.lua
6
2306
----------------------------------- -- Area: Al'Taieu -- HNM: Absolute Virtue ----------------------------------- require("scripts/globals/titles"); require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) -- setMod mob:setMod(MOD_REGEN, 500); local JoL = GetMobByID(16912848); -- Special check for regen modification by JoL pets killed if (JoL:getLocalVar("JoL_Qn_xzomit_Killed") == 9) then mob:addMod(MOD_REGEN, -130) end if (JoL:getLocalVar("JoL_Qn_hpemde_Killed") == 9) then mob:addMod(MOD_REGEN, -130) end end; ----------------------------------- -- onMobFight Action ----------------------------------- function onMobFight(mob, target) end; ------------------------------------ -- onSpellPrecast ------------------------------------ function onSpellPrecast(mob, spell) if (spell:getID() == 218) then -- Meteor spell:setAoE(SPELLAOE_RADIAL); spell:setFlag(SPELLFLAG_HIT_ALL); spell:setRadius(30); spell:setAnimation(280); -- AoE Meteor Animation spell:setMPCost(1); end end; ------------------------------------ -- onMonsterMagicPrepare ------------------------------------ function onMonsterMagicPrepare(caster, target) end; ----------------------------------- -- onMagicHit ----------------------------------- function onMagicHit(caster, target, spell) local REGEN = target:getMod(MOD_REGEN); local DAY = VanadielDayElement(); local ELEM = spell:getElement(); if (GetServerVariable("AV_Regen_Reduction") < 60) then -- Had to serverVar the regen instead of localVar because localVar reset on claim loss. if (ELEM == DAY and (caster:isPC() or caster:isPet())) then SetServerVariable("AV_Regen_Reduction", 1+GetServerVariable("AV_Regen_Reduction")); target:addMod(MOD_REGEN, -2); end end return 1; end; ----------------------------------- -- onMobDespawn ----------------------------------- function onMobDespawn(mob) end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob, killer, ally) ally:addTitle(VIRTUOUS_SAINT); end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Gusgen_Mines/npcs/_5ga.lua
13
1357
----------------------------------- -- Area: Gusgen Mines -- NPC: _5ga (Lever C) -- @pos 44 -40.561 -54.199 196 ----------------------------------- package.loaded["scripts/zones/Gusgen_Mines/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Gusgen_Mines/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) --local nID = npc:getID(); --printf("id: %u", nID); local Lever = npc:getID(); npc:openDoor(2); -- Lever animation if (GetNPCByID(Lever-6):getAnimation() == 9) then GetNPCByID(Lever-6):setAnimation(8);--open door C (_5g0) GetNPCByID(Lever-5):setAnimation(9);--close door B (_5g1) GetNPCByID(Lever-4):setAnimation(9);--close door A (_5g2) 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
lucgagnon/ntopng
scripts/lua/host_top_peers_protocols.lua
10
2411
-- -- (C) 2014-15-15 - ntop.org -- dirs = ntop.getDirs() package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path require "lua_utils" sendHTTPHeader('application/json') interface.select(ifname) host_info = url2hostinfo(_GET) flows = interface.getFlowPeers(host_info["host"],host_info["vlan"]) tot = 0 peers = {} peers_proto = {} ndpi = {} for key, value in pairs(flows) do flow = flows[key] if(flow.client == _GET["host"]) then peer = flow.server .. '@' .. flow['server.vlan'] else peer = flow.client .. '@' .. flow['client.vlan'] end v = flow.rcvd + flow.sent if(peers[peer] == nil) then peers[peer] = 0 end peers[peer] = peers[peer] + v if(ndpi[flow["proto.ndpi"]] == nil) then ndpi[flow["proto.ndpi"]] = 0 end ndpi[flow["proto.ndpi"]] = ndpi[flow["proto.ndpi"]] + v if(peers_proto[peer] == nil) then peers_proto[peer] = {} end if(peers_proto[peer][flow["proto.ndpi"]] == nil) then peers_proto[peer][flow["proto.ndpi"]] = 0 end peers_proto[peer][flow["proto.ndpi"]] = peers_proto[peer][flow["proto.ndpi"]] + v tot = tot + v end _peers = { } for key, value in pairs(peers) do _peers[value] = key end _ndpi = { } n = 0 for key, value in pairs(ndpi) do _ndpi[value] = key n = n + 1 end -- Print up to this number of entries max_num_peers = 10 print "[\n" num = 0 for value,peer in pairsByKeys(_peers, rev) do if(peers_proto[peer] ~= nil) then n = 0 for value,proto in pairsByKeys(_ndpi, rev) do if(peers_proto[peer][proto] ~= nil) then if((n+num) > 0) then print ",\n" end host = interface.getHostInfo(peer) if(host ~= nil) then if(host["name"] == nil) then host["name"] = ntop.getResolvedAddress(hostinfo2hostkey(host)) end print("\t { \"host\": \"" .. peer .."\", \"name\": \"".. host.name.."\", \"url\": \"<A HREF='"..ntop.getHttpPrefix().."/lua/host_details.lua?host=".. hostinfo2hostkey(host) .."'>"..host.name .."</A>\", \"l7proto\": \"".. proto .."\", \"l7proto_url\": \"<A HREF="..ntop.getHttpPrefix().."/lua/flows_stats.lua?host=".. hostinfo2hostkey(host) .."&application="..proto..">"..proto.."</A>\", \"traffic\": ".. math.log10(peers_proto[peer][proto]) .. " }") n = n + 1 end end end num = num + 1 if(num == max_num_peers) then break end end end print "\n]"
gpl-3.0
AlexandreCA/update
scripts/zones/Boneyard_Gully/bcnms/like_the_wind.lua
17
1655
----------------------------------- -- Area: Boneyard_Gully -- Name: like_the_wind -- BCNM: 673 -- Mask: 1 ----------------------------------- package.loaded["scripts/zones/Boneyard_Gully/TextIDs"] = nil; ----------------------------------- require("scripts/globals/missions"); require("scripts/globals/keyitems"); require("scripts/zones/Boneyard_Gully/TextIDs"); ----------------------------------- -- After registering the BCNM via bcnmRegister(bcnmid) function onBcnmRegister(player,instance) end; -- Physically entering the BCNM via bcnmEnter(bcnmid) function onBcnmEnter(player,instance) if (player:hasKeyItem(MIASMA_FILTER)) then player:delKeyItem(MIASMA_FILTER); end; end; -- Leaving the BCNM by every mean possible, given by the LeaveCode -- 1=Select Exit on circle -- 2=Winning the BC -- 3=Disconnected or warped out -- 4=Losing the BC -- via bcnmLeave(1) or bcnmLeave(2). LeaveCodes 3 and 4 are called -- from the core when a player disconnects or the time limit is up, etc function onBcnmLeave(player,instance,leavecode) if (leavecode == 2) then -- play end CS. Need time and battle id for record keeping + storage player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,0,0); elseif (leavecode == 4) then player:startEvent(0x7d02); end end; function onBcnmDestroy(player,instance) end; function onEventUpdate(player,csid,option) -- print("bc update csid "..csid.." and option "..option); end; function onEventFinish(player,csid,option) -- print("bc finish csid "..csid.." and option "..option); if (csid == 0x7d01) then player:addExp(2000); end end;
gpl-3.0
AlexandreCA/darkstar
scripts/globals/abilities/water_shot.lua
16
3124
----------------------------------- -- Ability: Water Shot -- Consumes a Water Card to enhance water-based debuffs. Deals water-based magic damage -- Drown Effect: Enhanced DoT and STR- ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/magic"); require("scripts/globals/weaponskills"); ----------------------------------- -- onAbilityCheck ----------------------------------- function onAbilityCheck(player,target,ability) --ranged weapon/ammo: You do not have an appropriate ranged weapon equipped. --no card: <name> cannot perform that action. if (player:getWeaponSkillType(SLOT_RANGED) ~= SKILL_MRK or player:getWeaponSkillType(SLOT_AMMO) ~= SKILL_MRK) then return 216,0; end if (player:hasItem(2181, 0) or player:hasItem(2974, 0)) then return 0,0; else return 71, 0; end end; ----------------------------------- -- onUseAbility ----------------------------------- function onUseAbility(player,target,ability) local params = {}; params.includemab = true; local dmg = (2 * player:getRangedDmg() + player:getAmmoDmg() + player:getMod(MOD_QUICK_DRAW_DMG)) * 1 + player:getMod(MOD_QUICK_DRAW_DMG_PERCENT)/100; dmg = addBonusesAbility(player, ELE_WATER, target, dmg, params); dmg = dmg * applyResistanceAbility(player,target,ELE_WATER,SKILL_MRK, (player:getStat(MOD_AGI)/2) + player:getMerit(MERIT_QUICK_DRAW_ACCURACY)); dmg = adjustForTarget(target,dmg,ELE_WATER); target:takeWeaponskillDamage(player, dmg, SLOT_RANGED, 1, 0, 0); -- targetTPMult is 0 because Quick Draw gives no TP to the mob target:updateEnmityFromDamage(player,dmg); local effects = {}; local counter = 1; local drown = target:getStatusEffect(EFFECT_DROWN); if (drown ~= nil) then effects[counter] = drown; counter = counter + 1; end local poison = target:getStatusEffect(EFFECT_POISON); if (poison ~= nil) then effects[counter] = poison; counter = counter + 1; end local threnody = target:getStatusEffect(EFFECT_THRENODY); if (threnody ~= nil and threnody:getSubPower() == MOD_FIRERES) then effects[counter] = threnody; counter = counter + 1; end if counter > 1 then local effect = effects[math.random(1, counter-1)]; local duration = effect:getDuration(); local startTime = effect:getStartTime(); local tick = effect:getTick(); local power = effect:getPower(); local subpower = effect:getSubPower(); local tier = effect:getTier(); local effectId = effect:getType(); local subId = effect:getSubType(); power = power * 1.2; target:delStatusEffectSilent(effectId); target:addStatusEffect(effectId, power, tick, duration, subId, subpower, tier); local newEffect = target:getStatusEffect(effectId); newEffect:setStartTime(startTime); end local del = player:delItem(2181, 1) or player:delItem(2974, 1) target:updateClaim(player); return dmg; end;
gpl-3.0
AlexandreCA/update
scripts/globals/items/alchemists_belt.lua
30
1200
----------------------------------------- -- ID: 15450 -- Item: Alchemist's belt -- Enchantment: Synthesis image support -- 2Min, All Races ----------------------------------------- -- Enchantment: Synthesis image support -- Duration: 2Min -- Alchemy Skill +3 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_ALCHEMY_IMAGERY) == true) then result = 242; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_ALCHEMY_IMAGERY,3,0,120); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_SKILL_ALC, 1); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_SKILL_ALC, 1); end;
gpl-3.0
martolini/Vana
scripts/npcs/world_trip.lua
1
3815
--[[ Copyright (C) 2008-2015 Vana Development Team 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --]] -- Spinel (Tour Guide, teleports to/from Zipangu) dofile("scripts/utils/npcHelper.lua"); if getMap() == 800000000 then wtOrigin = getPlayerVariable("wt_origin", type_int); if wtOrigin == nil then wtOrigin = 100000000; end choices = { makeChoiceHandler("Yes, I'm done with traveling. Can I go back to " .. mapRef(wtOrigin) .."? ", function() addText("Alright. "); addText("I'll now take you back to where you were before the visit to Japan. "); addText("If you ever feel like traveling again down the road, please let me know!"); sendNext(); setMap(wtOrigin); deletePlayerVariable("wt_origin"); end), makeChoiceHandler("No, I'd like to continue exploring this place.", function() addText("OK. If you ever change your mind, please let me know."); sendOk(); end), }; addText("How's the traveling? "); addText("Are you enjoying it?\r\n"); addText(blue(choiceRef(choices))); choice = askChoice(); selectChoice(choices, choice); else addText("If you're tired of the monotonous daily life, how about getting out for a change? "); addText("There's nothing quite like soaking up a new culture, learning something new by the minute! "); addText("It's time for you to get out and travel. "); addText("We, at the Maple Travel Agency recommend you going on a " .. blue("World Tour") .. "! "); addText("Are you worried about the travel expense? "); if getJob() == 0 then addText("No need to worry! "); addText("The " .. blue("Maple Travel Agency") .. " offers first class travel accommodation for the low price of " .. blue("300 mesos")); else addText("You shouldn't be! "); addText("We, the " .. blue("Maple Travel Agency") .. ", have carefully come up with a plan to let you travel for ONLY " .. blue("3,000 mesos!")); end sendNext(); addText("We currently offer this place for your traveling pleasure: " .. blue("Mushroom Shrine of Japan") .. ". "); addText("I'll be there serving you as the travel guide. "); addText("Rest assured, the number of destinations will increase over time. "); addText("Now, would you like to head over to the Mushroom Shrine?\r\n"); addText(blue(choiceRef(" Yes, take me to Mushroom Shrine (Japan)"))); choice = askChoice(); addText("Would you like to travel to " .. blue("Mushroom Shrine of Japan") .. "? "); addText("If you desire to feel the essence of Japan, there's nothing like visiting the Shrine, a Japanese cultural melting pot. "); addText("Mushroom Shrine is a mythical place that serves the incomparable Mushroom God from ancient times."); sendNext(); addText("Check out the female shaman serving the Mushroom God, and I strongly recommend trying Takoyaki, Yakisoba, and other delicious food sold in the streets of Japan. "); addText("Now, let's head over to " .. blue("Mushroom Shrine") .. ", a mythical place if there ever was one."); sendBackNext(); if getJob() == 0 then price = 300; else price = 3000; end if giveMesos(-price) then setPlayerVariable("wt_origin", getMap()); setMap(800000000); else addText("Please check and see if you have enough mesos to go."); sendBackOk(); end end
gpl-2.0
AlexandreCA/darkstar
scripts/globals/spells/curaga_iv.lua
28
1277
----------------------------------------- -- Spell: Curaga IV -- Restores HP of all party members within area of effect. ----------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------------- -- OnSpellCast ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) local minCure = 450; local divisor = 0.6666; local constant = 330; local power = getCurePowerOld(caster); if (power > 560) then divisor = 2.8333; constant = 591.2; elseif (power > 320) then divisor = 1; constant = 410; end local final = getCureFinal(caster,spell,getBaseCureOld(power,divisor,constant),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(); caster:updateEnmityFromCure(target,final); spell:setMsg(367); return final; end;
gpl-3.0
AlexandreCA/update
scripts/globals/items/loaf_of_pumpernickel.lua
35
1202
----------------------------------------- -- ID: 4591 -- Item: loaf_of_pumpernickel -- Food Effect: 60Min, All Races ----------------------------------------- -- Health 10 -- Vitality 2 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,3600,4591); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_HP, 10); target:addMod(MOD_VIT, 2); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_HP, 10); target:delMod(MOD_VIT, 2); end;
gpl-3.0
AlexandreCA/update
scripts/zones/Al_Zahbi/npcs/Gajaad.lua
18
2556
----------------------------------- -- Area: Al Zahbi -- NPC: Gajaad -- Type: Donation Taker -- @pos 40.781 -1.398 116.261 48 -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/Al_Zahbi/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) local walahraCoinCount = player:getVar("walahraCoinCount"); local TradeCount = trade:getItemQty(2184); if (TradeCount > 0 and TradeCount == trade:getItemCount()) then if (walahraCoinCount + TradeCount > 1000) then -- give player turban, donated over 1000 if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,15270); else player:addItem(15270); player:messageSpecial(ITEM_OBTAINED,15270); player:setVar("walahraCoinCount", walahraCoinCount - (1000 - TradeCount)); player:tradeComplete(); player:startEvent(0x0066, 2184, 0, TradeCount); end else -- turning in less than the amount needed to finish the quest if (TradeCount >= 100) then -- give bonus walahra water - only one water per trade, regardless of the amount. player:tradeComplete(); player:setVar("walahraCoinCount", walahraCoinCount + TradeCount); player:addItem(5354); player:messageSpecial(ITEM_OBTAINED,5354); player:startEvent(0x0066, 2184, 0, TradeCount); else player:tradeComplete(); player:setVar("walahraCoinCount", walahraCoinCount + TradeCount); player:startEvent(0x0066, 2184, 0, TradeCount); end end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) -- TODO beseige result can effect if this npc will accept trades player:startEvent(0x0066, 2184); 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
AlexandreCA/update
scripts/zones/Southern_San_dOria_[S]/npcs/Illeuse.lua
17
1617
----------------------------------- -- Area: Southern SandOria [S] -- NPC: Illeuse -- @zone 80 -- @pos -44.203 2 -36.216 ----------------------------------- package.loaded["scripts/zones/Southern_San_dOria_[S]/TextIDs"] = nil; require("scripts/zones/Southern_San_dOria_[S]/TextIDs"); require("scripts/globals/quests"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if (player:getQuestStatus(CRYSTAL_WAR,GIFTS_OF_THE_GRIFFON) == QUEST_ACCEPTED and player:getVar("GiftsOfGriffonProg") == 2) then local mask = player:getVar("GiftsOfGriffonPlumes"); if (trade:hasItemQty(2528,1) and trade:getItemCount() == 1 and not player:getMaskBit(mask,2)) then player:startEvent(0x01F) -- Gifts of Griffon Trade end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x0269); -- Default Dialogue 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 == 0x01F) then -- Gifts of Griffon Trade player:tradeComplete(); local mask = player:getVar("GiftsOfGriffonPlumes"); player:setMaskBit(mask,"GiftsOfGriffonPlumes",2,true); end end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Quicksand_Caves/npcs/qm5.lua
12
2198
----------------------------------- -- Area: Quicksand Caves -- NPC: ??? (qm5) -- Involved in Quest: The Missing Piece -- @pos --1:770 0 -419 --2:657 0 -537 --3:749 0 -573 --4:451 -16 -739 --5:787 -16 -819 --spawn in npc_list is 770 0 -419 ----------------------------------- package.loaded["scripts/zones/Quicksand_Caves/TextIDs"] = nil; ----------------------------------- require("scripts/globals/quests"); require("scripts/globals/keyitems"); require("scripts/zones/Quicksand_Caves/TextIDs"); ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local TheMissingPiece = player:getQuestStatus(OUTLANDS,THE_MISSING_PIECE); local HasAncientFragment = player:hasKeyItem(ANCIENT_TABLET_FRAGMENT); local HasAncientTablet = player:hasKeyItem(TABLET_OF_ANCIENT_MAGIC); --Need to make sure the quest is flagged the player is no further along in the quest if (TheMissingPiece == QUEST_ACCEPTED and not(HasAncientTablet or HasAncientFragment or player:getTitle() == ACQUIRER_OF_ANCIENT_ARCANUM)) then player:addKeyItem(ANCIENT_TABLET_FRAGMENT); player:messageSpecial(KEYITEM_OBTAINED,ANCIENT_TABLET_FRAGMENT); --move the ??? to a random location local i = math.random(0,100); if (i >= 0 and i < 20) then npc:setPos(770,0,-419,0); elseif (i >= 20 and i < 40) then npc:setPos(657,0,-537,0); elseif (i >= 40 and i < 60) then npc:setPos(749,0,-573,0); elseif (i >= 60 and i < 80) then npc:setPos(451,-16,-739,0); elseif (i >= 80 and i <= 100) then npc:setPos(787,-16,-819,0); else npc:setPos(787,-16,-819,0); end; else player:messageSpecial(NOTHING_OUT_OF_ORDINARY); end; end; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onEventFinish Action ----------------------------------- function onEventFinish(player,csid,option) --print("CSID:",csid); --print("RESULT:",option); end;
gpl-3.0
jstewart-amd/premake-core
src/actions/vstudio/vs2010_rules_xml.lua
5
8487
--- -- vs2010_rules_xml.lua -- Generate a Visual Studio 201x custom rules XML file. -- Copyright (c) 2014 Jason Perkins and the Premake project -- premake.vstudio.vs2010.rules.xml = {} local m = premake.vstudio.vs2010.rules.xml m.elements = {} local p = premake --- -- Entry point; generate the root <ProjectSchemaDefinitions> element. --- m.elements.project = function(r) return { m.projectSchemaDefinitions, m.rule, m.ruleItem, m.fileExtension, m.contentType, } end function m.generate(r) p.xmlUtf8() p.callArray(m.elements.project, r) p.out('</ProjectSchemaDefinitions>') end --- -- Generate the main <Rule> element. --- m.elements.rule = function(r) return { m.dataSource, m.categories, m.inputs, m.properties, m.commandLineTemplate, m.beforeTargets, m.afterTargets, m.outputs, m.executionDescription, m.additionalDependencies, m.additionalOptions, } end function m.rule(r) p.push('<Rule') p.w('Name="%s"', r.name) p.w('PageTemplate="tool"') p.w('DisplayName="%s"', r.display or r.name) p.w('Order="200">') p.callArray(m.elements.rule, r) p.pop('</Rule>') end --- -- Generate the list of categories. --- function m.categories(r) local categories = { [1] = { name="General" }, [2] = { name="Command Line", subtype="CommandLine" }, } p.push('<Rule.Categories>') for i = 1, #categories do m.category(categories[i]) end p.pop('</Rule.Categories>') end function m.category(cat) local attribs = p.capture(function() p.push() p.w('Name="%s"', cat.name) if cat.subtype then p.w('Subtype="%s"', cat.subtype) end p.pop() end) p.push('<Category') p.outln(attribs .. '>') p.push('<Category.DisplayName>') p.w('<sys:String>%s</sys:String>', cat.name) p.pop('</Category.DisplayName>') p.pop('</Category>') end --- -- Generate the list of property definitions. --- function m.properties(r) local defs = r.propertydefinition for i = 1, #defs do local def = defs[i] if def.kind == "boolean" then m.boolProperty(def) elseif def.kind == "list" then m.stringListProperty(def) elseif type(def.values) == "table" then m.enumProperty(def) elseif def.kind and def.kind:startswith("list:") then m.stringListProperty(def) else m.stringProperty(def) end end end function m.baseProperty(def, suffix) local c = p.capture(function () p.w('Name="%s"', def.name) p.w('HelpContext="0"') p.w('DisplayName="%s"', def.display or def.name) if def.description then p.w('Description="%s"', def.description) end end) if suffix then c = c .. suffix end p.outln(c) end function m.boolProperty(def) p.push('<BoolProperty') m.baseProperty(def) p.w('Switch="%s" />', def.switch or "[value]") p.pop() end function m.enumProperty(def) p.push('<EnumProperty') m.baseProperty(def, '>') local values = def.values local switches = def.switch or {} local keys = table.keys(def.values) table.sort(keys) for _, key in pairs(keys) do p.push('<EnumValue') p.w('Name="%d"', key) if switches[key] then p.w('DisplayName="%s"', values[key]) p.w('Switch="%s" />', switches[key]) else p.w('DisplayName="%s" />', values[key]) end p.pop() end p.pop('</EnumProperty>') end function m.stringProperty(def) p.push('<StringProperty') m.baseProperty(def) p.w('Switch="%s" />', def.switch or "[value]") p.pop() end function m.stringListProperty(def) p.push('<StringListProperty') m.baseProperty(def) p.w('Separator="%s"', def.separator or " ") p.w('Switch="%s" />', def.switch or "[value]") p.pop() end --- -- Implementations of individual elements. --- function m.additionalDependencies(r) p.push('<StringListProperty') p.w('Name="AdditionalDependencies"') p.w('DisplayName="Additional Dependencies"') p.w('IncludeInCommandLine="False"') p.w('Visible="false" />') p.pop() end function m.additionalOptions(r) p.push('<StringProperty') p.w('Subtype="AdditionalOptions"') p.w('Name="AdditionalOptions"') p.w('Category="Command Line">') p.push('<StringProperty.DisplayName>') p.w('<sys:String>Additional Options</sys:String>') p.pop('</StringProperty.DisplayName>') p.push('<StringProperty.Description>') p.w('<sys:String>Additional Options</sys:String>') p.pop('</StringProperty.Description>') p.pop('</StringProperty>') end function m.afterTargets(r) p.push('<DynamicEnumProperty') p.w('Name="%sAfterTargets"', r.name) p.w('Category="General"') p.w('EnumProvider="Targets"') p.w('IncludeInCommandLine="False">') p.push('<DynamicEnumProperty.DisplayName>') p.w('<sys:String>Execute After</sys:String>') p.pop('</DynamicEnumProperty.DisplayName>') p.push('<DynamicEnumProperty.Description>') p.w('<sys:String>Specifies the targets for the build customization to run after.</sys:String>') p.pop('</DynamicEnumProperty.Description>') p.push('<DynamicEnumProperty.ProviderSettings>') p.push('<NameValuePair') p.w('Name="Exclude"') p.w('Value="^%sAfterTargets|^Compute" />', r.name) p.pop() p.pop('</DynamicEnumProperty.ProviderSettings>') p.push('<DynamicEnumProperty.DataSource>') p.push('<DataSource') p.w('Persistence="ProjectFile"') p.w('ItemType=""') p.w('HasConfigurationCondition="true" />') p.pop() p.pop('</DynamicEnumProperty.DataSource>') p.pop('</DynamicEnumProperty>') end function m.beforeTargets(r) p.push('<DynamicEnumProperty') p.w('Name="%sBeforeTargets"', r.name) p.w('Category="General"') p.w('EnumProvider="Targets"') p.w('IncludeInCommandLine="False">') p.push('<DynamicEnumProperty.DisplayName>') p.w('<sys:String>Execute Before</sys:String>') p.pop('</DynamicEnumProperty.DisplayName>') p.push('<DynamicEnumProperty.Description>') p.w('<sys:String>Specifies the targets for the build customization to run before.</sys:String>') p.pop('</DynamicEnumProperty.Description>') p.push('<DynamicEnumProperty.ProviderSettings>') p.push('<NameValuePair') p.w('Name="Exclude"') p.w('Value="^%sBeforeTargets|^Compute" />', r.name) p.pop() p.pop('</DynamicEnumProperty.ProviderSettings>') p.push('<DynamicEnumProperty.DataSource>') p.push('<DataSource') p.w('Persistence="ProjectFile"') p.w('HasConfigurationCondition="true" />') p.pop() p.pop('</DynamicEnumProperty.DataSource>') p.pop('</DynamicEnumProperty>') end function m.commandLineTemplate(r) p.push('<StringProperty') p.w('Name="CommandLineTemplate"') p.w('DisplayName="Command Line"') p.w('Visible="False"') p.w('IncludeInCommandLine="False" />') p.pop() end function m.contentType(r) p.push('<ContentType') p.w('Name="%s"', r.name) p.w('DisplayName="%s"', r.display or r.name) p.w('ItemType="%s" />', r.name) p.pop() end function m.dataSource(r) p.push('<Rule.DataSource>') p.push('<DataSource') p.w('Persistence="ProjectFile"') p.w('ItemType="%s" />', r.name) p.pop() p.pop('</Rule.DataSource>') end function m.executionDescription(r) p.push('<StringProperty') p.w('Name="ExecutionDescription"') p.w('DisplayName="Execution Description"') p.w('Visible="False"') p.w('IncludeInCommandLine="False" />') p.pop() end function m.fileExtension(r) for _, v in ipairs(r.fileextension) do p.push('<FileExtension') p.w('Name="*%s"', v) p.w('ContentType="%s" />', r.name) p.pop() end end function m.inputs(r) p.push('<StringListProperty') p.w('Name="Inputs"') p.w('Category="Command Line"') p.w('IsRequired="true"') p.w('Switch=" ">') p.push('<StringListProperty.DataSource>') p.push('<DataSource') p.w('Persistence="ProjectFile"') p.w('ItemType="%s"', r.name) p.w('SourceType="Item" />') p.pop() p.pop('</StringListProperty.DataSource>') p.pop('</StringListProperty>') end function m.outputs(r) p.push('<StringListProperty') p.w('Name="Outputs"') p.w('DisplayName="Outputs"') p.w('Visible="False"') p.w('IncludeInCommandLine="False" />') p.pop() end function m.ruleItem(r) p.push('<ItemType') p.w('Name="%s"', r.name) p.w('DisplayName="%s" />', r.display or r.name) p.pop() end function m.projectSchemaDefinitions(r) p.push('<ProjectSchemaDefinitions xmlns="http://schemas.microsoft.com/build/2009/properties" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib">') end
bsd-3-clause
dromozoa/dromozoa-chunk
test_ieee754.lua
3
1433
-- Copyright (C) 2015 Tomoyuki Fujimori <moyu@dromozoa.com> -- -- This file is part of dromozoa-chunk. -- -- dromozoa-chunk is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- dromozoa-chunk is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with dromozoa-chunk. If not, see <http://www.gnu.org/licenses/>. local ieee754 = require "dromozoa.chunk.ieee754" local DBL_MAX = 1.7976931348623157e+308 local DBL_DENORM_MIN = 4.9406564584124654e-324 local DBL_MIN = 2.2250738585072014e-308 local DBL_EPSILON = 2.2204460492503131e-16 local function test(u) local s = ieee754.encode("<", 8, u) assert(#s == 8) local v = ieee754.decode("<", 8, s) if -math.huge <= u and u <= math.huge then assert(u == v) else assert(not (-math.huge <= v and v <= math.huge)) end end test(DBL_MAX) test(DBL_DENORM_MIN) test(DBL_MIN) test(DBL_EPSILON) test(math.pi) test(0) test(-1 / math.huge) -- -0 test(math.huge) -- inf test(-math.huge) -- -inf test(0 / 0) -- nan
gpl-3.0
exercism/xlua
exercises/practice/food-chain/food-chain_spec.lua
1
4090
local song = require('food-chain') describe('food-chain', function () it('fly', function () local expected = "I know an old lady who swallowed a fly.\nI don't know why she swallowed the fly. Perhaps she'll die.\n" assert.are.equal(expected, song.verse(1)) end) it('spider', function () local expected = "I know an old lady who swallowed a spider.\nIt wriggled and jiggled and tickled inside her.\n" .. "She swallowed the spider to catch the fly.\n" .. "I don't know why she swallowed the fly. Perhaps she'll die.\n" assert.are.equal(expected, song.verse(2)) end) it('bird', function () local expected = "I know an old lady who swallowed a bird.\n" .. "How absurd to swallow a bird!\n" .. "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" .. "She swallowed the spider to catch the fly.\n" .. "I don't know why she swallowed the fly. Perhaps she'll die.\n" assert.are.equal(expected, song.verse(3)) end) it('cat', function () local expected = "I know an old lady who swallowed a cat.\n" .. "Imagine that, to swallow a cat!\n" .. "She swallowed the cat to catch the bird.\n" .. "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" .. "She swallowed the spider to catch the fly.\n" .. "I don't know why she swallowed the fly. " .. "Perhaps she'll die.\n" assert.are.equal(expected, song.verse(4)) end) it('dog', function () local expected = "I know an old lady who swallowed a dog.\n" .. "What a hog, to swallow a dog!\n" .. "She swallowed the dog to catch the cat.\n" .. "She swallowed the cat to catch the bird.\n" .. "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" .. "She swallowed the spider to catch the fly.\n" .. "I don't know why she swallowed the fly. " .. "Perhaps she'll die.\n" assert.are.equal(expected, song.verse(5)) end) it('goat', function () local expected = "I know an old lady who swallowed a goat.\n" .. "Just opened her throat and swallowed a goat!\n" .. "She swallowed the goat to catch the dog.\n" .. "She swallowed the dog to catch the cat.\n" .. "She swallowed the cat to catch the bird.\n" .. "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" .. "She swallowed the spider to catch the fly.\n" .. "I don't know why she swallowed the fly. " .. "Perhaps she'll die.\n" assert.are.equal(expected, song.verse(6)) end) it('cow', function () local expected = "I know an old lady who swallowed a cow.\n" .. "I don't know how she swallowed a cow!\n" .. "She swallowed the cow to catch the goat.\n" .. "She swallowed the goat to catch the dog.\n" .. "She swallowed the dog to catch the cat.\n" .. "She swallowed the cat to catch the bird.\n" .. "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" .. "She swallowed the spider to catch the fly.\n" .. "I don't know why she swallowed the fly. " .. "Perhaps she'll die.\n" assert.are.equal(expected, song.verse(7)) end) it('horse', function () local expected = "I know an old lady who swallowed a horse.\n" .. "She's dead, of course!\n" assert.are.equal(expected, song.verse(8)) end) it('multiple verses', function () local expected = "" expected = "I know an old lady who swallowed a fly.\nI don't know why she swallowed the fly. Perhaps she'll die.\n\n" .. "I know an old lady who swallowed a spider.\nIt wriggled and jiggled and tickled inside her.\n" .. "She swallowed the spider to catch the fly.\n" .. "I don't know why she swallowed the fly. Perhaps she'll die.\n\n" assert.are.equal(expected, song.verses(1, 2)) end) it('the whole song', function () assert.are.equal(song.verses(1, 8), song.sing()) end) end)
mit
makehackvoid/MHV-Space-Probe
controller/probe.lua
1
2502
-- Module for interacting with the probe itself require "config" require "posix" local http = require("socket.http") probe = {} -- some common utility functions probe.leds_off = function() probe.set_leds(0,0,0) end probe.green_glow = function() probe.set_leds(0,30,0) end probe.fast_green_blink = function() probe.set_leds(0,255,0,50,100) end probe.fast_red_blink = function() probe.set_leds(255,0,0,200,200) end probe.slow_blue_blink = function(off_time) probe.set_leds(0,0,255,200,off_time) end if config.spaceprobe_name == "simulation" then -- shortcut the probe_sim module in its place dofile("probe_sim.lua") return end -- real probe functions follow local function probe_request(url, postdata) -- postdata can be nil, indicating a GET b, c, h = http.request("http://" .. config.spaceprobe_name .. url, postdata) if b == nil then log("Request failed. Probe offline? Error was " .. c) return nil elseif c ~= 200 then log("Probe refused request! Response was " .. b) return nil else return b end end local function get_offline() rsp = probe_request("/is_alive") return rsp ~= "OK" end local last_dial = nil local function set_dial(raw_value) if last_dial ~= raw_value then last_dial = raw_value return probe_request("/dial", string.format("%04d", raw_value)) end end local last_r,last_g,last_b,last_on,last_off local function set_leds(r,g,b,blink_on_time,blink_off_time) if r~=last_r or g~=last_g or b~=last_b or blink_on_time~=last_on or blink_off_time~=last_off then last_r = r last_g = g last_b = b last_on = blink_on_time last_off = blink_off_time return probe_request("/leds", string.format("%04d,%04d,%04d,%04d,%04d",r,g,b, blink_on_time or 1,blink_off_time or 0)) end end local function buzz(seconds) return probe_request( "/buzz", string.format("%04d", seconds*1000)) end local last_position = nil local function get_position() res = tonumber(probe_request("/knob")) if res and (res >= 1014) then return last_position -- our probe has a bug where 0 and 1014 are interchangeable, so ignore any 1014s end if res then last_position = res end return res end probe.get_position=get_position probe.ping=get_offline probe.get_offline=get_offline probe.set_dial=set_dial probe.set_leds=set_leds probe.buzz=buzz
mit
lancehilliard/TGNS
mods/tgns/output/lua/shine/extensions/push.lua
1
10426
local md = TGNSMessageDisplayer.Create("PUSH") local pushTempfilePath = "config://tgns/temp/push.json" local Plugin = {} local PUSHBULLET_CHANNEL_IDS = {'tgns-bots', 'tgns-infested', 'tgns-priming', 'tgns-seeded', 'tgns-primed', 'tgns-captains', 'tgns-test', 'tgns-guarded', 'tgns-admin', 'tgns-arclight'} function Plugin:Push(pushChannelId, pushTitle, pushMessage, client) local sourcePlayerId = client and TGNS.GetClientSteamId(client) or 0 if TGNS.Has(PUSHBULLET_CHANNEL_IDS, pushChannelId) then local pushUrl = string.format("%s&i=%s&c=%s&t=%s&m=%s", TGNS.Config.PushEndpointBaseUrl, sourcePlayerId, TGNS.UrlEncode(pushChannelId), TGNS.UrlEncode(pushTitle), TGNS.UrlEncode(pushMessage)) TGNS.GetHttpAsync(pushUrl, function(pushResponseJson) local pushResponse = json.decode(pushResponseJson) or {} if pushResponse.success then if Shine:IsValidClient(client) then md:ToClientConsole(client, string.format("Success. Sent '%s: %s' to channel '%s'.", pushTitle, pushMessage, pushChannelId)) end else local errorDisplayMessage = string.format("Unable to push title '%s' and message '%s' to channel '%s'", pushTitle, pushMessage, pushChannelId) if Shine:IsValidClient(client) then md:ToClientConsole(client, string.format("ERROR: %s. See server log for details.", errorDisplayMessage)) end local errorMessage = string.format("%s for NS2ID %s. msg: %s | response: %s | stacktrace: %s", errorDisplayMessage, sourcePlayerId, pushResponse.msg, pushResponseJson, pushResponse.stacktrace) TGNS.DebugPrint(string.format("push ERROR: %s", errorMessage), false, "pushes") end end) else TGNS.DebugPrint(string.format("push ERROR: %s not recognized. Message not pushed (sender: %s): %s - %s", pushChannelId, sourcePlayerId, pushTitle, pushMessage)) end pushMessage = string.format("%s - Manage Notifications: http://rr.tacticalgamer.com/Notifications", pushMessage) local notifyUrl = string.format("%s&sourcePlayerId=%s&offeringName=%s&title=%s&message=%s", TGNS.Config.NotifyEndpointBaseUrl, sourcePlayerId, TGNS.UrlEncode(pushChannelId), TGNS.UrlEncode(pushTitle), TGNS.UrlEncode(pushMessage)) TGNS.GetHttpAsync(notifyUrl, function(notifyResponseJson) local notifyResponse = json.decode(notifyResponseJson) or {} if notifyResponse.success then if Shine:IsValidClient(client) then md:ToClientConsole(client, string.format("Success. Sent '%s: %s' to subscription '%s'.", pushTitle, pushMessage, pushChannelId)) end else local errorDisplayMessage = string.format("Unable to notify title '%s' and message '%s' to subscription '%s'", pushTitle, pushMessage, pushChannelId) if Shine:IsValidClient(client) then md:ToClientConsole(client, string.format("ERROR: %s. See server log for details.", errorDisplayMessage)) end local errorMessage = string.format("%s for NS2ID %s. msg: %s | response: %s | stacktrace: %s", errorDisplayMessage, sourcePlayerId, notifyResponse.msg, notifyResponseJson, notifyResponse.stacktrace) TGNS.DebugPrint(string.format("notify ERROR: %s", errorMessage)) end end) end local function validatePushInput(pushInput) local result = false local messageData = TGNS.Split("|", pushInput) local title = #messageData > 0 and messageData[1] or "" local message = #messageData > 1 and messageData[2] or "" if TGNS.HasNonEmptyValue(title) and TGNS.HasNonEmptyValue(message) then result = true end return result, title, message end local function handlePushCommand(plugin, client, commandName, channelId, pushInput) local inputIsValid, title, message = validatePushInput(pushInput) if inputIsValid then plugin:Push(channelId, title, message, client) TGNS.Log(string.format("%s executed %s with title '%s' and message '%s' to channel '%s'.", TGNS.GetClientNameSteamIdCombo(client), commandName, title, message, channelId)) else md:ToClientConsole(client, "You must specify a title and message delimited by pipe (|). Example: Alert|This is a message.") end end local function createPushCommand(plugin, channelId, channelTitle) local channelIdCharactersToTrimFromCommandName = TGNS.StartsWith(channelId, "tgns-") and 5 or 0 local commandName = string.format("sh_push-%s", TGNS.Substring(channelId, channelIdCharactersToTrimFromCommandName + 1)) local command = plugin:BindCommand(commandName, nil, function(client, pushInput) handlePushCommand(plugin, client, commandName, channelId, pushInput) end) command:AddParam{ Type = "string", TakeRestOfLine = true, Optional = true } command:Help(string.format("<title|message> Push message on channel '%s'.", channelTitle)) end function Plugin:PostJoinTeam(gamerules, player, oldTeamNumber, newTeamNumber, force, shineForce) local numberOfPrimerSignersNecessaryToSendPrimingNotification = 6 local numberOfPrimerSignersNecessaryToSendPrimedNotification = 14 local playerList = TGNS.GetPlayerList() local playingClients = TGNS.GetPlayingClients(playerList) local numberOfPrimerSignersAmongPlayingClients = #TGNS.GetPrimerWithGamesClients(TGNS.GetPlayers(playingClients)) local secondsSinceEpoch = TGNS.GetSecondsSinceEpoch() local threeHoursInSeconds = TGNS.ConvertHoursToSeconds(3) if numberOfPrimerSignersAmongPlayingClients >= numberOfPrimerSignersNecessaryToSendPrimedNotification then local pushData = Shine.LoadJSONFile(pushTempfilePath) or {} local secondsSincePrimedNotifications = secondsSinceEpoch - (pushData.primedLastSentInSeconds or 0) if secondsSincePrimedNotifications >= threeHoursInSeconds then self:Push("tgns-primed", "TGNS primed!", string.format("%s+ Primer signers playing %s on %s. Server Info: http://rr.tacticalgamer.com/ServerInfo", numberOfPrimerSignersNecessaryToSendPrimedNotification, TGNS.GetCurrentMapName(), TGNS.GetSimpleServerName())) pushData.primedLastSentInSeconds = secondsSinceEpoch Shine.SaveJSONFile(pushData, pushTempfilePath) end elseif numberOfPrimerSignersAmongPlayingClients >= numberOfPrimerSignersNecessaryToSendPrimingNotification then local pushData = Shine.LoadJSONFile(pushTempfilePath) or {} local secondsSincePrimingNotifications = secondsSinceEpoch - (pushData.primingLastSentInSeconds or 0) local secondsSincePrimedNotifications = secondsSinceEpoch - (pushData.primedLastSentInSeconds or 0) if secondsSincePrimingNotifications >= threeHoursInSeconds and secondsSincePrimedNotifications >= threeHoursInSeconds then self:Push("tgns-priming", "TGNS priming!", string.format("%s+ Primer signers playing %s on %s. Server Info: http://rr.tacticalgamer.com/ServerInfo", numberOfPrimerSignersNecessaryToSendPrimingNotification, TGNS.GetCurrentMapName(), TGNS.GetSimpleServerName())) pushData.primingLastSentInSeconds = secondsSinceEpoch Shine.SaveJSONFile(pushData, pushTempfilePath) end end local client = TGNS.GetClient(player) if client and not TGNS.IsClientReadyRoom(client) then if TGNS.IsClientAdmin(client) or TGNS.IsClientGuardian(client) then local pushData = Shine.LoadJSONFile(pushTempfilePath) or {} local secondsSinceGuardedNotifications = secondsSinceEpoch - (pushData.guardedLastSentInSeconds or 0) if secondsSinceGuardedNotifications >= threeHoursInSeconds then TGNS.ScheduleAction(2, function() if Shine:IsValidClient(client) and TGNS.IsProduction() then self:Push("tgns-guarded", "TGNS guarded!", string.format("%s is guarded by %s (%s). Server Info: http://rr.tacticalgamer.com/ServerInfo", TGNS.GetSimpleServerName(), TGNS.GetClientName(client), TGNS.GetCurrentMapName())) end end) pushData.guardedLastSentInSeconds = secondsSinceEpoch Shine.SaveJSONFile(pushData, pushTempfilePath) end end end end function Plugin:CreateCommands() createPushCommand(self, "tgns", "TGNS") createPushCommand(self, "tgns-captains", "TGNS Captains") createPushCommand(self, "tgns-test", "TGNS Test") end function Plugin:Initialise() self.Enabled = true self:CreateCommands() TGNS.DoWithConfig(function() if Shine.GetGamemode() == "Infested" then local function sendInfestedNotification() local secondsSinceEpoch = TGNS.GetSecondsSinceEpoch() local threeHoursInSeconds = TGNS.ConvertHoursToSeconds(3) local pushData = Shine.LoadJSONFile(pushTempfilePath) or {} local secondsSinceInfestedNotifications = secondsSinceEpoch - (pushData.infestedLastSentInSeconds or 0) if secondsSinceInfestedNotifications >= threeHoursInSeconds and TGNS.IsProduction() then self:Push("tgns-infested", "TGNS Infested!", string.format("%s is Infested! Server Info: http://rr.tacticalgamer.com/ServerInfo", TGNS.GetSimpleServerName())) pushData.infestedLastSentInSeconds = secondsSinceEpoch Shine.SaveJSONFile(pushData, pushTempfilePath) end end TGNS.ScheduleAction(60, function() if TGNS.IsGameInCountdown() or TGNS.IsGameInProgress() then sendInfestedNotification() end TGNS.RegisterEventHook("GameCountdownStarted", function(secondsSinceEpoch) Shared.Message("Infested GameCountdownStarted...") sendInfestedNotification() end) end) end if TGNS.GetCurrentMapName() == "ns2_tgns_arclight" then local function sendArclightNotification() TGNS.ScheduleAction(5, function() local secondsSinceEpoch = TGNS.GetSecondsSinceEpoch() local threeHoursInSeconds = TGNS.ConvertHoursToSeconds(3) local pushData = Shine.LoadJSONFile(pushTempfilePath) or {} local secondsSinceArclightNotifications = secondsSinceEpoch - (pushData.arclightLastSentInSeconds or 0) if secondsSinceArclightNotifications >= threeHoursInSeconds and TGNS.IsProduction() and not GetServerContainsBots() then self:Push("tgns-arclight", "TGNS Arclight!", string.format("%s is playing Arclight! Server Info: http://rr.tacticalgamer.com/ServerInfo", TGNS.GetSimpleServerName())) pushData.arclightLastSentInSeconds = secondsSinceEpoch Shine.SaveJSONFile(pushData, pushTempfilePath) end end) end TGNS.ScheduleAction(60, function() if TGNS.IsGameInCountdown() or TGNS.IsGameInProgress() then sendArclightNotification() end TGNS.RegisterEventHook("GameCountdownStarted", function(secondsSinceEpoch) Shared.Message("Arclight GameCountdownStarted...") sendArclightNotification() end) end) end end) return true end function Plugin:Cleanup() --Cleanup your extra stuff like timers, data etc. self.BaseClass.Cleanup( self ) end Shine:RegisterExtension("push", Plugin )
mit
AlexandreCA/darkstar
scripts/zones/Sacrarium/npcs/Stale_Draft.lua
13
3995
----------------------------------- -- NPC: Stale Draft -- Area: Sacrarium -- Notes: Used to spawn Swift Belt NM's ----------------------------------- package.loaded["scripts/zones/Sacrarium/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Sacrarium/TextIDs"); ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local Hate = player:getVar("FOMOR_HATE"); if (Hate < 8) then --hate lvl 1 player:messageSpecial(NOTHING_OUT_OF_ORDINARY); elseif (Hate < 12) then player:messageSpecial(START_GET_GOOSEBUMPS); elseif (Hate < 50) then player:messageSpecial(HEART_RACING); elseif (Hate >= 50) then player:messageSpecial(LEAVE_QUICKLY_AS_POSSIBLE); end end; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if (trade:hasItemQty(1877,1) and trade:getItemCount() == 1) then --trade 1 fomor codex local X = npc:getXPos(); local Race = player:getRace(); local Hate = player:getVar("FOMOR_HATE"); if (X == 73) then --luaith spawnpoint-- if ((Race==3 or Race==4)and GetMobAction(16892069) == 0) then --elvaan if (Hate >= 50) then player:setVar("FOMOR_HATE",0); --reset fomor hate player:tradeComplete(); SpawnMob(16892069,180):updateClaim(player); else player:messageSpecial(NOTHING_HAPPENS); end else player:messageSpecial(NOTHING_HAPPENS); end elseif (X == 7) then --Caithleann spawnpoint if (Race==7 and GetMobAction(16892073) == 0) then -- mithra if (Hate >= 50) then player:setVar("FOMOR_HATE",0); --reset fomor hate player:tradeComplete(); SpawnMob(16892073,180):updateClaim(player); else player:messageSpecial(NOTHING_HAPPENS); end else player:messageSpecial(NOTHING_HAPPENS); end elseif (X == 47) then --Indich spawnpoint if (Race==8 and GetMobAction(16892074) == 0) then --galka if (Hate >= 50) then player:setVar("FOMOR_HATE",0); --reset fomor hate player:tradeComplete(); SpawnMob(16892074,180):updateClaim(player); else player:messageSpecial(NOTHING_HAPPENS); end else player:messageSpecial(NOTHING_HAPPENS); end elseif (X == 113) then --Lobais spawnpoint if ((Race==5 or Race==6 )and GetMobAction(16892070) == 0) then --tarutaru if (Hate >= 50) then player:setVar("FOMOR_HATE",0); --reset fomor hate player:tradeComplete(); SpawnMob(16892070,180):updateClaim(player); else player:messageSpecial(NOTHING_HAPPENS); end else player:messageSpecial(NOTHING_HAPPENS); end elseif (X == 33) then --Balor spawnpoint-- if ((Race==2 or Race==1)and GetMobAction(16892068) == 0) then -- hume if (Hate >= 50) then player:setVar("FOMOR_HATE",0); --reset fomor hate player:tradeComplete(); SpawnMob(16892068,180):updateClaim(player); else player:messageSpecial(NOTHING_HAPPENS); end else player:messageSpecial(NOTHING_HAPPENS); end end end end; ----------------------------------- -- onEventFinish Action ----------------------------------- function onEventFinish(player,csid,option) end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Northern_San_dOria/npcs/Morunaude.lua
13
1412
----------------------------------- -- Area: Northern San d'Oria -- NPC: Morunaude -- Standard Info NPC ----------------------------------- package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/quests"); require("scripts/zones/Northern_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- "Flyers for Regine" conditional script FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE); if (FlyerForRegine == 1) then count = trade:getItemCount(); MagicFlyer = trade:hasItemQty(532,1); if (MagicFlyer == true and count == 1) then player:messageSpecial(FLYER_REFUSED); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x027a); 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
AlexandreCA/darkstar
scripts/globals/items/pot-au-feu.lua
32
1707
----------------------------------------- -- ID: 5752 -- Item: Pot-au-feu -- Food Effect: 30Min, All Races ----------------------------------------- -- Strength 3 -- Agility 3 -- Intelligence -3 -- Ranged Attk % 15 Cap 60 -- Ranged ACC % 10 Cap 50 -- Enmity -3 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) result = 0 if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,1800,5752); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_STR, 3); target:addMod(MOD_AGI, 3); target:addMod(MOD_INT, -3); target:addMod(MOD_FOOD_RATTP, 15); target:addMod(MOD_FOOD_RATT_CAP, 60); target:addMod(MOD_FOOD_RACCP, 10); target:addMod(MOD_FOOD_RACC_CAP, 50); target:addMod(MOD_ENMITY, -3); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_STR, 3); target:delMod(MOD_AGI, 3); target:delMod(MOD_INT, -3); target:delMod(MOD_FOOD_RATTP, 15); target:delMod(MOD_FOOD_RATT_CAP, 60); target:delMod(MOD_FOOD_RACCP, 10); target:delMod(MOD_FOOD_RACC_CAP, 50); target:delMod(MOD_ENMITY, -3); end;
gpl-3.0
AlexandreCA/update
scripts/zones/RuAun_Gardens/mobs/Groundskeeper.lua
25
1323
----------------------------------- -- Area: RuAun Gardens -- MOB: Groundskeeper -- Note: Place holder Despot ----------------------------------- require("scripts/zones/RuAun_Gardens/MobIDs"); require("scripts/globals/fieldsofvalor"); ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob,killer) checkRegime(killer,mob,143,2); checkRegime(killer,mob,144,1); -- Get Groundskeeper ID and check if it is a PH of Despot mob = mob:getID(); -- Check if Groundskeeper is within the Despot_PH table if (Despot_PH[mob] ~= nil) then -- printf("%u is a PH",mob); -- Get Despot previous ToD Despot_ToD = GetServerVariable("[POP]Despot"); -- Check if Despot window is open, and there is not an Despot popped already(ACTION_NONE = 0) if (Despot_ToD <= os.time(t) and GetMobAction(Despot) == 0) then -- printf("Despot window open"); -- Give Groundskeeper 5 percent chance to pop Despot if (math.random(1,20) == 5) then -- printf("Despot will pop"); GetMobByID(Despot):setRespawnTime(GetMobRespawnTime(mob)); SetServerVariable("[PH]Despot", mob); DeterMob(mob, true); end end end end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Port_San_dOria/npcs/Callort.lua
13
1355
----------------------------------- -- Area: Port San d'Oria -- NPC: Callort -- Standard Info NPC ----------------------------------- package.loaded["scripts/zones/Port_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/quests"); require("scripts/zones/Port_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- "Flyers for Regine" conditional script FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE); if (FlyerForRegine == 1) then count = trade:getItemCount(); MagicFlyer = trade:hasItemQty(532,1); if (MagicFlyer == true and count == 1) then player:messageSpecial(FLYER_REFUSED); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x22d); 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
annulen/premake-annulen
tests/actions/test_clean.lua
2
4345
-- -- tests/actions/test_clean.lua -- Automated test suite for the "clean" action. -- Copyright (c) 2009 Jason Perkins and the Premake project -- T.clean = { } -- -- Replacement functions for remove() and rmdir() for testing -- local os_remove, os_rmdir, cwd local removed local function test_remove(fn) if not cwd then cwd = os.getcwd() end table.insert(removed, path.getrelative(cwd, fn)) end -- -- Setup/teardown -- local sln function T.clean.setup() _ACTION = "clean" os_remove = os.remove os_rmdir = os.rmdir os.remove = test_remove os.rmdir = test_remove removed = {} sln = solution "MySolution" configurations { "Debug", "Release" } end function T.clean.teardown() os.remove = os_remove os.rmdir = os_rmdir end local function prepare() premake.bake.buildconfigs() premake.action.call("clean") end -- -- Tests -- function T.clean.SolutionFiles() prepare() test.contains(removed, "MySolution.sln") test.contains(removed, "MySolution.suo") test.contains(removed, "MySolution.ncb") test.contains(removed, "MySolution.userprefs") test.contains(removed, "MySolution.usertasks") test.contains(removed, "MySolution.workspace") test.contains(removed, "MySolution_wsp.mk") test.contains(removed, "MySolution.tags") test.contains(removed, "Makefile") end function T.clean.CppProjectFiles() prj = project "MyProject" language "C++" kind "ConsoleApp" prepare() test.contains(removed, "MyProject.vcproj") test.contains(removed, "MyProject.pdb") test.contains(removed, "MyProject.idb") test.contains(removed, "MyProject.ilk") test.contains(removed, "MyProject.cbp") test.contains(removed, "MyProject.depend") test.contains(removed, "MyProject.layout") test.contains(removed, "MyProject.mk") test.contains(removed, "MyProject.list") test.contains(removed, "MyProject.out") test.contains(removed, "MyProject.make") end function T.clean.CsProjectFiles() prj = project "MyProject" language "C#" kind "ConsoleApp" prepare() test.contains(removed, "MyProject.csproj") test.contains(removed, "MyProject.csproj.user") test.contains(removed, "MyProject.pdb") test.contains(removed, "MyProject.idb") test.contains(removed, "MyProject.ilk") test.contains(removed, "MyProject.make") end function T.clean.ObjectDirsAndFiles() prj = project "MyProject" language "C++" kind "ConsoleApp" prepare() test.contains(removed, "obj") test.contains(removed, "obj/Debug") test.contains(removed, "obj/Release") end function T.clean.CppConsoleAppFiles() prj = project "MyProject" language "C++" kind "ConsoleApp" prepare() test.contains(removed, "MyProject") test.contains(removed, "MyProject.exe") test.contains(removed, "MyProject.elf") test.contains(removed, "MyProject.vshost.exe") test.contains(removed, "MyProject.exe.manifest") end function T.clean.CppWindowedAppFiles() prj = project "MyProject" language "C++" kind "WindowedApp" prepare() test.contains(removed, "MyProject") test.contains(removed, "MyProject.exe") test.contains(removed, "MyProject.app") end function T.clean.CppSharedLibFiles() prj = project "MyProject" language "C++" kind "SharedLib" prepare() test.contains(removed, "MyProject.dll") test.contains(removed, "libMyProject.so") test.contains(removed, "MyProject.lib") test.contains(removed, "libMyProject.dylib") end function T.clean.CppStaticLibFiles() prj = project "MyProject" language "C++" kind "StaticLib" prepare() test.contains(removed, "MyProject.lib") test.contains(removed, "libMyProject.a") end function T.clean.PlatformObjects() platforms { "Native", "x32" } prj = project "MyProject" language "C++" kind "ConsoleApp" prepare() test.contains(removed, "obj/Debug") test.contains(removed, "obj/Release") test.contains(removed, "obj/x32/Debug") test.contains(removed, "obj/x32/Release") end function T.clean.CppConsoleAppFiles_OnSuffix() prj = project "MyProject" language "C++" kind "ConsoleApp" targetsuffix "_x" prepare() test.contains(removed, "MyProject_x") test.contains(removed, "MyProject_x.exe") test.contains(removed, "MyProject_x.elf") test.contains(removed, "MyProject_x.vshost.exe") test.contains(removed, "MyProject_x.exe.manifest") end
bsd-3-clause
AlexandreCA/darkstar
scripts/globals/spells/foe_requiem_vi.lua
26
1736
----------------------------------------- -- Spell: Foe Requiem VI ----------------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------------- -- OnSpellCast ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) local effect = EFFECT_REQUIEM; local duration = 143; local power = 6; local pCHR = caster:getStat(MOD_CHR); local mCHR = target:getStat(MOD_CHR); local dCHR = (pCHR - mCHR); local resm = applyResistance(caster,spell,target,dCHR,SINGING_SKILL,0); if (resm < 0.5) then spell:setMsg(85);--resist message return 1; end -- level 75 gets a bonus if (caster:getMainLvl() >= 75) then power = power + 1; end local iBoost = caster:getMod(MOD_REQUIEM_EFFECT) + caster:getMod(MOD_ALL_SONGS_EFFECT); power = power + iBoost; if (caster:hasStatusEffect(EFFECT_SOUL_VOICE)) then power = power * 2; elseif (caster:hasStatusEffect(EFFECT_MARCATO)) then power = power * 1.5; end caster:delStatusEffect(EFFECT_MARCATO); duration = duration * ((iBoost * 0.1) + (caster:getMod(MOD_SONG_DURATION_BONUS)/100) + 1); if (caster:hasStatusEffect(EFFECT_TROUBADOUR)) then duration = duration * 2; end -- Try to overwrite weaker slow / haste if (canOverwrite(target, effect, power)) then -- overwrite them target:delStatusEffect(effect); target:addStatusEffect(effect,power,3,duration); spell:setMsg(237); else spell:setMsg(75); -- no effect end return effect; end;
gpl-3.0
AlexandreCA/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
paly2/minetest-minetestforfun-server
minetestforfun_game/mods/farming/beanpole.lua
1
5473
--[[ All textures by (C) Auke Kok <sofar@foo-projects.org> CC-BY-SA-3.0 --]] minetest.register_craftitem("farming:beans", { description = "Green Beans", inventory_image = "farming_beans.png", on_use = minetest.item_eat(1), on_place = function(itemstack, placer, pointed_thing) local nod = minetest.get_node_or_nil(pointed_thing.under) if nod and nod.name == "farming:beanpole" then minetest.set_node(pointed_thing.under, {name="farming:beanpole_1"}) else return end if not minetest.setting_getbool("creative_mode") then itemstack:take_item() end return itemstack end }) -- Beanpole minetest.register_node("farming:beanpole", { description = "Bean Pole (place on soil before planting beans)", drawtype = "plantlike", tiles = {"farming_beanpole.png"}, inventory_image = "farming_beanpole.png", visual_scale = 1.45, paramtype = "light", walkable = false, buildable_to = true, sunlight_propagates = true, drop = { items = { {items = {'farming:beanpole'},rarity=1}, } }, selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, groups = {snappy=3,flammable=2,not_in_creative_inventory=1,attached_node=1}, sounds = default.node_sound_leaves_defaults(), on_place = function(itemstack, placer, pointed_thing) local nod = minetest.get_node_or_nil(pointed_thing.under) if nod and minetest.get_item_group(nod.name, "soil") < 2 then return end local top = {x=pointed_thing.above.x, y=pointed_thing.above.y+1, z=pointed_thing.above.z} nod = minetest.get_node_or_nil(top) if nod and nod.name ~= "air" then return end minetest.set_node(pointed_thing.above, {name="farming:beanpole"}) if not minetest.setting_getbool("creative_mode") then itemstack:take_item() end return itemstack end }) minetest.register_craft({ output = "farming:beanpole", recipe = { {'', '', ''}, {'default:stick', '', 'default:stick'}, {'default:stick', '', 'default:stick'}, } }) -- Define Green Bean growth stages minetest.register_node("farming:beanpole_1", { drawtype = "plantlike", tiles = {"farming_beanpole_1.png"}, visual_scale = 1.45, paramtype = "light", walkable = false, buildable_to = true, sunlight_propagates = true, drop = { items = { {items = {'farming:beanpole'},rarity=1}, } }, selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, groups = {snappy=3,flammable=3,not_in_creative_inventory=1,attached_node=1,growing=1}, sounds = default.node_sound_leaves_defaults(), }) minetest.register_node("farming:beanpole_2", { drawtype = "plantlike", tiles = {"farming_beanpole_2.png"}, visual_scale = 1.45, paramtype = "light", walkable = false, buildable_to = true, sunlight_propagates = true, drop = { items = { {items = {'farming:beanpole'},rarity=1}, } }, selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1,growing=1}, sounds = default.node_sound_leaves_defaults(), }) minetest.register_node("farming:beanpole_3", { drawtype = "plantlike", tiles = {"farming_beanpole_3.png"}, visual_scale = 1.45, paramtype = "light", walkable = false, buildable_to = true, sunlight_propagates = true, drop = { items = { {items = {'farming:beanpole'},rarity=1}, } }, selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1,growing=1}, sounds = default.node_sound_leaves_defaults(), }) minetest.register_node("farming:beanpole_4", { drawtype = "plantlike", tiles = {"farming_beanpole_4.png"}, visual_scale = 1.45, paramtype = "light", walkable = false, buildable_to = true, sunlight_propagates = true, drop = { items = { {items = {'farming:beanpole'},rarity=1}, } }, selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1,growing=1}, sounds = default.node_sound_leaves_defaults(), }) -- Last stage of Green Bean growth does not have growing=1 so abm never has to check these minetest.register_node("farming:beanpole_5", { drawtype = "plantlike", tiles = {"farming_beanpole_5.png"}, visual_scale = 1.45, paramtype = "light", waving = 1, walkable = false, buildable_to = true, sunlight_propagates = true, drop = { items = { {items = {'farming:beanpole'},rarity=1}, {items = {'farming:beans 3'},rarity=1}, {items = {'farming:beans 2'},rarity=2}, {items = {'farming:beans 2'},rarity=3}, } }, selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1}, sounds = default.node_sound_leaves_defaults(), }) -- Wild Green Bean Bush (this is what you find on the map) minetest.register_node("farming:beanbush", { drawtype = "plantlike", tiles = {"farming_beanbush.png"}, paramtype = "light", waving = 1, walkable = false, buildable_to = true, sunlight_propagates = true, drop = { items = { {items = {'farming:beans 1'},rarity=1}, {items = {'farming:beans 1'},rarity=2}, {items = {'farming:beans 1'},rarity=3}, } }, selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1}, sounds = default.node_sound_leaves_defaults(), })
unlicense
AlexandreCA/update
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
AlexandreCA/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
AlexandreCA/darkstar
scripts/zones/Abyssea-Attohwa/npcs/qm16.lua
17
1763
----------------------------------- -- Zone: Abyssea-Attohwa -- NPC: ??? -- Spawns: Itzpapalotl ----------------------------------- require("scripts/globals/status"); require("scripts/globals/keyitems"); ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) --[[ if (GetMobAction(17658277) == ACTION_NONE) then -- NM not already spawned from this if (player:hasKeyItem(VENOMOUS_WAMOURA_FEELER) and player:hasKeyItem(BULBOUS_CRAWLER_COCOON) and player:hasKeyItem(DISTENDED_CHIGOE_ABDOMEN)) then -- I broke it into 3 lines at the 'and' because it was so long. player:startEvent(1022, VENOMOUS_WAMOURA_FEELER, BULBOUS_CRAWLER_COCOON, DISTENDED_CHIGOE_ABDOMEN); -- Ask if player wants to use KIs else player:startEvent(1023, VENOMOUS_WAMOURA_FEELER, BULBOUS_CRAWLER_COCOON, DISTENDED_CHIGOE_ABDOMEN); -- Do not ask, because player is missing at least 1. end end ]] end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID2: %u",csid); -- printf("RESULT2: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 1022 and option == 1) then SpawnMob(17658277):updateClaim(player); -- Spawn NM, Despawn after inactive for 5 minutes (pt has to reclaim within 5 of a wipe) player:delKeyItem(VENOMOUS_WAMOURA_FEELER); player:delKeyItem(BULBOUS_CRAWLER_COCOON); player:delKeyItem(DISTENDED_CHIGOE_ABDOMEN); end end;
gpl-3.0
AlexandreCA/update
scripts/zones/Meriphataud_Mountains/npcs/Muzeze.lua
38
1035
----------------------------------- -- Area: Meriphataud Mountains -- NPC: Muzeze -- Type: Armor Storer -- @pos -6.782 -18.428 208.185 119 ----------------------------------- package.loaded["scripts/zones/Meriphataud_Mountains/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Meriphataud_Mountains/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x002c); 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
AlexandreCA/darkstar
scripts/zones/Quicksand_Caves/npcs/_5s9.lua
13
1253
----------------------------------- -- Area: Quicksand Caves -- NPC: Ornate Door -- Door blocked by Weight system -- @pos -345 0 820 208 ----------------------------------- package.loaded["scripts/zones/Quicksand_Caves/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Quicksand_Caves/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local difX = player:getXPos()-(-352); local difZ = player:getZPos()-(820); local Distance = math.sqrt( math.pow(difX,2) + math.pow(difZ,2) ); if (Distance < 3) then return -1; end player:messageSpecial(DOOR_FIRMLY_SHUT); 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); end;
gpl-3.0
Wiladams/LJIT2XCB
testy/test_hello_xcb.lua
1
1714
--test_hello_xcb.lua --[[ Reference: http://www.x.org/releases/X11R7.6/doc/libxcb/tutorial/index.html#helloworld Press Ctl-C to terminate Simply closing the window will not terminate the app --]] package.path = package.path..";../?.lua" local ffi = require("ffi") local xcb = require("xcb") local utils = require("test_utils"); ffi.cdef[[ extern int pause (void); ]] local pause = ffi.C.pause; local function main () -- Open the connection to the X server local c = xcb.xcb_connect (nil, nil); -- Get the first screen local screen = xcb.xcb_setup_roots_iterator (xcb.xcb_get_setup (c)).data; -- Ask for our window's Id local win = xcb.xcb_generate_id(c); -- Create the window xcb.xcb_create_window (c, -- Connection xcb.XCB_COPY_FROM_PARENT, -- depth (same as root) win, -- window Id screen.root, -- parent window 0, 0, -- x, y 150, 150, -- width, height 10, -- border_width xcb.XCB_WINDOW_CLASS_INPUT_OUTPUT, -- class screen.root_visual, -- visual 0, nil); -- masks, not used yet -- Map the window on the screen xcb.xcb_map_window (c, win); -- Make sure commands are sent before we pause, so window is shown xcb.xcb_flush (c); -- hold client until Ctrl-C pause (); return 0; end main()
mit
AlexandreCA/darkstar
scripts/zones/Lower_Jeuno/npcs/Derrick.lua
25
4615
----------------------------------- -- Area: Lower Jeuno -- NPC: Derrick -- Involved in Quests and finish : Save the Clock Tower -- @zone 245 -- @pos -32 -1 -7 ----------------------------------- package.loaded["scripts/zones/Lower_Jeuno/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/titles"); require("scripts/globals/keyitems"); require("scripts/globals/shop"); require("scripts/globals/quests"); require("scripts/zones/Lower_Jeuno/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) TotalNPC = player:getVar("saveTheClockTowerNPCz1") + player:getVar("saveTheClockTowerNPCz2"); if (TotalNPC == 1023 and trade:hasItemQty(555,1) == true and trade:getItemCount() == 1) then player:startEvent(0x00e7); -- Ending quest "save the clock tower" end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) AirshipKI = player:hasKeyItem(AIRSHIP_PASS); saveTheClockTower = player:getQuestStatus(JEUNO,SAVE_THE_CLOCK_TOWER); NPCNumber = player:getVar("saveTheClockTowerVar"); -- Quest step & number of npc AgreeSignPetition = player:getVar("saveTheClockTowerVar2"); -- Sum of all NPC if (AirshipKI == false and saveTheClockTower == QUEST_ACCEPTED and NPCNumber >= 1 and NPCNumber <= 11) then player:startEvent(0x00e6,4,10); -- airship + petition help/restart elseif (AirshipKI == true and saveTheClockTower == QUEST_ACCEPTED and NPCNumber >= 1 and NPCNumber <= 11) then player:startEvent(0x00e6,6,10); -- petition help/restart elseif (AirshipKI == false and saveTheClockTower == QUEST_ACCEPTED and NPCNumber == 0) then player:startEvent(0x00e6,8,10); -- airship + petition elseif (AirshipKI == true and saveTheClockTower == QUEST_ACCEPTED and NPCNumber == 0) then player:startEvent(0x00e6,10,10); -- petition elseif (AirshipKI == false) then player:startEvent(0x00e6,12); -- airship else player:startEvent(0x00e6,14); -- rien end end; ----------------------------------- -- onEventUpdate Action ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x00e6 and option == 10) then if (player:delGil(500000)) then player:addKeyItem(AIRSHIP_PASS); player:updateEvent(0, 1); else player:updateEvent(0, 0); end end end; ----------------------------------- -- onEventFinish Action ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x00e6 and option == 10) then if (player:hasKeyItem(AIRSHIP_PASS) == true) then player:messageSpecial(KEYITEM_OBTAINED,AIRSHIP_PASS); end elseif (csid == 0x00e6 and option == 20) then if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,555); else player:addItem(555); player:messageSpecial(ITEM_OBTAINED,555); player:setVar("saveTheClockTowerVar",1); player:setVar("saveTheClockTowerNPCz1",0); player:setVar("saveTheClockTowerNPCz2",0); end elseif (csid == 0x00e6 and option == 30) then if (player:hasItem(555) == true) then player:messageSpecial(ITEM_OBTAINED,555); player:setVar("saveTheClockTowerVar",1); player:setVar("saveTheClockTowerNPCz1",0); player:setVar("saveTheClockTowerNPCz2",0); else if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,555); else player:addItem(555); player:messageSpecial(ITEM_OBTAINED,555); player:setVar("saveTheClockTowerVar",1); player:setVar("saveTheClockTowerNPCz1",0); player:setVar("saveTheClockTowerNPCz2",0); end end elseif (csid == 0x00e7) then player:setVar("saveTheClockTowerVar",0); player:setVar("saveTheClockTowerNPCz1",0); player:setVar("saveTheClockTowerNPCz2",0); player:addTitle(CLOCK_TOWER_PRESERVATIONIST); player:addFame(JEUNO, 30); player:tradeComplete(trade); player:completeQuest(JEUNO,SAVE_THE_CLOCK_TOWER); end end;
gpl-3.0
jstewart-amd/premake-core
tests/actions/vstudio/vc2010/test_rule_xml.lua
5
1168
-- -- tests/actions/vstudio/vc2010/test_rule_xml.lua -- Validate generation of custom rules -- Author Jason Perkins -- Copyright (c) 2016 Jason Perkins and the Premake project -- local suite = test.declare("vstudio_vs2010_rule_xml") local vc2010 = premake.vstudio.vc2010 local m = premake.vstudio.vs2010.rules.xml -- -- Setup -- function suite.setup() premake.action.set("vs2010") rule "MyRule" wks, prj = test.createWorkspace() rules { "MyRule" } end local function createVar(def) rule "MyRule" propertydefinition(def) project "MyProject" end --- -- Property definitions --- function suite.properties_onString() createVar { name="MyVar", kind="string" } local r = test.getRule("MyRule") m.properties(r) test.capture [[ <StringProperty Name="MyVar" HelpContext="0" DisplayName="MyVar" Switch="[value]" /> ]] end function suite.properties_onStringWithNoKind() createVar { name="MyVar" } local r = test.getRule("MyRule") m.properties(r) test.capture [[ <StringProperty Name="MyVar" HelpContext="0" DisplayName="MyVar" Switch="[value]" /> ]] end
bsd-3-clause
dani-sj/evillbot
plugins/add_bot.lua
189
1492
--[[ Bot can join into a group by replying a message contain an invite link or by typing !add [invite link]. URL.parse cannot parsing complicated message. So, this plugin only works for single [invite link] in a post. [invite link] may be preceeded but must not followed by another characters. --]] do local function parsed_url(link) local parsed_link = URL.parse(link) local parsed_path = URL.parse_path(parsed_link.path) i = 0 for k,segment in pairs(parsed_path) do i = i + 1 if segment == 'joinchat' then invite_link = string.gsub(parsed_path[i+1], '[ %c].+$', '') break end end return invite_link end local function action_by_reply(extra, success, result) local hash = parsed_url(result.text) join = import_chat_link(hash, ok_cb, false) end function run(msg, matches) if is_sudo(msg) then if msg.reply_id then msgr = get_message(msg.reply_id, action_by_reply, {msg=msg}) elseif matches[1] then local hash = parsed_url(matches[1]) join = import_chat_link(hash, ok_cb, false) end end end return { description = 'Invite the bot into a group chat via its invite link.', usage = { '!AddBot : Join a group by replying a message containing invite link.', '!AddBot [invite_link] : Join into a group by providing their [invite_link].' }, patterns = { '^[/!](addBot)$', '^[/!](ddBot) (.*)$' }, run = run } end
gpl-2.0
niedzielski/premake-4.4-beta4
src/actions/vstudio/vs2005_csproj.lua
1
7794
-- -- vs2005_csproj.lua -- Generate a Visual Studio 2005/2008 C# project. -- Copyright (c) 2009-2011 Jason Perkins and the Premake project -- -- -- Set up namespaces -- premake.vstudio.cs2005 = { } local vstudio = premake.vstudio local cs2005 = premake.vstudio.cs2005 -- -- Figure out what elements a particular source code file need in its item -- block, based on its build action and any related files in the project. -- local function getelements(prj, action, fname) if action == "Compile" and fname:endswith(".cs") then if fname:endswith(".Designer.cs") then -- is there a matching *.cs file? local basename = fname:sub(1, -13) local testname = basename .. ".cs" if premake.findfile(prj, testname) then return "Dependency", testname end -- is there a matching *.resx file? testname = basename .. ".resx" if premake.findfile(prj, testname) then return "AutoGen", testname end else -- is there a *.Designer.cs file? local basename = fname:sub(1, -4) local testname = basename .. ".Designer.cs" if premake.findfile(prj, testname) then return "SubTypeForm" end end end if action == "EmbeddedResource" and fname:endswith(".resx") then -- is there a matching *.cs file? local basename = fname:sub(1, -6) local testname = path.getname(basename .. ".cs") if premake.findfile(prj, testname) then if premake.findfile(prj, basename .. ".Designer.cs") then return "DesignerType", testname else return "Dependency", testname end else -- is there a matching *.Designer.cs? testname = path.getname(basename .. ".Designer.cs") if premake.findfile(prj, testname) then return "AutoGenerated" end end end if action == "Content" then return "CopyNewest" end return "None" end -- -- Return the Visual Studio architecture identification string. The logic -- to select this is getting more complicated in VS2010, but I haven't -- tackled all the permutations yet. -- function cs2005.arch(prj) return "AnyCPU" end -- -- Write out the <Files> element. -- function cs2005.files(prj) local tr = premake.project.buildsourcetree(prj) premake.tree.traverse(tr, { onleaf = function(node) local action = premake.dotnet.getbuildaction(node.cfg) local fname = path.translate(premake.esc(node.cfg.name), "\\") local elements, dependency = getelements(prj, action, node.path) if elements == "None" then _p(' <%s Include="%s" />', action, fname) else _p(' <%s Include="%s">', action, fname) if elements == "AutoGen" then _p(' <AutoGen>True</AutoGen>') elseif elements == "AutoGenerated" then _p(' <SubType>Designer</SubType>') _p(' <Generator>ResXFileCodeGenerator</Generator>') _p(' <LastGenOutput>%s.Designer.cs</LastGenOutput>', premake.esc(path.getbasename(node.name))) elseif elements == "SubTypeDesigner" then _p(' <SubType>Designer</SubType>') elseif elements == "SubTypeForm" then _p(' <SubType>Form</SubType>') elseif elements == "PreserveNewest" then _p(' <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>') end if dependency then _p(' <DependentUpon>%s</DependentUpon>', path.translate(premake.esc(dependency), "\\")) end _p(' </%s>', action) end end }, false) end -- -- Write the opening <Project> element. -- function cs2005.projectelement(prj) local toolversion = { vs2005 = '', vs2008 = ' ToolsVersion="3.5"', vs2010 = ' ToolsVersion="4.0"', } if _ACTION > "vs2008" then _p('<?xml version="1.0" encoding="utf-8"?>') end _p('<Project%s DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">', toolversion[_ACTION]) end -- -- Write the opening PropertyGroup, which contains the project-level settings. -- function cs2005.projectsettings(prj) local version = { vs2005 = '8.0.50727', vs2008 = '9.0.21022', vs2010 = '8.0.30703', } _p(' <PropertyGroup>') _p(' <Configuration Condition=" \'$(Configuration)\' == \'\' ">%s</Configuration>', premake.esc(prj.solution.configurations[1])) _p(' <Platform Condition=" \'$(Platform)\' == \'\' ">%s</Platform>', cs2005.arch(prj)) _p(' <ProductVersion>%s</ProductVersion>', version[_ACTION]) _p(' <SchemaVersion>2.0</SchemaVersion>') _p(' <ProjectGuid>{%s}</ProjectGuid>', prj.uuid) _p(' <OutputType>%s</OutputType>', premake.dotnet.getkind(prj)) _p(' <AppDesignerFolder>Properties</AppDesignerFolder>') _p(' <RootNamespace>%s</RootNamespace>', prj.buildtarget.basename) _p(' <AssemblyName>%s</AssemblyName>', prj.buildtarget.basename) local framework = prj.framework or iif(_ACTION == "vs2010", "4.0", nil) if framework then _p(' <TargetFrameworkVersion>v%s</TargetFrameworkVersion>', framework) end if _ACTION == "vs2010" then _p(' <TargetFrameworkProfile>Client</TargetFrameworkProfile>') _p(' <FileAlignment>512</FileAlignment>') end _p(' </PropertyGroup>') end -- -- Write the PropertyGroup element for a specific configuration block. -- function cs2005.propertygroup(cfg) _p(' <PropertyGroup Condition=" \'$(Configuration)|$(Platform)\' == \'%s|%s\' ">', premake.esc(cfg.name), cs2005.arch(cfg)) if _ACTION > "vs2008" then _p(' <PlatformTarget>%s</PlatformTarget>', cs2005.arch(cfg)) end end -- -- The main function: write the project file. -- function cs2005.generate(prj) io.eol = "\r\n" cs2005.projectelement(prj) cs2005.projectsettings(prj) for cfg in premake.eachconfig(prj) do cs2005.propertygroup(cfg) if cfg.flags.Symbols then _p(' <DebugSymbols>true</DebugSymbols>') _p(' <DebugType>full</DebugType>') else _p(' <DebugType>pdbonly</DebugType>') end _p(' <Optimize>%s</Optimize>', iif(cfg.flags.Optimize or cfg.flags.OptimizeSize or cfg.flags.OptimizeSpeed, "true", "false")) _p(' <OutputPath>%s</OutputPath>', cfg.buildtarget.directory) _p(' <DefineConstants>%s</DefineConstants>', table.concat(premake.esc(cfg.defines), ";")) _p(' <ErrorReport>prompt</ErrorReport>') _p(' <WarningLevel>4</WarningLevel>') if cfg.flags.Unsafe then _p(' <AllowUnsafeBlocks>true</AllowUnsafeBlocks>') end if cfg.flags.FatalWarnings then _p(' <TreatWarningsAsErrors>true</TreatWarningsAsErrors>') end _p(' </PropertyGroup>') end _p(' <ItemGroup>') for _, ref in ipairs(premake.getlinks(prj, "siblings", "object")) do _p(' <ProjectReference Include="%s">', path.translate(path.getrelative(prj.location, vstudio.projectfile(ref)), "\\")) _p(' <Project>{%s}</Project>', ref.uuid) _p(' <Name>%s</Name>', premake.esc(ref.name)) _p(' </ProjectReference>') end for _, linkname in ipairs(premake.getlinks(prj, "system", "basename")) do _p(' <Reference Include="%s" />', premake.esc(linkname)) end _p(' </ItemGroup>') _p(' <ItemGroup>') cs2005.files(prj) _p(' </ItemGroup>') _p(' <Import Project="$(MSBuildBinPath)\\Microsoft.CSharp.targets" />') _p(' <!-- To modify your build process, add your task inside one of the targets below and uncomment it.') _p(' Other similar extension points exist, see Microsoft.Common.targets.') _p(' <Target Name="BeforeBuild">') _p(' </Target>') _p(' <Target Name="AfterBuild">') _p(' </Target>') _p(' -->') _p('</Project>') end
bsd-3-clause
AlexandreCA/update
scripts/zones/Port_Jeuno/npcs/qm1.lua
17
2397
----------------------------------- -- Area: Port Jeuno -- NPC: ??? -- Finish Quest: Borghertz's Hands (AF Hands, Many job) -- @zone 246 -- @pos -51 8 -4 ----------------------------------- package.loaded["scripts/zones/Port_Jeuno/TextIDs"] = nil; package.loaded["scripts/globals/settings"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/shop"); require("scripts/globals/quests"); require("scripts/zones/Port_Jeuno/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) OldGauntlets = player:hasKeyItem(OLD_GAUNTLETS); ShadowFlames = player:hasKeyItem(SHADOW_FLAMES); BorghertzCS = player:getVar("BorghertzCS"); if (OldGauntlets == true and ShadowFlames == false and BorghertzCS == 1) then player:startEvent(0x0014); elseif (OldGauntlets == true and ShadowFlames == false and BorghertzCS == 2) then player:startEvent(0x0031); elseif (OldGauntlets == true and ShadowFlames == true) then player:startEvent(0x0030); 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 == 0x0014 and option == 1) then player:setVar("BorghertzCS",2); elseif (csid == 0x0030) then NumQuest = 43 + player:getVar("BorghertzAlreadyActiveWithJob"); NumHands = 13960 + player:getVar("BorghertzAlreadyActiveWithJob"); if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,NumHands); else player:addItem(NumHands); player:messageSpecial(ITEM_OBTAINED,NumHands); player:delKeyItem(OLD_GAUNTLETS); player:delKeyItem(SHADOW_FLAMES); player:setVar("BorghertzCS",0); player:setVar("BorghertzAlreadyActiveWithJob",0); player:addFame(JEUNO,30); player:completeQuest(JEUNO,NumQuest); end end end;
gpl-3.0
martolini/Vana
scripts/npcs/contimoveOrbEre.lua
1
1820
--[[ Copyright (C) 2008-2015 Vana Development Team 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --]] -- Kiru dofile("scripts/utils/mapManagerHelper.lua"); dofile("scripts/utils/npcHelper.lua"); price = nil; if getLevel() < 30 then price = 100; else price = 1000; end addText("This ship will head toward " .. blue(mapRef(130000000)) .. ", an island where you'll find crimson leaves soaking up the sun, the gentle breeze that glides past the stream, and the Empress of Maple, Cygnus. "); addText("If you're interested in joining the Cygnus Knights, then you should definitely pay a visit there. "); addText("Are you interested in visiting " .. mapRef(130000000) .. "?\r\n\r\n"); addText("The trip will cost you " .. blue(price) .. " Mesos."); answer = askYesNo(); if answer == answer_no then addText("Not interested? "); addText("Oh well..."); sendNext(); else mapId = queryManagedMap("orbisToEreveTrip"); if mapId == nil then addText("There are no more boats available right now. "); addText("Try again later."); sendNext(); elseif giveMesos(-price) then setMap(mapId); else addText("Hey, you don't have enough Mesos with you... the ride will cost you " .. blue(price) .. " Mesos."); sendNext(); end end
gpl-2.0
AlexandreCA/darkstar
scripts/globals/weaponskills/shadow_of_death.lua
9
1254
----------------------------------- -- Shadow Of Death -- Scythe weapon skill -- Skill Level: 70 -- Delivers a dark elemental attack. Damage varies with TP. -- Aligned with the Snow Gorget & Aqua Gorget. -- Aligned with the Snow Belt & Aqua Belt. -- Element: Dark -- Modifiers: STR:40% ; INT:40% -- 100%TP 200%TP 300%TP -- 1.00 2.50 3.00 ----------------------------------- require("scripts/globals/magic"); require("scripts/globals/status"); require("scripts/globals/settings"); require("scripts/globals/weaponskills"); ----------------------------------- function onUseWeaponSkill(player, target, wsID, tp, primary) local params = {}; params.ftp100 = 1; params.ftp200 = 2.5; params.ftp300 = 3; params.str_wsc = 0.3; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.3; params.mnd_wsc = 0.0; params.chr_wsc = 0.0; params.ele = ELE_DARK; params.skill = SKILL_SYH; params.includemab = true; if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then params.str_wsc = 0.4; params.int_wsc = 0.4; end local damage, criticalHit, tpHits, extraHits = doMagicWeaponskill(player, target, wsID, params, tp, primary); return tpHits, extraHits, criticalHit, damage; end
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Tavnazian_Safehold/npcs/Pradiulot.lua
13
2380
----------------------------------- -- Area: Tavnazian Safehold -- NPC: Pradiulot -- Involved in Quest: Unforgiven -- @zone 26 -- @pos -20.814 -22 8.399 ----------------------------------- package.loaded["scripts/zones/Tavnazian_Safehold/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Tavnazian_Safehold/TextIDs"); require("scripts/globals/quests"); ----------------------------------- -- For those who don't know -- at the end of if (player:getQuestStatus(REGION,QUEST_NAME) -- == 0 means QUEST_AVAILABLE -- == 1 means QUEST_ACCEPTED -- == 2 means QUEST_COMPLETED -- e.g. if (player:getQuestStatus(OTHER_AREAS,UNFORGIVEN) == 0 -- means if (player:getQuestStatus(OTHER_AREAS,UNFORGIVEN) == QUEST AVAILABLE ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if (player:getQuestStatus(OTHER_AREAS,UNFORGIVEN) == 2 and trade:getGil() == 1 == true) then player:startEvent(0x00CE); -- Dialogue after completing quest (optional) end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local Unforgiven = player:getQuestStatus(OTHER_AREAS,UNFORGIVEN); if (Unforgiven == 1 and player:getVar("UnforgivenVar") == 1) then player:startEvent(0x00CC); -- Dialogue for final stage of Unforgiven Quest elseif (player:getQuestStatus(OTHER_AREAS,UNFORGIVEN) == 2 and player:getVar("UnforgivenVar") == 2) then player:startEvent(0x00CE); -- Dialogue after completing quest (optional) else player:startEvent(0x0173); -- Default Dialogue end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); if (csid == 0x00CC) then player:setVar("UnforgivenVar",2); player:addKeyItem(440) player:messageSpecial(KEYITEM_OBTAINED,440); -- Map of Tavnazia player:completeQuest(OTHER_AREAS,UNFORGIVEN); player:addFame(OTHER_AREAS,30); elseif (csid == 0x00CE) then player:setVar("UnforgivenVar",0); end end;
gpl-3.0
AlexandreCA/update
scripts/zones/Uleguerand_Range/npcs/Fissure.lua
19
1692
----------------------------------- -- Area: Uleguerand Range -- NPC: Fissure -- Teleports players from underground to surface -- @pos 380.267 34.859 -179.655 5 -- @pos 460.339 -29.137 220.311 5 -- @pos 180.207 -77.147 500.276 5 ----------------------------------- package.loaded["scripts/zones/Uleguerand_Range/TextIDs"] = nil; ----------------------------------- require("scripts/globals/keyitems"); require("scripts/zones/Uleguerand_Range/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local z = player:getZPos(); if (player:hasKeyItem(MYSTIC_ICE) == true) then if (z > -200 and z < -150) then -- southern Fissure (J-9) player:startEvent(0x0002,MYSTIC_ICE); elseif (z > 200 and z < 250) then -- middle Fissure (K-7) player:startEvent(0x0003,MYSTIC_ICE); elseif (z > 450) then -- northern Fissure (I-6) player:startEvent(0x0004,MYSTIC_ICE); 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 ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if ((csid == 0x0002 or csid == 0x0003 or csid == 0x0004) and option == 2) then player:delKeyItem(MYSTIC_ICE); end end;
gpl-3.0
AlexandreCA/update
scripts/zones/West_Ronfaure/npcs/Harvetour.lua
17
1867
----------------------------------- -- Area: West Ronfaure -- NPC: Harvetour -- Type: Outpost Vendor -- @pos -448 -19 -214 100 ----------------------------------- package.loaded["scripts/zones/West_Ronfaure/TextIDs"] = nil; ----------------------------------- require("scripts/globals/shop"); require("scripts/globals/conquest"); require("scripts/zones/West_Ronfaure/TextIDs"); local region = RONFAURE; local csid = 0x7ff4; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local owner = GetRegionOwner(region); local arg1 = getArg1(owner,player); if (owner == player:getNation()) then nation = 1; elseif (arg1 < 1792) then nation = 2; else nation = 0; end player:startEvent(csid,nation,OP_TeleFee(player,region),0,OP_TeleFee(player,region),player:getCP(),0,0,0); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("OPTION: %u",option); player:updateEvent(player:getGil(),OP_TeleFee(player,region),0,OP_TeleFee(player,region),player:getCP()); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("OPTION: %u",option); if (option == 1) then ShowOPVendorShop(player); elseif (option == 2) then if (player:delGil(OP_TeleFee(player,region))) then toHomeNation(player); end elseif (option == 6) then player:delCP(OP_TeleFee(player,region)); toHomeNation(player); end end;
gpl-3.0
moteus/lzmq-auth
test/test_auth.lua
3
5904
local HAS_RUNNER = not not lunit local lunit = require "lunit" local TEST_CASE = assert(lunit.TEST_CASE) local skip = lunit.skip or function() end local zmq = require "lzmq" local zauth = require "lzmq.auth" local zcert = require "lzmq.cert" local path = require "path" local ZSOCKET_DYNFROM = 0xc000 local ZSOCKET_DYNTO = 0xffff local function dyn_bind (sok, address) local ok, err for port = ZSOCKET_DYNFROM, ZSOCKET_DYNTO do ok, err = sok:bind(address .. ":" .. tostring(port)) if ok then return port end end return nil, err end local _ENV = TEST_CASE "lzmq.auth" do local TESTDIR = ".test_auth" local pass_path = path.join(TESTDIR, "password-file") local auth, ctx, server, client, auth2 local function test_connect() local port_nbr = assert_number(dyn_bind(server, "tcp://127.0.0.1")) assert(client:connect("tcp://127.0.0.1:" .. tostring(port_nbr))) server:send("Hello, World") local success = (client:recv() == "Hello, World") return success end function setup() ctx = assert(zmq.context()) auth = assert(zauth.new(ctx)) assert(auth:start()) auth:verbose(false) -- to wait path.mkdir(TESTDIR) assert(path.isdir(TESTDIR)) server = assert(ctx:socket{zmq.PUSH}) client = assert(ctx:socket{zmq.PULL, rcvtimeo = 200}) end function teardown() if client then client:close() end if server then server:close() end if auth then auth:stop() end if auth2 then auth2:stop() end if ctx then ctx:destroy() end path.each(path.join(TESTDIR, "*.*"), path.remove) -- path.each with lfs <1.6 close dir iterator only on gc. collectgarbage("collect") collectgarbage("collect") path.rmdir(TESTDIR) end function test_null() -- A default NULL connection should always success, and not -- go through our authentication infrastructure at all. assert_true(test_connect()) end function test_null_domain() -- When we set a domain on the server, we switch on authentication -- for NULL sockets, but with no policies, the client connection -- will be allowed. server:set_zap_domain("global") assert_true(test_connect()) end function test_blacklist() -- Blacklist 127.0.0.1, connection should fail server:set_zap_domain("global") auth:deny("127.0.0.1") assert_false(test_connect()) end function test_whitelist() -- Whitelist our address, which overrides the blacklist server:set_zap_domain("global") auth:deny("127.0.0.1") auth:allow("127.0.0.1") assert_true(test_connect()) end function test_plain_no_auth() -- Try PLAIN authentication server:set_plain_server(1) client:set_plain_username("admin") client:set_plain_password("Password") assert_false(test_connect()) end function test_plain() local password = assert(io.open(pass_path, "w+")) password:write("admin=Password\n") password:close() server:set_plain_server(1) client:set_plain_username("admin") client:set_plain_password("Password") auth:configure_plain("*", pass_path) assert_true(test_connect()) end function test_plain_default_domain() local password = assert(io.open(pass_path, "w+")) password:write("admin=Password\n") password:close() server:set_plain_server(1) client:set_plain_username("admin") client:set_plain_password("Password") assert_error(function() auth:configure_plain(pass_path, nil) end) auth:configure_plain(pass_path) assert_true(test_connect()) end function test_plain_wrong_pass() local password = assert(io.open(pass_path, "w+")) password:write("admin=Password\n") password:close() server:set_plain_server(1) client:set_plain_username("admin") client:set_plain_password("Bogus") auth:configure_plain("*", pass_path); assert_false(test_connect()) end function test_curve_fail() -- Try CURVE authentication -- We'll create two new certificates and save the client public -- certificate on disk; in a real case we'd transfer this securely -- from the client machine to the server machine. local server_cert = zcert.new() local client_cert = zcert.new() local server_key = server_cert:public_key(true) -- Test without setting-up any authentication server_cert:apply(server) client_cert:apply(client) server:set_curve_server(1) client:set_curve_serverkey(server_key) assert_false(test_connect()) end function test_curve() -- Try CURVE authentication -- We'll create two new certificates and save the client public -- certificate on disk; in a real case we'd transfer this securely -- from the client machine to the server machine. local server_cert = zcert.new() local client_cert = zcert.new() local server_key = server_cert:public_key(true) -- Test full client authentication using certificates server_cert:apply(server) client_cert:apply(client) server:set_curve_server(1) client:set_curve_serverkey(server_key) client_cert:save_public(path.join(TESTDIR, "mycert.key")) auth:configure_curve("*", TESTDIR) assert_true(test_connect()) end function test_curve_default_domain() -- Try CURVE authentication -- We'll create two new certificates and save the client public -- certificate on disk; in a real case we'd transfer this securely -- from the client machine to the server machine. local server_cert = zcert.new() local client_cert = zcert.new() local server_key = server_cert:public_key(true) -- Test full client authentication using certificates server_cert:apply(server) client_cert:apply(client) server:set_curve_server(1) client:set_curve_serverkey(server_key) client_cert:save_public(path.join(TESTDIR, "mycert.key")) assert_error(function() auth:configure_curve(TESTDIR, nil) end) auth:configure_curve(TESTDIR) assert_true(test_connect()) end function test_start_error() local auth2 = zauth.new(ctx) local ok, err = auth2:start() assert( not ok ) end end if not HAS_RUNNER then lunit.run() end
mit
AlexandreCA/update
scripts/zones/Windurst_Waters_[S]/npcs/Porter_Moogle.lua
41
1550
----------------------------------- -- Area: Windurst Waters [S] -- NPC: Porter Moogle -- Type: Storage Moogle -- @zone 94 -- @pos TODO ----------------------------------- package.loaded["scripts/zones/Windurst_Waters_[S]/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Windurst_Waters_[S]/TextIDs"); require("scripts/globals/porter_moogle_util"); local e = { TALK_EVENT_ID = 523, STORE_EVENT_ID = 524, RETRIEVE_EVENT_ID = 525, ALREADY_STORED_ID = 526, MAGIAN_TRIAL_ID = 527 }; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) porterMoogleTrade(player, trade, e); end ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) -- No idea what the params are, other than event ID and gil. player:startEvent(e.TALK_EVENT_ID, 0x6FFFFF, 0x01, 0x06DD, 0x27, 0x7C7E, 0x15, player:getGil(), 0x03E8); end ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) porterEventUpdate(player, csid, option, e.RETRIEVE_EVENT_ID, RETRIEVE_DIALOG_ID, ITEM_CANNOT_BE_OBTAINED); end ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) porterEventFinish(player, csid, option, e.TALK_EVENT_ID, ITEM_CANNOT_BE_OBTAINED, ITEM_OBTAINED, NOT_HAVE_ENOUGH_GIL); end
gpl-3.0
yasharsa/yashartg
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
lancehilliard/TGNS
mods/tgns/output/lua/shine/extensions/stagedteamjoins.lua
1
2429
//local FIRSTCLIENT_TIME_BEFORE_ALLJOIN = 45 local GAMEEND_TIME_BEFORE_ALLJOIN = TGNS.ENDGAME_TIME_TO_READYROOM + 5 local allMayJoinAt = 0 // Shared.GetSystemTime() + FIRSTCLIENT_TIME_BEFORE_ALLJOIN //local firstClientProcessed = false local md = TGNSMessageDisplayer.Create() local Plugin = {} //function Plugin:ClientConnect(client) // if not firstClientProcessed then // allMayJoinAt = Shared.GetTime() + FIRSTCLIENT_TIME_BEFORE_ALLJOIN // firstClientProcessed = true // end //end function atLeastOneSupportingMemberIsPresent() local result = TGNS.Any(TGNS.GetReadyRoomClients(TGNS.GetPlayerList()), TGNS.IsClientSM) return result end function Plugin:EndGame(gamerules, winningTeam) allMayJoinAt = Shared.GetTime() + GAMEEND_TIME_BEFORE_ALLJOIN -- TGNS.ScheduleAction(TGNS.ENDGAME_TIME_TO_READYROOM + 2.5, function() -- if atLeastOneSupportingMemberIsPresent() then -- if not Shine.Plugins.mapvote or not Shine.Plugins.mapvote:VoteStarted() then -- if not Shine.Plugins.captains or not Shine.Plugins.captains:IsCaptainsModeEnabled() then -- md:ToAllNotifyInfo("Supporting Members get just a few seconds to join their team of choice.") -- end -- end -- end -- end) end function Plugin:JoinTeam(gamerules, player, newTeamNumber, force, shineForce) local cancel = false local balanceIsInProgress = Balance and Balance.IsInProgress() if not force and not shineForce and not balanceIsInProgress and not TGNS.ClientAction(player, TGNS.GetIsClientVirtual) and not TGNS.IsGameInCountdown() and not TGNS.IsGameInProgress() then if TGNS.IsGameplayTeamNumber(newTeamNumber) then if atLeastOneSupportingMemberIsPresent() then local secondsRemainingBeforeAllMayJoin = math.floor(allMayJoinAt - Shared.GetTime()) if secondsRemainingBeforeAllMayJoin > 0 then if not TGNS.ClientAction(player, TGNS.IsClientSM) then local chatMessage = string.format("Supporting Members may join teams now. Wait %s seconds and try again.", secondsRemainingBeforeAllMayJoin) md:ToPlayerNotifyError(player, chatMessage) TGNS.RespawnPlayer(player) cancel = true end end end end end if cancel then return false end end function Plugin:Initialise() self.Enabled = true return true end function Plugin:Cleanup() --Cleanup your extra stuff like timers, data etc. self.BaseClass.Cleanup( self ) end Shine:RegisterExtension("stagedteamjoins", Plugin )
mit
AlexandreCA/darkstar
scripts/zones/Apollyon/Zone.lua
31
11702
----------------------------------- -- -- Zone: Apollyon -- ----------------------------------- require("scripts/globals/settings"); package.loaded["scripts/zones/Apollyon/TextIDs"] = nil; require("scripts/zones/Apollyon/TextIDs"); require("scripts/globals/limbus"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) SetServerVariable("[NW_Apollyon]UniqueID",0); SetServerVariable("[SW_Apollyon]UniqueID",0); SetServerVariable("[NE_Apollyon]UniqueID",0) ; SetServerVariable("[SE_Apollyon]UniqueID",0); SetServerVariable("[CS_Apollyon]UniqueID",0); SetServerVariable("[CS_Apollyon_II]UniqueID",0); SetServerVariable("[Central_Apollyon]UniqueID",0); SetServerVariable("[Central_Apollyon_II]UniqueID",0); zone:registerRegion(1, 637,-4,-642,642,4,-637); -- APPOLLYON_SE_NE exit zone:registerRegion(2, -642,-4,-642,-637,4,-637); -- APPOLLYON_NW_SW exit zone:registerRegion(3, 468,-4,-637, 478,4,-622); -- appolyon SE register zone:registerRegion(4, 421,-4,-98, 455,4,-78); -- appolyon NE register zone:registerRegion(5, -470,-4,-629, -459,4,-620); -- appolyon SW register zone:registerRegion(6, -455,-4,-95, -425,4,-67); -- appolyon NW register zone:registerRegion(7, -3,-4,-214, 3,4,-210); -- appolyon CS register zone:registerRegion(8, -3,-4, 207, 3,4, 215); -- appolyon Center register zone:registerRegion(20, 396,-4,-522, 403,4,-516); -- appolyon SE telporter floor1 to floor2 zone:registerRegion(21, 116,-4,-443, 123,4,-436); -- appolyon SE telporter floor2 to floor3 zone:registerRegion(22, 276,-4,-283, 283,4,-276); -- appolyon SE telporter floor3 to floor4 zone:registerRegion(23, 517,-4,-323, 523,4,-316); -- appolyon SE telporter floor4 to entrance zone:registerRegion(24, 396,-4,76, 403,4,83); -- appolyon NE telporter floor1 to floor2 zone:registerRegion(25, 276,-4,356, 283,4,363); -- appolyon NE telporter floor2 to floor3 zone:registerRegion(26, 236,-4,517, 243,4,523); -- appolyon NE telporter floor3 to floor4 zone:registerRegion(27, 517,-4,637, 523,4,643); -- appolyon NE telporter floor4 to floor5 zone:registerRegion(28, 557,-4,356, 563,4,363); -- appolyon NE telporter floor5 to entrance zone:registerRegion(29, -403,-4,-523, -396,4,-516); -- appolyon SW telporter floor1 to floor2 zone:registerRegion(30, -123,-4,-443, -116,4,-436); -- appolyon SW telporter floor2 to floor3 zone:registerRegion(31, -283,-4,-283, -276,4,-276); -- appolyon SW telporter floor3 to floor4 zone:registerRegion(32, -523,-4,-323, -517,4,-316); -- appolyon SW telporter floor4 to entrance zone:registerRegion(33, -403,-4,76, -396,4,83); -- appolyon NW telporter floor1 to floor2 zone:registerRegion(34, -283,-4,356, -276,4,363); -- appolyon NW telporter floor2 to floor3 zone:registerRegion(35, -243,-4,516, -236,4,523); -- appolyon NW telporter floor3 to floor4 zone:registerRegion(36, -523,-4,636, -516,4,643); -- appolyon NW telporter floor4 to floor5 zone:registerRegion(37, -563,-4,356, -556,4,363); -- appolyon NW telporter floor5 to entrance 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) cs = -1; if (prevZone~=33) then local playerLimbusID = player:getVar("LimbusID"); if (playerLimbusID== 1290 or playerLimbusID== 1291 or playerLimbusID== 1294 or playerLimbusID== 1295 or playerLimbusID== 1296 or playerLimbusID== 1297) then player:setPos(-668,0.1,-666); else player:setPos(643,0.1,-600); end elseif ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then player:setPos(643,0.1,-600); end return cs; end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) local regionID = region:GetRegionID(); switch (regionID): caseof { [1] = function (x) player:startEvent(0x0064); -- APPOLLYON_SE_NE exit end, [2] = function (x) player:startEvent(0x0065); -- APPOLLYON_NW_SW exit -- print("APPOLLYON_NW_SW"); end, [3] = function (x) if (player:hasStatusEffect(EFFECT_BATTLEFIELD) == false) then RegisterLimbusInstance(player,1293); end --create instance appolyon SE end, [4] = function (x) if (player:hasStatusEffect(EFFECT_BATTLEFIELD) == false) then RegisterLimbusInstance(player,1292); end --create instance appolyon NE end, [5] = function (x) if (player:hasStatusEffect(EFFECT_BATTLEFIELD) == false) then RegisterLimbusInstance(player,1291); end --create instance appolyon SW end, [6] = function (x) if (player:hasStatusEffect(EFFECT_BATTLEFIELD) == false) then RegisterLimbusInstance(player,1290); end --create instance appolyon NW end, [7] = function (x) if (player:hasStatusEffect(EFFECT_BATTLEFIELD) == false) then RegisterLimbusInstance(player,1294); end --create instance appolyon CS end, [8] = function (x) if (player:hasStatusEffect(EFFECT_BATTLEFIELD) == false) then RegisterLimbusInstance(player,1296); end --create instance appolyon CENTER end, -- ///////////////////////APPOLLYON SE TELEPORTER/////////////////////////////////////////// [20] = function (x) -- print("SE_telporter_f1_to_f2"); if (IsMobDead(16932992)==true and player:getAnimation()==0) then player:startEvent(0x00DB);end end, [21] = function (x) -- print("SE_telporter_f2_to_f3"); if (IsMobDead(16933006)==true and player:getAnimation()==0) then player:startEvent(0x00DA);end end, [22] = function (x) -- print("SE_telporter_f3_to_f4"); if (IsMobDead(16933020)==true and player:getAnimation()==0) then player:startEvent(0x00D8);end end, [23] = function (x) -- print("SE_telporter_f3_to_entrance"); if (IsMobDead(16933032)==true and player:getAnimation()==0) then player:startEvent(0x00D9);end end, -- /////////////////////////////////////////////////////////////////////////////////////////// -- ///////////////////// APPOLLYON NE TELEPORTER //////////////////////////////// [24] = function (x) -- print("NE_telporter_f1_to_f2"); if (IsMobDead(16933044)==true and player:getAnimation()==0) then player:startEvent(0x00D6);end end, [25] = function (x) -- print("NE_telporter_f2_to_f3"); if (IsMobDead(16933064)==true and player:getAnimation()==0) then player:startEvent(0x00D4);end --212 end, [26] = function (x) -- print("NE_telporter_f3_to_f4"); if (IsMobDead(16933086)==true and player:getAnimation()==0) then player:startEvent(0x00D2);end --210 end, [27] = function (x) -- print("NE_telporter_f4_to_f5"); if (IsMobDead(16933101)==true and player:getAnimation()==0) then player:startEvent(0x00D7);end --215 end, [28] = function (x) -- print("NE_telporter_f5_to_entrance"); if ( (IsMobDead(16933114)==true or IsMobDead(16933113)==true) and player:getAnimation()==0) then player:startEvent(0x00D5);end --213 end, -- ////////////////////////////////////////////////////////////////////////////////////////////////// -- ///////////////////// APPOLLYON SW TELEPORTER //////////////////////////////// [29] = function (x) if (IsMobDead(16932873)==true and player:getAnimation()==0) then player:startEvent(0x00D0);end --208 end, [30] = function (x) if (IsMobDead(16932885)==true and player:getAnimation()==0) then player:startEvent(0x00D1);end --209 --printf("Mimics should be 0: %u",GetServerVariable("[SW_Apollyon]MimicTrigger")); end, [31] = function (x) if (( IsMobDead(16932896)==true or IsMobDead(16932897)==true or IsMobDead(16932898)==true or IsMobDead(16932899)==true )and player:getAnimation()==0) then player:startEvent(0x00CF);end -- 207 end, [32] = function (x) if (IselementalDayAreDead()==true and player:getAnimation()==0) then player:startEvent(0x00CE);end -- 206 end, -- ////////////////////////////////////////////////////////////////////////////////////////////////// -- ///////////////////// APPOLLYON NW TELEPORTER //////////////////////////////// [33] = function (x) if (IsMobDead(16932937)==true and player:getAnimation()==0) then player:startEvent(0x00CD);end --205 end, [34] = function (x) if (IsMobDead(16932950)==true and player:getAnimation()==0) then player:startEvent(0x00CB);end --203 end, [35] = function (x) if (IsMobDead(16932963)==true and player:getAnimation()==0) then player:startEvent(0x00C9);end --201 end, [36] = function (x) if (IsMobDead(16932976)==true and player:getAnimation()==0) then player:startEvent(0x00C8);end --200 end, [37] = function (x) if (IsMobDead(16932985)==true and player:getAnimation()==0) then player:startEvent(0x00CA);end --202 end, } end; ----------------------------------- -- onRegionLeave ----------------------------------- function onRegionLeave(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x00D1 and option == 0 and GetServerVariable("[SW_Apollyon]MimicTrigger")==0) then SpawnCofferSWfloor3(); --printf("Mimics should be 1: %u",GetServerVariable("[SW_Apollyon]MimicTrigger")); elseif (csid == 0x00CF and option == 0 and GetServerVariable("[SW_Apollyon]ElementalTrigger")==0) then SetServerVariable("[SW_Apollyon]ElementalTrigger",VanadielDayElement()+1); -- printf("Elementals should be 1: %u",GetServerVariable("[SW_Apollyon]ElementalTrigger")); end end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x0064 and option == 1) then player:setPos(557,-1,441,128,0x21); -- APPOLLYON_SE_NE exit elseif (csid == 0x0065 and option == 1) then player:setPos(-561,0,443,242,0x21); -- APPOLLYON_NW_SW exit end end;
gpl-3.0
bruceburge/Non-Random-Spawn-Oxide-Plugin
Meph.NonRandomSpawn.lua
1
3771
PLUGIN.Title = "Non Random Spawn" PLUGIN.Description = "Sets first time spawn to a fixed location" PLUGIN.Version = "0.2.0" PLUGIN.Author = "Meph" -- Called when oxide loads or user types oxide.reload example at F1 console function PLUGIN:Init() self:AddChatCommand("nrsSetLocation", self.cmdSetLocation) --attempt to load config file self.LocationFile, self.Location = self:readFileToMap("nrsLocation") --check if config file had valid data structure if(tablelength(self.Location) > 0 and tablelength(self.Location.Pos) == 3) then print( self.Title .. "Spawn location x:"..self.Location.Pos.x.." y:"..self.Location.Pos.y.." z:"..self.Location.Pos.z) else --if we got a blank table back from the config loader then create the structure and save it to the config file self.Location = {} self.Location.Pos = {} self.Location.Pos.x = 0 self.Location.Pos.y = 0 self.Location.Pos.z = 0 self:SaveMapToFile(self.Location,self.LocationFile) end print( self.Title .. " v" .. self.Version .. " loaded!" ) end function PLUGIN:OnSpawnPlayer ( playerclient, usecamp, avatar ) if (not playerclient) then print( self.Title .. " no player client") return end if (playerclient.netuser.playerClient.hasLastKnownPosition ) then --print( self.Title .. "player has known location no tp") return end if (usecamp) then --print( self.Title .. " using camp no tp") return end self:TeleportNetuser(playerclient.netuser, self.Location.Pos.x,self.Location.Pos.y,self.Location.Pos.z) end function PLUGIN:cmdSetLocation(netuser, cmd, args) local isAuthorized = netuser:CanAdmin() or (oxmin_Plugin and oxmin_Plugin:HasFlag(netuser, self.FLAG_nrsSetter, false)) if not isAuthorized then rust.SendChatToUser( netuser,"You are not authorized to set spawn location ") return end local pos = netuser.playerClient.lastKnownPosition print( self.Title..": set spawn location "..pos.x..","..pos.y..","..pos.z) self.Location = {} self.Location.Pos = {} self.Location.Pos.x = pos.x self.Location.Pos.y = pos.y self.Location.Pos.z = pos.z self:SaveMapToFile(self.Location,self.LocationFile) rust.SendChatToUser( netuser, "Spawn Location Set") end -- Teleport NetUser to Specific Coordinates function PLUGIN:TeleportNetuser(netuser, x, y, z) local coords = netuser.playerClient.lastKnownPosition coords.x ,coords.y ,coords.z = x,y,z -- make sure the values aren't default before warping if(x ~= 0 and y~= 0 and z~=0) then --timer wrapper because without it, the teleport will kill player. timer.Once( 0, function() rust.ServerManagement():TeleportPlayer(netuser.playerClient.netPlayer, coords) --TODO: rust.SendChatToUser( netuser,_CONFIG_._TELEPORTMESSAGE_) end) end end -- Automated Oxide help function (added to /help list) function PLUGIN:SendHelpText( netuser ) local isAuthorized = netuser:CanAdmin() or (oxmin_Plugin and oxmin_Plugin:HasFlag(netuser, self.FLAG_nrsSetter, false)) if not isAuthorized then return end --only add to help for admins rust.SendChatToUser( netuser, "Use /nrsSetLocation to set spawn to your current location." ) end function PLUGIN:readFileToMap(filename, map) local file = util.GetDatafile(filename) local txt = file:GetText() if (txt ~= "") then local decoded = json.decode( txt ) print( self.Title ..": ".. filename.." loaded: ") return file, decoded else print( self.Title ..": "..filename.." not loaded: ") return file, {} end end function PLUGIN:SaveMapToFile(table, file) file:SetText( json.encode( table ) ) file:Save() end function tablelength(table) local count = 0 for _ in pairs(table) do count = count + 1 end return count end
unlicense
AlexandreCA/darkstar
scripts/globals/abilities/reverse_flourish.lua
12
2324
----------------------------------- -- Ability: Reverse Flourish -- Converts remaining finishing moves into TP. Requires at least one Finishing Move. -- Obtained: Dancer Level 40 -- Finishing Moves Used: 1-5 -- Recast Time: 00:30 ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); ----------------------------------- -- onAbilityCheck ----------------------------------- function onAbilityCheck(player,target,ability) if (player:hasStatusEffect(EFFECT_FINISHING_MOVE_1)) then return 0,0; elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_2)) then return 0,0; elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_3)) then return 0,0; elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_4)) then return 0,0; elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_5)) then return 0,0; else return MSGBASIC_NO_FINISHINGMOVES,0; end; end; ----------------------------------- -- onUseAbility ----------------------------------- function onUseAbility(player,target,ability) local TPGain = 0; local STM = 0.5; if player:getEquipID(SLOT_HANDS) == 11222 then STM = 1.0; elseif player:getEquipID(SLOT_HANDS) == 11122 then STM = 1.5; end local Merits = player:getMerit(MERIT_REVERSE_FLOURISH_EFFECT); if (player:hasStatusEffect(EFFECT_FINISHING_MOVE_1)) then TPGain = 9.5 * 1 + STM * 1 ^ 2 + Merits; elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_2)) then TPGain = 9.5 * 2 + STM * 2 ^ 2 + Merits; elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_3)) then TPGain = 9.5 * 3 + STM * 3 ^ 2 + Merits; elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_4)) then TPGain = 9.5 * 4 + STM * 4 ^ 2 + Merits; elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_5)) then TPGain = 9.5 * 5 + STM * 5 ^ 2 + Merits; end; TPGain = TPGain * 10; player:addTP(TPGain); player:delStatusEffect(EFFECT_FINISHING_MOVE_1); player:delStatusEffect(EFFECT_FINISHING_MOVE_2); player:delStatusEffect(EFFECT_FINISHING_MOVE_3); player:delStatusEffect(EFFECT_FINISHING_MOVE_4); player:delStatusEffect(EFFECT_FINISHING_MOVE_5); return TPGain; end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Castle_Oztroja/npcs/relic.lua
13
1848
----------------------------------- -- Area: Castle Oztroja -- NPC: <this space intentionally left blank> -- @pos -104 -73 85 151 ----------------------------------- package.loaded["scripts/zones/Castle_Oztroja/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Castle_Oztroja/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- Working on correct relic, 4 items, Stage 4 item, Shard, Necropsyche, currencypiece if (player:getVar("RELIC_IN_PROGRESS") == 18263 and trade:getItemCount() == 4 and trade:hasItemQty(18263,1) and trade:hasItemQty(1571,1) and trade:hasItemQty(1589,1) and trade:hasItemQty(1457,1)) then player:startEvent(59,18264); end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:messageSpecial(NOTHING_OUT_OF_ORDINARY); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); if (csid == 59) then if (player:getFreeSlotsCount() < 2) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,18264); player:messageSpecial(FULL_INVENTORY_AFTER_TRADE,1456); else player:tradeComplete(); player:addItem(18264); player:addItem(1456,30); player:messageSpecial(ITEM_OBTAINED,18264); player:messageSpecial(ITEMS_OBTAINED,1456,30); player:setVar("RELIC_IN_PROGRESS",0); end end end;
gpl-3.0
elfinlazz/melia
system/scripts/npc/field/f_rokas_26.lua
1
9775
addnpc(20142, "QUEST_LV_0100_20150317_001278", "f_rokas_26", 42, 1739, -1171, -45, "npc_dummy") addnpc(20016, "QUEST_LV_0100_20150317_001281", "f_rokas_26", -406, 1837, -312, 45, "npc_dummy") addnpc(20016, "QUEST_LV_0100_20150317_000372", "f_rokas_26", 923, 1670, -749, 45, "npc_dummy") addnpc(20118, "QUEST_LV_0100_20150317_001284", "f_rokas_26", -49, 1739, -1210, 45, "npc_dummy") addnpc(47201, "ITEM_20150317_003027", "f_rokas_26", 1013, 1670, -1558, 45, "npc_dummy") addnpc(47201, "ITEM_20150317_003027", "f_rokas_26", 1143, 1670, -1121, 45, "npc_dummy") addnpc(47201, "ITEM_20150317_003027", "f_rokas_26", 1183, 1670, -1363, 45, "npc_dummy") addnpc(47201, "ITEM_20150317_003027", "f_rokas_26", 1181, 1670, -1526, 45, "npc_dummy") addnpc(47201, "ITEM_20150317_003027", "f_rokas_26", 1058, 1670, -1037, -45, "npc_dummy") addnpc(47201, "ITEM_20150317_003027", "f_rokas_26", 1196, 1670, -1232, 45, "npc_dummy") addnpc(47201, "ITEM_20150317_003027", "f_rokas_26", 826, 1670, -1198, 45, "npc_dummy") addnpc(47201, "ITEM_20150317_003027", "f_rokas_26", 1224, 1670, -1296, 45, "npc_dummy") addnpc(47201, "ITEM_20150317_003027", "f_rokas_26", 1193, 1670, -1167, 45, "npc_dummy") addnpc(47201, "ITEM_20150317_003027", "f_rokas_26", 1019, 1670, -1479, 45, "npc_dummy") addnpc(47201, "ITEM_20150317_003027", "f_rokas_26", 928, 1670, -1213, 45, "npc_dummy") addnpc(47201, "ITEM_20150317_003027", "f_rokas_26", 968, 1670, -1298, 45, "npc_dummy") addnpc(10043, "ITEM_20150317_003029", "f_rokas_26", -1179, 2093, 784, 45, "npc_dummy") addnpc(10043, "ITEM_20150317_003029", "f_rokas_26", -1146, 2093, 826, 45, "npc_dummy") addnpc(10043, "ITEM_20150317_003029", "f_rokas_26", -1386, 2093, 814, 45, "npc_dummy") addnpc(10043, "ITEM_20150317_003029", "f_rokas_26", -1341, 2093, 766, 45, "npc_dummy") addnpc(10043, "ITEM_20150317_003029", "f_rokas_26", -1340, 2093, 940, 45, "npc_dummy") addnpc(10043, "ITEM_20150317_003029", "f_rokas_26", -1115, 2093, 925, 45, "npc_dummy") addnpc(10043, "ITEM_20150317_003029", "f_rokas_26", -1289, 2015, 457, 45, "npc_dummy") addnpc(10043, "ITEM_20150317_003029", "f_rokas_26", -1092, 2015, 551, 45, "npc_dummy") addnpc(10043, "ITEM_20150317_003029", "f_rokas_26", -991, 2015, 474, 45, "npc_dummy") addnpc(10043, "ITEM_20150317_003029", "f_rokas_26", -987, 2015, 250, 45, "npc_dummy") addnpc(10043, "ITEM_20150317_003029", "f_rokas_26", -1000, 2015, 210, 45, "npc_dummy") addnpc(10043, "ITEM_20150317_003029", "f_rokas_26", -1061, 2015, 126, 45, "npc_dummy") addnpc(10043, "ITEM_20150317_003029", "f_rokas_26", -1128, 2015, 70, 45, "npc_dummy") addnpc(147372, "ETC_20150804_014185", "f_rokas_26", -1117.032, 2168.34, 1548.978, 45, "npc_dummy") addnpc(147405, "QUEST_LV_0100_20150317_001286", "f_rokas_26", -340, 1738, -1440, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", 1090, 1670, -1431, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", 1232.232, 1670.067, -606.4296, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", 1697.524, 1722.86, -70.34364, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", -530.0923, 1761.812, -999.4754, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", -130.4085, 1836.6, -343.4164, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", 56.90261, 1836.6, 652.4448, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", -622.9779, 1938.6, 452.8378, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", -1109.115, 2015.318, 298.2169, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", -1265.19, 2015.318, 350.3629, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", -1240.616, 2093.517, 866.124, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", 1123.74, 1670.067, -2283.188, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", 1269.898, 1670.067, -1807.297, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", 975.9224, 1670.067, -1913.241, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", 1132.79, 1670.067, -1892.028, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", 1037.492, 1670.067, -1165.422, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", 953.2856, 1670.067, -927.5645, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", 1880.087, 1722.86, -234.9917, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", 1614, 1722, -371, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", -623.1043, 1805.33, -739.4564, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", 50.07603, 1836.6, -173.4256, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", 235.2008, 1836.6, 341.5596, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", 94.76505, 1836.6, 426.5108, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", -1209.114, 2015.318, 131.6314, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", -1454.758, 2168.34, 1342.088, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", -1119.969, 2168.34, 1642.898, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", -1160, 2168, 1319, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", -958.4808, 2168.34, 1500.241, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", 42.52741, 2140.5, 1782.511, 45, "npc_dummy") addnpc(147372, "ETC_20150317_009450", "f_rokas_26", 30.31939, 2140.5, 1582.565, 45, "npc_dummy") addnpc(147366, "ETC_20150317_009233", "f_rokas_26", -308.3382, 1738.3, -1457.703, 45, "npc_dummy") addnpc(147366, "ETC_20150317_009233", "f_rokas_26", 112.6538, 1738.3, -1131.566, 45, "npc_dummy") addnpc(147366, "ETC_20150317_009233", "f_rokas_26", -951.1649, 1767.128, -1759.029, 45, "npc_dummy") addnpc(147366, "ETC_20150317_009233", "f_rokas_26", -619.9429, 1738.557, -1670.718, 45, "npc_dummy") addnpc(57038, "ETC_20150317_000894", "f_rokas_26", 1337.859, 1670.067, -590.4032, 45, "npc_dummy") addnpc(57038, "ETC_20150317_000894", "f_rokas_26", -1197.5, 2168.34, 1448.956, 51, "npc_dummy") addnpc(57038, "ETC_20150317_000894", "f_rokas_26", -205.8421, 1836.6, -415.1861, 45, "npc_dummy") addnpc(45136, "QUEST_LV_0200_20150317_000504", "f_rokas_26", 2000.746, 1722.86, -26.28829, 45, "npc_dummy") addnpc(45136, "QUEST_LV_0200_20150317_000504", "f_rokas_26", 1636.305, 1722.86, -97.75717, 45, "npc_dummy") addnpc(45136, "QUEST_LV_0200_20150317_000504", "f_rokas_26", 1198.012, 1670.067, -556.2982, 45, "npc_dummy") addnpc(45136, "QUEST_LV_0200_20150317_000504", "f_rokas_26", 1183.78, 1670.067, -1271.093, 45, "npc_dummy") addnpc(45136, "QUEST_LV_0200_20150317_000504", "f_rokas_26", 821.7767, 1670.067, -962.6804, 45, "npc_dummy") addnpc(45136, "QUEST_LV_0200_20150317_000504", "f_rokas_26", 1350.56, 1670.067, -1846.795, 45, "npc_dummy") addnpc(45136, "QUEST_LV_0200_20150317_000504", "f_rokas_26", 261.9757, 1738.3, -1448.668, 45, "npc_dummy") addnpc(45136, "QUEST_LV_0200_20150317_000504", "f_rokas_26", -362.9111, 1738.3, -1716.797, 45, "npc_dummy") addnpc(45136, "QUEST_LV_0200_20150317_000504", "f_rokas_26", -630.7979, 1798.684, -774.2977, 45, "npc_dummy") addnpc(45136, "QUEST_LV_0200_20150317_000504", "f_rokas_26", 76.56154, 1836.6, -331.2823, 45, "npc_dummy") addnpc(45136, "QUEST_LV_0200_20150317_000504", "f_rokas_26", 167.0485, 1836.6, 527.9109, 45, "npc_dummy") addnpc(45136, "QUEST_LV_0200_20150317_000504", "f_rokas_26", -578.3215, 1938.6, 499.2757, 45, "npc_dummy") addnpc(45136, "QUEST_LV_0200_20150317_000504", "f_rokas_26", -1004.517, 2015.318, 319.564, 45, "npc_dummy") addnpc(45136, "QUEST_LV_0200_20150317_000504", "f_rokas_26", -1210.203, 2093.517, 844.5256, 45, "npc_dummy") addnpc(45136, "QUEST_LV_0200_20150317_000504", "f_rokas_26", -1078.653, 2168.34, 1765.677, 45, "npc_dummy") addnpc(45136, "QUEST_LV_0200_20150317_000504", "f_rokas_26", 10.7306, 2140.5, 1774.75, 45, "npc_dummy") addnpc(45136, "QUEST_LV_0200_20150317_000504", "f_rokas_26", 508.1066, 1738.3, -1930.209, 45, "npc_dummy") addnpc(47106, "ETC_20150317_005293", "f_rokas_26", -1503.52, 2015.318, 232.3539, 45, "npc_dummy") addnpc(47106, "ETC_20150317_005293", "f_rokas_26", -1359.735, 2168.34, 1179.565, 45, "npc_dummy") addnpc(47106, "ETC_20150317_005293", "f_rokas_26", -143.99, 2140, 1496.51, 45, "npc_dummy") addnpc(147366, "ETC_20150317_009233", "f_rokas_26", -1236.018, 2015.318, 422.9372, 45, "npc_dummy") addnpc(57038, "ETC_20150317_000894", "f_rokas_26", -229.5443, 1836.6, -253.6168, 45, "npc_dummy") addnpc(57038, "ETC_20150317_000894", "f_rokas_26", -108.8394, 1836.6, -148.2667, 45, "npc_dummy") addnpc(57038, "ETC_20150317_000894", "f_rokas_26", -105.6722, 1836.6, -319.4214, 45, "npc_dummy") addnpc(57038, "ETC_20150317_000894", "f_rokas_26", -21.83044, 1836.6, -433.6986, 45, "npc_dummy") addnpc(57038, "ETC_20150317_000894", "f_rokas_26", 41.32026, 1836.6, -234.9978, 45, "npc_dummy") addnpc(57038, "ETC_20150317_000894", "f_rokas_26", -1458.265, 2168.34, 1306.892, 45, "npc_dummy") addnpc(57038, "ETC_20150317_000894", "f_rokas_26", -1294.906, 2168.34, 1238.013, 45, "npc_dummy") addnpc(57038, "ETC_20150317_000894", "f_rokas_26", -1361.935, 2168.34, 1523.256, 45, "npc_dummy") addnpc(57038, "ETC_20150317_000894", "f_rokas_26", -1084.583, 2168.34, 1755.784, 45, "npc_dummy") addnpc(57038, "ETC_20150317_000894", "f_rokas_26", -1192.396, 2168.34, 1636.219, 45, "npc_dummy") addnpc(57038, "ETC_20150317_000894", "f_rokas_26", -985.2193, 2168.34, 1562.761, 45, "npc_dummy") addnpc(57038, "ETC_20150317_000894", "f_rokas_26", -1031.093, 2168.34, 1348.025, 45, "npc_dummy") addnpc(147392, "ETC_20150317_009100", "f_rokas_26", 2048.05, 1722.96, 204, 45, "npc_dummy")
gpl-3.0
AlexandreCA/update
scripts/zones/Southern_San_dOria/Zone.lua
28
2885
----------------------------------- -- -- Zone: Southern_San_dOria (230) -- ----------------------------------- package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/events/harvest_festivals"); require("scripts/globals/zone"); require("scripts/globals/settings"); require("scripts/zones/Southern_San_dOria/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) zone:registerRegion(1, -292,-10,90 ,-258,10,105); applyHalloweenNpcCostumes(zone:getID()) end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) local cs = -1; -- FIRST LOGIN (START CS) if (player:getPlaytime(false) == 0) then if (OPENING_CUTSCENE_ENABLE == 1) then cs = 0x1f7; end player:setPos(-96,1,-40,224); player:setHomePoint(); end -- MOG HOUSE EXIT if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then player:setPos(161,-2,161,94); if (player:getMainJob() ~= player:getVar("PlayerMainJob")) then cs = 0x7534; end player:setVar("PlayerMainJob",0); 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) local regionID =region:GetRegionID(); if (regionID==1 and player:getCurrentMission(COP) == DAWN and player:getVar("COP_louverance_story")== 2) then player:startEvent(0x02F6); end end; ----------------------------------- -- onRegionLeave ----------------------------------- function onRegionLeave(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x1f7) then player:messageSpecial(ITEM_OBTAINED,0x218); elseif (csid == 0x7534 and option == 0) then player:setHomePoint(); player:messageSpecial(HOMEPOINT_SET); elseif (csid == 0x02F6) then player:setVar("COP_louverance_story",3); end end;
gpl-3.0
AlexandreCA/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
AlexandreCA/darkstar
scripts/globals/abilities/hasso.lua
27
1129
----------------------------------- -- Ability: Hasso -- Grants a bonus to attack speed, accuracy, and Strength when using two-handed weapons, but increases recast and casting times. -- Obtained: Samurai Level 25 -- Recast Time: 1:00 -- Duration: 5:00 ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); ----------------------------------- -- onAbilityCheck ----------------------------------- function onAbilityCheck(player,target,ability) if (not target:isWeaponTwoHanded()) then return MSGBASIC_NEEDS_2H_WEAPON,0; else return 0,0; end end; ----------------------------------- -- onUseAbility ----------------------------------- function onUseAbility(player,target,ability) local strboost = target:getMainLvl()/7; if (target:getMainJob()~=12) then --sjob sam, use sub level strboost = target:getSubLvl()/7; end if (target:isWeaponTwoHanded()) then target:delStatusEffect(EFFECT_HASSO); target:delStatusEffect(EFFECT_SEIGAN); target:addStatusEffect(EFFECT_HASSO,strboost,0,300); end end;
gpl-3.0
AlexandreCA/update
scripts/globals/spells/bluemagic/feather_barrier.lua
18
1353
----------------------------------------- -- Spell: Feather Barrier -- Enhances evasion -- Spell cost: 29 MP -- Monster Type: Birds -- Spell Type: Magical (Wind) -- Blue Magic Points: 2 -- Stat Bonus: None -- Level: 56 -- Casting Time: 2 seconds -- Recast Time: 120 seconds -- Duration: 30 Seconds -- -- Combos: Resist Gravity ----------------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); require("scripts/globals/bluemagic"); ----------------------------------------- -- OnMagicCastingCheck ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; ----------------------------------------- -- OnSpellCast ----------------------------------------- function onSpellCast(caster,target,spell) local typeEffect = EFFECT_EVASION_BOOST; local power = 10; local duration = 30; if (caster:hasStatusEffect(EFFECT_DIFFUSION)) then local diffMerit = caster:getMerit(MERIT_DIFFUSION); if (diffMerit > 0) then duration = duration + (duration/100)* diffMerit; end; caster:delStatusEffect(EFFECT_DIFFUSION); end; if (target:addStatusEffect(typeEffect,power,0,duration) == false) then spell:setMsg(75); end; return typeEffect; end;
gpl-3.0
AlexandreCA/update
scripts/zones/The_Eldieme_Necropolis/npcs/_5fd.lua
34
1106
----------------------------------- -- Area: The Eldieme Necropolis -- NPC: Shiva's Gate -- @pos 110 -34 -60 195 ----------------------------------- package.loaded["scripts/zones/The_Eldieme_Necropolis/TextIDs"] = nil; ----------------------------------- require("scripts/zones/The_Eldieme_Necropolis/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (npc:getAnimation() == 9) then player:messageSpecial(SOLID_STONE); end return 0; end; -- ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
Fornost461/yet-another-tetris-like-game
src/code/Square.lua
1
1317
require("code.Vector") Square = {} Square.__index = Square Square.halfGap = 1 Square.visibleLength = 16 Square.length = Square.visibleLength + Square.halfGap function Square.new(position) return setmetatable( { position = position or Vector() -- row and column in a grid }, Square ) end setmetatable(Square, { __call = function (t, ...) return Square.new(...) end }) local fromCornerToCenter = (directions.right + directions.down) / 2 local fromCenterToCorner = -fromCornerToCenter function Square:getCenter() return self.position + fromCornerToCenter end function Square:setCenter(position) self.position = position + fromCenterToCorner end function Square:isBlocked(direction, frozenSquares) local target = self.position + direction return frozenSquares:invalidCoords(target) or frozenSquares:squareAt(target) end function Square:forceTranslation(vector) self.position = vector:translate(self.position) end function Square:realPosition(grid) return grid.position + (Square.length * (self.position + Vector(-1, -1))) end function Square:draw(grid) local location = self:realPosition(grid) love.graphics.rectangle("fill", location.x + Square.halfGap, location.y + Square.halfGap, Square.visibleLength, Square.visibleLength) end
cc0-1.0
AlexandreCA/darkstar
scripts/zones/Port_Bastok/npcs/Rafaela.lua
13
1083
----------------------------------- -- Area: Port Bastok -- NPC: Rafaela -- Standard Info NPC ----------------------------------- package.loaded["scripts/zones/Port_Bastok/TextIDs"] = nil; require("scripts/zones/Port_Bastok/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x0016); 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); PastPerfectVar = player:getVar("PastPerfectVar"); if (csid == 0x0016 and PastPerfectVar == 1) then player:setVar("PastPerfectVar",2); end end;
gpl-3.0
AlexandreCA/update
scripts/zones/Dynamis-Qufim/mobs/Goblin_Replica.lua
4
1185
----------------------------------- -- Area: Dynamis qufim -- NPC: Goblin Replica ----------------------------------- package.loaded["scripts/zones/Dynamis-Qufim/TextIDs"] = nil; ----------------------------------- require("scripts/globals/dynamis"); require("scripts/zones/Dynamis-Qufim/TextIDs"); ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) mob:setMobMod(MOBMOD_SUPERLINK, mob:getShortID()); end; ----------------------------------- -- onMobEngaged ----------------------------------- function onMobEngaged(mob,target) dynamis.spawnGroup(mob, QufimGoblinList); end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob,killer) local mobID = mob:getID(); if ( mobID == 16945528 or mobID == 16945538 or mobID == 16945546 ) then --hp killer:messageBasic(024,(killer:getMaxHP()-killer:getHP())); killer:restoreHP(3000); elseif (mobID == 16945529 or mobID == 16945545) then --mp killer:messageBasic(025,(killer:getMaxMP()-killer:getMP())); killer:restoreMP(3000); end end;
gpl-3.0
AlexandreCA/update
scripts/globals/items/kusamochi+1.lua
35
2086
----------------------------------------- -- ID: 6263 -- Item: kusamochi+1 -- Food Effect: 60 Min, All Races ----------------------------------------- -- HP + 30 (Pet & Master) -- Vitality + 4 (Pet & Master) -- Attack + 21% Cap: 77 (Pet & Master) Pet Cap: 120 -- Ranged Attack + 21% Cap: 77 (Pet & Master) Pet Cap: 120 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD)) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,3600,6263); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_HP, 30) target:addMod(MOD_VIT, 4) target:addMod(MOD_FOOD_ATTP, 21) target:addMod(MOD_FOOD_ATT_CAP, 77) target:addMod(MOD_FOOD_RATTP, 16) target:addMod(MOD_FOOD_RATT_CAP, 77) target:addPetMod(MOD_HP, 30) target:addPetMod(MOD_VIT, 4) target:addPetMod(MOD_FOOD_ATTP, 21) target:addPetMod(MOD_FOOD_ATT_CAP, 120) target:addPetMod(MOD_FOOD_RATTP, 21) target:addPetMod(MOD_FOOD_RATT_CAP, 120) end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_HP, 30) target:delMod(MOD_VIT, 4) target:delMod(MOD_FOOD_ATTP, 21) target:delMod(MOD_FOOD_ATT_CAP, 77) target:delMod(MOD_FOOD_RATTP, 16) target:delMod(MOD_FOOD_RATT_CAP, 77) target:delPetMod(MOD_HP, 30) target:delPetMod(MOD_VIT, 4) target:delPetMod(MOD_FOOD_ATTP, 21) target:delPetMod(MOD_FOOD_ATT_CAP, 120) target:delPetMod(MOD_FOOD_RATTP, 21) target:delPetMod(MOD_FOOD_RATT_CAP, 120) end;
gpl-3.0
AlexandreCA/update
scripts/zones/Castle_Oztroja/npcs/Antiqix.lua
32
7283
----------------------------------- -- Area: Castle Oztroja -- NPC: Antiqix -- Type: Dynamis Vendor -- @pos -207.835 -0.751 -25.498 151 ----------------------------------- package.loaded["scripts/zones/Castle_Oztroja/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Castle_Oztroja/TextIDs"); require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/dynamis"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) local count = trade:getItemCount(); local buying = false; local exchange; local gil = trade:getGil(); if (player:hasKeyItem(VIAL_OF_SHROUDED_SAND) == true) then if (count == 1 and gil == TIMELESS_HOURGLASS_COST) then -- Hourglass purchase player:startEvent(54); elseif (gil == 0) then if (count == 1 and trade:hasItemQty(4236,1)) then -- Bringing back a Timeless Hourglass player:startEvent(97); -- Currency Exchanges elseif (count == CURRENCY_EXCHANGE_RATE and trade:hasItemQty(1449,CURRENCY_EXCHANGE_RATE)) then -- Single -> Hundred player:startEvent(55,CURRENCY_EXCHANGE_RATE); elseif (count == CURRENCY_EXCHANGE_RATE and trade:hasItemQty(1450,CURRENCY_EXCHANGE_RATE)) then -- Hundred -> Ten thousand player:startEvent(56,CURRENCY_EXCHANGE_RATE); elseif (count == 1 and trade:hasItemQty(1451,1)) then -- Ten thousand -> 100 Hundreds player:startEvent(58,1451,1450,CURRENCY_EXCHANGE_RATE); -- Currency Shop elseif (count == 7 and trade:hasItemQty(1450,7)) then -- Angel Skin (1312) buying = true; exchange = {7, 1312}; elseif (count == 23 and trade:hasItemQty(1450,23)) then -- Chronos Tooth (1463) buying = true; exchange = {23,1463}; elseif (count == 8 and trade:hasItemQty(1450,8)) then -- Colossal Skull (1518) buying = true; exchange = {8, 1518}; elseif (count == 28 and trade:hasItemQty(1450,28)) then -- Damascus Ingot (658) buying = true; exchange = {28, 658}; elseif (count == 9 and trade:hasItemQty(1450,9)) then -- Lancewood Log (1464) buying = true; exchange = {9, 1464}; elseif (count == 25 and trade:hasItemQty(1450,25)) then -- Lancewood Lumber (1462) buying = true; exchange = {25, 1462}; elseif (count == 24 and trade:hasItemQty(1450,24)) then -- Relic Steel (1467) buying = true; exchange = {24, 1467}; end end end -- Handle the shop trades. -- Item obtained dialog appears before CS. Could be fixed with a non-local variable and onEventFinish, but meh. if (buying == true) then if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,exchange[2]); else player:startEvent(57,1450,exchange[1],exchange[2]); player:tradeComplete(); player:addItem(exchange[2]); player:messageSpecial(ITEM_OBTAINED,exchange[2]); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:hasKeyItem(VIAL_OF_SHROUDED_SAND) == true) then player:startEvent(53, 1449, CURRENCY_EXCHANGE_RATE, 1450, CURRENCY_EXCHANGE_RATE, 1451, TIMELESS_HOURGLASS_COST, 4236, TIMELESS_HOURGLASS_COST); else player:startEvent(50); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("Update CSID: %u",csid); -- printf("Update RESULT: %u",option); if (csid == 53) then if (option == 11) then -- Main menu, and many others. Param1 = map bitmask, param2 = player's gil player:updateEvent(getDynamisMapList(player), player:getGil()); elseif (option == 10) then -- Final line of the ancient currency explanation. "I'll trade you param3 param2s for a param1." player:updateEvent(1451, 1450, CURRENCY_EXCHANGE_RATE); -- Map sales handling. elseif (option >= MAP_OF_DYNAMIS_SANDORIA and option <= MAP_OF_DYNAMIS_TAVNAZIA) then -- The returned option is actually the keyitem ID, making this much easier. -- The prices are set in the menu's dialog, so they cannot be (visibly) changed. if (option == MAP_OF_DYNAMIS_BEAUCEDINE) then -- 15k gil player:delGil(15000); elseif (option == MAP_OF_DYNAMIS_XARCABARD or option == MAP_OF_DYNAMIS_TAVNAZIA) then -- 20k gil player:delGil(20000); else -- All others 10k player:delGil(10000); end player:addKeyItem(option); player:updateEvent(getDynamisMapList(player),player:getGil()); -- Ancient Currency shop menu elseif (option == 2) then -- Hundreds sales menu Page 1 (price1 item1 price2 item2 price3 item3 price4 item4) player:updateEvent(7,1312,23,1463,8,1518,28,658); elseif (option == 3) then -- Hundreds sales menu Page 2 (price1 item1 price2 item2 price3 item3) player:updateEvent(9,1464,25,1462,24,1467); end end end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("Finish CSID: %u",csid); -- printf("Finish RESULT: %u",option); if (csid == 54) then -- Buying an Hourglass if (player:getFreeSlotsCount() == 0 or player:hasItem(4236) == true) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,4236); else player:tradeComplete(); player:addItem(4236); player:messageSpecial(ITEM_OBTAINED,4236); end elseif (csid == 97) then -- Bringing back an hourglass for gil. player:tradeComplete(); player:addGil(TIMELESS_HOURGLASS_COST); player:messageSpecial(GIL_OBTAINED,TIMELESS_HOURGLASS_COST); elseif (csid == 55) then -- Trading Singles for a Hundred if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,1450); else player:tradeComplete(); player:addItem(1450); player:messageSpecial(ITEM_OBTAINED,1450); end elseif (csid == 56) then -- Trading 100 Hundreds for Ten thousand if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,1451); else player:tradeComplete(); player:addItem(1451); player:messageSpecial(ITEM_OBTAINED,1451); end elseif (csid == 58) then -- Trading Ten thousand for 100 Hundreds if (player:getFreeSlotsCount() <= 1) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,1450); else player:tradeComplete(); player:addItem(1450,CURRENCY_EXCHANGE_RATE); if (CURRENCY_EXCHANGE_RATE >= 100) then -- Turns out addItem cannot add > stackSize, so we need to addItem twice for quantities > 99. player:addItem(1450,CURRENCY_EXCHANGE_RATE - 99); end player:messageSpecial(ITEMS_OBTAINED,1450,CURRENCY_EXCHANGE_RATE); end end end;
gpl-3.0
AlexandreCA/darkstar
scripts/zones/Mhaura/npcs/Willah_Maratahya.lua
13
3834
----------------------------------- -- Area: Mhaura -- NPC: Willah Maratahya -- Title Change NPC -- @pos 23 -8 63 249 ----------------------------------- require("scripts/globals/titles"); local title2 = { PURVEYOR_IN_TRAINING , ONESTAR_PURVEYOR , TWOSTAR_PURVEYOR , THREESTAR_PURVEYOR , 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 title3 = { FOURSTAR_PURVEYOR , FIVESTAR_PURVEYOR , HEIR_OF_THE_GREAT_LIGHTNING , ORCISH_SERJEANT , BRONZE_QUADAV , YAGUDO_INITIATE , MOBLIN_KINSMAN , DYNAMISBUBURIMU_INTERLOPER , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } local title4 = { FODDERCHIEF_FLAYER , WARCHIEF_WRECKER , DREAD_DRAGON_SLAYER , OVERLORD_EXECUTIONER , DARK_DRAGON_SLAYER , ADAMANTKING_KILLER , BLACK_DRAGON_SLAYER , MANIFEST_MAULER , BEHEMOTHS_BANE , ARCHMAGE_ASSASSIN , HELLSBANE , GIANT_KILLER , LICH_BANISHER , JELLYBANE , BOGEYDOWNER , BEAKBENDER , SKULLCRUSHER , MORBOLBANE , GOLIATH_KILLER , MARYS_GUIDE , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } local title5 = { SIMURGH_POACHER , ROC_STAR , SERKET_BREAKER , CASSIENOVA , THE_HORNSPLITTER , TORTOISE_TORTURER , MON_CHERRY , BEHEMOTH_DETHRONER , THE_VIVISECTOR , DRAGON_ASHER , EXPEDITIONARY_TROOPER , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } local title6 = { ADAMANTKING_USURPER , OVERLORD_OVERTHROWER , DEITY_DEBUNKER , FAFNIR_SLAYER , ASPIDOCHELONE_SINKER , NIDHOGG_SLAYER , MAAT_MASHER , KIRIN_CAPTIVATOR , CACTROT_DESACELERADOR , LIFTER_OF_SHADOWS , TIAMAT_TROUNCER , VRTRA_VANQUISHER , WORLD_SERPENT_SLAYER , XOLOTL_XTRAPOLATOR , BOROKA_BELEAGUERER , OURYU_OVERWHELMER , VINEGAR_EVAPORATOR , VIRTUOUS_SAINT , BYEBYE_TAISAI , TEMENOS_LIBERATOR , APOLLYON_RAVAGER , WYRM_ASTONISHER , NIGHTMARE_AWAKENER , 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(0x2711,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==0x2711) 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 elseif (option > 768 and option <797) then if (player:delGil(500)) then player:setTitle( title5[option - 768] ) end elseif (option > 1024 and option < 1053) then if (player:delGil(600)) then player:setTitle( title6[option - 1024] ) end end end end;
gpl-3.0
AlexandreCA/update
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
AlexandreCA/update
scripts/zones/Sauromugue_Champaign/npcs/qm4.lua
19
2298
----------------------------------- -- Area: Sauromugue Champaign -- NPC: qm4 (???) (Tower 4) -- Involved in Quest: THF AF "As Thick As Thieves" -- @pos 129.587 -0.600 -235.525 120 ----------------------------------- package.loaded["scripts/zones/Sauromugue_Champaign/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/quests"); require("scripts/globals/keyitems"); require("scripts/zones/Sauromugue_Champaign/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) local thickAsThievesGrapplingCS = player:getVar("thickAsThievesGrapplingCS"); if (thickAsThievesGrapplingCS >= 2 and thickAsThievesGrapplingCS <= 7) then if (trade:hasItemQty(17474,1) and trade:getItemCount() == 1) then -- Trade grapel player:messageSpecial(THF_AF_WALL_OFFSET+3,0,17474); -- You cannot get a decent grip on the wall using the [Grapnel]. end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local thickAsThieves = player:getQuestStatus(WINDURST,AS_THICK_AS_THIEVES); local thickAsThievesGrapplingCS = player:getVar("thickAsThievesGrapplingCS"); if (thickAsThieves == QUEST_ACCEPTED) then if (thickAsThievesGrapplingCS == 4) then player:messageSpecial(THF_AF_MOB); SpawnMob(17269107,120):updateClaim(player); -- Climbpix Highrise setMobPos(17269107,122,0,230,0); elseif (thickAsThievesGrapplingCS == 0 or thickAsThievesGrapplingCS == 1 or thickAsThievesGrapplingCS == 2 or thickAsThievesGrapplingCS == 3 or thickAsThievesGrapplingCS == 5 or thickAsThievesGrapplingCS == 6 or thickAsThievesGrapplingCS == 7) then player:messageSpecial(THF_AF_WALL_OFFSET); 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 ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
gpl-3.0
paly2/minetest-minetestforfun-server
mods/homedecor_modpack/lrfurn/sofas.lua
1
2383
local sofas_list = { { "Red Sofa", "red"}, { "Orange Sofa", "orange"}, { "Yellow Sofa", "yellow"}, { "Green Sofa", "green"}, { "Blue Sofa", "blue"}, { "Violet Sofa", "violet"}, { "Black Sofa", "black"}, { "Grey Sofa", "grey"}, { "White Sofa", "white"}, } local sofa_sbox = { type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 1.5} } local sofa_cbox = { type = "fixed", fixed = { {-0.5, -0.5, -0.5, 0.5, 0, 1.5 }, {-0.5, -0.5, 0.5, -0.4, 0.5, 1.5 } } } for i in ipairs(sofas_list) do local sofadesc = sofas_list[i][1] local colour = sofas_list[i][2] minetest.register_node("lrfurn:sofa_"..colour, { description = sofadesc, drawtype = "mesh", mesh = "lrfurn_sofa_short.obj", tiles = { "lrfurn_sofa_"..colour..".png", "lrfurn_sofa_bottom.png" }, paramtype = "light", paramtype2 = "facedir", groups = {snappy=3}, sounds = default.node_sound_wood_defaults(), selection_box = sofa_sbox, node_box = sofa_cbox, on_rotate = screwdriver.disallow, after_place_node = function(pos, placer, itemstack, pointed_thing) if minetest.is_protected(pos, placer:get_player_name()) then return true end local fdir = minetest.dir_to_facedir(placer:get_look_dir(), false) if lrfurn.check_forward(pos, fdir, false, placer) then minetest.set_node(pos, {name = "lrfurn:sofa_"..colour, param2 = fdir}) itemstack:take_item() else minetest.chat_send_player(placer:get_player_name(), "No room to place the sofa!") minetest.set_node(pos, { name = "air" }) end return itemstack end, on_rightclick = function(pos, node, clicker) if not clicker:is_player() then return end pos.y = pos.y-0.5 clicker:setpos(pos) end }) minetest.register_alias("lrfurn:sofa_left_"..colour, "air") minetest.register_alias("lrfurn:sofa_right_"..colour, "lrfurn:sofa_"..colour) minetest.register_craft({ output = "lrfurn:sofa_"..colour, recipe = { {"wool:"..colour, "wool:"..colour, "", }, {"stairs:slab_wood", "stairs:slab_wood", "", }, {"group:stick", "group:stick", "", } } }) minetest.register_craft({ output = "lrfurn:sofa_"..colour, recipe = { {"wool:"..colour, "wool:"..colour, "", }, {"moreblocks:slab_wood", "moreblocks:slab_wood", "", }, {"group:stick", "group:stick", "", } } }) end if minetest.setting_get("log_mods") then minetest.log("action", "sofas loaded") end
unlicense
Dugy/wesnoth-names
host.lua
26
2733
-- host.lua -- -- Try to host a game called "Test" local function plugin() local function log(text) std_print("host: " .. text) end local counter = 0 local events, context, info local helper = wesnoth.require("lua/helper.lua") local function idle_text(text) counter = counter + 1 if counter >= 100 then counter = 0 log("idling " .. text) end end log("hello world") repeat events, context, info = coroutine.yield() idle_text("in " .. info.name .. " waiting for titlescreen or lobby") until info.name == "titlescreen" or info.name == "Multiplayer Lobby" while info.name == "titlescreen" do context.play_multiplayer({}) log("playing multiplayer...") events, context, info = coroutine.yield() end repeat events, context, info = coroutine.yield() idle_text("in " .. info.name .. " waiting for lobby") until info.name == "Multiplayer Lobby" context.chat({message = "hosting"}) log("creating a game") context.create({}) repeat events, context, info = coroutine.yield() idle_text("in " .. info.name .. " waiting for create") until info.name == "Multiplayer Create" context.select_type({type = "scenario"}) local s = info.find_level({id = "test1"}) if s.index < 0 then log(" error: Could not find scenario with id=test1") end context.select_level({index = s.index}) events, context, info = coroutine.yield() log("configuring a game") context.create({}) repeat events, context, info = coroutine.yield() idle_text("in " .. info.name .. " waiting for configure") until info.name == "Multiplayer Configure" context.set_name({name = "Test"}) log("hosting a game") context.launch({}) ready = nil repeat events, context, info = coroutine.yield() for i,v in ipairs(events) do if v[1] == "chat" then std_print(events[i][2]) if v[2].message == "ready" then ready = true end end end idle_text("in " .. info.name .. " waiting for ready in chat") until ready log("starting game...") context.chat({message = "starting"}) context.launch({}) repeat events, context, info = coroutine.yield() idle_text("in " .. info.name .. " waiting for game") until info.name == "Game" log("got to a game context...") repeat events, context, info = coroutine.yield() idle_text("in " .. info.name .. " waiting for not game") until info.name ~= "Game" log("left a game context...") repeat context.quit({}) log("quitting a " .. info.name .. " context...") events, context, info = coroutine.yield() until info.name == "titlescreen" context.exit({code = 0}) coroutine.yield() end return plugin
gpl-2.0
techtonik/wesnoth
data/lua/wml/objectives.lua
4
6695
local helper = wesnoth.require "lua/helper.lua" local wml_actions = wesnoth.wml_actions local game_events = wesnoth.game_events local function color_prefix(r, g, b) return string.format('<span foreground="#%02x%02x%02x">', r, g, b) end local function insert_before_nl(s, t) return string.gsub(tostring(s), "[^\n]*", "%0" .. t, 1) end local scenario_objectives = {} local old_on_save = game_events.on_save function game_events.on_save() local custom_cfg = old_on_save() for i,v in pairs(scenario_objectives) do v.side = i table.insert(custom_cfg, { "objectives", v }) end return custom_cfg end local old_on_load = game_events.on_load function game_events.on_load(cfg) for i = #cfg,1,-1 do local v = cfg[i] if v[1] == "objectives" then local v2 = v[2] scenario_objectives[v2.side or 0] = v2 table.remove(cfg, i) end end old_on_load(cfg) end local function generate_objectives(cfg) -- Note: when changing the text formatting, remember to check if you also -- need to change the hardcoded default multiplayer objective text in -- multiplayer_connect.cpp. local _ = wesnoth.textdomain("wesnoth") local objectives = "" local win_objectives = "" local lose_objectives = "" local gold_carryover = "" local notes = "" local win_string = cfg.victory_string or _ "Victory:" local lose_string = cfg.defeat_string or _ "Defeat:" local gold_carryover_string = cfg.gold_carryover_string or _ "Gold carryover:" local notes_string = cfg.notes_string or _ "Notes:" local bullet = cfg.bullet or "&#8226; " for obj in helper.child_range(cfg, "objective") do local show_if = helper.get_child(obj, "show_if") if not show_if or wesnoth.eval_conditional(show_if) then local objective_bullet = obj.bullet or bullet local condition = obj.condition local description = obj.description or "" local turn_counter = "" if obj.show_turn_counter then local current_turn = wesnoth.current.turn local turn_limit = wesnoth.game_config.last_turn if turn_limit >= current_turn then if turn_limit - current_turn + 1 > 1 then turn_counter = "<small> " .. string.format(tostring(_"(%d turns left)"), turn_limit - current_turn + 1) .. "</small>" else turn_counter = "<small> " .. _"(this turn left)" .. "</small>" end end end if condition == "win" then local caption = obj.caption local r = obj.red or 0 local g = obj.green or 255 local b = obj.blue or 0 if caption then win_objectives = win_objectives .. caption .. "\n" end win_objectives = win_objectives .. color_prefix(r, g, b) .. objective_bullet .. description .. turn_counter .. "</span>" .. "\n" elseif condition == "lose" then local caption = obj.caption local r = obj.red or 255 local g = obj.green or 0 local b = obj.blue or 0 if caption then lose_objectives = lose_objectives .. caption .. "\n" end lose_objectives = lose_objectives .. color_prefix(r, g, b) .. objective_bullet .. description .. turn_counter .. "</span>" .. "\n" else wesnoth.message "Unknown condition, ignoring." end end end for obj in helper.child_range(cfg, "gold_carryover") do local gold_carryover_bullet = obj.bullet or bullet local r = obj.red or 255 local g = obj.green or 255 local b = obj.blue or 192 if obj.bonus ~= nil then if obj.bonus then gold_carryover = color_prefix(r, g, b) .. gold_carryover_bullet .. "<small>" .. _"Early finish bonus." .. "</small></span>\n" else gold_carryover = color_prefix(r, g, b) .. gold_carryover_bullet .. "<small>" .. _"No early finish bonus." .. "</small></span>\n" end end if obj.carryover_percentage then local carryover_amount_string = "" if obj.carryover_percentage == 0 then carryover_amount_string = _"No gold carried over to the next scenario." else carryover_amount_string = string.format(tostring(_ "%d%% of gold carried over to the next scenario."), obj.carryover_percentage) end gold_carryover = gold_carryover .. color_prefix(r, g, b) .. gold_carryover_bullet .. "<small>" .. carryover_amount_string .. "</small></span>\n" end end for note in helper.child_range(cfg, "note") do local show_if = helper.get_child(note, "show_if") if not show_if or wesnoth.eval_conditional(show_if) then local note_bullet = note.bullet or bullet local r = note.red or 255 local g = note.green or 255 local b = note.blue or 255 if note.description then notes = notes .. color_prefix(r, g, b) .. note_bullet .. "<small>" .. note.description .. "</small></span>\n" end end end local summary = cfg.summary if summary then objectives = "<big>" .. insert_before_nl(summary, "</big>") .. "\n" end if win_objectives ~= "" then objectives = objectives .. "<big>" .. win_string .. "</big>\n" .. win_objectives end if lose_objectives ~= "" then objectives = objectives .. "<big>" .. lose_string .. "</big>\n" .. lose_objectives end if gold_carryover ~= "" then objectives = objectives .. gold_carryover_string .. "\n" .. gold_carryover end if notes ~= "" then objectives = objectives .. notes_string .. "\n" .. notes end local note = cfg.note if note then objectives = objectives .. note .. "\n" end return string.sub(tostring(objectives), 1, -2) end local function remove_ssf_info_from(cfg) cfg.side = nil cfg.team_name = nil for i, v in ipairs(cfg) do if v[1] == "has_unit" or v[1] == "enemy_of" or v[1] == "allied_with" then table.remove(cfg, i) end end end function wml_actions.objectives(cfg) cfg = helper.parsed(cfg) local sides = wesnoth.get_sides(cfg) local silent = cfg.silent remove_ssf_info_from(cfg) cfg.silent = nil local objectives = generate_objectives(cfg) local function set_objectives(sides, save) for i, team in ipairs(sides) do if save then scenario_objectives[team.side] = cfg end team.objectives = objectives team.objectives_changed = not silent end end if #sides == #wesnoth.sides or #sides == 0 then scenario_objectives[0] = cfg set_objectives(wesnoth.sides) else set_objectives(sides, true) end end function wml_actions.show_objectives(cfg) local cfg0 = scenario_objectives[0] local function local_show_objectives(sides) local objectives0 = cfg0 and generate_objectives(cfg0) for i, team in ipairs(sides) do cfg = scenario_objectives[team.side] local objectives = (cfg and generate_objectives(cfg)) or objectives0 if objectives then team.objectives = objectives end team.objectives_changed = true end end local sides = wesnoth.get_sides(cfg) if #sides == 0 then local_show_objectives(wesnoth.sides) else local_show_objectives(sides) end end
gpl-2.0
TheRealGold/minetest-mod-carbonite
init.lua
1
3835
minetest.register_node("carbonite:carbonitewallsplit", { description = "Carbonite Wall Split", tiles = { "carbonite_wall_half_top.png", "carbonite_wall_half_bottom.png", "carbonite_wall_half_invert.png", "carbonite_wall_half.png", "carbonite_wall.png", "carbonite_wall_light.png" }, paramtype2 = "facedir", is_ground_content = true, groups = {cracky = 3}, drop = "carbonite:carbonitewallsplit" }) minetest.register_node("carbonite:carbonitewalllight", { description = "Carbonite Wall Light", tiles = { "carbonite_wall_light.png", "carbonite_wall_light.png", "carbonite_wall_light.png", "carbonite_wall_light.png", "carbonite_wall_light.png", "carbonite_wall_light.png" }, paramtype2 = "facedir", is_ground_content = true, groups = {cracky = 3}, drop = "carbonite:carbonitewalllight" }) minetest.register_node("carbonite:carbonitewall", { description = "Carbonite Wall", tiles = { "carbonite_wall.png", "carbonite_wall.png", "carbonite_wall.png", "carbonite_wall.png", "carbonite_wall.png", "carbonite_wall.png" }, paramtype2 = "facedir", is_ground_content = true, groups = {cracky = 3}, drop = "carbonite:carbonitewall" }) minetest.register_node("carbonite:carbonitewalldouble", { description = "Carbonite Wall Double", tiles = { "carbonite_wall_double_top.png", "carbonite_wall_double_bottom.png", "carbonite_wall_double_invert.png", "carbonite_wall_double.png", "carbonite_wall.png", "carbonite_wall.png" }, paramtype2 = "facedir", is_ground_content = true, groups = {cracky = 3}, drop = "carbonite:carbonitewalldouble" }) minetest.register_node("carbonite:carbonitewallsplitline", { description = "Carbonite Wall Split Line", tiles = { "carbonite_wall_half_top.png", "carbonite_wall_half_bottom.png", "carbonite_wall_half_horizontal_invert.png", "carbonite_wall_half_horizontal.png", "carbonite_wall_horizontal.png", "carbonite_wall_light.png" }, paramtype2 = "facedir", is_ground_content = true, groups = {cracky = 3}, drop = "carbonite:carbonitewallsplitline" }) minetest.register_node("carbonite:carbonitewalljunctionline", { description = "Carbonite Wall Junction Line", tiles = { "carbonite_wall_verticle_top.png", "carbonite_wall_verticle_bottom.png", "carbonite_wall_junction_invert.png", "carbonite_wall_junction.png", "carbonite_wall.png", "carbonite_wall_horizontal.png" }, paramtype2 = "facedir", is_ground_content = true, groups = {cracky = 3}, drop = "carbonite:carbonitewalljunctionline" }) minetest.register_node("carbonite:carbonitewallhorizontalline", { description = "Carbonite Wall Horizontal Line", tiles = { "carbonite_wall.png", "carbonite_wall.png", "carbonite_wall_horizontal.png", "carbonite_wall_horizontal.png", "carbonite_wall_horizontal.png", "carbonite_wall_horizontal.png" }, paramtype2 = "facedir", is_ground_content = true, groups = {cracky = 3}, drop = "carbonite:carbonitewallhorizontalline" }) minetest.register_node("carbonite:carbonitewallverticalline", { description = "Carbonite Wall Vertical Line", tiles = { "carbonite_wall_verticle.png", "carbonite_wall_verticle.png", "carbonite_wall.png", "carbonite_wall.png", "carbonite_wall_verticle_invert.png", "carbonite_wall_verticle.png" }, is_ground_content = true, groups = {cracky = 3}, drop = "carbonite:carbonitewallverticallineline" })
gpl-3.0
AlexandreCA/darkstar
scripts/globals/mobskills/Fulmination.lua
27
1503
--------------------------------------------- -- Fulmination -- -- Description: Deals heavy magical damage in an area of effect. Additional effect: Paralysis + Stun -- Type: Magical -- Utsusemi/Blink absorb: Wipes Shadows -- Range: 30 yalms --------------------------------------------- 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 == 1805) then return 0; else return 1; end end local family = mob:getFamily(); local mobhp = mob:getHPP(); local result = 1 if (family == 168 and mobhp <= 35) then -- Khimera < 35% result = 0; elseif (family == 315 and mobhp <= 50) then -- Tyger < 50% result = 0; end return result; end; function onMobWeaponSkill(target, mob, skill) -- TODO: Hits all players near Khimaira, not just alliance. local dmgmod = 3; local info = MobMagicalMove(mob,target,skill,mob:getWeaponDmg() * 4,ELE_LIGHTNING,dmgmod,TP_MAB_BONUS,1); local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_MAGICAL,MOBPARAM_THUNDER,MOBPARAM_WIPE_SHADOWS); MobStatusEffectMove(mob,target,EFFECT_PARALYSIS, 40, 0, 60); MobStatusEffectMove(mob,target,EFFECT_STUN, 1, 0, 4); target:delHP(dmg); return dmg; end;
gpl-3.0
Dugy/wesnoth-names
data/ai/micro_ais/cas/ca_messenger_attack.lua
4
4866
local H = wesnoth.require "lua/helper.lua" local AH = wesnoth.require "ai/lua/ai_helper.lua" local messenger_next_waypoint = wesnoth.require "ai/micro_ais/cas/ca_messenger_f_next_waypoint.lua" local best_attack local function messenger_find_enemies_in_way(messenger, goal_x, goal_y) -- Returns the first unit on or next to the path of the messenger -- @messenger: proxy table for the messenger unit -- @goal_x,@goal_y: coordinates of the goal toward which the messenger moves -- Returns proxy table for the first unit found, or nil if none was found local path, cost = wesnoth.find_path(messenger, goal_x, goal_y, { ignore_units = true }) if cost >= 42424242 then return end -- The second path hex is the first that is important for the following analysis if (not path[2]) then return end -- Is there an enemy unit on the second path hex? -- This would be caught by the adjacent hex check later, but not in the right order local enemy = wesnoth.get_units { x = path[2][1], y = path[2][2], { "filter_side", { { "enemy_of", { side = wesnoth.current.side } } } } }[1] if enemy then return enemy end -- After that, go through adjacent hexes of all the other path hexes for i = 2,#path do local sub_path, sub_cost = wesnoth.find_path(messenger, path[i][1], path[i][2], { ignore_units = true }) if (sub_cost <= messenger.moves) then for xa,ya in H.adjacent_tiles(path[i][1], path[i][2]) do local enemy = wesnoth.get_units { x = xa, y = ya, { "filter_side", { { "enemy_of", { side = wesnoth.current.side } } } } }[1] if enemy then return enemy end end else -- If we've reached the end of the path for this turn return end end end local function messenger_find_clearing_attack(messenger, goal_x, goal_y, cfg) -- Check if an enemy is in the way of the messenger -- If so, find attack that would clear that enemy out of the way -- @messenger: proxy table for the messenger unit -- @goal_x,@goal_y: coordinates of the goal toward which the messenger moves -- Returns proxy table containing the attack, or nil if none was found local enemy_in_way = messenger_find_enemies_in_way(messenger, goal_x, goal_y) if (not enemy_in_way) then return end local filter = H.get_child(cfg, "filter") or { id = cfg.id } local units = AH.get_units_with_attacks { side = wesnoth.current.side, { "not", filter }, { "and", H.get_child(cfg, "filter_second") } } if (not units[1]) then return end local attacks = AH.get_attacks(units, { simulate_combat = true }) local max_rating = -9e99 for _,attack in ipairs(attacks) do if (attack.target.x == enemy_in_way.x) and (attack.target.y == enemy_in_way.y) then -- Rating: expected HP of attacker and defender local rating = attack.att_stats.average_hp - 2 * attack.def_stats.average_hp if (rating > max_rating) then max_rating, best_attack = rating, attack end end end if best_attack then return best_attack end -- If we got here, that means there's an enemy in the way, but none of the units can reach it --> try to fight our way to that enemy for _,attack in ipairs(attacks) do -- Rating: expected HP of attacker and defender local rating = attack.att_stats.average_hp - 2 * attack.def_stats.average_hp -- Give a huge bonus for closeness to enemy_in_way local tmp_defender = wesnoth.get_unit(attack.target.x, attack.target.y) local dist = H.distance_between(enemy_in_way.x, enemy_in_way.y, tmp_defender.x, tmp_defender.y) rating = rating + 100. / dist if (rating > max_rating) then max_rating, best_attack = rating, attack end end if best_attack then return best_attack end end local ca_messenger_attack = {} function ca_messenger_attack:evaluation(cfg) -- Attack units in the path of the messengers local messenger, x, y = messenger_next_waypoint(cfg) if (not messenger) then return 0 end local attack = messenger_find_clearing_attack(messenger, x, y, cfg) if attack then return cfg.ca_score end return 0 end function ca_messenger_attack:execution(cfg) local attacker = wesnoth.get_unit(best_attack.src.x, best_attack.src.y) local defender = wesnoth.get_unit(best_attack.target.x, best_attack.target.y) AH.movefull_stopunit(ai, attacker, best_attack.dst.x, best_attack.dst.y) if (not attacker) or (not attacker.valid) then return end if (not defender) or (not defender.valid) then return end AH.checked_attack(ai, attacker, defender) best_attack = nil end return ca_messenger_attack
gpl-2.0
AlexandreCA/darkstar
scripts/zones/Bastok_Mines/npcs/Deidogg.lua
12
5208
----------------------------------- -- Area: Bastok Mines -- NPC: Deidogg -- Starts and Finishes Quest: The Talekeeper's Truth, The Talekeeper's Gift (start) -- @pos -13 7 29 234 ----------------------------------- package.loaded["scripts/zones/Bastok_Mines/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/quests"); require("scripts/zones/Bastok_Mines/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if (player:getVar("theTalekeeperTruthCS") == 3) then if (trade:hasItemQty(1101,1) and trade:getItemCount() == 1) then -- Trade Mottled Quadav Egg player:startEvent(0x00a2); end elseif (player:getVar("theTalekeeperTruthCS") == 4) then if (trade:hasItemQty(1099,1) and trade:getItemCount() == 1) then -- Trade Parasite Skin player:startEvent(0x00a4); end elseif (player:getVar("theTalekeeperGiftCS") == 2) then if (trade:hasItemQty(4394,1) and trade:getItemCount() == 1) then -- Trade Ginger Cookie player:startEvent(0x00ac); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local theDoorman = player:getQuestStatus(BASTOK,THE_DOORMAN); local theTalekeeperTruth = player:getQuestStatus(BASTOK,THE_TALEKEEPER_S_TRUTH); local theTalekeeperTruthCS = player:getVar("theTalekeeperTruthCS"); local Wait1DayForAF3 = player:getVar("DeidoggWait1DayForAF3"); local theTalekeeperGiftCS = player:getVar("theTalekeeperGiftCS"); local WildcatBastok = player:getVar("WildcatBastok"); if (player:getQuestStatus(BASTOK,LURE_OF_THE_WILDCAT_BASTOK) == QUEST_ACCEPTED and player:getMaskBit(WildcatBastok,18) == false) then player:startEvent(0x01f8); elseif (theDoorman == QUEST_COMPLETED and theTalekeeperTruth == QUEST_AVAILABLE and player:getMainJob() == 1 and player:getMainLvl() >= 50) then if (theTalekeeperTruthCS == 1) then player:startEvent(0x00a0); player:setVar("theTalekeeperTruthCS",2); elseif (theTalekeeperTruthCS == 2) then player:startEvent(0x00a1); -- Start Quest "The Talekeeper's Truth" else player:startEvent(0x0020); -- Standard dialog end elseif (theTalekeeperTruthCS == 4) then player:startEvent(0x00a3); -- During Quest "The Talekeeper's Truth" elseif (theTalekeeperTruthCS == 5 and VanadielDayOfTheYear() ~= player:getVar("theTalekeeperTruth_timer")) then player:startEvent(0x00a5); -- Finish Quest "The Talekeeper's Truth" elseif (theTalekeeperTruthCS == 5 or (theTalekeeperTruth == QUEST_COMPLETED and (player:needToZone() or VanadielDayOfTheYear() == Wait1DayForAF3))) then player:startEvent(0x00a6); -- New standard dialog after "The Talekeeper's Truth" elseif (player:needToZone() == false and VanadielDayOfTheYear() ~= Wait1DayForAF3 and Wait1DayForAF3 ~= 0 and theTalekeeperGiftCS == 0 and player:getMainJob() == 1) then player:startEvent(0x00aa); player:setVar("theTalekeeperGiftCS",1); player:setVar("DeidoggWait1DayForAF3",0); else player:startEvent(0x0020); -- Standard 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); if (csid == 0x00a1) then player:addQuest(BASTOK,THE_TALEKEEPER_S_TRUTH); player:setVar("theTalekeeperTruthCS",3); elseif (csid == 0x00a2) then player:tradeComplete(); player:setVar("theTalekeeperTruthCS",4); elseif (csid == 0x00a4) then player:tradeComplete(); player:setVar("theTalekeeperTruthCS",5); player:setVar("theTalekeeperTruth_timer",VanadielDayOfTheYear()); elseif (csid == 0x00a5) then if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,14089); -- Fighter's Calligae else player:addItem(14089); player:messageSpecial(ITEM_OBTAINED, 14089); -- Fighter's Calligae player:setVar("theTalekeeperTruthCS",0); player:setVar("theTalekeeperTruth_timer",0); player:setVar("DeidoggWait1DayForAF3",VanadielDayOfTheYear()); player:needToZone(true); player:addFame(BASTOK,AF2_FAME); player:completeQuest(BASTOK,THE_TALEKEEPER_S_TRUTH); end elseif (csid == 0x00ac) then player:tradeComplete(); player:addQuest(BASTOK,THE_TALEKEEPER_S_GIFT); player:setVar("theTalekeeperGiftCS",3); elseif (csid == 0x01f8) then player:setMaskBit(player:getVar("WildcatBastok"),"WildcatBastok",18,true); end end;
gpl-3.0
paly2/minetest-minetestforfun-server
mods/hudbars/init.lua
1
11571
hb = {} hb.hudtables = {} -- number of registered HUD bars hb.hudbars_count = 0 hb.settings = {} hb.settings.custom = {} --MFF (crabman|19/06/15) add custom pos -- default settings hb.settings.max_bar_length = 160 -- statbar positions hb.settings.pos_left = { x=0.5, y=1 } hb.settings.pos_right= { x = 0.5, y = 1 } hb.settings.start_offset_left = { x = -175, y = -100 } hb.settings.start_offset_right = { x = 15, y = -100 } hb.settings.vmargin = 24 hb.settings.tick = 0.1 -- Table which contains all players with active default HUD bars (only for internal use) hb.players = {} function hb.value_to_barlength(value, max) if max == 0 then return 0 else return math.ceil((value/max) * hb.settings.max_bar_length) end end function hb.get_hudtable(identifier) return hb.hudtables[identifier] end function hb.register_hudbar(identifier, text_color, label, textures, default_start_value, default_start_max, default_start_hidden, format_string) local hudtable = {} local pos, offset --MFF (crabman|19/06/15)|DEBUT add custom pos if hb.settings.custom.custom and hb.settings.custom[identifier] ~= nil then if hb.settings.custom[identifier].x == 0 then pos = hb.settings.pos_left offset = { x = hb.settings.start_offset_left.x, y = hb.settings.start_offset_left.y - hb.settings.vmargin * math.floor(hb.settings.custom[identifier].y) } else pos = hb.settings.pos_right offset = { x = hb.settings.start_offset_right.x, y = hb.settings.start_offset_right.y - hb.settings.vmargin * math.floor(hb.settings.custom[identifier].y) } end --MFF (crabman|19/06/15) /FIN elseif hb.hudbars_count % 2 == 0 then pos = hb.settings.pos_left offset = { x = hb.settings.start_offset_left.x, y = hb.settings.start_offset_left.y - hb.settings.vmargin * math.floor(hb.hudbars_count/2) } else pos = hb.settings.pos_right offset = { x = hb.settings.start_offset_right.x, y = hb.settings.start_offset_right.y - hb.settings.vmargin * math.floor((hb.hudbars_count-1)/2) } end if format_string == nil then format_string = "%s: %d/%d" end hudtable.add_all = function(player, hudtable, start_value, start_max, start_hidden) if start_value == nil then start_value = hudtable.default_start_value end if start_max == nil then start_max = hudtable.default_start_max end if start_hidden == nil then start_hidden = hudtable.default_start_hidden end local ids = {} local state = {} local name = player:get_player_name() local bgscale, iconscale, text, barnumber if start_max == 0 or start_hidden then bgscale = { x=0, y=0 } else bgscale = { x=1, y=1 } end if start_hidden then iconscale = { x=0, y=0 } barnumber = 0 text = "" else iconscale = { x=1, y=1 } barnumber = hb.value_to_barlength(start_value, start_max) text = string.format(format_string, label, start_value, start_max) end ids.bg = player:hud_add({ hud_elem_type = "image", position = pos, scale = bgscale, text = "hudbars_bar_background.png", alignment = {x=1,y=1}, offset = { x = offset.x - 1, y = offset.y - 1 }, }) if textures.icon ~= nil then ids.icon = player:hud_add({ hud_elem_type = "image", position = pos, scale = iconscale, text = textures.icon, alignment = {x=-1,y=1}, offset = { x = offset.x - 3, y = offset.y }, }) end ids.bar = player:hud_add({ hud_elem_type = "statbar", position = pos, text = textures.bar, number = barnumber, alignment = {x=-1,y=-1}, offset = offset, }) ids.text = player:hud_add({ hud_elem_type = "text", position = pos, text = text, alignment = {x=1,y=1}, number = text_color, direction = 0, offset = { x = offset.x + 2, y = offset.y }, }) -- Do not forget to update hb.get_hudbar_state if you add new fields to the state table state.hidden = start_hidden state.value = start_value state.max = start_max state.text = text state.barlength = hb.value_to_barlength(start_value, start_max) local main_error_text = "[hudbars] Bad initial values of HUD bar identifier “"..tostring(identifier).."” for player "..name..". " if start_max < start_value then minetest.log("error", main_error_text.."start_max ("..start_max..") is smaller than start_value ("..start_value..")!") end if start_max < 0 then minetest.log("error", main_error_text.."start_max ("..start_max..") is smaller than 0!") end if start_value < 0 then minetest.log("error", main_error_text.."start_value ("..start_value..") is smaller than 0!") end hb.hudtables[identifier].hudids[name] = ids hb.hudtables[identifier].hudstate[name] = state end hudtable.identifier = identifier hudtable.format_string = format_string hudtable.label = label hudtable.hudids = {} hudtable.hudstate = {} hudtable.default_start_hidden = default_start_hidden hudtable.default_start_value = default_start_value hudtable.default_start_max = default_start_max hb.hudbars_count= hb.hudbars_count + 1 hb.hudtables[identifier] = hudtable end function hb.init_hudbar(player, identifier, start_value, start_max, start_hidden) local hudtable = hb.get_hudtable(identifier) hb.hudtables[identifier].add_all(player, hudtable, start_value, start_max, start_hidden) end function hb.change_hudbar(player, identifier, new_value, new_max_value) if new_value == nil and new_max_value == nil then return end local name = player:get_player_name() local hudtable = hb.get_hudtable(identifier) local value_changed, max_changed = false, false if new_value ~= nil then if new_value ~= hudtable.hudstate[name].value then hudtable.hudstate[name].value = new_value value_changed = true end else new_value = hudtable.hudstate[name].value end if new_max_value ~= nil then if new_max_value ~= hudtable.hudstate[name].max then hudtable.hudstate[name].max = new_max_value max_changed = true end else new_max_value = hudtable.hudstate[name].max end local main_error_text = "[hudbars] Bad call to hb.change_hudbar, identifier: “"..tostring(identifier).."”, player name: “"..name.."”. " if new_max_value < new_value then minetest.log("error", main_error_text.."new_max_value ("..new_max_value..") is smaller than new_value ("..new_value..")!") end if new_max_value < 0 then minetest.log("error", main_error_text.."new_max_value ("..new_max_value..") is smaller than 0!") end if new_value < 0 then minetest.log("error", main_error_text.."new_value ("..new_value..") is smaller than 0!") end if hudtable.hudstate[name].hidden == false then if max_changed then if hudtable.hudstate[name].max == 0 then player:hud_change(hudtable.hudids[name].bg, "scale", {x=0,y=0}) else player:hud_change(hudtable.hudids[name].bg, "scale", {x=1,y=1}) end end if value_changed or max_changed then local new_barlength = hb.value_to_barlength(new_value, new_max_value) if new_barlength ~= hudtable.hudstate[name].barlength then player:hud_change(hudtable.hudids[name].bar, "number", hb.value_to_barlength(new_value, new_max_value)) hudtable.hudstate[name].barlength = new_barlength end local new_text = string.format(hudtable.format_string, hudtable.label, new_value, new_max_value) if new_text ~= hudtable.hudstate[name].text then player:hud_change(hudtable.hudids[name].text, "text", new_text) hudtable.hudstate[name].text = new_text end end end end function hb.hide_hudbar(player, identifier) local name = player:get_player_name() local hudtable = hb.get_hudtable(identifier) if(hudtable.hudstate[name].hidden == false) then if hudtable.hudids[name].icon ~= nil then player:hud_change(hudtable.hudids[name].icon, "scale", {x=0,y=0}) end player:hud_change(hudtable.hudids[name].bg, "scale", {x=0,y=0}) player:hud_change(hudtable.hudids[name].bar, "number", 0) player:hud_change(hudtable.hudids[name].text, "text", "") hudtable.hudstate[name].hidden = true end end function hb.unhide_hudbar(player, identifier) local name = player:get_player_name() local hudtable = hb.get_hudtable(identifier) if(hudtable.hudstate[name] and hudtable.hudstate[name].hidden) then local name = player:get_player_name() local value = hudtable.hudstate[name].value local max = hudtable.hudstate[name].max if hudtable.hudids[name].icon ~= nil then player:hud_change(hudtable.hudids[name].icon, "scale", {x=1,y=1}) end if hudtable.hudstate[name].max ~= 0 then player:hud_change(hudtable.hudids[name].bg, "scale", {x=1,y=1}) end player:hud_change(hudtable.hudids[name].bar, "number", hb.value_to_barlength(value, max)) player:hud_change(hudtable.hudids[name].text, "text", tostring(string.format(hudtable.format_string, hudtable.label, value, max))) hudtable.hudstate[name].hidden = false end end function hb.get_hudbar_state(player, identifier) local ref = hb.get_hudtable(identifier).hudstate[player:get_player_name()] -- Do not forget to update this chunk of code in case the state changes local copy = { hidden = ref.hidden, value = ref.value, max = ref.max, text = ref.text, barlength = ref.barlength, } return copy end --load custom settings local set = io.open(minetest.get_modpath("hudbars").."/hudbars.conf", "r") if set then dofile(minetest.get_modpath("hudbars").."/hudbars.conf") set:close() end --register built-in HUD bars if minetest.setting_getbool("enable_damage") then hb.register_hudbar("health", 0xFFFFFF, "Health", { bar = "hudbars_bar_health.png", icon = "hudbars_icon_health.png" }, 20, 20, false) hb.register_hudbar("breath", 0xFFFFFF, "Breath", { bar = "hudbars_bar_breath.png", icon = "hudbars_icon_breath.png" }, 10, 10, true) end local function hide_builtin(player) local flags = player:hud_get_flags() flags.healthbar = false flags.breathbar = false player:hud_set_flags(flags) end local function custom_hud(player) if minetest.setting_getbool("enable_damage") then hb.init_hudbar(player, "health", player:get_hp()) local breath = player:get_breath() local hide_breath if breath == 11 then hide_breath = true else hide_breath = false end hb.init_hudbar(player, "breath", math.min(breath, 10), nil, hide_breath) end end -- update built-in HUD bars local function update_hud(player) if minetest.setting_getbool("enable_damage") then --air local breath = player:get_breath() if breath == 11 then hb.hide_hudbar(player, "breath") elseif breath then hb.unhide_hudbar(player, "breath") hb.change_hudbar(player, "breath", math.min(breath, 10)) end --health hb.change_hudbar(player, "health", player:get_hp()) end hb.change_hudbar(player, "sprint", sprint.players[player:get_player_name()].stamina, sprint.players[player:get_player_name()].maxStamina) end minetest.register_on_joinplayer(function(player) hide_builtin(player) custom_hud(player) hb.players[player:get_player_name()] = player end) minetest.register_on_leaveplayer(function(player) hb.players[player:get_player_name()] = nil end) local main_timer = 0 local timer = 0 minetest.register_globalstep(function(dtime) main_timer = main_timer + dtime timer = timer + dtime if main_timer > hb.settings.tick or timer > 4 then if main_timer > hb.settings.tick then main_timer = 0 end for playername, player in pairs(hb.players) do -- only proceed if damage is enabled if minetest.setting_getbool("enable_damage") then -- update all hud elements update_hud(player) end end end if timer > 4 then timer = 0 end end) -- Our legacy dofile(minetest.get_modpath("hudbars").."/hud_legacy.lua")
unlicense
AlexandreCA/darkstar
scripts/zones/Newton_Movalpolos/npcs/Treasure_Coffer.lua
13
3837
----------------------------------- -- Area: Newton Movalpolos -- NPC: Treasure Coffer -- @zone 12 ----------------------------------- package.loaded["scripts/zones/Newton_Movalpolos/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/treasure"); require("scripts/globals/quests"); require("scripts/zones/Newton_Movalpolos/TextIDs"); local TreasureType = "Coffer"; local TreasureLvL = 53; local TreasureMinLvL = 43; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- trade:hasItemQty(1063,1); -- Treasure Key -- trade:hasItemQty(1115,1); -- Skeleton Key -- trade:hasItemQty(1023,1); -- Living Key -- trade:hasItemQty(1022,1); -- Thief's Tools local questItemNeeded = 0; -- Player traded a key. if ((trade:hasItemQty(1063,1) or trade:hasItemQty(1115,1) or trade:hasItemQty(1023,1) or trade:hasItemQty(1022,1)) and trade:getItemCount() == 1) then -- IMPORTANT ITEM: AF Keyitems, AF Items, & Map ----------- local zone = player:getZoneID(); if (player:hasKeyItem(MAP_OF_NEWTON_MOVALPOLOS) == false) then questItemNeeded = 3; end -------------------------------------- local pack = openChance(player,npc,trade,TreasureType,TreasureLvL,TreasureMinLvL,questItemNeeded); local success = 0; if (pack[2] ~= nil) then player:messageSpecial(pack[2]); success = pack[1]; else success = pack[1]; end if (success ~= -2) then player:tradeComplete(); if (math.random() <= success) then -- Succeded to open the coffer player:messageSpecial(CHEST_UNLOCKED); if (questItemNeeded == 3) then player:addKeyItem(MAP_OF_NEWTON_MOVALPOLOS); player:messageSpecial(KEYITEM_OBTAINED,MAP_OF_NEWTON_MOVALPOLOS); -- Map of Newton Movalpolos (KI) else player:setVar("["..zone.."]".."Treasure_"..TreasureType,os.time() + math.random(CHEST_MIN_ILLUSION_TIME,CHEST_MAX_ILLUSION_TIME)); local loot = cofferLoot(zone,npc); -- print("loot array: "); -- debug -- print("[1]", loot[1]); -- debug -- print("[2]", loot[2]); -- debug if (loot[1]=="gil") then player:addGil(loot[2]); player:messageSpecial(GIL_OBTAINED,loot[2]); else -- Item player:addItem(loot[2]); player:messageSpecial(ITEM_OBTAINED,loot[2]); end end UpdateTreasureSpawnPoint(npc:getID()); else player:messageSpecial(CHEST_MIMIC); spawnMimic(zone,npc,player); UpdateTreasureSpawnPoint(npc:getID(), true); end end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:messageSpecial(CHEST_LOCKED,1063); 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
AlexandreCA/darkstar
scripts/zones/Maze_of_Shakhrami/npcs/qm2.lua
12
1872
----------------------------------- -- Area: Maze of Shakhrami -- NPC: qm2 -- Type: Quest NPC -- @pos 143 9 -219 198 ----------------------------------- package.loaded["scripts/zones/Maze_of_Shakhrami/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Maze_of_Shakhrami/TextIDs"); require("scripts/globals/quests"); require("scripts/globals/keyitems"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local wyrm1 = 17588701; local wyrm2 = 17588702; local wyrm3 = 17588703; if (player:getQuestStatus(WINDURST,ECO_WARRIOR_WIN) ~= QUEST_AVAILABLE and player:getVar("ECO_WARRIOR_ACTIVE") == 238 and player:hasStatusEffect(EFFECT_LEVEL_RESTRICTION) and player:hasKeyItem(INDIGESTED_MEAT) == false) then if (player:getVar("ECOR_WAR_WIN-NMs_killed") == 1) then player:addKeyItem(INDIGESTED_MEAT); player:messageSpecial(KEYITEM_OBTAINED,INDIGESTED_MEAT); elseif (GetMobAction(wyrm1) + GetMobAction(wyrm1) + GetMobAction(wyrm1) == 0) then SpawnMob(wyrm1,180):updateClaim(player); SpawnMob(wyrm2,180):updateClaim(player); SpawnMob(wyrm3,180):updateClaim(player); end end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
gpl-3.0
chourobin/kong
kong/plugins/basicauth/api.lua
13
1537
local crud = require "kong.api.crud_helpers" return { ["/consumers/:username_or_id/basicauth/"] = { before = function(self, dao_factory, helpers) crud.find_consumer_by_username_or_id(self, dao_factory, helpers) self.params.consumer_id = self.consumer.id end, GET = function(self, dao_factory, helpers) crud.paginated_set(self, dao_factory.basicauth_credentials) end, PUT = function(self, dao_factory) crud.put(self.params, dao_factory.basicauth_credentials) end, POST = function(self, dao_factory) crud.post(self.params, dao_factory.basicauth_credentials) end }, ["/consumers/:username_or_id/basicauth/:id"] = { before = function(self, dao_factory, helpers) crud.find_consumer_by_username_or_id(self, dao_factory, helpers) self.params.consumer_id = self.consumer.id local data, err = dao_factory.basicauth_credentials:find_by_keys({ id = self.params.id }) if err then return helpers.yield_error(err) end self.credential = data[1] if not self.credential then return helpers.responses.send_HTTP_NOT_FOUND() end end, GET = function(self, dao_factory, helpers) return helpers.responses.send_HTTP_OK(self.credential) end, PATCH = function(self, dao_factory) crud.patch(self.params, self.credential, dao_factory.basicauth_credentials) end, DELETE = function(self, dao_factory) crud.delete(self.credential, dao_factory.basicauth_credentials) end } }
mit