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 |
|---|---|---|---|---|---|
CZ-NIC/ucollect | src/plugins/majordomo/scripts/majordomo_cache.lua | 1 | 3747 | #!/usr/bin/env lua
--[[
Copyright 2014, CZ.NIC z.s.p.o. (http://www.nic.cz/)
This script is part of majordomo plugin for ucollect
NUCI 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.
NUCI 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 NUCI. If not, see <http://www.gnu.org/licenses/>.
]]
require("os");
package.path = package.path .. ';/usr/share/lcollect/lua/?.lua'
require("majordomo_lib");
local CMD_INVALIDATE = "invalidate";
local CMD_PRECACHE = "precache";
function invalidate(db_path)
os.execute("rm '" .. db_path .. "/majordomo_serialized_'*");
end
function precache(db_path, ml_mac, ml_dns)
local macdb = get_inst_macdb();
macdb:deserialize();
local handles = { };
table.insert(handles, io.popen("/bin/ls '" .. db_path .. "/" .. DAILY_PREFIX .."'*", "r"));
table.insert(handles, io.popen("/bin/ls '" .. db_path .. "/" .. HOURLY_PREFIX .."'*", "r"));
table.insert(handles, io.popen("/bin/ls '" .. db_path .. "/" .. MONTHLY_PREFIX .."'*", "r"));
--[[
This operation provide 2 important things:
1) It is reusing cache from previous versions of Majordomo. Otherwise, DB
migration takes few days. With this operation it takes just few minutes or
hours.
2) Cache from previous versions should be completely eliminated.
]]
local ptrdb = get_inst_ptrdb();
ptrdb:deserialize();
ptrdb:checkall();
ptrdb:serialize();
for _, handle in ipairs(handles) do
for filename in handle:lines() do
--[[
PTR cache per file
There is no serialize operation! This cache is in-memory only.
]]
local ptrdb = get_inst_ptrdb();
ptrdb:deserialize();
local changed = false;
local tmp_filename = "/tmp/_tmp_edit"..string.gsub(filename, "/", "_");
local tmp_file = io.open(tmp_filename, "w");
local file = io.open(filename, "r");
for line in file:lines() do
data = parse_line(line);
if ml_mac then
macdb:check(data[DD_SRC]);
macdb:lookup(data[DD_SRC]);
end
if ml_dns then
if data[DD_RESOLVED] == CACHE_EMPTY_NAME then
changed = true;
local ptr = ptrdb:lookup(data[DD_DST]);
data[DD_RESOLVED] = ptr or CACHE_EMPTY_NAME;
end
tmp_file:write(restore_line(data).."\n");
end
end
file:close();
tmp_file:close();
if changed then
--[[
This ugly piece of code is necessary due to os.rename(src, dst)
implementation. In Lua, it is just thin wrapper and it is not
able to handle with different filesystems.
]]
if not string.find(filename, "\\") and not string.find(filename, "'") then
os.execute("mv '" .. tmp_filename .. "' '" .. filename .. "'");
else
io.stderr:write("File ignored: Inadmissible character in file name\n");
end
else
os.remove(tmp_filename);
end
end
handle:close();
end
macdb:serialize();
end
function main()
local db_path, make_lookup_mac, make_lookup_dns, _ = majordomo_get_configuration();
if #arg ~= 1 then
io.stderr:write(string.format("Usage: %s (%s|%s)\n", arg[0], CMD_PRECACHE, CMD_INVALIDATE));
os.exit(1);
end
if arg[1] == CMD_INVALIDATE then
invalidate(db_path);
elseif arg[1] == CMD_PRECACHE then
if make_lookup_mac or make_lookup_dns then
precache(db_path, make_lookup_mac, make_lookup_dns);
else
io.stderr:write("Precache: Lookup is disabled\n");
os.exit(0);
end
end
end
main();
| gpl-2.0 |
lancehilliard/TGNS | mods/tgns/output/lua/shine/extensions/adminmenu/client.lua | 1 | 3894 | local Plugin = Plugin
local tgnsMenuDisplayer
local helpTexts = {}
local function getPageNameHelpText(pageName)
local result = helpTexts[pageName]
return result
end
function Plugin:Initialise()
self.Enabled = true
tgnsMenuDisplayer = TGNSMenuDisplayer.Create(function(menu)
menu:EditPage("Main", function(x)
x:AddSideButton("Notifications", function()
TGNS.ShowUrl("http://rr.tacticalgamer.com/Notifications", "Notifications - http://rr.tacticalgamer.com/Notifications")
end)
x:AddPage("Info", "Info", {"Choose an option to learn more about this server, called \"TGNS\"."}, "Main")
x:EditPage("Info", function(y)
y:AddSideButton("TGNS Required Reading", function()
TGNS.ShowUrl("https://docs.google.com/document/d/1tZ0ZcqnMnfklz6QPp5QwLqPuJDxaxp8U5IIh7HDN19k/edit#heading=h.lm98a2s5v77s", "TGNS Required Reading")
end)
y:AddSideButton("TGNS Forums", function()
TGNS.ShowUrl("www.tacticalgamer.com/forum/action/natural-selection/natural-selection-general-discussion", "TGNS Forums: https://tacticalgamer.com/ns2")
end)
y:AddSideButton("TGNS FAQ", function()
TGNS.ShowUrl("https://docs.google.com/document/d/1tZ0ZcqnMnfklz6QPp5QwLqPuJDxaxp8U5IIh7HDN19k/edit#heading=h.cf6zpe9oporr", "TGNS FAQ")
end)
y:AddSideButton("TGNS MapCycle", function()
TGNS.ShowUrl("http://rr.tacticalgamer.com/MapCycle", "TGNS MapCycle")
end)
y:AddSideButton("TGNS Replay", function()
TGNS.ShowUrl("http://rr.tacticalgamer.com/Replay", "TGNS Replay")
end)
end)
x:AddSideButton("Info", function()
x:SetPage("Info")
end)
x:AddSideButton("Feedback", function()
TGNS.ShowUrl("http://rr.tacticalgamer.com/Feedback", "TGNS Portal - http://rr.tacticalgamer.com")
end)
x:AddSideButton("Supporting Memberships", function()
TGNS.ShowUrl("https://www.tacticalgamer.com/forum/action/natural-selection/natural-selection-general-discussion/16821-help-out-your-fellow-player-this-is-important", "TG Supporting Memberships")
end)
x:AddBottomButton("TGNS Portal", function()
TGNS.ShowUrl("http://rr.tacticalgamer.com", "TGNS Portal - http://rr.tacticalgamer.com")
end)
end)
end)
TGNS.HookNetworkMessage(self.MAIN_BUTTONS_REQUESTED, function(message)
tgnsMenuDisplayer = TGNSMenuDisplayer.Create(function(menu)
menu:EditPage("Main", function(x)
x:AddSideButton(message.pageName, function()
TGNS.SendNetworkMessage(self.ADMIN_MENU_REQUESTED, {commandIndex=0, argName=message.pageName, argValue=""})
end)
end)
end)
end)
TGNS.HookNetworkMessage(self.HELP_TEXT, function(message)
helpTexts[message.pageName] = message.helpText
end)
TGNS.HookNetworkMessage(self.MENU_DATA, function(message)
local argName = message.argName
local pageId = message.pageId
local pageName = message.pageName
local backPageId = message.backPageId
local chatCmd = message.chatCmd
local pageNameHelpText = getPageNameHelpText(pageName)
local helpText = TGNS.HasNonEmptyValue(pageNameHelpText) and pageNameHelpText or string.format("%s%s -- Help in console: sh_help %s", pageName, (TGNS.HasNonEmptyValue(chatCmd) and string.format(" (chat: !%s)", chatCmd) or ""), pageName)
local buttons = json.decode(message.buttonsJson)
tgnsMenuDisplayer = TGNSMenuDisplayer.Create(function(menu)
if TGNS.HasNonEmptyValue(backPageId) then
menu:AddPage(pageId, pageName, {helpText}, backPageId)
menu:EditPage(pageId, function(x)
TGNS.DoFor(buttons, function(b)
x:AddSideButton(b.n, function()
TGNS.SendNetworkMessage(self.ADMIN_MENU_REQUESTED, {commandIndex=b.c, argName=argName, argValue=TGNS.HasNonEmptyValue(b.v) and b.v or b.n})
end)
end)
end)
menu:SetPage(pageId)
else
menu:Finish()
end
end)
end)
return true
end
function Plugin:Cleanup()
--Cleanup your extra stuff like timers, data etc.
self.BaseClass.Cleanup( self )
end | mit |
AlexandreCA/update | scripts/zones/Waughroon_Shrine/bcnms/operation_desert_swarm.lua | 17 | 1780 | -----------------------------------
-- Area: Waughroon_Shrine
-- Name: Operation desert swarm
-----------------------------------
package.loaded["scripts/zones/Waughroon_Shrine/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/titles");
require("scripts/globals/quests");
require("scripts/zones/Waughroon_Shrine/TextIDs");
-----------------------------------
-- EXAMPLE SCRIPT
--
-- What should go here:
-- giving key items, playing ENDING cutscenes
--
-- What should NOT go here:
-- Handling of "battlefield" status, spawning of monsters,
-- putting loot into treasure pool,
-- enforcing ANY rules (SJ/number of people/etc), moving
-- chars around, playing entrance CSes (entrance CSes go in bcnm.lua)
-- 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
player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,1,0);
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);
end;
| gpl-3.0 |
lucgagnon/ntopng | scripts/lua/index.lua | 5 | 6903 | --
-- (C) 2013-15 - ntop.org
--
if(ntop.isPro()) then
print(ntop.httpRedirect(ntop.getHttpPrefix().."/lua/pro/dashboard.lua"))
return
end
dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
-- io.write ("Session:".._SESSION["session"].."\n")
require "lua_utils"
sendHTTPHeader('text/html; charset=iso-8859-1')
ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/header.inc")
-- NOTE: in the home page, footer.lua checks the ntopng version
-- so in case we change it, footer.lua must also be updated
active_page = "home"
dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua")
interface.select(ifname)
ifstats = interface.getStats()
is_loopback = isLoopback(ifname)
iface_id = interface.name2id(ifname)
-- Load from or set in redis the refresh frequency for the top flow sankey
refresh = _GET["refresh"]
refresh_key = 'ntopng.prefs.'.._SESSION["user"]..'.'..ifname..'.top_flow_refresh'
if (refresh ~= nil) then
ntop.setCache(refresh_key,refresh)
else
refresh = ntop.getCache(refresh_key)
end
-- Default frequency (ms)
if (refresh == '') then refresh = 5000 end
--
page = _GET["page"]
if(page == nil) then
if(not(is_loopback)) then
page = "TopFlowTalkers"
else
page = "TopHosts"
end
end
if((ifstats ~= nil) and (ifstats.stats_packets > 0)) then
-- Print tabbed header
print('<nav class="navbar navbar-default" role="navigation">\n\t<div class="navbar-collapse collapse">\n\t<ul class="nav navbar-nav">\n')
print('<li><a href="#">Dashboard: </a></li>\n')
if(not(is_loopback)) then
if(page == "TopFlowTalkers") then active=' class="active"' else active = "" end
print('<li'..active..'><a href="'..ntop.getHttpPrefix()..'/?page=TopFlowTalkers">Talkers</a></li>\n')
end
if((page == "TopHosts")) then active=' class="active"' else active = "" end
print('<li'..active..'><a href="'..ntop.getHttpPrefix()..'/?page=TopHosts">Hosts</a></li>\n')
if((page == "TopPorts")) then active=' class="active"' else active = "" end
print('<li'..active..'><a href="'..ntop.getHttpPrefix()..'/?page=TopPorts">Ports</a></li>\n')
if((page == "TopApplications")) then active=' class="active"' else active = "" end
print('<li'..active..'><a href="'..ntop.getHttpPrefix()..'/?page=TopApplications">Applications</a></li>\n')
if(not(is_loopback)) then
if((page == "TopASNs")) then active=' class="active"' else active = "" end
print('<li'..active..'><a href="'..ntop.getHttpPrefix()..'/?page=TopASNs">ASNs</a></li>\n')
if((page == "TopFlowSenders")) then active=' class="active"' else active = "" end
print('<li'..active..'><a href="'..ntop.getHttpPrefix()..'/?page=TopFlowSenders">Senders</a></li>\n')
end
print('</ul>\n\t</div>\n\t</nav>\n')
if(page == "TopFlowTalkers") then
print('<div style="text-align: center;">\n<h4>Top Flow Talkers</h4></div>\n')
print('<div class="row" style="text-align: center;">')
dofile(dirs.installdir .. "/scripts/lua/inc/sankey.lua")
print('\n</div><br/><br/><br/>\n')
print [[
<div class="control-group" style="text-align: center;">
Refresh frequency: <div class="btn-group btn-small">
<button class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
]]
if (refresh ~= '0') then
if (refresh == '60000') then
print('1 Minute')
else
print((refresh/1000)..' Seconds ')
end
else
print(' Never ')
end
print [[<span class="caret"></span></button>
<ul class="dropdown-menu ">
]]
print('<li style="text-align: left;"> <a href="'..ntop.getHttpPrefix()..'?refresh=5000" >5 Seconds</a></li>\n')
print('<li style="text-align: left;"> <a href="'..ntop.getHttpPrefix()..'?refresh=10000" >10 Seconds</a></li>\n')
print('<li style="text-align: left;"> <a href="'..ntop.getHttpPrefix()..'?refresh=30000" >30 Seconds</a></li>\n')
print('<li style="text-align: left;"> <a href="'..ntop.getHttpPrefix()..'?refresh=60000" >1 Minute</a></li>\n')
print('<li style="text-align: left;"> <a href="'..ntop.getHttpPrefix()..'?refresh=0" >Never</a></li>\n')
print [[
</ul>
</div><!-- /btn-group -->
]]
if (refresh ~= '0') then
print [[
Live update: <div class="btn-group btn-group-xs" data-toggle="buttons-radio" data-toggle-name="topflow_graph_state">
<button id="topflow_graph_state_play" value="1" type="button" class="btn btn-default btn-xs active" data-toggle="button" ><i class="fa fa-play"></i></button>
<button id="topflow_graph_state_stop" value="0" type="button" class="btn btn-default btn-xs" data-toggle="button" ><i class="fa fa-stop"></i></button>
</div>
]]
else
print [[
Refresh: <div class="btn-group btn-small">
<button id="topflow_graph_refresh" class="btn btn-default btn-xs">
<i rel="tooltip" data-toggle="tooltip" data-placement="top" data-original-title="Refresh graph" class="glyphicon glyphicon-refresh"></i></button>
</div>
]]
end
print [[
</div>
]]
print [[
<script>
// Stop sankey interval in order to change the default refresh frequency
clearInterval(sankey_interval);
]]
if (refresh ~= '0') then
print ('sankey_interval = window.setInterval(sankey,'..refresh..');')
end
print [[
var topflow_stop = false;
$("#topflow_graph_state_play").click(function() {
if (topflow_stop) {
sankey();
sankey_interval = window.setInterval(sankey, 5000);
topflow_stop = false;
$("#topflow_graph_state_stop").removeClass("active");
$("#topflow_graph_state_play").addClass("active");
}
});
$("#topflow_graph_state_stop").click(function() {
if (!topflow_stop) {
clearInterval(sankey_interval);
topflow_stop = true;
$("#topflow_graph_state_play").removeClass("active");
$("#topflow_graph_state_stop").addClass("active");
}
});
$("#topflow_graph_refresh").click(function() {
sankey();
});
</script>
]]
else
ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/index_" .. page .. ".inc")
end
--ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/index_top.inc")
-- ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/index_bottom.inc")
else
print("<div class=\"alert alert-warning\">No packet has been received yet on interface " .. getHumanReadableInterfaceName(ifname) .. ".<p>Please wait <span id='countdown'></span> seconds until this page reloads.</div> <script type=\"text/JavaScript\">(function countdown(remaining) { if(remaining <= 0) location.reload(true); document.getElementById('countdown').innerHTML = remaining; setTimeout(function(){ countdown(remaining - 1); }, 1000);})(10);</script>")
end
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua") | gpl-3.0 |
jstewart-amd/premake-core | src/base/global.lua | 21 | 2163 | ---
-- global.lua
-- The global container holds workspaces and rules.
-- Copyright (c) 2014-2015 Jason Perkins and the Premake project
---
local p = premake
p.global = p.api.container("global")
local global = p.global
---
-- Create a new global container instance.
---
function global.new(name)
return p.container.new(p.global, name)
end
---
-- Bakes the global scope.
---
function global.bake(self)
p.container.bakeChildren(self)
end
---
-- Iterate over the collection of rules in a session.
--
-- @returns
-- An iterator function.
---
function global.eachRule()
local root = p.api.rootContainer()
return p.container.eachChild(root, p.rule)
end
---
-- Iterate over the collection of workspaces in a session.
--
-- @returns
-- A workspace iterator function.
---
function global.eachWorkspace()
local root = p.api.rootContainer()
return p.container.eachChild(root, p.workspace)
end
p.alias(global, "eachWorkspace", "eachSolution")
---
-- Retrieve a rule by name or index.
--
-- @param key
-- The rule key, either a string name or integer index.
-- @returns
-- The rule with the provided key.
---
function global.getRule(key)
local root = p.api.rootContainer()
return root.rules[key]
end
---
-- Retrieve the rule to applies to the provided file name, if any such
-- rule exists.
--
-- @param fname
-- The name of the file.
-- @param rules
-- A list of rule names to be included in the search. If not specified,
-- all rules will be checked.
-- @returns
-- The rule, is one has been registered, or nil.
---
function global.getRuleForFile(fname, rules)
for rule in global.eachRule() do
if not rules or table.contains(rules, rule.name) then
if path.hasextension(fname, rule.fileextension) then
return rule
end
end
end
end
---
-- Retrieve a workspace by name or index.
--
-- @param key
-- The workspace key, either a string name or integer index.
-- @returns
-- The workspace with the provided key.
---
function global.getWorkspace(key)
local root = p.api.rootContainer()
return root.workspaces[key]
end
p.alias(global, "getWorkspace", "getSolution")
| bsd-3-clause |
AlexandreCA/darkstar | scripts/zones/Windurst_Walls/npcs/Koru-Moru.lua | 25 | 11771 | -----------------------------------
-- Area: Windurst Walls
-- NPC: Koru-Moru
-- Starts & Ends Quest: Star Struck
-- Involved in Quest: Making the Grade, Riding on the Clouds
-- @pos -120 -6 124 239
-----------------------------------
package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
require("scripts/zones/Windurst_Waters/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
local qStarStruck = player:getQuestStatus(WINDURST,STAR_STRUCK);
local count = trade:getItemCount();
if (trade:hasItemQty(544,1) and count == 1 and trade:getGil() == 0) then
if (player:getQuestStatus(WINDURST,MAKING_THE_GRADE) == QUEST_ACCEPTED) then
if (player:getVar("QuestMakingTheGrade_prog") == 1) then
player:startEvent(0x011d); -- MAKING THE GRADE: Turn in Test Answer & Told to go back to Fuepepe & Chomoro
else
player:startEvent(0x011f); -- MAKING THE GRADE: Have test answers but not talked/given to Fuepepe
end
end
elseif (trade:hasItemQty(584,1) and count == 1 and trade:getGil() == 0) then
player:startEvent(0x00c7);
elseif (qStarStruck == QUEST_ACCEPTED and trade:hasItemQty(582,1) and count == 1 and trade:getGil() == 0) then
player:startEvent(0x00d3);
elseif (trade:hasItemQty(1127,1) and trade:getItemCount() == 1) then -- Trade Kindred seal
if (player:getQuestStatus(JEUNO,RIDING_ON_THE_CLOUDS) == QUEST_ACCEPTED and player:getVar("ridingOnTheClouds_4") == 4) then
player:setVar("ridingOnTheClouds_4",0);
player:tradeComplete();
player:addKeyItem(SPIRITED_STONE);
player:messageSpecial(KEYITEM_OBTAINED,SPIRITED_STONE);
end
elseif (trade:hasItemQty(16511,1) and count == 1 and trade:getGil() == 0) then
if (player:getQuestStatus(WINDURST,BLAST_FROM_THE_PAST) == QUEST_ACCEPTED) then
player:startEvent(0x00e0); -- Complete quest!
else
player:startEvent(0x00e1); -- not the shell
end
elseif (trade:hasItemQty(829,1) and count == 1 and trade:getGil() == 0) then
if (player:getQuestStatus(WINDURST,THE_ROOT_OF_THE_PROBLEM) == QUEST_ACCEPTED) then
player:startEvent(0x15D);
player:tradeComplete();
player:setVar("rootProblem",2);
end
elseif (trade:hasItemQty(17299,4) and count == 4 and trade:getGil() == 0) then -- trade:getItemCount() is apparently checking total of all 8 slots combined. Could have sworn that wasn't how it worked before.
if (player:getQuestStatus(WINDURST,CLASS_REUNION) == 1 and player:getVar("ClassReunionProgress") == 2) then
player:startEvent(0x0197); -- now Koru remembers something that you need to inquire his former students.
end;
end;
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local qStarStruck = player:getQuestStatus(WINDURST,STAR_STRUCK);
local blastFromPast = player:getQuestStatus(WINDURST,BLAST_FROM_THE_PAST);
local blastProg = player:getVar("BlastFromThePast_Prog");
local rootProblem = player:getQuestStatus(WINDURST,THE_ROOT_OF_THE_PROBLEM);
local ThePuppetMaster = player:getQuestStatus(WINDURST,THE_PUPPET_MASTER);
local ThePuppetMasterProgress = player:getVar("ThePuppetMasterProgress");
local ClassReunion = player:getQuestStatus(WINDURST,CLASS_REUNION);
local ClassReunionProgress = player:getVar("ClassReunionProgress");
local talk1 = player:getVar("ClassReunion_TalkedToFupepe");
local talk2 = player:getVar("ClassReunion_TalkedToFurakku");
local CarbuncleDebacle = player:getQuestStatus(WINDURST,CARBUNCLE_DEBACLE);
local CarbuncleDebacleProgress = player:getVar("CarbuncleDebacleProgress");
if (blastFromPast == QUEST_AVAILABLE and qStarStruck == QUEST_COMPLETED and player:getQuestStatus(WINDURST,CLASS_REUNION) ~= QUEST_ACCEPTED and player:getFameLevel(WINDURST) >= 3 and player:needToZone() == false) then
player:startEvent(0x00d6);
elseif (blastFromPast == QUEST_ACCEPTED and blastProg >= 2) then
player:startEvent(0x00d7);
elseif (blastFromPast == QUEST_ACCEPTED) then
player:startEvent(0x00d8);
elseif (player:getQuestStatus(WINDURST,MAKING_THE_GRADE) == QUEST_ACCEPTED) then
local makingGradeProg = player:getVar("QuestMakingTheGrade_prog");
if (makingGradeProg == 0 and player:hasItem(544)) then
player:startEvent(0x011f); -- MAKING THE GRADE: Have test answers but not talked/given to Fuepepe
elseif (makingGradeProg == 1) then
player:startEvent(0x011d); -- MAKING THE GRADE: Turn in Test Answer & Told to go back to Fuepepe & Chomoro
elseif (makingGradeProg >= 2) then
player:startEvent(0x011e); -- MAKING THE GRADE: Reminder to go away
else
player:startEvent(0x00c1);
end
elseif (qStarStruck == QUEST_ACCEPTED) then
player:startEvent(0x00c6);
elseif ((qStarStruck == QUEST_AVAILABLE) and (ClassReunion ~= QUEST_ACCEPTED) and player:hasItem(584)) then
player:startEvent(0x00c5);
----------------------------------------------------------
-- Carbuncle Debacle
elseif (CarbuncleDebacle == QUEST_ACCEPTED and CarbuncleDebacleProgress == 1 or CarbuncleDebacleProgress == 2) then
player:startEvent(0x01a0); -- go and see Ripapa
elseif (CarbuncleDebacle == QUEST_ACCEPTED and CarbuncleDebacleProgress == 4) then
player:startEvent(0x01a1); -- now go and see Agado-Pugado
elseif (CarbuncleDebacle == QUEST_ACCEPTED and CarbuncleDebacleProgress == 5) then
player:startEvent(0x01a2); -- Uran-Mafran must be stopped
elseif (CarbuncleDebacle == QUEST_ACCEPTED and CarbuncleDebacleProgress == 7) then
player:startEvent(0x01a3); -- ending cs
elseif (ThePuppetMaster == QUEST_COMPLETED and ClassReunion == QUEST_COMPLETED and CarbuncleDebacle == QUEST_COMPLETED) then
player:startEvent(0x01a4); -- new cs after all 3 SMN AFs done
----------------------------------------------------------
-- Class Reunion
elseif (ClassReunion == QUEST_ACCEPTED and ClassReunionProgress == 1) then
player:startEvent(0x019c,0,450,17299,0,0,0,0,0); -- bring Koru 4 astragaloi
elseif (ClassReunion == QUEST_ACCEPTED and ClassReunionProgress == 2) then
player:startEvent(0x019e,0,0,17299,0,0,0,0,0); -- reminder to bring 4 astragaloi
elseif ((ClassReunion == QUEST_ACCEPTED and ClassReunionProgress >= 3) and (talk1 ~= 1 or talk2 ~= 1)) then
player:startEvent(0x0198); -- reminder to visit the students
elseif (ClassReunion == QUEST_ACCEPTED and ClassReunionProgress == 6 and talk1 == 1 and talk2 == 1) then
player:startEvent(0x019a); -- ending cs
elseif (ThePuppetMaster == QUEST_COMPLETED and ClassReunion == QUEST_COMPLETED) then
player:startEvent(0x019b); -- new cs after completed AF2
----------------------------------------------------------
-- The Puppet Master
elseif (ThePuppetMaster == QUEST_ACCEPTED and ThePuppetMasterProgress == 4) then
player:startEvent(0x0194); -- ending cs
elseif (ThePuppetMaster == QUEST_COMPLETED and ClassReunion ~= 2) then
player:startEvent(0x0195); -- new cs after completed AF1
----------------------------------------------------------
elseif (rootProblem == QUEST_ACCEPTED and player:getVar("rootProblem") == 1) then
player:startEvent(0x015C,0,829);
else
if (qStarStruck == QUEST_COMPLETED) then
player:startEvent(0x00d5);
else
player:startEvent(0x00c1);
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);
if (csid == 0x011d) then -- Giving him KI from Principle
player:tradeComplete();
player:addKeyItem(TATTERED_TEST_SHEET);
player:messageSpecial(KEYITEM_OBTAINED,TATTERED_TEST_SHEET);
player:setVar("QuestMakingTheGrade_prog",2);
elseif (csid == 0x00d3) then
player:tradeComplete();
player:addItem(12502);
player:messageSpecial(ITEM_OBTAINED,12502);
player:completeQuest(WINDURST,STAR_STRUCK);
player:needToZone(true);
player:addFame(WINDURST,20);
elseif (csid == 0x00c7) then
player:tradeComplete();
player:messageSpecial(GIL_OBTAINED,50);
player:addGil(50);
elseif (csid == 0x00c5 and option == 0) then
player:addQuest(WINDURST,STAR_STRUCK);
elseif (csid == 0x00d6 and option == 0) then
player:addQuest(WINDURST,BLAST_FROM_THE_PAST);
elseif (csid == 0x00e0) then
player:tradeComplete();
player:setVar("BlastFromThePast_Prog",0);
player:completeQuest(WINDURST,BLAST_FROM_THE_PAST);
player:addItem(17030);
player:messageSpecial(ITEM_OBTAINED,17030);
player:addTitle(FOSSILIZED_SEA_FARER);
player:addFame(WINDURST,30);
player:needToZone(true);
elseif (csid == 0x0194) then
if (player:getFreeSlotsCount() ~= 0) then
player:addItem(17532);
player:messageSpecial(ITEM_OBTAINED,17532);
player:completeQuest(WINDURST,THE_PUPPET_MASTER);
player:setVar("ThePuppetMasterProgress",0);
player:needToZone(true);
player:addFame(WINDURST,AF1_FAME);
else
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,17532);
end;
elseif (csid == 0x019c) then
player:delKeyItem(CARBUNCLES_TEAR);
player:setVar("ClassReunionProgress",2);
elseif (csid == 0x0197) then
player:tradeComplete();
player:setVar("ClassReunionProgress",3);
elseif (csid == 0x019a) then
if (player:getFreeSlotsCount() ~= 0) then
player:addItem(14228);
player:messageSpecial(ITEM_OBTAINED,14228);
player:completeQuest(WINDURST,CLASS_REUNION);
player:setVar("ClassReunionProgress",0);
player:setVar("ClassReunion_TalkedToFurakku",0);
player:setVar("ClassReunion_TalkedToFupepe",0);
player:needToZone(true);
player:addFame(WINDURST,AF2_FAME);
else
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,14228);
end;
elseif (csid == 0x01a0) then
player:setVar("CarbuncleDebacleProgress",2);
elseif (csid == 0x01a1) then
player:setVar("CarbuncleDebacleProgress",5);
player:addKeyItem(DAZEBREAKER_CHARM);
player:messageSpecial(KEYITEM_OBTAINED,DAZEBREAKER_CHARM);
elseif (csid == 0x01a3) then
if (player:getFreeSlotsCount() ~= 0) then
player:addItem(12520); -- Evoker's Horn
player:messageSpecial(ITEM_OBTAINED,12520);
player:addTitle(PARAGON_OF_SUMMONER_EXCELLENCE);
player:completeQuest(WINDURST,CARBUNCLE_DEBACLE);
player:addFame(WINDURST,AF3_FAME);
player:setVar("CarbuncleDebacleProgress",0);
player:needToZone(true);
else
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,12520);
end;
end;
end; | gpl-3.0 |
AlexandreCA/darkstar | scripts/globals/mobskills/Gregale_Wing_Air.lua | 33 | 1081 | ---------------------------------------------
-- Gregale Wing
--
-- Description: An icy wind deals Ice damage to enemies within a very wide area of effect. Additional effect: Paralyze
-- Type: Magical
-- Utsusemi/Blink absorb: Wipes shadows
-- Range: 30' radial.
-- Notes: Used only Jormungand and Isgebind
---------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------
function onMobSkillCheck(target,mob,skill)
if (mob:AnimationSub() ~= 1) then
return 1;
end
return 0;
end;
function onMobWeaponSkill(target, mob, skill)
local typeEffect = EFFECT_PARALYSIS;
MobStatusEffectMove(mob, target, typeEffect, 40, 0, 120);
local dmgmod = 1;
local info = MobMagicalMove(mob,target,skill,mob:getWeaponDmg()*5,ELE_ICE,dmgmod,TP_NO_EFFECT);
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_MAGICAL,MOBPARAM_ICE,MOBPARAM_WIPE_SHADOWS);
target:delHP(dmg);
return dmg;
end;
| gpl-3.0 |
mountainwalker/progams | startup_2.lua | 1 | 3880 | local mode = 0
rednet.open("top")
modem = peripheral.wrap("top")
local status = {[1]=1,[2]=1,[3]=1,[4]=2,[5]=2,[6]=2}
local RPM_1 = {[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0}
local RPM_vars = {[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0}
--mode 0 mode normal
--mode 2 mode economie
--mode 1 mode boost
local turbine_1,turbine_2,turbine_3,turbine_4,turbine_5,turbine_6 = "","","","","","" -- nom des turbines peripheriques
function console(message)
heure = tostring(os.time())
print("["..heure.."] "..message)
end
function receive()
local sender = 0
local message = ""
sender,message = rednet.receive()
if (sender == 1) then
mode = tonumber(message)
print(mode)
message = "passage en mode"..message
console(message)
end
end
function change()
for i=1,6 do
local PeripheralName = "turbine_"..tostring(i)
if (status[i] = 1) then
modem.callRemote(PeripheralName, setInductorEngaged(false))
modem.callRemote(PeripheralName, setFluidlowRateMax(10))
elseif (status[i] = 2) then
modem.callRemote(PeripheralName, setInductorEngaged(true))
modem.callRemote(PeripheralName, setFluidlowRateMax(2000))
elseif (status [i] = 0)
modem.callRemote(PeripheralName, setActive(false))
local message = "reactor"..tostring(i).."dissbled"
console(message)
end
end
end
function adjust()
while (mode == 1) do
for (i=1,6) do
local PeripheralName = "turbine_"..tostring(i)
local RPM = modem.callRemote(PeripheralName,getRotorSpeed())
if (RPM <= 1750)then
if (RPM <= 1600) then
modem.callRemote(PeripheralName,setFluidlowRateMax(modem.callRemote(PeripheralName, getFluidlowRateMax())+10))
else
modem.callRemote(PeripheralName,setFluidlowRateMax(modem.callRemote(PeripheralName, getFluidlowRateMax())+1))
end
elseif(RPM >= 1850) then
if (RPM >= 2000) then
modem.callRemote(PeripheralName,setFluidlowRateMax(modem.callRemote(PeripheralName, getFluidlowRateMax())-10))
else
modem.callRemote(PeripheralName,setFluidlowRateMax(modem.callRemote(PeripheralName, getFluidlowRateMax())-1))
end
end
end
end
while (mode == 0) do
for (i=1,6) do
local PeripheralName = "turbine_"..tostring(i)
local RPM = modem.callRemote(PeripheralName,getRotorSpeed())
if (RPM <= 1750)then
if (RPM <= 1600) then
modem.callRemote(PeripheralName,setFluidlowRateMax(modem.callRemote(PeripheralName, getFluidlowRateMax())+10))
else
modem.callRemote(PeripheralName,setFluidlowRateMax(modem.callRemote(PeripheralName, getFluidlowRateMax())+1))
end
elseif(RPM >= 1850) then
if (RPM >= 2000) then
modem.callRemote(PeripheralName,setFluidlowRateMax(modem.callRemote(PeripheralName, getFluidlowRateMax())-10))
else
modem.callRemote(PeripheralName,setFluidlowRateMax(modem.callRemote(PeripheralName, getFluidlowRateMax())-1))
end
end
end
end
while (mode == 2) do
for (i=1,6) do
local PeripheralName = "turbine_"..tostring(i)
local RPM = modem.callRemote(PeripheralName,getRotorSpeed())
if (RPM <= 1750)then
if (RPM <= 1600) then
modem.callRemote(PeripheralName,setFluidlowRateMax(modem.callRemote(PeripheralName, getFluidlowRateMax())+10))
else
modem.callRemote(PeripheralName,setFluidlowRateMax(modem.callRemote(PeripheralName, getFluidlowRateMax())+1))
end
elseif(RPM >= 1850) then
if (RPM >= 2000) then
modem.callRemote(PeripheralName,setFluidlowRateMax(modem.callRemote(PeripheralName, getFluidlowRateMax())-10))
else
modem.callRemote(PeripheralName,setFluidlowRateMax(modem.callRemote(PeripheralName, getFluidlowRateMax())-1))
end
end
end
end
if (mode == 0) then
status = {1,1,1,2,2,2}
elseif (mode == 1) then
status = {2,2,2,2,2,2}
elseif (mode == 2) then
status = {1,1,1,1,1,1}
end
change()
end
receive()
parallel.waitForAll(receive,adjust)
| gpl-2.0 |
AlexandreCA/update | scripts/globals/items/bowl_of_delicious_puls.lua | 35 | 1320 | -----------------------------------------
-- ID: 4533
-- Item: Bowl of Delicious Puls
-- Food Effect: 240Min, All Races
-----------------------------------------
-- Dexterity -1
-- Vitality 3
-- Health Regen While Healing 5
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,14400,4533);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_DEX, -1);
target:addMod(MOD_VIT, 3);
target:addMod(MOD_HPHEAL, 5);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_DEX, -1);
target:delMod(MOD_VIT, 3);
target:delMod(MOD_HPHEAL, 5);
end;
| gpl-3.0 |
AlexandreCA/darkstar | scripts/zones/Southern_San_dOria/npcs/Ashene.lua | 13 | 2238 | -----------------------------------
-- Area: Southern San d'Oria
-- NPC: Ashene
-- Standard Merchant NPC
-- @zone 230
-- @pos 70 0 61
-----------------------------------
package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/shop");
require("scripts/globals/quests");
require("scripts/zones/Southern_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
-- "Flyers for Regine" conditional script
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:showText(npc,ASH_THADI_ENE_SHOP_DIALOG);
local stock = {0x4047,4309,1, --Baselard
0x4094,16934,1, --Gladius
0x40a1,21067,1, --Broadsword
0x40c0,35769,1, --Hunting Sword
0x408c,13406,1, --Fleuret
0x4001,129,2, --Cesti
0x4042,1827,2, --Dagger
0x4098,7128,2, --Iron Sword
0x40b6,8294,2, --Longsword
0x4040,140,3, --Bronze Dagger
0x4041,837,3, --Brass Dagger
0x4093,3523,3, --Brass Xiphos
0x4097,241,3, --Bronze Sword
0x40b5,1674,3} --Spatha
showNationShop(player, SANDORIA, stock);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
AlexandreCA/darkstar | scripts/zones/Alzadaal_Undersea_Ruins/TextIDs.lua | 22 | 1261 | -- Variable TextID Description text
-- General Texts
ITEM_CANNOT_BE_OBTAINED = 6379; -- You cannot obtain the item <item> come back again after sorting your inventory
ITEM_OBTAINED = 6384; -- Obtained: <item>
GIL_OBTAINED = 6385; -- Obtained <number> gil
KEYITEM_OBTAINED = 6387; -- Obtained key item: <keyitem>
-- Assault / Salvage
CANNOT_ENTER = 7437; -- You cannot enter at this time. Please wait a while before trying again.
AREA_FULL = 7438; -- This area is fully occupied. You were unable to enter.
MEMBER_NO_REQS = 7442; -- Not all of your party members meet the requirements for this objective. Unable to enter area.
MEMBER_TOO_FAR = 7446; -- One or more party members are too far away from the entrance. Unable to enter area.
MEMBER_IMBUED_ITEM = 7447; -- One or more party members are carrying imbued items. Unable to enter area
IMBUED_ITEM = 7448; -- You are carrying imbued items. Unable to enter area
MYTHIC_REQUIRED = 7450; -- You do not have the appropriate mythic weapon equipped. Unable to enter area.
-- Other Texts
NOTHING_HAPPENS = 119; -- Nothing happens...
RESPONSE = 7225; -- There is no response...
DEVICE_MALFUNCTIONING = 7241; -- The device appears to be malfunctioning...
| gpl-3.0 |
xinran505982/videolan_vlc | share/lua/playlist/vimeo.lua | 65 | 3213 | --[[
$Id$
Copyright © 2009-2013 the VideoLAN team
Authors: Konstantin Pavlov (thresh@videolan.org)
François Revol (revol@free.fr)
Pierre Ynard
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; either version 2 of the License, or
(at your option) any later version.
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.
--]]
function get_prefres()
local prefres = -1
if vlc.var and vlc.var.inherit then
prefres = vlc.var.inherit(nil, "preferred-resolution")
if prefres == nil then
prefres = -1
end
end
return prefres
end
-- Probe function.
function probe()
return ( vlc.access == "http" or vlc.access == "https" )
and ( string.match( vlc.path, "vimeo%.com/%d+$" )
or string.match( vlc.path, "player%.vimeo%.com" ) )
-- do not match other addresses,
-- else we'll also try to decode the actual video url
end
-- Parse function.
function parse()
if not string.match( vlc.path, "player%.vimeo%.com" ) then -- Web page URL
while true do
local line = vlc.readline()
if not line then break end
path = string.match( line, "data%-config%-url=\"(.-)\"" )
if path then
path = vlc.strings.resolve_xml_special_chars( path )
return { { path = path } }
end
end
vlc.msg.err( "Couldn't extract vimeo video URL, please check for updates to this script" )
return { }
else -- API URL
local prefres = get_prefres()
local line = vlc.readline() -- data is on one line only
for stream in string.gmatch( line, "{([^}]*\"profile\":[^}]*)}" ) do
local url = string.match( stream, "\"url\":\"(.-)\"" )
if url then
path = url
if prefres < 0 then
break
end
local height = string.match( stream, "\"height\":(%d+)[,}]" )
if not height or tonumber(height) <= prefres then
break
end
end
end
if not path then
vlc.msg.err( "Couldn't extract vimeo video URL, please check for updates to this script" )
return { }
end
local name = string.match( line, "\"title\":\"(.-)\"" )
local artist = string.match( line, "\"owner\":{[^}]-\"name\":\"(.-)\"" )
local arturl = string.match( line, "\"thumbs\":{\"[^\"]+\":\"(.-)\"" )
local duration = string.match( line, "\"duration\":(%d+)[,}]" )
return { { path = path; name = name; artist = artist; arturl = arturl; duration = duration } }
end
end
| gpl-2.0 |
virgo-agent-toolkit/rackspace-monitoring-agent | hostinfo/procs.lua | 3 | 2054 | --[[
Copyright 2015 Rackspace
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--]]
local HostInfo = require('./base').HostInfo
local sigar = require('sigar')
--[[ Process Info ]]--
local Info = HostInfo:extend()
function Info:initialize()
HostInfo.initialize(self)
end
function Info:_run(callback)
local ctx, procs
ctx = sigar:new()
procs = ctx:procs()
for i=1, #procs do
local pid = procs[i]
local proc = ctx:proc(pid)
local obj = {}
obj.pid = pid
local t = proc:exe()
if t then
local exe_fields = {
'name',
'cwd',
'root'
}
for _, v in pairs(exe_fields) do
obj['exe_' .. v] = t[v]
end
end
t = proc:time()
if t then
local time_fields = {
'start_time',
'user',
'sys',
'total'
}
for _, v in pairs(time_fields) do
obj['time_' .. v] = t[v]
end
end
t = proc:state()
if t then
local proc_fields = {
'name',
'ppid',
'priority',
'nice',
'threads'
}
for _, v in pairs(proc_fields) do
obj['state_' .. v] = t[v]
end
end
t = proc:mem()
if t then
local memory_fields = {
'size',
'resident',
'share',
'major_faults',
'minor_faults',
'page_faults'
}
for _, v in pairs(memory_fields) do
obj['memory_' .. v] = t[v]
end
end
table.insert(self._params, obj)
end
callback()
end
function Info:getType()
return 'PROCS'
end
return Info
| apache-2.0 |
AlexandreCA/darkstar | scripts/zones/RuLude_Gardens/npcs/Ghye_Dachanthu.lua | 13 | 1065 | ----------------------------------
-- Area: Ru'Lude Gardens
-- NPC: Ghye Dachanthu
-- Type: Item Deliverer
-- @zone: 243
-- @pos -62.789 11.999 -25.959
--
-----------------------------------
package.loaded["scripts/zones/RuLude_Gardens/TextIDs"] = nil;
require("scripts/zones/RuLude_Gardens/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc, ITEM_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 |
amedlock/breakout | conf.lua | 1 | 1594 |
function love.conf(t)
t.title = "Breakout" -- The title of the window the game is in (string)
t.author = "David Medlock" -- The author of the game (string)
t.url = nil -- The website of the game (string)
t.identity = "breakout" -- The name of the save directory (string)
t.version = "0.8.0" -- The LOVE version this game was made for (string)
t.console = false -- Attach a console (boolean, Windows only)
t.release = false -- Enable release mode (boolean)
t.screen.width = 800 -- The window width (number)
t.screen.height = 600 -- The window height (number)
t.screen.fullscreen = false -- Enable fullscreen (boolean)
t.screen.vsync = false -- Enable vertical sync (boolean)
t.screen.fsaa = 0 -- The number of FSAA-buffers (number)
t.modules.joystick = true -- Enable the joystick module (boolean)
t.modules.audio = true -- Enable the audio module (boolean)
t.modules.keyboard = true -- Enable the keyboard module (boolean)
t.modules.event = true -- Enable the event module (boolean)
t.modules.image = true -- Enable the image module (boolean)
t.modules.graphics = true -- Enable the graphics module (boolean)
t.modules.timer = true -- Enable the timer module (boolean)
t.modules.mouse = true -- Enable the mouse module (boolean)
t.modules.sound = true -- Enable the sound module (boolean)
t.modules.physics = false -- Enable the physics module (boolean)
end
| mit |
AlexandreCA/darkstar | scripts/globals/weaponskills/blade_shun.lua | 11 | 1803 | -----------------------------------
-- Blade Shun
-- Katana weapon skill
-- Skill level: N/A
-- Description: Delivers a fivefold attack. Attack power varies with TP.
-- In order to obtain Blade: Shun the quest Martial Mastery must be completed.
-- This Weapon Skill's first hit params.ftp is duplicated for all additional hits.
-- Alignet with the Flame Gorget, Light Gorget & Thunder Gorget.
-- Alignet with the Flame Belt, Light Belt & Thunder Belt.
-- Element: None
-- Skillchain Properties: Fusion/Impaction
-- Modifiers: DEX:73~85%, depending on merit points upgrades.
-- Damage Multipliers by TP:
-- 100% 200% 300%
-- 0.6875 0.6875 0.6875
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/weaponskills");
-----------------------------------
function onUseWeaponSkill(player, target, wsID, tp, primary)
local params = {};
params.numHits = 5;
params.ftp100 = 0.6875; params.ftp200 = 0.6875; params.ftp300 = 0.6875;
params.str_wsc = 0.0; params.dex_wsc = 0.85 + (player:getMerit(MERIT_BLADE_SHUN) / 100); params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0;
params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0;
params.canCrit = false;
params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0;
params.atkmulti = 1;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.ftp100 = 1; params.ftp200 = 1; params.ftp300 = 1;
params.dex_wsc = 0.7 + (player:getMerit(MERIT_BLADE_SHUN) / 100);
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, params, tp, primary);
return tpHits, extraHits, criticalHit, damage;
end | gpl-3.0 |
AlexandreCA/update | scripts/zones/Al_Zahbi/npcs/Banjanu.lua | 38 | 1025 | -----------------------------------
-- Area: Al Zahbi
-- NPC: Banjanu
-- Type: Standard NPC
-- @zone: 48
-- @pos -75.954 0.999 105.367
--
-- Auto-Script: Requires Verification (Verified by Brawndo)
-----------------------------------
package.loaded["scripts/zones/Al_Zahbi/TextIDs"] = nil;
-----------------------------------
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x0106);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
jstewart-amd/premake-core | tests/actions/vstudio/vc2010/test_link.lua | 2 | 12670 | --
-- tests/actions/vstudio/vc2010/test_link.lua
-- Validate linking and project references in Visual Studio 2010 C/C++ projects.
-- Copyright (c) 2011-2013 Jason Perkins and the Premake project
--
local suite = test.declare("vs2010_link")
local vc2010 = premake.vstudio.vc2010
local project = premake.project
--
-- Setup
--
local wks, prj
function suite.setup()
premake.action.set("vs2010")
wks, prj = test.createWorkspace()
kind "SharedLib"
end
local function prepare(platform)
local cfg = test.getconfig(prj, "Debug", platform)
vc2010.linker(cfg)
end
--
-- Check the basic element structure with default settings.
--
function suite.defaultSettings()
kind "SharedLib"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<ImportLibrary>bin\Debug\MyProject.lib</ImportLibrary>
</Link>
]]
end
--
-- Check the basic element structure with a release build.
--
function suite.defaultSettings_onOptimize()
optimize "On"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ImportLibrary>bin\Debug\MyProject.lib</ImportLibrary>
</Link>
]]
end
--
-- Check subsystem values with each project kind.
--
function suite.subsystem_onConsoleApp()
kind "ConsoleApp"
prepare()
test.capture [[
<Link>
<SubSystem>Console</SubSystem>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
]]
end
function suite.subsystem_onWindowedApp()
kind "WindowedApp"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
]]
end
function suite.subsystem_onSharedLib()
kind "SharedLib"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<ImportLibrary>bin\Debug\MyProject.lib</ImportLibrary>
</Link>
]]
end
function suite.subsystem_onStaticLib()
kind "StaticLib"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
</Link>
]]
end
--
-- Test the handling of the NoImplicitLink flag.
--
function suite.linkDependencies_onNoImplicitLink()
flags "NoImplicitLink"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<ImportLibrary>bin\Debug\MyProject.lib</ImportLibrary>
</Link>
<ProjectReference>
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
]]
end
--
-- Test the handling of the Symbols flag.
--
function suite.generateDebugInfo_onSymbolsOn_on2010()
premake.action.set("vs2010")
symbols "On"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
]]
end
function suite.generateDebugInfo_onSymbolsFastLink_on2010()
premake.action.set("vs2010")
symbols "FastLink"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
]]
end
function suite.generateDebugInfo_onSymbolsFull_on2010()
premake.action.set("vs2010")
symbols "Full"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
]]
end
function suite.generateDebugInfo_onSymbolsOn_on2015()
premake.action.set("vs2015")
symbols "On"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
]]
end
function suite.generateDebugInfo_onSymbolsFastLink_on2015()
premake.action.set("vs2015")
symbols "FastLink"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<GenerateDebugInformation>DebugFastLink</GenerateDebugInformation>
]]
end
function suite.generateDebugInfo_onSymbolsFull_on2015()
premake.action.set("vs2015")
symbols "Full"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
]]
end
function suite.generateDebugInfo_onSymbolsFull_on2017()
premake.action.set("vs2017")
symbols "Full"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
]]
end
--
-- Any system libraries specified in links() should be listed as
-- additional dependencies.
--
function suite.additionalDependencies_onSystemLinks()
links { "lua", "zlib" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalDependencies>lua.lib;zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
]]
end
function suite.additionalDependencies_onSystemLinksStatic()
kind "StaticLib"
links { "lua", "zlib" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
</Link>
<Lib>
<AdditionalDependencies>lua.lib;zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Lib>
]]
end
--
-- Any system libraries specified in links() with valid extensions should
-- be listed with those extensions.
--
function suite.additionalDependencies_onSystemLinksExtensions()
links { "lua.obj", "zlib.lib" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalDependencies>lua.obj;zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
]]
end
function suite.additionalDependencies_onSystemLinksExtensionsStatic()
kind "StaticLib"
links { "lua.obj", "zlib.lib" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
</Link>
<Lib>
<AdditionalDependencies>lua.obj;zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Lib>
]]
end
--
-- Any system libraries specified in links() with multiple dots should
-- only have .lib appended to the end when no valid extension is found
--
function suite.additionalDependencies_onSystemLinksExtensionsMultipleDots()
links { "lua.5.3.lib", "lua.5.4" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalDependencies>lua.5.3.lib;lua.5.4.lib;%(AdditionalDependencies)</AdditionalDependencies>
]]
end
function suite.additionalDependencies_onSystemLinksExtensionsMultipleDotsStatic()
kind "StaticLib"
links { "lua.5.3.lib", "lua.5.4" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
</Link>
<Lib>
<AdditionalDependencies>lua.5.3.lib;lua.5.4.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Lib>
]]
end
--
-- Additional library directories should be specified, relative to the project.
--
function suite.additionalLibraryDirectories_onLibDirs()
libdirs { "../lib", "../lib64" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalLibraryDirectories>..\lib;..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
]]
end
--
-- Sibling projects do not need to be listed in additional dependencies, as Visual
-- Studio will link them implicitly.
--
function suite.excludeSiblings()
links { "MyProject2" }
test.createproject(wks)
kind "SharedLib"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<ImportLibrary>bin\Debug\MyProject.lib</ImportLibrary>
</Link>
]]
end
--
-- If the NoImplicitLink flag is set, all dependencies should be listed explicitly.
--
function suite.includeSiblings_onNoImplicitLink()
flags { "NoImplicitLink" }
links { "MyProject2" }
test.createproject(wks)
kind "SharedLib"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalDependencies>bin\Debug\MyProject2.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImportLibrary>bin\Debug\MyProject.lib</ImportLibrary>
</Link>
<ProjectReference>
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
]]
end
--
-- Static libraries do not link dependencies directly, to maintain
-- compatibility with GCC and others.
--
function suite.additionalDependencies_onSystemLinksAndStaticLib()
kind "StaticLib"
links { "lua", "zlib" }
libdirs { "../lib", "../lib64" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
</Link>
]]
end
--
-- Check handling of the import library settings.
--
function suite.importLibrary_onImpLibDir()
implibdir "../lib"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<ImportLibrary>..\lib\MyProject.lib</ImportLibrary>
</Link>
]]
end
--
-- Check handling of additional options.
--
function suite.additionalOptions_onNonStaticLib()
kind "SharedLib"
linkoptions { "/kupo" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<ImportLibrary>bin\Debug\MyProject.lib</ImportLibrary>
<AdditionalOptions>/kupo %(AdditionalOptions)</AdditionalOptions>
]]
end
function suite.additionalOptions_onStaticLib()
kind "StaticLib"
linkoptions { "/kupo" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
</Link>
<Lib>
<AdditionalOptions>/kupo %(AdditionalOptions)</AdditionalOptions>
</Lib>
]]
end
--
-- Enable reference optimizing if Optimize flag is specified.
--
function suite.optimizeReferences_onOptimizeFlag()
optimize "On"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
]]
end
--
-- Correctly handle module definition (.def) files.
--
function suite.recognizesModuleDefinitionFile()
files { "hello.cpp", "hello.def" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<ImportLibrary>bin\Debug\MyProject.lib</ImportLibrary>
<ModuleDefinitionFile>hello.def</ModuleDefinitionFile>
</Link>
]]
end
--
-- Managed assembly references should not be listed in additional dependencies.
--
function suite.ignoresAssemblyReferences()
links { "kernel32", "System.dll", "System.Data.dll" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
]]
end
--
-- Xbox 360 doesn't list a subsystem or entry point.
--
function suite.onXbox360()
kind "ConsoleApp"
system "Xbox360"
prepare()
test.capture [[
]]
end
--
-- Xbox 360 uses .lib for library extensions
--
function suite.libAdded_onXbox360SystemLibs()
kind "ConsoleApp"
system "Xbox360"
links { "user32" }
prepare()
test.capture [[
<Link>
<AdditionalDependencies>user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
]]
end
--
-- Check handling of warning flags.
--
function suite.fatalWarnings_onDynamicLink()
kind "ConsoleApp"
flags { "FatalLinkWarnings" }
prepare()
test.capture [[
<Link>
<SubSystem>Console</SubSystem>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
]]
end
function suite.fatalWarnings_onStaticLink()
kind "StaticLib"
flags { "FatalLinkWarnings" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
</Link>
<Lib>
<TreatLibWarningAsErrors>true</TreatLibWarningAsErrors>
</Lib>
]]
end
--
-- Test generating .map files.
--
function suite.generateMapFile_onMapsFlag()
flags { "Maps" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<ImportLibrary>bin\Debug\MyProject.lib</ImportLibrary>
<GenerateMapFile>true</GenerateMapFile>
</Link>
]]
end
--
-- Test ignoring default libraries with extensions specified.
--
function suite.ignoreDefaultLibraries_WithExtensions()
ignoredefaultlibraries { "lib1.lib", "lib2.obj" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<ImportLibrary>bin\Debug\MyProject.lib</ImportLibrary>
<IgnoreSpecificDefaultLibraries>lib1.lib;lib2.obj</IgnoreSpecificDefaultLibraries>
</Link>
]]
end
--
-- Test ignoring default libraries without extensions specified.
--
function suite.ignoreDefaultLibraries_WithExtensions()
ignoredefaultlibraries { "lib1", "lib2.obj" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<ImportLibrary>bin\Debug\MyProject.lib</ImportLibrary>
<IgnoreSpecificDefaultLibraries>lib1.lib;lib2.obj</IgnoreSpecificDefaultLibraries>
</Link>
]]
end
| bsd-3-clause |
lancehilliard/TGNS | mods/tgns/output/lua/shine/extensions/scoreboard/server.lua | 1 | 41484 | Plugin.HasConfig = true
Plugin.ConfigName = "scoreboard.json"
local changers = {}
local approvalCounts = {}
local vrConfirmed = {}
-- local vrConfirmedBy = {}
local teamScoresDatas = {}
local vouches = {}
local squadNumbers = {}
local NUMBER_OF_GAMEPLAY_SECONDS_TO_SHOW_LIFEFORM_ICONS = 270
local tunnelDescriptions = {}
local streamingWebAddresses = {}
local approveCache = {}
local approveCacheWasPreloaded = false
local resourceTowersKilled = {}
local lastStartTimeSeconds = 0
local lastKnownPrefixes = {}
local function PlayerCanSeeAfkStatus(sourcePlayer, targetPlayer)
local result = false
if sourcePlayer ~= nil and targetPlayer ~= nil then
end
local sendToPlayerCanKickAfkPlayers = TGNS.ClientAction(targetPlayer, function(c)
local playerIsAdmin = TGNS.IsClientAdmin(c)
local playerIsGuardian = TGNS.IsClientGuardian(c)
return playerIsAdmin or playerIsGuardian
end
)
local sameTeams = TGNS.PlayersAreTeammates(sourcePlayer, targetPlayer)
result = sameTeams or sendToPlayerCanKickAfkPlayers
return result
end
local function GetPlayerPrefix(sourcePlayer, targetPlayer)
local result = ""
local client = TGNS.GetClient(sourcePlayer)
if client then
local groupIcons = Shine.Plugins.scoreboard.Config.GroupIcons
table.sort(groupIcons, function(t1, t2) return t1.sort < t2.sort end)
for _, groupicon in ipairs(groupIcons) do
if TGNS.ClientIsInGroup(client, groupicon.group) then
result = groupicon.icon
break
end
end
if result == nil then
result = Shine.Plugins.scoreboard.Config.CatchAll
end
if TGNS.IsPlayerAFK(sourcePlayer) and PlayerCanSeeAfkStatus(sourcePlayer, targetPlayer) then
result = Shine.Plugins.scoreboard.Config.AFK .. result
end
if Shine.Plugins.betterknownas and Shine.Plugins.betterknownas.Enabled and Shine.Plugins.betterknownas.IsPlayingWithoutBkaName and Shine.Plugins.betterknownas:IsPlayingWithoutBkaName(sourcePlayer) then
result = result .. "*"
end
else
result = lastKnownPrefixes[sourcePlayer:GetId()]
end
lastKnownPrefixes[sourcePlayer:GetId()] = result
return result
end
local function SendNetworkMessage(sourcePlayer, targetPlayer)
if sourcePlayer and targetPlayer then
local sourceClient = TGNS.GetClient(sourcePlayer)
local sourcePlayerHasWelder = (TGNS.IsPlayerAlive(sourcePlayer) and TGNS.PlayerIsMarine(sourcePlayer)) and sourcePlayer:GetWeapon(Welder.kMapName) ~= nil
if Shine.GetGamemode() == "Infested" then
sourcePlayerHasWelder = false
end
local sourcePlayerHasMines = TGNS.IsPlayerAlive(sourcePlayer) and sourcePlayer:GetWeapon(LayMines.kMapName) ~= nil
local sourcePlayerHasClusterGrenades = TGNS.IsPlayerAlive(sourcePlayer) and sourcePlayer:GetWeapon(ClusterGrenadeThrower.kMapName) ~= nil
local sourcePlayerHasGasGrenades = TGNS.IsPlayerAlive(sourcePlayer) and sourcePlayer:GetWeapon(GasGrenadeThrower.kMapName) ~= nil
local sourcePlayerHasPulseGrenades = TGNS.IsPlayerAlive(sourcePlayer) and sourcePlayer:GetWeapon(PulseGrenadeThrower.kMapName) ~= nil
local sourcePlayerTunnelDescription = TGNS.PlayerIsAlien(sourcePlayer) and (tunnelDescriptions[sourcePlayer:GetClientIndex()] or "") or ""
local sourcePlayerHasCelerity = TGNS.IsPlayerAlive(sourcePlayer) and GetHasCelerityUpgrade(sourcePlayer)
local sourcePlayerHasAdrenaline = TGNS.IsPlayerAlive(sourcePlayer) and GetHasAdrenalineUpgrade(sourcePlayer)
local sourcePlayerHasSilence = TGNS.IsPlayerAlive(sourcePlayer) and GetHasSilenceUpgrade(sourcePlayer)
local sourcePlayerHasRegeneration = TGNS.IsPlayerAlive(sourcePlayer) and GetHasRegenerationUpgrade(sourcePlayer)
local sourcePlayerHasCarapace = TGNS.IsPlayerAlive(sourcePlayer) and GetHasCarapaceUpgrade(sourcePlayer)
local sourcePlayerHasCrush = TGNS.IsPlayerAlive(sourcePlayer) and GetHasCrushUpgrade(sourcePlayer)
local sourcePlayerHasAura = TGNS.IsPlayerAlive(sourcePlayer) and GetHasAuraUpgrade(sourcePlayer)
local sourcePlayerHasFocus = TGNS.IsPlayerAlive(sourcePlayer) and GetHasFocusUpgrade(sourcePlayer)
local sourcePlayerHasVampirism = TGNS.IsPlayerAlive(sourcePlayer) and GetHasVampirismUpgrade(sourcePlayer)
local resourceTowersKilled = resourceTowersKilled[TGNS.GetClient(sourcePlayer)] or 0
local isOptedInAsCaptainsPlayer = Shine.Plugins.captains and Shine.Plugins.captains.IsOptedInAsPlayer and Shine.Plugins.captains:IsOptedInAsPlayer(sourceClient)
local isOptedInAsCaptainsCaptain = Shine.Plugins.captains and Shine.Plugins.captains.IsOptedInAsCaptain and Shine.Plugins.captains:IsOptedInAsCaptain(sourceClient)
local isOptedInForCaptains = isOptedInAsCaptainsPlayer or isOptedInAsCaptainsCaptain
TGNS.SendNetworkMessageToPlayer(targetPlayer, Shine.Plugins.scoreboard.SCOREBOARD_DATA, {i=sourcePlayer:GetClientIndex(), p=GetPlayerPrefix(sourcePlayer, targetPlayer), c=TGNS.ClientIsInGroup(sourceClient, "captains_group"),s=Shine.Plugins.speclisten and Shine.Plugins.speclisten:GetIsUsingSvi(sourceClient), b=(Shine.Plugins.betterknownas and Shine.Plugins.betterknownas:PlayerFailsBkaPrerequisite(sourcePlayer)), n=(Shine.Plugins.newcomms and Shine.Plugins.newcomms.ClientIsGated and Shine.Plugins.newcomms:ClientIsGated(sourceClient)), w=sourcePlayerHasWelder, m=sourcePlayerHasMines, cg=sourcePlayerHasClusterGrenades, gg=sourcePlayerHasGasGrenades, pg=sourcePlayerHasPulseGrenades, t=sourcePlayerTunnelDescription, u1=sourcePlayerHasCelerity, u2=sourcePlayerHasAdrenaline, u3=sourcePlayerHasSilence, u4=sourcePlayerHasRegeneration, u5=sourcePlayerHasCarapace, u6=sourcePlayerHasCrush, u7=sourcePlayerHasAura, u8=sourcePlayerHasFocus, u9=sourcePlayerHasVampirism, streaming=streamingWebAddresses[sourceClient] or "", rtk=resourceTowersKilled, o=isOptedInForCaptains})
end
end
function Plugin:SendTeamScoresDatas()
local marineTeamName = "Marine Team"
local marineTeamScore = 0
local alienTeamName = "Alien Team"
local alienTeamScore = 0
local teamNameCreator = function(c) return string.format("Team %s", TGNS.Truncate(TGNS.GetClientName(c), kMaxNameLength)) end
TGNS.DoFor(teamScoresDatas, function(d)
local client = TGNS.GetClientByNs2Id(d.i)
if client ~= nil then
if TGNS.GetClientTeamNumber(client) == kMarineTeamType then
marineTeamName = teamNameCreator(client)
marineTeamScore = d.s or 0
elseif TGNS.GetClientTeamNumber(client) == kAlienTeamType then
alienTeamName = teamNameCreator(client)
alienTeamScore = d.s or 0
end
end
end)
TGNS.DoFor(TGNS.GetPlayerList(), function(p)
TGNS.SendNetworkMessageToPlayer(p, Shine.Plugins.scoreboard.TEAM_SCORES_DATA, {mn=marineTeamName,an=alienTeamName,ms=marineTeamScore,as=alienTeamScore})
end)
end
function Plugin:SetTeamScoresData(client, teamScore)
local steamId = TGNS.GetClientSteamId(client)
TGNS.DoForReverse(teamScoresDatas, function(d, index)
if d.i == steamId then
table.remove(teamScoresDatas, index)
end
end)
table.insert(teamScoresDatas, {i=steamId,s=teamScore})
TGNS.ScheduleAction(1, function()
self:SendTeamScoresDatas()
end)
end
function Plugin:AnnouncePlayerPrefix(player)
TGNS.DoFor(TGNS.GetPlayerList(), function(p)
SendNetworkMessage(player, p)
end)
end
local function UpdatePlayerPrefixes(player)
TGNS.DoFor(TGNS.GetPlayerList(), function(p)
SendNetworkMessage(p, player)
end)
end
local function initScoreboardDecorations(client)
if Shine:IsValidClient(client) then
local sourcePlayer = TGNS.GetPlayer(client)
local sourceSteamId = TGNS.GetClientSteamId(client)
if sourcePlayer then
TGNS.SendNetworkMessageToPlayer(sourcePlayer, Shine.Plugins.scoreboard.TOGGLE_OPTIONALS, {t=not TGNS.IsClientStranger(client)})
UpdatePlayerPrefixes(sourcePlayer)
Shine.Plugins.scoreboard:AnnouncePlayerPrefix(sourcePlayer)
local approvedSentTotal = 0
local approvedReceivedTotal = 0
TGNS.DoFor(TGNS.GetClientList(), function(c)
if c then
local p = TGNS.GetPlayer(c)
local targetSteamId = TGNS.GetClientSteamId(c)
if Shine.Plugins.targetedcommands:GetApprovedClients(targetSteamId)[sourceSteamId] then
TGNS.SendNetworkMessageToPlayer(p, Shine.Plugins.scoreboard.APPROVE_ALREADY_APPROVED, {c=sourcePlayer:GetClientIndex()})
approvedReceivedTotal = approvedReceivedTotal + 1
end
if Shine.Plugins.targetedcommands:GetApprovedClients(sourceSteamId)[targetSteamId] then
TGNS.SendNetworkMessageToPlayer(sourcePlayer, Shine.Plugins.scoreboard.APPROVE_ALREADY_APPROVED, {c=p:GetClientIndex()})
approvedSentTotal = approvedSentTotal + 1
end
TGNS.SendNetworkMessageToPlayer(sourcePlayer, Shine.Plugins.scoreboard.SQUAD_CONFIRMED, {c=TGNS.GetClientIndex(c),s=squadNumbers[c]})
TGNS.SendNetworkMessageToPlayer(sourcePlayer, Shine.Plugins.squadnumbers.SQUAD_CONFIRMED, {c=TGNS.GetClientIndex(c),s=squadNumbers[c]})
TGNS.SendNetworkMessageToPlayer(p, Shine.Plugins.scoreboard.SQUAD_CONFIRMED, {c=TGNS.GetClientIndex(client),s=squadNumbers[client]})
TGNS.SendNetworkMessageToPlayer(p, Shine.Plugins.squadnumbers.SQUAD_CONFIRMED, {c=TGNS.GetClientIndex(client),s=squadNumbers[client]})
local recentCaptainsData = Shine.Plugins.captains:GetRecentCaptainsData()
local recentCaptainClientIndexes = {}
TGNS.DoFor(recentCaptainsData, function(d)
local recentCaptainClient = TGNS.GetClientByNs2Id(d.steamId)
if recentCaptainClient then
local recentCaptainClientIndex = TGNS.GetClientIndex(recentCaptainClient)
table.insert(recentCaptainClientIndexes, recentCaptainClientIndex)
end
end)
if #recentCaptainClientIndexes > 0 then
local recentCaptainClientIndexesString = TGNS.Join(recentCaptainClientIndexes, ",")
TGNS.SendNetworkMessageToPlayer(p, Shine.Plugins.scoreboard.RECENT_CAPTAINS, {c=recentCaptainClientIndexesString})
end
end
end)
TGNS.SendNetworkMessageToPlayer(sourcePlayer, Shine.Plugins.scoreboard.APPROVE_RECEIVED_TOTAL, {t=approvedReceivedTotal})
TGNS.SendNetworkMessageToPlayer(sourcePlayer, Shine.Plugins.scoreboard.APPROVE_SENT_TOTAL, {t=approvedSentTotal})
end
end
end
function Plugin:GetApprovalsCount(client)
local approvalCount = TGNS.FirstOrNil(approvalCounts, function(c) return c[1] == client end)
local result = (client and approvalCount) and approvalCount[1] or 0
return result
end
function Plugin:IsVouched(client)
local result = vrConfirmed[client]
return result
end
function Plugin:ClientConnect(client)
if not TGNS.GetIsClientVirtual(client) then
local steamId = TGNS.GetClientSteamId(client)
if approveCache[steamId] ~= nil and not TGNS.Any(approvalCounts, function(c) return c[1] == client end) then
table.insert(approvalCounts, {client, approveCache[steamId]})
elseif not approveCacheWasPreloaded then
local approvalsUrl = string.format("%s&i=%s&t=14", TGNS.Config.ApproveEndpointBaseUrl, steamId)
TGNS.GetHttpAsync(approvalsUrl, function(approvalsResponseJson)
if Shine:IsValidClient(client) then
local approvalsResponse = json.decode(approvalsResponseJson) or {}
if approvalsResponse.success then
table.insert(approvalCounts, {client, approvalsResponse.result})
else
TGNS.DebugPrint(string.format("approvals ERROR: Unable to access approvals count data for NS2ID %s. msg: %s | response: %s | stacktrace: %s", steamId, approvalsResponse.msg, approvalsResponseJson, approvalsResponse.stacktrace))
end
end
end)
end
if TGNS.Any(vouches, function(v) return v.TargetPlayerId == steamId end) then
vrConfirmed[client] = true
end
local player = TGNS.GetPlayer(client)
--TGNS.ScheduleAction(2, function()
if Shine:IsValidClient(client) then
initScoreboardDecorations(client)
TGNS.DoFor(TGNS.GetClientList(), function(c)
if vrConfirmed[c] then
TGNS.SendNetworkMessageToPlayer(player, self.VR_CONFIRMED, {c=TGNS.GetClientId(c)})
end
if vrConfirmed[client] then
TGNS.SendNetworkMessageToPlayer(TGNS.GetPlayer(c), self.VR_CONFIRMED, {c=TGNS.GetClientId(client)})
end
end)
TGNS.SendNetworkMessageToPlayer(player, self.GAME_IN_PROGRESS, {b=TGNS.IsGameInProgress()})
TGNS.SendNetworkMessageToPlayer(player, self.GAME_IN_COUNTDOWN, {b=TGNS.IsGameInCountdown()})
TGNS.SendNetworkMessageToPlayer(player, self.SERVER_SIMPLE_NAME, {n=TGNS.GetSimpleServerName()})
local communityDesignationCharacter = TGNS.GetClientCommunityDesignationCharacter(client)
TGNS.SendNetworkMessageToPlayer(player, self.DESIGNATION, {c=communityDesignationCharacter})
-- TGNS.DebugPrint(string.format("communityDesignationCharacter %s: %s", steamId, communityDesignationCharacter), false, "welcomebanner")
TGNS.ScheduleAction(3, function()
if Shine:IsValidClient(client) then
communityDesignationCharacter = TGNS.GetClientCommunityDesignationCharacter(client)
TGNS.SendNetworkMessageToPlayer(TGNS.GetPlayer(client), self.DESIGNATION, {c=communityDesignationCharacter})
-- TGNS.DebugPrint(string.format("communityDesignationCharacter %s: %s", steamId, communityDesignationCharacter), false, "welcomebanner")
end
end)
end
--end)
self:AlertApplicationIconForPlayer(player)
TGNS.SendNetworkMessageToPlayer(player, Shine.Plugins.scoreboard.SERVER_ADDRESS, {a=TGNS.Config.ServerAddress})
end
end
function Plugin:AlertApplicationIconForPlayer(player)
TGNS.SendNetworkMessageToPlayer(player, self.ALERT_ICON)
end
function Plugin:PlayerNameChange(player, newName, oldName)
self:AnnouncePlayerPrefix(player)
end
function Plugin:OnEntityKilled(gamerules, victimEntity, attackerEntity, inflictorEntity, point, direction)
if victimEntity then
if victimEntity:isa("JetpackMarine") then
TGNS.DoFor(TGNS.GetPlayerList(), function(p)
TGNS.SendNetworkMessageToPlayer(p, self.HAS_JETPACK, {c=victimEntity:GetClientIndex(),h=false})
end)
end
end
if victimEntity:isa("ResourceTower") then
local attackerClient = TGNS.GetClient(attackerEntity)
if attackerClient then
resourceTowersKilled[attackerClient] = resourceTowersKilled[attackerClient] or 0
resourceTowersKilled[attackerClient] = resourceTowersKilled[attackerClient] + 1
self:AnnouncePlayerPrefix(attackerEntity)
end
end
end
function Plugin:PostJoinTeam(gamerules, player, oldTeamNumber, newTeamNumber, force, shineForce)
local client = TGNS.GetClient(player)
if client then
if newTeamNumber == kMarineTeamType then
local updateJetpackStatus = function(p)
TGNS.SendNetworkMessageToPlayer(player, self.HAS_JETPACK, {c=p:GetClientIndex(),h=p:isa("JetpackMarine")})
end
local playerList = TGNS.GetPlayerList()
TGNS.DoFor(TGNS.GetMarinePlayers(playerList), updateJetpackStatus)
TGNS.DoFor(TGNS.GetSpectatorPlayers(playerList), updateJetpackStatus)
elseif TGNS.IsPlayerReadyRoom(player) then
-- if player.GiveJetpack then
-- player:GiveJetpack()
-- local giveFuel
-- giveFuel = function()
-- if Shine:IsValidClient(client) and TGNS.IsClientReadyRoom(client) then
-- local jetpackPlayer = TGNS.GetPlayer(client)
-- if jetpackPlayer.SetFuel then
-- jetpackPlayer:SetFuel(1)
-- TGNS.ScheduleAction(1, giveFuel)
-- end
-- end
-- end
-- giveFuel()
-- end
-- TGNS.ClientGive(client, "onos", kTeam2Index)
end
squadNumbers[client] = 0
TGNS.SendNetworkMessageToPlayer(p, self.SQUAD_CONFIRMED, {c=TGNS.GetClientIndex(client),s=squadNumbers[client]})
initScoreboardDecorations(client)
end
end
function Plugin:EndGame(gamerules, winningTeam)
-- tunnelDescriptions = {}
TGNS.DoFor(TGNS.GetPlayerList(), function(p)
TGNS.SendNetworkMessageToPlayer(p, self.HAS_JETPACK_RESET, {})
TGNS.SendNetworkMessageToPlayer(p, self.GAME_IN_PROGRESS, {b=false})
self:AnnouncePlayerPrefix(p)
end)
TGNS.ScheduleAction(TGNS.ENDGAME_TIME_TO_READYROOM, function()
TGNS.DoFor(TGNS.GetPlayerList(), function(p)
TGNS.DoFor(TGNS.GetClientList(), function(c)
squadNumbers[c] = 0
TGNS.SendNetworkMessageToPlayer(p, self.SQUAD_CONFIRMED, {c=TGNS.GetClientIndex(c),s=squadNumbers[c]})
end)
end)
end)
local captainsModeEnabled = Shine.Plugins.captains and Shine.Plugins.captains.IsCaptainsModeEnabled and Shine.Plugins.captains:IsCaptainsModeEnabled()
if not captainsModeEnabled then
TGNS.ScheduleAction(TGNS.ENDGAME_TIME_TO_READYROOM + 240, function()
if not TGNS.IsGameInProgress() then
local md = TGNSMessageDisplayer.Create("APPROVALS")
TGNS.DoFor(TGNS.GetClientList(), function(c)
if c and not TGNS.IsClientStranger(c) then
local p = TGNS.GetPlayer(c)
-- local message = math.random() < 0.5 and "Someone impress you lately? Click a chevron (^) on the scoreboard to show your Approval!" or string.format("Do you like to watch? %s", math.random() < .5 and "Opt into FullSpec to join the server when it's full! http://rr.tacticalgamer.com/FullSpec/Manage" or "Use TGNS Replay to re-watch games you've played here! http://rr.tacticalgamer.com/Replay")
local message = math.random() < 0.5 and "Someone impress you lately? Click a chevron (^) on the scoreboard to show your Approval!" or "Do you like to watch? Use TGNS Replay to re-watch games you've played here! http://rr.tacticalgamer.com/Replay"
md:ToPlayerNotifyInfo(p, message)
end
end)
end
end)
end
end
function Plugin:CreateCommands()
local approvalsCountsCommand = self:BindCommand( "sh_approvalcounts", nil, function(client)
local md = TGNSMessageDisplayer.Create("APPROVALS")
local approvalCountsToDisplay = TGNS.Where(approvalCounts, function(c) return Shine:IsValidClient(c[1]) end)
TGNS.SortAscending(approvalCountsToDisplay, function(c) return c[2] end)
TGNS.DoFor(approvalCountsToDisplay, function(c)
md:ToClientConsole(client, string.format("%s: %s", TGNS.GetClientName(c[1]), c[2]))
end)
end)
approvalsCountsCommand:Help( "Show approval counts." )
local enableMuteCommand = self:BindCommand( "sh_enablemute", nil, function(client, playerPredicate)
local player = TGNS.GetPlayer(client)
if playerPredicate == nil or playerPredicate == "" then
md:ToPlayerNotifyError(player, "You must specify a player.")
else
local targetPlayer = TGNS.GetPlayerMatching(playerPredicate, nil)
if targetPlayer ~= nil then
local targetClient = TGNS.GetClient(targetPlayer)
TGNS.SendNetworkMessageToPlayer(targetPlayer, self.ENABLE_MUTE)
local mutesMd = TGNSMessageDisplayer.Create("MUTES")
mutesMd:ToPlayerNotifyInfo(TGNS.GetPlayer(client), string.format("Mute enabled for %s.", TGNS.GetClientName(targetClient)))
else
md:ToPlayerNotifyError(player, string.format("'%s' does not uniquely match a player.", playerPredicate))
end
end
end)
enableMuteCommand:AddParam{ Type = "string", TakeRestOfLine = true, Optional = true }
enableMuteCommand:Help( "<player> Enable player to mute other players." )
local textTestCommand = self:BindCommand( "sh_texttest", "tt", function(client, message, x, y)
-- Shine:SendText(client, Shine.BuildScreenMessage(81, x, y, message, 15, 255, 255, 255, 1, 1, 0 ) )
Shine.ScreenText.Add(81, {X = x, Y = y, Text = message, Duration = 15, R = 255, G = 255, B = 255, Alignment = TGNS.ShineTextAlignmentCenter, Size = 1, FadeIn = 0, IgnoreFormat = true}, client)
end)
textTestCommand:AddParam{ Type = "string" }
textTestCommand:AddParam{ Type = "number", Min = 0, Max = 1 }
textTestCommand:AddParam{ Type = "number", Min = 0, Max = 1 }
textTestCommand:Help( "Show test text to yourself." )
local wyzCommand = self:BindCommand( "otherserverall", nil, function(client)
TGNS.DoFor(TGNS.GetPlayerList(), function(p)
TGNS.SendNetworkMessageToPlayer(p, self.WYZ)
end)
end)
local streamingCommand = self:BindCommand( "sh_streaming", "streaming", function(client, webAddress)
local player = TGNS.GetPlayer(client)
local steamId = TGNS.GetClientSteamId(client)
local md = TGNSMessageDisplayer.Create("STREAMING")
if TGNS.HasNonEmptyValue(webAddress) then
md:ToPlayerNotifyInfo(player, string.format("Streaming icon created for web address '%s'.", webAddress))
md:ToPlayerNotifyInfo(player, "To remove the icon, execute this command again with no web address.")
else
if TGNS.HasNonEmptyValue(streamingWebAddresses[client]) then
md:ToPlayerNotifyInfo(player, "Streaming icon removed.")
end
md:ToPlayerNotifyInfo(player, "To show a streaming icon, execute this command again with a web address parameter.")
end
streamingWebAddresses[client] = webAddress
self:AnnouncePlayerPrefix(player)
end, true)
streamingCommand:AddParam{ Type = "string", TakeRestOfLine = true, Optional = true }
streamingCommand:Help( "<webaddress> Show your 'I'm Streaming' icon on the scoreboard" )
end
function Plugin:Initialise()
self.Enabled = true
self:CreateCommands()
TGNS.RegisterEventHook("OnEverySecond", function()
if not TGNS.IsGameInProgress() then
TGNS.DoFor(TGNS.GetPlayerList(), function(p)
self:AnnouncePlayerPrefix(p)
end)
end
end)
TGNS.RegisterEventHook("AFKChanged", function(client, playerIsAfk)
self:AnnouncePlayerPrefix(TGNS.GetPlayer(client))
end)
TGNS.RegisterEventHook("SviChanged", function(client, sviEnabled)
self:AnnouncePlayerPrefix(TGNS.GetPlayer(client))
end)
TGNS.RegisterEventHook("ClientGroupsChanged", function(client)
if client and Shine:IsValidClient(client) then
local player = TGNS.GetPlayer(client)
if player then
self:AnnouncePlayerPrefix(player)
end
end
end)
TGNS.RegisterEventHook("BkaChanged", function(client)
if Shine:IsValidClient(client) then
self:AnnouncePlayerPrefix(TGNS.GetPlayer(client))
end
end)
TGNS.RegisterEventHook("GameCountdownStarted", function(secondsSinceEpoch)
resourceTowersKilled = {}
tunnelDescriptions = {}
TGNS.DoFor(TGNS.GetPlayerList(), function(p)
self:AnnouncePlayerPrefix(p)
TGNS.SendNetworkMessageToPlayer(p, self.GAME_IN_COUNTDOWN, {b=true})
end)
end)
TGNS.RegisterEventHook("GameStarted", function(secondsSinceEpoch)
TGNS.DoFor(TGNS.GetPlayerList(), function(p)
TGNS.SendNetworkMessageToPlayer(p, self.GAME_IN_PROGRESS, {b=true})
TGNS.SendNetworkMessageToPlayer(p, self.GAME_IN_COUNTDOWN, {b=false})
end)
TGNS.ScheduleAction(NUMBER_OF_GAMEPLAY_SECONDS_TO_SHOW_LIFEFORM_ICONS, function()
if TGNS.IsGameInProgress() and TGNS.GetCurrentGameDurationInSeconds() > NUMBER_OF_GAMEPLAY_SECONDS_TO_SHOW_LIFEFORM_ICONS - 2 then
local playerList = TGNS.GetPlayerList()
TGNS.DoFor(TGNS.GetAlienClients(playerList), function(c)
squadNumbers[c] = 0
TGNS.DoFor(TGNS.GetPlayerList(), function(p)
TGNS.SendNetworkMessageToPlayer(p, self.SQUAD_CONFIRMED, {c=TGNS.GetClientIndex(c),s=squadNumbers[c]})
end)
end)
TGNS.DoFor(TGNS.GetReadyRoomPlayers(playerList), function(p)
if TGNS.IsPlayerAFK(p) then
TGNS.SendToTeam(p, kSpectatorIndex)
end
end)
end
end)
end)
TGNS.HookNetworkMessage(self.CHATTING_OR_MENUING_STARTED_RECENTLY, function(client)
-- local wasAfk = TGNS.IsClientAFK(client)
local player = TGNS.GetPlayer(client)
TGNS.ClearPlayerAFK(player)
-- if wasAfk then
self:AnnouncePlayerPrefix(player)
-- end
end)
TGNS.HookNetworkMessage(self.GAME_FEEDBACK, function(client, message)
local steamId = TGNS.GetClientSteamId(client)
local gameFeedbackUrl = string.format("%s&n=%s&t=%s&i=%s&rating=%s&reasons=%s", TGNS.Config.GameFeedbackEndpointBaseUrl, TGNS.GetSimpleServerName(), lastStartTimeSeconds, steamId, message.rating, TGNS.UrlEncode(message.reasons))
TGNS.GetHttpAsync(gameFeedbackUrl, function(gameFeedbackResponseJson)
local gameFeedbackResponse = json.decode(gameFeedbackResponseJson) or {}
if not gameFeedbackResponse.success then
TGNS.DebugPrint(string.format("scoreboard ERROR: Unable to record game feedback. msg: %s | response: %s | stacktrace: %s | url: %s", gameFeedbackResponse.msg, gameFeedbackResponseJson, gameFeedbackResponse.stacktrace, gameFeedbackUrl), false, "gamefeedback")
end
end)
end)
TGNS.HookNetworkMessage(self.APPROVE_REQUESTED, function(client, message)
local md = TGNSMessageDisplayer.Create("APPROVE")
local targetClientIndex = message.c
local player = TGNS.GetPlayer(client)
if player then
local targetClient = TGNS.GetClientById(targetClientIndex)
if targetClient and Shine:IsValidClient(targetClient) then
if client ~= targetClient then
local targetPlayer = TGNS.GetPlayer(targetClient)
if (TGNS.PlayersAreTeammates(player, targetPlayer) or TGNS.IsPlayerSpectator(player)) and not TGNS.HasClientSignedPrimerWithGames(targetClient) and not vrConfirmed[targetClient] then
vrConfirmed[targetClient] = true
-- vrConfirmedBy[targetClient] = TGNS.GetClientName(client)
local sourceSteamId = TGNS.GetClientSteamId(client)
local targetSteamId = TGNS.GetClientSteamId(targetClient)
local vouch = {}
vouch.SourcePlayerId = sourceSteamId
vouch.TargetPlayerId = targetSteamId
table.insertunique(vouches, vouch)
local vouchUrl = string.format("%s&i=%s&v=%s", TGNS.Config.VouchesEndpointBaseUrl, sourceSteamId, targetSteamId)
TGNS.GetHttpAsync(vouchUrl, function(vouchResponseJson)
local vouchResponse = json.decode(vouchResponseJson) or {}
if not vouchResponse.success then
TGNS.DebugPrint(string.format("scoreboard ERROR: Unable to vouch NS2ID %s. msg: %s | response: %s | stacktrace: %s", targetSteamId, vouchResponse.msg, vouchResponseJson, vouchResponse.stacktrace))
end
end)
TGNS.Karma(sourceSteamId, "VouchingVoicecomm")
if TGNS.IsClientStranger(targetClient) and Balance.GetTotalGamesPlayed(targetClient) <= 20 then
TGNS.Karma(targetSteamId, "ConfirmingYouCanHearVoicecomm")
TGNS.ScheduleAction(5, function()
if Shine:IsValidClient(targetClient) then
md:ToPlayerNotifyInfo(TGNS.GetPlayer(targetClient), "Welcome! We verified your hearing since you haven't read our Required Reading (are you new here?).")
end
end)
TGNS.ScheduleAction(8, function()
if Shine:IsValidClient(targetClient) then
md:ToPlayerNotifyInfo(TGNS.GetPlayer(targetClient), "Press M > Info (later) to read our Required Reading. Get a reserved slot, too!")
end
end)
end
TGNS.ExecuteEventHooks("VrConfirmed", targetClient)
TGNS.DoFor(TGNS.GetPlayerList(), function(p)
TGNS.SendNetworkMessageToPlayer(p, self.VR_CONFIRMED, {c=targetClientIndex})
end)
md:ToTeamConsole(TGNS.GetPlayerTeamNumber(player), string.format("%s confirmed that %s responded to voicecomm.", TGNS.GetPlayerName(player), TGNS.GetClientName(targetClient)))
TGNS.SendNetworkMessageToPlayer(player, self.APPROVE_MAY_TRY_AGAIN, {c=targetClientIndex})
else
Shine.Plugins.targetedcommands:Approve(client, targetClient, nil, md)
end
else
md:ToPlayerNotifyError(player, "Your modesty knows no bounds.")
end
else
md:ToPlayerNotifyError(player, "There was a problem approving.")
TGNS.SendNetworkMessageToPlayer(player, self.APPROVE_MAY_TRY_AGAIN, {c=targetClientIndex})
end
else
TGNS.ScheduleAction(1, function()
if Shine:IsValidClient(client) then
local retryPlayer = TGNS.GetPlayer(client)
if retryPlayer then
md:ToPlayerNotifyError(retryPlayer, "There was a problem approving.")
TGNS.SendNetworkMessageToPlayer(retryPlayer, self.APPROVE_MAY_TRY_AGAIN, {c=targetClientIndex})
end
end
end)
end
end)
TGNS.HookNetworkMessage(self.QUERY_REQUESTED, function(client, message)
local player = TGNS.GetPlayer(client)
local targetClientIndex = message.c
local targetClient = TGNS.GetClientById(targetClientIndex)
local md = TGNSMessageDisplayer.Create("QUERY")
local sourceSteamId = TGNS.GetClientSteamId(client)
local targetSteamId = TGNS.GetClientSteamId(targetClient)
local targetClientName = TGNS.GetClientName(targetClient)
if targetClient and Shine:IsValidClient(targetClient) then
TGNS.ScheduleAction(5, function()
if Shine:IsValidClient(client) then
TGNS.SendNetworkMessageToPlayer(TGNS.GetPlayer(client), self.QUERY_ALLOWED, {c=targetClientIndex})
end
end)
Shine.Plugins.betterknownas:ShowCurrentBka(client, targetSteamId, "BKA", "AKAs", "BKA")
if Balance then
local totalGamesCount = Balance.GetTotalGamesPlayedBySteamId(targetSteamId)
if totalGamesCount > 0 then
local targetPlayer = TGNS.GetPlayer(targetClient)
md:ToPlayerNotifyInfo(player, string.format("%s has played %s on TGNS.", targetClientName, totalGamesCount < 50 and string.format("%s games so far", totalGamesCount) or "more than 50 games"))
end
end
else
md:ToPlayerNotifyError(player, "There was a problem querying.")
end
local queryUrl = string.format("%s&sourcePlayerId=%s&targetPlayerId=%s&targetPlayerName=%s", TGNS.Config.QueryContactEndpointBaseUrl, sourceSteamId, targetSteamId, TGNS.UrlEncode(targetClientName))
TGNS.GetHttpAsync(queryUrl, function(queryResponseJson)
local queryResponse = json.decode(queryResponseJson) or {}
if not queryResponse.success then
TGNS.DebugPrint(string.format("query ERROR: Unable to report contact query. url: %s | msg: %s | response: %s | stacktrace: %s", queryUrl, queryResponse.msg, queryResponseJson, queryResponse.stacktrace))
end
end)
if math.random() < .1 then
TGNS.ScheduleAction(6, function()
if Shine:IsValidClient(client) then
md:ToPlayerNotifyInfo(TGNS.GetPlayer(client), "View recently clicked Contact Cards: M > TGNS Portal")
end
end)
end
end)
TGNS.HookNetworkMessage(self.VR_REQUESTED, function(client, message)
local player = TGNS.GetPlayer(client)
local targetClientIndex = message.c
local targetClient = TGNS.GetClientById(targetClientIndex)
local md = TGNSMessageDisplayer.Create("VR")
if targetClient and Shine:IsValidClient(targetClient) then
TGNS.ScheduleAction(10, function()
if Shine:IsValidClient(client) then
TGNS.SendNetworkMessageToPlayer(TGNS.GetPlayer(client), self.VR_ALLOWED, {})
end
end)
if vrConfirmed[targetClient] then
local vouch = TGNS.FirstOrNil(vouches, function(v) return v.TargetPlayerId == TGNS.GetClientSteamId(targetClient) end)
local vouchSourceClient = vouch and TGNS.GetClientByNs2Id(vouch.SourcePlayerId) or nil
md:ToPlayerNotifyInfo(player, string.format("%s already confirmed that %s responded to voicecomm. Learn more: M > Info > TGNS FAQ", vouchSourceClient and TGNS.GetClientName(vouchSourceClient) or "Someone", TGNS.GetClientName(targetClient)))
elseif TGNS.PlayerAction(targetClient, TGNS.IsPlayerAFK) then
md:ToPlayerNotifyError(player, string.format("This icon is disabled because %s is AFK.", TGNS.GetClientName(targetClient)))
else
local targetPlayer = TGNS.GetPlayer(targetClient)
Shine.Plugins.voicecommreminder:SendVoicecommReminder(client, targetPlayer)
end
else
md:ToPlayerNotifyError(player, "There was a problem showing the voicecomm reminder.")
end
end)
TGNS.HookNetworkMessage(self.REQUEST_AFKRR, function(client, message)
local targetClientIndex = message.c
local targetClient = TGNS.GetClientById(targetClientIndex)
local md = TGNSMessageDisplayer.Create("AFKRR")
Shine.Plugins.targetedcommands:AfkRr(client, targetClient, md)
end)
TGNS.HookNetworkMessage(self.REQUEST_STREAMING_ICON, function(client, message)
local url = message.u
streamingWebAddresses[client] = url
self:AnnouncePlayerPrefix(TGNS.GetPlayer(client))
end)
-- TGNS.RegisterEventHook("LookDownChanged", function(player, isLookingDown)
-- local isLookingUp = not isLookingDown
-- TGNS.SendNetworkMessageToPlayer(player, self.TOGGLE_CUSTOM_NUMBERS_COLUMN, {t=isLookingUp})
-- end)
TGNS.RegisterEventHook("FullGamePlayed", function(clients, winningTeam, gameDurationInSeconds, gameStartTimeInSeconds)
lastStartTimeSeconds = gameStartTimeInSeconds
local md = TGNSMessageDisplayer.Create()
md:ToAllConsole(string.format("Gametime: %s", string.DigitalTime(gameDurationInSeconds)))
end)
originalMarineGiveJetpack = Marine.GiveJetpack
Marine.GiveJetpack = function(marineSelf)
originalMarineGiveJetpack(marineSelf)
local updateJetpackStatus = function(p)
TGNS.SendNetworkMessageToPlayer(p, self.HAS_JETPACK, {c=marineSelf:GetClientIndex(),h=true})
end
local playerList = TGNS.GetPlayerList()
TGNS.DoFor(TGNS.GetMarinePlayers(playerList), updateJetpackStatus)
TGNS.DoFor(TGNS.GetSpectatorPlayers(playerList), updateJetpackStatus)
end
TGNS.ScheduleAction(5, function()
local originalAfkkickPrePlayerInfoUpdate = Shine.Plugins.afkkick.PrePlayerInfoUpdate
Shine.Plugins.afkkick.PrePlayerInfoUpdate = function(self, playerInfo, player) end
local originalAfkkickPostPlayerInfoUpdate = Shine.Plugins.afkkick.PostPlayerInfoUpdate
Shine.Plugins.afkkick.PostPlayerInfoUpdate = function(self, playerInfo, player) end
end)
local originalSelectableMixinSetHotGroupNumber = SelectableMixin.SetHotGroupNumber
SelectableMixin.SetHotGroupNumber = function(mixinSelf, hotGroupNumber)
originalSelectableMixinSetHotGroupNumber(mixinSelf, hotGroupNumber)
if mixinSelf:isa("Player") then
local mixinClient = TGNS.GetClient(mixinSelf)
squadNumbers[mixinClient] = hotGroupNumber
TGNS.DoFor(TGNS.GetPlayerList(), function(p)
TGNS.SendNetworkMessageToPlayer(p, Shine.Plugins.scoreboard.SQUAD_CONFIRMED, {c=TGNS.GetClientIndex(mixinClient),s=squadNumbers[mixinClient]})
TGNS.SendNetworkMessageToPlayer(p, Shine.Plugins.squadnumbers.SQUAD_CONFIRMED, {c=TGNS.GetClientIndex(mixinClient),s=squadNumbers[mixinClient]})
end)
end
end
local isShownOnMarineScoreboard = function(weapon)
local result = weapon:isa("Welder") or weapon:isa("LayMines") or weapon:isa("GrenadeThrower")
return result
end
local originalWeaponOwnerMixinAddWeapon = WeaponOwnerMixin.AddWeapon
WeaponOwnerMixin.AddWeapon = function(weaponOwnerMixinSelf, weapon, setActive)
local result = originalWeaponOwnerMixinAddWeapon(weaponOwnerMixinSelf, weapon, setActive)
if isShownOnMarineScoreboard(weapon) then
self:AnnouncePlayerPrefix(weaponOwnerMixinSelf)
end
return result
end
local originalWeaponOwnerMixinRemoveWeapon = WeaponOwnerMixin.RemoveWeapon
WeaponOwnerMixin.RemoveWeapon = function(weaponOwnerMixinSelf, weapon)
originalWeaponOwnerMixinRemoveWeapon(weaponOwnerMixinSelf, weapon)
if isShownOnMarineScoreboard(weapon) then
self:AnnouncePlayerPrefix(weaponOwnerMixinSelf)
end
end
local OnTunnelExitAddedOrRemoved = function(tunnelSelf, exit, original)
original(tunnelSelf, exit)
local unnamedLocationName = "<Unnamed Location>"
local exitLocationNames = {}
if tunnelSelf.exitAId and tunnelSelf.exitAId ~= Entity.invalidId then
local location = GetLocationForPoint(tunnelSelf.exitAEntityPosition)
local locationName = location and (location:GetName() and location:GetName() or unnamedLocationName) or unnamedLocationName
table.insert(exitLocationNames, locationName)
end
if tunnelSelf.exitBId and tunnelSelf.exitBId ~= Entity.invalidId then
local location = GetLocationForPoint(tunnelSelf.exitBEntityPosition)
local locationName = location and (location:GetName() and location:GetName() or unnamedLocationName) or unnamedLocationName
table.insert(exitLocationNames, locationName)
end
if #exitLocationNames == 2 and tunnelSelf.timeExitBChanged < tunnelSelf.timeExitAChanged then
exitLocationNames = {exitLocationNames[2], exitLocationNames[1]}
end
local tunnelDescription = TGNS.Join(exitLocationNames, " / ")
local client = TGNS.GetClientByNs2Id(tunnelSelf.ownerClientId)
if client then
local clientIndex = TGNS.GetClientIndex(client)
tunnelDescriptions[clientIndex] = tunnelDescription
self:AnnouncePlayerPrefix(TGNS.GetPlayer(client))
if TGNS.HasNonEmptyValue(tunnelDescription) then
local messagePlayers = TGNS.Where(TGNS.GetPlayerList(), function(p) return TGNS.IsPlayerSpectator(p) or TGNS.PlayerIsAlien(p) end)
local tunnelsMd = TGNSMessageDisplayer.Create("TUNNELS")
TGNS.DoFor(messagePlayers, function(p)
local message
if #exitLocationNames == 2 then
message = string.format("an OPEN tunnel: %s <-> %s", exitLocationNames[1], exitLocationNames[2])
else
message = string.format("a CLOSED tunnel: %s", exitLocationNames[1])
end
tunnelsMd:ToPlayerNotifyInfo(p, string.format("%s has %s", TGNS.GetClientName(client), message))
end)
end
end
end
local originalTunnelAddExit = Tunnel.AddExit
Tunnel.AddExit = function(tunnelSelf, exit)
OnTunnelExitAddedOrRemoved(tunnelSelf, exit, originalTunnelAddExit)
end
local originalTunnelRemoveExit = Tunnel.RemoveExit
Tunnel.RemoveExit = function(tunnelSelf, exit)
OnTunnelExitAddedOrRemoved(tunnelSelf, exit, originalTunnelRemoveExit)
end
local originalEmbryoSetGestationData = Embryo.SetGestationData
Embryo.SetGestationData = function(embryoSelf, techIds, previousTechId, healthScalar, armorScalar)
originalEmbryoSetGestationData(embryoSelf, techIds, previousTechId, healthScalar, armorScalar)
local gestationTime = embryoSelf:GetGestationTime(embryoSelf.gestationTypeTechId)
local embryoClient = TGNS.GetClient(embryoSelf)
TGNS.ScheduleAction(gestationTime, function()
if Shine:IsValidClient(embryoClient) then
self:AnnouncePlayerPrefix(TGNS.GetPlayer(embryoClient))
end
end)
end
TGNS.DoWithConfig(function()
local vouchesUrl = string.format("%s&h=3", TGNS.Config.VouchesEndpointBaseUrl)
TGNS.GetHttpAsync(vouchesUrl, function(vouchesResponseJson)
local vouchesResponse = json.decode(vouchesResponseJson) or {}
if vouchesResponse.success then
vouches = vouchesResponse.result
else
TGNS.DebugPrint(string.format("vouches ERROR: Unable to access vouches data. msg: %s | response: %s | stacktrace: %s", vouchesResponse.msg, vouchesResponseJson, vouchesResponse.stacktrace))
end
end)
local url = TGNS.Config.ApproveEndpointBaseUrl
TGNS.GetHttpAsync(url, function(approveResponseJson)
local approveResponse = json.decode(approveResponseJson) or {}
if approveResponse.success then
TGNS.DoForPairs(approveResponse.result, function(steamId, count)
approveCache[tonumber(steamId)] = count
end)
approveCacheWasPreloaded = true
else
TGNS.DebugPrint(string.format("approvals ERROR: Unable to access approve data. url: %s | msg: %s | response: %s | stacktrace: %s", url, approveResponse.msg, approveResponseJson, approveResponse.stacktrace))
end
end)
end)
TGNS.ExecuteServerCommand("sh_alltalk false")
local originalTeamInfoOnCommanderLogin
originalTeamInfoOnCommanderLogin = TGNS.ReplaceClassMethod("TeamInfo", "OnCommanderLogin", function(teamInfoSelf, commanderPlayer, forced)
originalTeamInfoOnCommanderLogin(teamInfoSelf, commanderPlayer, forced)
if TGNS.PlayerIsAlien(commanderPlayer) and not TGNS.IsGameInProgress() then
local commanderClient = TGNS.GetClient(commanderPlayer)
local commanderClientIndex = TGNS.GetClientIndex(commanderClient)
squadNumbers[commanderClient] = 6
TGNS.DoFor(TGNS.GetPlayerList(), function(p)
TGNS.SendNetworkMessageToPlayer(p, self.SQUAD_CONFIRMED, {c=commanderClientIndex,s=squadNumbers[commanderClient]})
TGNS.SendNetworkMessageToPlayer(p, Shine.Plugins.squadnumbers.SQUAD_CONFIRMED, {c=commanderClientIndex,s=squadNumbers[commanderClient]})
end)
end
end)
-- GetSeason = function()
-- return Seasons.kWinter
-- end
-- local fogIsLifted = false
-- local function setFogLiftState(shouldFogBeLifted)
-- fogIsLifted = shouldFogBeLifted
-- TGNS.DoFor(TGNS.GetPlayerList(), function(p)
-- TGNS.SendNetworkMessageToPlayer(p, Shine.Plugins.scoreboard.FOG_NEEDS_LIFT, {b=shouldFogBeLifted})
-- end)
-- TGNS.DoForPairs(EntityListToTable(Shared.GetEntitiesWithClassname("MapBlip")), function(index, blip) blip:Update() end)
-- end
-- local originalMapBlipGetIsSighted = MapBlip.GetIsSighted
-- MapBlip.GetIsSighted = function(mapBlipSelf) return fogIsLifted and true or originalMapBlipGetIsSighted(mapBlipSelf) end
-- TGNS.RegisterEventHook("WinOrLoseCalled", function(teamNumber)
-- setFogLiftState(true)
-- end)
-- TGNS.RegisterEventHook("EndGame", function(gamerules, winningTeam)
-- setFogLiftState(true)
-- TGNS.ScheduleAction(TGNS.ENDGAME_TIME_TO_READYROOM, function()
-- setFogLiftState(false)
-- end)
-- end)
local originalSetResources
originalSetResources = TGNS.ReplaceClassMethod("Player", "SetResources", function(playerSelf, amount)
originalSetResources(playerSelf, amount)
local clientSelf = TGNS.GetClient(playerSelf)
if clientSelf ~= nil and amount ~= nil and amount < 5 then
if playerSelf then
TGNS.DoFor(TGNS.GetAlienPlayers(TGNS.GetPlayerList()), function(p)
TGNS.SendNetworkMessageToPlayer(p, self.PRECISIONRESOURCES, {i=TGNS.GetClientIndex(clientSelf), r=amount})
end)
end
end
end)
local originalPlayingTeamAddTeamResources
originalPlayingTeamAddTeamResources = TGNS.ReplaceClassMethod("PlayingTeam", "AddTeamResources", function(playingTeamSelf, amount, isIncome)
originalPlayingTeamAddTeamResources(playingTeamSelf, amount, isIncome)
TGNS.DoFor(TGNS.GetPlayerList(), function(p)
TGNS.SendNetworkMessageToPlayer(p, self.TOTAL_TEAM_RESOURCES, {t=playingTeamSelf:GetTeamNumber(), r=playingTeamSelf:GetTotalTeamResources()})
end)
end)
return true
end
function Plugin:Cleanup()
--Cleanup your extra stuff like timers, data etc.
self.BaseClass.Cleanup( self )
end | mit |
AlexandreCA/darkstar | scripts/zones/Arrapago_Reef/Zone.lua | 11 | 2059 | -----------------------------------
--
-- Zone: Arrapago_Reef (54)
--
-----------------------------------
package.loaded["scripts/zones/Arrapago_Reef/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Arrapago_Reef/TextIDs");
require("scripts/globals/missions");
require("scripts/globals/keyitems");
require("scripts/globals/settings");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
zone:registerRegion(1,-462,-4,-420,-455,-1,-392);
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
player:setPos(-180.028,-10.335,-559.987,182);
end
return cs;
end;
-----------------------------------
-- afterZoneIn
-----------------------------------
function afterZoneIn(player)
player:entityVisualPacket("1pb1");
player:entityVisualPacket("2pb1");
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
if (player:getCurrentMission(TOAU) == THE_BLACK_COFFIN and player:hasKeyItem(EPHRAMADIAN_GOLD_COIN) and player:getVar("AhtUrganStatus") == 0) then
player:startEvent(8);
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 == 8) then
player:setVar("AhtUrganStatus",1);
player:delKeyItem(EPHRAMADIAN_GOLD_COIN);
player:startEvent(34,1,1,1,1,1,1,1,1);
elseif (csid == 34 and player:getVar("AhtUrganStatus") == 1) then
player:startEvent(35);
end
end; | gpl-3.0 |
AlexandreCA/darkstar | scripts/zones/Upper_Jeuno/npcs/Deadly_Minnow.lua | 13 | 1826 | -----------------------------------
-- Area: Upper Jeuno
-- NPC: Deadly Minnow
-- Standard Merchant NPC
-- Involved in Quest: Borghertz's Hands (1st quest only)
-- @zone 244
-- @pos -5 1 48
-----------------------------------
package.loaded["scripts/zones/Upper_Jeuno/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/shop");
require("scripts/zones/Upper_Jeuno/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getVar("BorghertzHandsFirstTime") == 1) then
player:startEvent(0x0018);
player:setVar("BorghertzHandsFirstTime",2);
else
player:showText(npc,DEADLYMINNOW_SHOP_DIALOG);
stock = {0x309A,13179, --Studded Bandana
0x3089,22800, --Silver Mask
0x308A,47025, --Banded Helm
0x311A,20976, --Studded Vest
0x3109,35200, --Silver Mail
0x310A,66792, --Banded Mail
0x319A,11012, --Studded Gloves
0x3189,18800, --Silver Mittens
0x3180,23846, --Gauntlets
0x318A,35673} --Mufflers
showShop(player, STATIC, stock);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
elfinlazz/melia | system/scripts/npc/field/f_pilgrimroad_31_1.lua | 1 | 2554 | addnpc(154049, "ETC_20150730_014064", "f_pilgrimroad_31_1", -303.4865, 1.635254, -330.2439, -44, "npc_dummy")
addnpc(154049, "ETC_20150730_014064", "f_pilgrimroad_31_1", 339.2367, 75.61414, 462.41, -90, "npc_dummy")
addnpc(57337, "ETC_20150730_014065", "f_pilgrimroad_31_1", -1260.809, 75.61414, 1255.095, 45, "npc_dummy")
addnpc(57264, "ETC_20150730_014066", "f_pilgrimroad_31_1", 816.7902, -54.19531, -404.8547, 45, "npc_dummy")
addnpc(147363, "ETC_20150401_010678", "f_pilgrimroad_31_1", -1235.526, 1.635254, -836.2787, 45, "npc_dummy")
addnpc(147363, "ETC_20150401_010678", "f_pilgrimroad_31_1", 339.2509, 75.61414, 479.7626, 45, "npc_dummy")
addnpc(147363, "ETC_20150401_010678", "f_pilgrimroad_31_1", -281.6831, 1.635254, -347.85, 45, "npc_dummy")
addnpc(147363, "ETC_20150401_010678", "f_pilgrimroad_31_1", 1051.995, -51.83533, 1064.2, 45, "npc_dummy")
addnpc(147363, "ETC_20150401_010678", "f_pilgrimroad_31_1", 1760.679, -52.9705, -430.7483, 45, "npc_dummy")
addnpc(147363, "ETC_20150401_010678", "f_pilgrimroad_31_1", 801.163, -54.19531, -406.9104, 45, "npc_dummy")
addnpc(147363, "ETC_20150401_010678", "f_pilgrimroad_31_1", -1286.134, 75.61414, 1309.675, 45, "npc_dummy")
addnpc(57264, "ETC_20150730_014066", "f_pilgrimroad_31_1", 96.76518, 0.783522, -464.6755, 45, "npc_dummy")
addnpc(45132, "QUEST_LV_0200_20150317_000504", "f_pilgrimroad_31_1", -486.0732, 1.635254, -387.2689, 45, "npc_dummy")
addnpc(45132, "QUEST_LV_0200_20150317_000504", "f_pilgrimroad_31_1", 454.7198, -51.83533, -918.7335, 45, "npc_dummy")
addnpc(45132, "QUEST_LV_0200_20150317_000504", "f_pilgrimroad_31_1", 245.0508, 1.635254, -344.2827, 45, "npc_dummy")
addnpc(45132, "QUEST_LV_0200_20150317_000504", "f_pilgrimroad_31_1", 145.1847, 75.61414, 273.8596, 45, "npc_dummy")
addnpc(45132, "QUEST_LV_0200_20150317_000504", "f_pilgrimroad_31_1", -794.457, 75.61414, 1325.494, 45, "npc_dummy")
addnpc(45132, "QUEST_LV_0200_20150317_000504", "f_pilgrimroad_31_1", 74.69391, 75.61414, 1055.164, 45, "npc_dummy")
addnpc(45132, "QUEST_LV_0200_20150317_000504", "f_pilgrimroad_31_1", 774.3535, -51.83534, 681.1902, 45, "npc_dummy")
addnpc(45132, "QUEST_LV_0200_20150317_000504", "f_pilgrimroad_31_1", 1252.367, -54.19531, -409.3566, 45, "npc_dummy")
addnpc(45132, "QUEST_LV_0200_20150317_000504", "f_pilgrimroad_31_1", -461.4138, 75.61417, 249.9842, 45, "npc_dummy")
addnpc(45132, "QUEST_LV_0200_20150317_000504", "f_pilgrimroad_31_1", -978.3019, 1.635254, -813.7061, 45, "npc_dummy")
addnpc(147392, "ETC_20150317_009100", "f_pilgrimroad_31_1", 174, 75, 1269, 45, "npc_dummy")
| gpl-3.0 |
AlexandreCA/darkstar | scripts/zones/Windurst_Woods/npcs/Ponono.lua | 44 | 2111 | -----------------------------------
-- Area: Windurst Woods
-- NPC: Ponono
-- Type: Clothcraft Guild Master
-- @pos -38.243 -2.25 -120.954 241
-----------------------------------
package.loaded["scripts/zones/Windurst_Woods/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/crafting");
require("scripts/zones/Windurst_Woods/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
local newRank = tradeTestItem(player,npc,trade,SKILL_CLOTHCRAFT);
if (newRank ~= 0) then
player:setSkillRank(SKILL_CLOTHCRAFT,newRank);
player:startEvent(0x271c,0,0,0,0,newRank);
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local getNewRank = 0;
local craftSkill = player:getSkillLevel(SKILL_CLOTHCRAFT);
local testItem = getTestItem(player,npc,SKILL_CLOTHCRAFT);
local guildMember = isGuildMember(player,3);
if (guildMember == 1) then guildMember = 10000; end
if (canGetNewRank(player,craftSkill,SKILL_CLOTHCRAFT) == 1) then getNewRank = 100; end
player:startEvent(0x271b,testItem,getNewRank,30,guildMember,44,0,0,0);
end;
-- 0x271b 0x271c 0x02bc 0x02bd 0x02be 0x02bf 0x02c0 0x02c1 0x0340 0x02fd
-----------------------------------
-- 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 == 0x271b and option == 1) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,4099);
else
player:addItem(4099);
player:messageSpecial(ITEM_OBTAINED,4099);
signupGuild(player,8);
end
end
end; | gpl-3.0 |
LSBOSS/bgfx | scripts/bgfx.lua | 5 | 3948 | --
-- Copyright 2010-2015 Branimir Karadzic. All rights reserved.
-- License: http://www.opensource.org/licenses/BSD-2-Clause
--
function bgfxProject(_name, _kind, _defines)
project ("bgfx" .. _name)
uuid (os.uuid("bgfx" .. _name))
kind (_kind)
if _kind == "SharedLib" then
defines {
"BGFX_SHARED_LIB_BUILD=1",
}
configuration { "vs20* or mingw*" }
links {
"gdi32",
"psapi",
}
configuration { "mingw*" }
linkoptions {
"-shared",
}
configuration { "linux-*" }
buildoptions {
"-fPIC",
}
configuration {}
end
includedirs {
path.join(BGFX_DIR, "3rdparty"),
path.join(BGFX_DIR, "3rdparty/dxsdk/include"),
path.join(BGFX_DIR, "../bx/include"),
}
defines {
_defines,
}
if _OPTIONS["with-glfw"] then
defines {
"BGFX_CONFIG_MULTITHREADED=0",
}
end
if _OPTIONS["with-ovr"] then
defines {
"BGFX_CONFIG_USE_OVR=1",
}
includedirs {
"$(OVR_DIR)/LibOVR/Include",
}
end
configuration { "Debug" }
defines {
"BGFX_CONFIG_DEBUG=1",
}
configuration { "android*" }
links {
"EGL",
"GLESv2",
}
configuration { "winphone8* or winstore8*" }
linkoptions {
"/ignore:4264" -- LNK4264: archiving object file compiled with /ZW into a static library; note that when authoring Windows Runtime types it is not recommended to link with a static library that contains Windows Runtime metadata
}
configuration { "*clang*" }
buildoptions {
"-Wno-microsoft-enum-value", -- enumerator value is not representable in the underlying type 'int'
"-Wno-microsoft-const-init", -- default initialization of an object of const type '' without a user-provided default constructor is a Microsoft extension
}
configuration { "osx" }
linkoptions {
"-framework Cocoa",
"-framework Metal",
"-framework QuartzCore",
"-framework OpenGL",
}
configuration { "not nacl" }
includedirs {
--nacl has GLES2 headers modified...
path.join(BGFX_DIR, "3rdparty/khronos"),
}
configuration {}
includedirs {
path.join(BGFX_DIR, "include"),
}
files {
path.join(BGFX_DIR, "include/**.h"),
path.join(BGFX_DIR, "src/**.cpp"),
path.join(BGFX_DIR, "src/**.h"),
}
removefiles {
path.join(BGFX_DIR, "src/**.bin.h"),
}
if _OPTIONS["with-amalgamated"] then
excludes {
path.join(BGFX_DIR, "src/bgfx.cpp"),
path.join(BGFX_DIR, "src/glcontext_egl.cpp"),
path.join(BGFX_DIR, "src/glcontext_glx.cpp"),
path.join(BGFX_DIR, "src/glcontext_ppapi.cpp"),
path.join(BGFX_DIR, "src/glcontext_wgl.cpp"),
path.join(BGFX_DIR, "src/image.cpp"),
path.join(BGFX_DIR, "src/ovr.cpp"),
path.join(BGFX_DIR, "src/renderdoc.cpp"),
path.join(BGFX_DIR, "src/renderer_d3d9.cpp"),
path.join(BGFX_DIR, "src/renderer_d3d11.cpp"),
path.join(BGFX_DIR, "src/renderer_d3d12.cpp"),
path.join(BGFX_DIR, "src/renderer_null.cpp"),
path.join(BGFX_DIR, "src/renderer_gl.cpp"),
path.join(BGFX_DIR, "src/renderer_vk.cpp"),
path.join(BGFX_DIR, "src/shader_dx9bc.cpp"),
path.join(BGFX_DIR, "src/shader_dxbc.cpp"),
path.join(BGFX_DIR, "src/shader_spirv.cpp"),
path.join(BGFX_DIR, "src/vertexdecl.cpp"),
}
configuration { "xcode* or osx or ios*" }
files {
path.join(BGFX_DIR, "src/amalgamated.mm"),
}
excludes {
path.join(BGFX_DIR, "src/glcontext_eagl.mm"),
path.join(BGFX_DIR, "src/glcontext_nsgl.mm"),
path.join(BGFX_DIR, "src/renderer_mtl.mm"),
path.join(BGFX_DIR, "src/amalgamated.cpp"),
}
configuration {}
else
configuration { "xcode* or osx or ios*" }
files {
path.join(BGFX_DIR, "src/glcontext_eagl.mm"),
path.join(BGFX_DIR, "src/glcontext_nsgl.mm"),
path.join(BGFX_DIR, "src/renderer_mtl.mm"),
}
configuration {}
excludes {
path.join(BGFX_DIR, "src/amalgamated.**"),
}
end
configuration {}
copyLib()
end
| bsd-2-clause |
AlexandreCA/darkstar | scripts/globals/mobskills/Polar_Blast.lua | 33 | 1412 | ---------------------------------------------
-- Polar Blast
--
-- Description: Deals Ice damage to enemies within a fan-shaped area. Additional effect: Paralyze
-- Type: Breath
-- Ignores Shadows
-- Range: Unknown Cone
---------------------------------------------
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 == 1796) then
return 0;
else
return 1;
end
end
if (mob:AnimationSub() <= 1) then
return 0;
else
return 1;
end
end;
function onMobWeaponSkill(target, mob, skill)
local dmgmod = MobBreathMove(mob, target, 0.01, 0.1, ELE_ICE, 700);
local dmg = MobFinalAdjustments(dmgmod,mob,skill,target,MOBSKILL_BREATH,MOBPARAM_ICE,MOBPARAM_IGNORE_SHADOWS);
MobStatusEffectMove(mob, target, EFFECT_PARALYSIS, 15, 0, 60);
target:delHP(dmg);
if (mob:getFamily() == 313 and bit.band(mob:getBehaviour(),BEHAVIOUR_NO_TURN) == 0 and mob:AnimationSub() == 1) then -- re-enable no turn if third head is dead (Tinnin), else it's re-enabled after the upcoming Pyric Blast
mob:setBehaviour(bit.bor(mob:getBehaviour(), BEHAVIOUR_NO_TURN))
end
return dmg;
end;
| gpl-3.0 |
crazyhamedboy/crazyspamm | plugins/plugins.lua | 72 | 6113 | do
-- Returns the key (index) in the config.enabled_plugins table
local function plugin_enabled( name )
for k,v in pairs(_config.enabled_plugins) do
if name == v then
return k
end
end
-- If not found
return false
end
-- Returns true if file exists in plugins folder
local function plugin_exists( name )
for k,v in pairs(plugins_names()) do
if name..'.lua' == v then
return true
end
end
return false
end
local function list_all_plugins(only_enabled)
local text = ''
local nsum = 0
for k, v in pairs( plugins_names( )) do
-- ✔ enabled, ❌ disabled
local status = '❎'
nsum = nsum+1
nact = 0
-- Check if is enabled
for k2, v2 in pairs(_config.enabled_plugins) do
if v == v2..'.lua' then
status = '✅'
end
nact = nact+1
end
if not only_enabled or status == '✅' then
-- get the name
v = string.match (v, "(.*)%.lua")
text = text..nsum..'. '..v..' '..status..'\n'
end
end
local text = text..'\nThere are '..nsum..' plugins installed.\n'..nact..' plugins enabled and '..nsum-nact..' disabled'
return text
end
local function list_plugins(only_enabled)
local text = ''
local nsum = 0
for k, v in pairs( plugins_names( )) do
-- ✔ enabled, ❌ disabled
local status = '❎'
nsum = nsum+1
nact = 0
-- Check if is enabled
for k2, v2 in pairs(_config.enabled_plugins) do
if v == v2..'.lua' then
status = '✅'
end
nact = nact+1
end
if not only_enabled or status == '✅' then
-- get the name
v = string.match (v, "(.*)%.lua")
-- text = text..v..' '..status..'\n'
end
end
local text = text..'\n'..nact..' plugins enabled from '..nsum..' plugins installed.'
return text
end
local function reload_plugins( )
plugins = {}
load_plugins()
return list_plugins(true)
end
local function enable_plugin( plugin_name )
print('checking if '..plugin_name..' exists')
-- Check if plugin is enabled
if plugin_enabled(plugin_name) then
return 'Plugin '..plugin_name..' is enabled'
end
-- Checks if plugin exists
if plugin_exists(plugin_name) then
-- Add to the config table
table.insert(_config.enabled_plugins, plugin_name)
print(plugin_name..' added to _config table')
save_config()
-- Reload the plugins
return reload_plugins( )
else
return 'Plugin '..plugin_name..' does not exists'
end
end
local function disable_plugin( name, chat )
-- Check if plugins exists
if not plugin_exists(name) then
return 'Plugin '..name..' does not exists'
end
local k = plugin_enabled(name)
-- Check if plugin is enabled
if not k then
return 'Plugin '..name..' not enabled'
end
-- Disable and reload
table.remove(_config.enabled_plugins, k)
save_config( )
return reload_plugins(true)
end
local function disable_plugin_on_chat(receiver, plugin)
if not plugin_exists(plugin) then
return "Plugin doesn't exists"
end
if not _config.disabled_plugin_on_chat then
_config.disabled_plugin_on_chat = {}
end
if not _config.disabled_plugin_on_chat[receiver] then
_config.disabled_plugin_on_chat[receiver] = {}
end
_config.disabled_plugin_on_chat[receiver][plugin] = true
save_config()
return 'Plugin '..plugin..' disabled on this chat'
end
local function reenable_plugin_on_chat(receiver, plugin)
if not _config.disabled_plugin_on_chat then
return 'There aren\'t any disabled plugins'
end
if not _config.disabled_plugin_on_chat[receiver] then
return 'There aren\'t any disabled plugins for this chat'
end
if not _config.disabled_plugin_on_chat[receiver][plugin] then
return 'This plugin is not disabled'
end
_config.disabled_plugin_on_chat[receiver][plugin] = false
save_config()
return 'Plugin '..plugin..' is enabled again'
end
local function run(msg, matches)
-- Show the available plugins
if matches[1] == '!plugins' and is_sudo(msg) then --after changed to moderator mode, set only sudo
return list_all_plugins()
end
-- Re-enable a plugin for this chat
if matches[1] == '+' and matches[3] == 'chat' then
local receiver = get_receiver(msg)
local plugin = matches[2]
print("enable "..plugin..' on this chat')
return reenable_plugin_on_chat(receiver, plugin)
end
-- Enable a plugin
if matches[1] == '+' and is_sudo(msg) then --after changed to moderator mode, set only sudo
local plugin_name = matches[2]
print("enable: "..matches[2])
return enable_plugin(plugin_name)
end
-- Disable a plugin on a chat
if matches[1] == '-' and matches[3] == 'chat' then
local plugin = matches[2]
local receiver = get_receiver(msg)
print("disable "..plugin..' on this chat')
return disable_plugin_on_chat(receiver, plugin)
end
-- Disable a plugin
if matches[1] == '-' and is_sudo(msg) then --after changed to moderator mode, set only sudo
if matches[2] == 'plugins' then
return 'This plugin can\'t be disabled'
end
print("disable: "..matches[2])
return disable_plugin(matches[2])
end
-- Reload all the plugins!
if matches[1] == '*' and is_sudo(msg) then --after changed to moderator mode, set only sudo
return reload_plugins(true)
end
end
return {
description = "Plugin to manage other plugins. Enable, disable or reload.",
usage = {
moderator = {
"!plugins disable [plugin] chat : disable plugin only this chat.",
"!plugins enable [plugin] chat : enable plugin only this chat.",
},
sudo = {
"!plugins : list all plugins.",
"!plugins enable [plugin] : enable plugin.",
"!plugins disable [plugin] : disable plugin.",
"!plugins reload : reloads all plugins." },
},
patterns = {
"^!plugins$",
"^!plugins? (+) ([%w_%.%-]+)$",
"^!plugins? (-) ([%w_%.%-]+)$",
"^!plugins? (+) ([%w_%.%-]+) (chat)",
"^!plugins? (-) ([%w_%.%-]+) (chat)",
"^!plugins? (*)$" },
run = run,
moderated = true, -- set to moderator mode
--privileged = true
}
end
| gpl-2.0 |
AlexandreCA/update | scripts/zones/Valkurm_Dunes/npcs/qm4.lua | 37 | 1033 | -----------------------------------
-- Area: Valkurm Dunes
-- NPC: qm4 (???)
-- Involved in quest: Pirate's Chart
-- @pos -160 4 -131 103
-----------------------------------
package.loaded["scripts/zones/Valkurm_Dunes/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Valkurm_Dunes/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:messageSpecial(MONSTERS_KILLED_ADVENTURERS);
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 |
treytomes/mgreboot | mods/flowers/init.lua | 4 | 7757 | -- Minetest 0.4 mod: default
-- See README.txt for licensing and other information.
-- Namespace for functions
flowers = {}
-- Map Generation
dofile(minetest.get_modpath("flowers") .. "/mapgen.lua")
--
-- Flowers
--
-- Aliases for original flowers mod
minetest.register_alias("flowers:flower_rose", "flowers:rose")
minetest.register_alias("flowers:flower_tulip", "flowers:tulip")
minetest.register_alias("flowers:flower_dandelion_yellow", "flowers:dandelion_yellow")
minetest.register_alias("flowers:flower_geranium", "flowers:geranium")
minetest.register_alias("flowers:flower_viola", "flowers:viola")
minetest.register_alias("flowers:flower_dandelion_white", "flowers:dandelion_white")
-- Flower registration
local function add_simple_flower(name, desc, box, f_groups)
-- Common flowers' groups
f_groups.snappy = 3
f_groups.flower = 1
f_groups.flora = 1
f_groups.attached_node = 1
minetest.register_node("flowers:" .. name, {
description = desc,
drawtype = "plantlike",
waving = 1,
tiles = {"flowers_" .. name .. ".png"},
inventory_image = "flowers_" .. name .. ".png",
wield_image = "flowers_" .. name .. ".png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
buildable_to = true,
stack_max = 99,
groups = f_groups,
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = box
}
})
end
flowers.datas = {
{
"rose",
"Rose",
{-2 / 16, -0.5, -2 / 16, 2 / 16, 5 / 16, 2 / 16},
{color_red = 1, flammable = 1}
},
{
"tulip",
"Orange Tulip",
{-2 / 16, -0.5, -2 / 16, 2 / 16, 3 / 16, 2 / 16},
{color_orange = 1, flammable = 1}
},
{
"dandelion_yellow",
"Yellow Dandelion",
{-2 / 16, -0.5, -2 / 16, 2 / 16, 4 / 16, 2 / 16},
{color_yellow = 1, flammable = 1}
},
{
"geranium",
"Blue Geranium",
{-2 / 16, -0.5, -2 / 16, 2 / 16, 2 / 16, 2 / 16},
{color_blue = 1, flammable = 1}
},
{
"viola",
"Viola",
{-5 / 16, -0.5, -5 / 16, 5 / 16, -1 / 16, 5 / 16},
{color_violet = 1, flammable = 1}
},
{
"dandelion_white",
"White dandelion",
{-5 / 16, -0.5, -5 / 16, 5 / 16, -2 / 16, 5 / 16},
{color_white = 1, flammable = 1}
},
}
for _,item in pairs(flowers.datas) do
add_simple_flower(unpack(item))
end
-- Flower spread
-- Public function to enable override by mods
function flowers.flower_spread(pos, node)
pos.y = pos.y - 1
local under = minetest.get_node(pos)
pos.y = pos.y + 1
if under.name == "default:desert_sand" then
minetest.set_node(pos, {name = "default:dry_shrub"})
return
elseif under.name ~= "default:dirt_with_grass" and
under.name ~= "default:dirt_with_dry_grass" then
return
end
local light = minetest.get_node_light(pos)
if not light or light < 13 then
return
end
local pos0 = vector.subtract(pos, 4)
local pos1 = vector.add(pos, 4)
if #minetest.find_nodes_in_area(pos0, pos1, "group:flora") > 3 then
return
end
local seedling = minetest.find_nodes_in_area_under_air(pos0, pos1,
{"default:dirt_with_grass", "default:dirt_with_dry_grass"})
if #seedling > 0 then
seedling = seedling[math.random(#seedling)]
seedling.y = seedling.y + 1
light = minetest.get_node_light(seedling)
if not light or light < 13 then
return
end
minetest.set_node(seedling, {name = node.name})
end
end
minetest.register_abm({
label = "Flower spread",
nodenames = {"group:flora"},
neighbors = {"default:dirt_with_grass", "default:dirt_with_dry_grass",
"default:desert_sand"},
interval = 13,
chance = 96,
action = function(...)
flowers.flower_spread(...)
end,
})
--
-- Mushrooms
--
minetest.register_node("flowers:mushroom_red", {
description = "Red Mushroom",
tiles = {"flowers_mushroom_red.png"},
inventory_image = "flowers_mushroom_red.png",
wield_image = "flowers_mushroom_red.png",
drawtype = "plantlike",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
groups = {snappy = 3, attached_node = 1, flammable = 1},
sounds = default.node_sound_leaves_defaults(),
on_use = minetest.item_eat(-5),
selection_box = {
type = "fixed",
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, -1 / 16, 4 / 16},
}
})
minetest.register_node("flowers:mushroom_brown", {
description = "Brown Mushroom",
tiles = {"flowers_mushroom_brown.png"},
inventory_image = "flowers_mushroom_brown.png",
wield_image = "flowers_mushroom_brown.png",
drawtype = "plantlike",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
groups = {snappy = 3, attached_node = 1, flammable = 1},
sounds = default.node_sound_leaves_defaults(),
on_use = minetest.item_eat(1),
selection_box = {
type = "fixed",
fixed = {-3 / 16, -0.5, -3 / 16, 3 / 16, -2 / 16, 3 / 16},
}
})
-- Mushroom spread and death
minetest.register_abm({
label = "Mushroom spread",
nodenames = {"flowers:mushroom_brown", "flowers:mushroom_red"},
interval = 11,
chance = 50,
action = function(pos, node)
if minetest.get_node_light(pos, nil) == 15 then
minetest.remove_node(pos)
return
end
local random = {
x = pos.x + math.random(-2, 2),
y = pos.y + math.random(-1, 1),
z = pos.z + math.random(-2, 2)
}
local random_node = minetest.get_node_or_nil(random)
if not random_node or random_node.name ~= "air" then
return
end
local node_under = minetest.get_node_or_nil({x = random.x,
y = random.y - 1, z = random.z})
if not node_under then
return
end
if (minetest.get_item_group(node_under.name, "soil") ~= 0 or
minetest.get_item_group(node_under.name, "tree") ~= 0) and
minetest.get_node_light(pos, 0.5) <= 3 and
minetest.get_node_light(random, 0.5) <= 3 then
minetest.set_node(random, {name = node.name})
end
end
})
-- These old mushroom related nodes can be simplified now
minetest.register_alias("flowers:mushroom_spores_brown", "flowers:mushroom_brown")
minetest.register_alias("flowers:mushroom_spores_red", "flowers:mushroom_red")
minetest.register_alias("flowers:mushroom_fertile_brown", "flowers:mushroom_brown")
minetest.register_alias("flowers:mushroom_fertile_red", "flowers:mushroom_red")
minetest.register_alias("mushroom:brown_natural", "flowers:mushroom_brown")
minetest.register_alias("mushroom:red_natural", "flowers:mushroom_red")
--
-- Waterlily
--
minetest.register_node("flowers:waterlily", {
description = "Waterlily",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
tiles = {"flowers_waterlily.png", "flowers_waterlily_bottom.png"},
inventory_image = "flowers_waterlily.png",
wield_image = "flowers_waterlily.png",
liquids_pointable = true,
walkable = false,
buildable_to = true,
sunlight_propagates = true,
floodable = true,
groups = {snappy = 3, flower = 1, flammable = 1},
sounds = default.node_sound_leaves_defaults(),
node_placement_prediction = "",
node_box = {
type = "fixed",
fixed = {-0.5, -31 / 64, -0.5, 0.5, -15 / 32, 0.5}
},
selection_box = {
type = "fixed",
fixed = {-7 / 16, -0.5, -7 / 16, 7 / 16, -15 / 32, 7 / 16}
},
on_place = function(itemstack, placer, pointed_thing)
local pos = pointed_thing.above
local node = minetest.get_node(pointed_thing.under).name
local def = minetest.registered_nodes[node]
local player_name = placer:get_player_name()
if def and def.liquidtype == "source" and
minetest.get_item_group(node, "water") > 0 then
if not minetest.is_protected(pos, player_name) then
minetest.set_node(pos, {name = "flowers:waterlily",
param2 = math.random(0, 3)})
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
else
minetest.chat_send_player(player_name, "Node is protected")
minetest.record_protection_violation(pos, player_name)
end
end
return itemstack
end
})
| mit |
AlexandreCA/update | scripts/zones/Tavnazian_Safehold/npcs/Porter_Moogle.lua | 41 | 1547 | -----------------------------------
-- Area: Tavnazian_Safehold
-- NPC: Porter Moogle
-- Type: Storage Moogle
-- @zone 26
-- @pos TODO
-----------------------------------
package.loaded["scripts/zones/Tavnazian_Safehold/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Tavnazian_Safehold/TextIDs");
require("scripts/globals/porter_moogle_util");
local e =
{
TALK_EVENT_ID = 619,
STORE_EVENT_ID = 620,
RETRIEVE_EVENT_ID = 621,
ALREADY_STORED_ID = 622,
MAGIAN_TRIAL_ID = 623
};
-----------------------------------
-- 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 |
AlexandreCA/darkstar | scripts/zones/Norg/npcs/Mamaulabion.lua | 17 | 8832 | -----------------------------------
-- Area: Norg
-- NPC: Mamaulabion
-- Starts and finishes Quest: Mama Mia
-- @zone 252
-- @pos -57 -9 68 (88)
--CSIDs for Mamaulabion
--0x005D / 93 = Standard
--0x00BF / 191 = start quest
--0x00C0 / 192 = quest accepted
--0x00C1 / 193 = given an item
--0x00C2 / 194 = given an item you already gave
--0x00C3 / 195 = all 7 items given
--0x00C4 / 196 = after 7 items, but need more time until reward is given
--0x00C5 / 197 = reward
--0x00C6 / 198 = after quest is complete
--0x00F3 / 243 = get new ring if you dropped yours
--I did alot of copy/pasting, so you may notice a reduncency on comments XD
--But it can make it easier to follow aswell.
--"Mamaulabion will inform you of the items delivered thus far, as of the May 2011 update."
--i have no clue where this event is, so i have no idea how to add this (if this gets scripted, please remove this comment)
--"Upon completion of this quest, the above items no longer appear in the rewards list for defeating the Prime Avatars."
--will require changing other avatar quests and making a variable for it all. (if this gets scripted, please remove this comment)
-----------------------------------
package.loaded["scripts/zones/Norg/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/quests");
require("scripts/zones/Norg/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:getQuestStatus(OUTLANDS,MAMA_MIA) == QUEST_ACCEPTED) then
local tradesMamaMia = player:getVar("tradesMamaMia")
if (trade:hasItemQty(1202,1) and trade:getItemCount() == 1) then -- Trade Bubbly water
wasSet = player:getMaskBit(tradesMamaMia,0)
tradesMamaMia = player:setMaskBit(tradesMamaMia,"tradesMamaMia",0,true)
if (player:isMaskFull(tradesMamaMia,7) == true) then
player:startEvent(0x00C3); -- Traded all seven items
elseif (wasSet) then
player:startEvent(0x00C2); -- Traded an item you already gave
else
player:startEvent(0x00C1); -- Traded an item
end
elseif (trade:hasItemQty(1203,1) and trade:getItemCount() == 1) then -- Trade Egil's torch
wasSet = player:getMaskBit(tradesMamaMia,1)
tradesMamaMia = player:setMaskBit(tradesMamaMia,"tradesMamaMia",1,true)
if (player:isMaskFull(tradesMamaMia,7) == true) then
player:startEvent(0x00C3); -- Traded all seven items
elseif (wasSet) then
player:startEvent(0x00C2); -- Traded an item you already gave
else
player:startEvent(0x00C1); -- Traded an item
end
elseif (trade:hasItemQty(1204,1) and trade:getItemCount() == 1) then -- Trade Eye of mept
wasSet = player:getMaskBit(tradesMamaMia,2)
tradesMamaMia = player:setMaskBit(tradesMamaMia,"tradesMamaMia",2,true)
if (player:isMaskFull(tradesMamaMia,7) == true) then
player:startEvent(0x00C3); -- Traded all seven items
elseif (wasSet) then
player:startEvent(0x00C2); -- Traded an item you already gave
else
player:startEvent(0x00C1); -- Traded an item
end
elseif (trade:hasItemQty(1205,1) and trade:getItemCount() == 1) then -- Trade Desert Light
wasSet = player:getMaskBit(tradesMamaMia,3)
tradesMamaMia = player:setMaskBit(tradesMamaMia,"tradesMamaMia",3,true)
if (player:isMaskFull(tradesMamaMia,7) == true) then
player:startEvent(0x00C3); -- Traded all seven items
elseif (wasSet) then
player:startEvent(0x00C2); -- Traded an item you already gave
else
player:startEvent(0x00C1); -- Traded an item
end
elseif (trade:hasItemQty(1206,1) and trade:getItemCount() == 1) then -- Trade Elder Branch
wasSet = player:getMaskBit(tradesMamaMia,4)
tradesMamaMia = player:setMaskBit(tradesMamaMia,"tradesMamaMia",4,true)
if (player:isMaskFull(tradesMamaMia,7) == true) then
player:startEvent(0x00C3); -- Traded all seven items
elseif (wasSet) then
player:startEvent(0x00C2); -- Traded an item you already gave
else
player:startEvent(0x00C1); -- Traded an item
end
elseif (trade:hasItemQty(1207,1) and trade:getItemCount() == 1) then -- Trade Rust 'B' Gone
wasSet = player:getMaskBit(tradesMamaMia,5)
tradesMamaMia = player:setMaskBit(tradesMamaMia,"tradesMamaMia",5,true)
if (player:isMaskFull(tradesMamaMia,7) == true) then
player:startEvent(0x00C3); -- Traded all seven items
elseif (wasSet) then
player:startEvent(0x00C2); -- Traded an item you already gave
else
player:startEvent(0x00C1); -- Traded an item
end
elseif (trade:hasItemQty(1208,1) and trade:getItemCount() == 1) then -- Trade Ancients' Key
wasSet = player:getMaskBit(tradesMamaMia,6)
tradesMamaMia = player:setMaskBit(tradesMamaMia,"tradesMamaMia",6,true)
if (player:isMaskFull(tradesMamaMia,7) == true) then
player:startEvent(0x00C3); -- Traded all seven items
elseif (wasSet) then
player:startEvent(0x00C2); -- Traded an item you already gave
else
player:startEvent(0x00C1); -- Traded an item
end
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local MamaMia = player:getQuestStatus(OUTLANDS,MAMA_MIA);
local moonlitPath = player:getQuestStatus(WINDURST,THE_MOONLIT_PATH);
local EvokersRing = player:hasItem(14625);
local realday = tonumber(os.date("%j")); -- %M for next minute, %j for next day
local questday = player:getVar("MamaMia_date")
if (MamaMia == QUEST_AVAILABLE and player:getFameLevel(NORG) >= 4 and moonlitPath == QUEST_COMPLETED) then
player:startEvent(0x00BF); -- Start Quest "Mama Mia"
elseif (MamaMia == QUEST_ACCEPTED) then
local tradesMamaMia = player:getVar("tradesMamaMia")
local maskFull = player:isMaskFull(tradesMamaMia,7)
if (maskFull) then
if (realday == questday) then
player:startEvent(0x00C4); --need to wait longer for reward
elseif (questday ~= 0) then
player:startEvent(0x00C5); --Reward
end
else
player:startEvent(0x00C0); -- During Quest "Mama Mia"
end
elseif (MamaMia == QUEST_COMPLETED and EvokersRing) then
player:startEvent(0x00C6); -- New standard dialog after "Mama Mia" is complete
elseif (MamaMia == QUEST_COMPLETED and EvokersRing == false) then
player:startEvent(0x00F3); -- Quest completed, but dropped ring
else
player:startEvent(0x005D); -- 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 == 0x00BF) then
player:addQuest(OUTLANDS,MAMA_MIA);
elseif (csid == 0x00C1) then
player:tradeComplete();
elseif (csid == 0x00C3) then
player:tradeComplete();
player:setVar("MamaMia_date", os.date("%j")); -- %M for next minute, %j for next day
elseif (csid == 0x00C5) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,14625); -- Evokers Ring
else
player:addItem(14625); -- Evokers Ring
player:messageSpecial(ITEM_OBTAINED,14625); -- Evokers Ring
player:addFame(OUTLANDS,30); --idk how much fame the quest adds, just left at 30 which the levi quest gave.
player:completeQuest(OUTLANDS,MAMA_MIA);
player:setVar("tradesMamaMia",0)
end
elseif (csid == 0x00F3) then
if (option == 1) then
player:delQuest(OUTLANDS,MAMA_MIA);
player:addQuest(OUTLANDS,MAMA_MIA);
end
end
end; | gpl-3.0 |
tartina/ardour | share/scripts/jump_to_marker.lua | 2 | 1986 | ardour { ["type"] = "EditorAction", name = "Search and Jump to Marker",
license = "MIT",
author = "Ardour Team",
description = [[Jump to the first marker that matches a given name pattern]]
}
function factory () return function ()
local keep = false
::restart::
local dlg = LuaDialog.Dialog ("Search and Jump to Marker",
{
{ type = "entry", key = "marker", default = '', title = "Marker Prefix" },
{ type = "checkbox", key = "keep", default = keep, title = "Keep Dialog Open" },
})
local rv = dlg:run()
if not rv then return end
keep = rv['keep']
if (rv['marker'] == "") then
if keep then goto restart end
return
end
for l in Session:locations():list():iter() do
if l:is_mark() and string.find (l:name(), "^" .. rv['marker'] .. ".*$") then
Session:request_locate (l:start (), ARDOUR.LocateTransportDisposition.RollIfAppropriate, ARDOUR.TransportRequestSource.TRS_UI)
if keep then goto restart end
return
end
end
LuaDialog.Message ("Jump to Marker", "No marker matching the given pattern was found.", LuaDialog.MessageType.Warning, LuaDialog.ButtonType.Close):run ()
if keep then goto restart end
end end
function icon (params) return function (ctx, width, height, fg)
local mh = height - 3.5;
local m3 = width / 3;
local m6 = width / 6;
ctx:set_line_width (.5)
-- compare to gtk2_ardour/marker.cc "Marker"
ctx:set_source_rgba (.6, .6, .6, 1.0)
ctx:move_to (width / 2 - m6, 2)
ctx:rel_line_to (m3, 0)
ctx:rel_line_to (0, mh * 0.4)
ctx:rel_line_to (-m6, mh * 0.6)
ctx:rel_line_to (-m6, -mh * 0.6)
ctx:close_path ()
ctx:fill_preserve ()
ctx:set_source_rgba (.0, .0, .0, 1.0)
ctx:stroke ()
ctx:set_source_rgba (ARDOUR.LuaAPI.color_to_rgba (fg))
local txt = Cairo.PangoLayout (ctx, "ArdourMono ".. math.ceil(math.min (width, height) * .5) .. "px")
txt:set_text ("txt")
local tw, th = txt:get_pixel_size ()
ctx:move_to (.5 * (width - tw), .5 * (height - th))
txt:show_in_cairo_context (ctx)
end end
| gpl-2.0 |
AlexandreCA/update | scripts/zones/Jugner_Forest/npcs/Pure_Heart_IM.lua | 30 | 3050 | -----------------------------------
-- Area: Jugner Forest
-- NPC: Pure Heart, I.M.
-- Type: Border Conquest Guards
-- @pos 570.732 -2.637 553.508 104
-----------------------------------
package.loaded["scripts/zones/Jugner_Forest/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/conquest");
require("scripts/zones/Jugner_Forest/TextIDs");
local guardnation = BASTOK; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno
local guardtype = 4; -- 1: city, 2: foreign, 3: outpost, 4: border
local region = NORVALLEN;
local csid = 0x7ff8;
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
tradeConquestGuard(player,npc,trade,guardnation,guardtype);
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:hasKeyItem(getSupplyKey(region)) and player:getNation() == guardnation) then
if (supplyRunFresh(player) == 1) then
player:startEvent(csid,16,0,0,0,1,0,0,255); -- you have brought us supplies !
else
player:showText(npc, CONQUEST - 1); -- "Hmm... These supplies you have brought us are too old to be of any use."
player:delKeyItem(getSupplyKey(region));
player:messageSpecial(KEYITEM_OBTAINED + 1, getSupplyKey(region));
player:setVar("supplyQuest_region",0);
end
else
local arg1 = getArg1(guardnation, player) - 1;
if (arg1 >= 1792) then -- foreign, non-allied
player:startEvent(csid,1808,0,0,0,0,player:getRank(),0,0);
else -- citizen or allied
player:startEvent(csid,arg1,0,0x3F0000,0,0,getArg6(player),0,0);
end
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("OPTION: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("OPTION: %u",option);
if (option == 1) then
local duration = (player:getRank() + getNationRank(player:getNation()) + 3) * 3600;
player:delStatusEffect(EFFECT_SIGIL);
player:delStatusEffect(EFFECT_SANCTION);
player:delStatusEffect(EFFECT_SIGNET);
player:addStatusEffect(EFFECT_SIGNET,0,0,duration); -- Grant Signet
elseif (option == 2) then
player:delKeyItem(getSupplyKey(region));
player:addCP(supplyReward[region + 1])
player:messageSpecial(CONQUEST); -- "You've earned conquest points!"
if (hasOutpost(player, region+5) == 0) then
local supply_quests = 2^(region+5);
player:addNationTeleport(guardnation,supply_quests);
player:setVar("supplyQuest_region",0);
end
elseif (option == 4) then
if (player:delGil(giltosetHP(guardnation,player))) then
player:setHomePoint();
player:messageSpecial(CONQUEST + 94); -- "Your home point has been set."
else
player:messageSpecial(CONQUEST + 95); -- "You do not have enough gil to set your home point here."
end
end
end; | gpl-3.0 |
AlexandreCA/darkstar | scripts/zones/Riverne-Site_A01/mobs/Carmine_Dobsonfly.lua | 7 | 1800 | -----------------------------------
-- Area: Riverne Site A01
-- MOB: Carmine Dobsonfly
-----------------------------------
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
mob:setMobMod(MOBMOD_SUPERLINK, 16900230); -- mobID of the first one
mob:SetMagicCastingEnabled(false); -- does not cast spells while idle
end;
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
mob:SetMagicCastingEnabled(true);
end;
-----------------------------------
-- onMobDisengage
-----------------------------------
function onMobDisengage(mob)
mob:SetMagicCastingEnabled(false);
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, killer, ally)
local firstDobsonfly = 16900230;
local mobID = mob:getID();
local carminesKilled = GetServerVariable("[NM]Carmine_Dobsonflies_Killed");
if (bit.band(carminesKilled, bit.lshift(1, (mobID - firstDobsonfly))) == 0) then
carminesKilled = bit.bor(carminesKilled, bit.lshift(1, (mobID - firstDobsonfly)));
if (carminesKilled == 1023) then -- all have been defeated, allow for them to respawn while setting their respawn time to be all the same
local respawnTime = math.random(75600,86400);
for i = firstDobsonfly, firstDobsonfly + 9, 1 do
DeterMob(i, false);
GetMobByID(i):setRespawnTime(respawnTime);
end
carminesKilled = 0; -- clear the server var
else -- prevent them from respawning
DeterMob(mobID, true);
end
SetServerVariable("[NM]Carmine_Dobsonflies_Killed", carminesKilled);
end
end; | gpl-3.0 |
AlexandreCA/darkstar | scripts/zones/Quicksand_Caves/TextIDs.lua | 15 | 1486 | -- Variable TextID Description text
-- General Texts
ITEM_CANNOT_BE_OBTAINED = 6379; -- You cannot obtain the item <item> come back again after sorting your inventory
ITEM_OBTAINED = 6384; -- Obtained: <item>
GIL_OBTAINED = 6385; -- Obtained <number> gil
KEYITEM_OBTAINED = 6387; -- Obtained key item: <keyitem>
FISHING_MESSAGE_OFFSET = 7204; -- You can't fish here.
HOMEPOINT_SET = 11414; -- Home point set!
-- Treasure Coffer/Chest Dialog
CHEST_UNLOCKED = 7306; -- You unlock the chest!
CHEST_FAIL = 7307; -- Fails to open the chest.
CHEST_TRAP = 7308; -- The chest was trapped!
CHEST_WEAK = 7309; -- You cannot open the chest when you are in a weakened state.
CHEST_MIMIC = 7310; -- The chest was a mimic!
CHEST_MOOGLE = 7311; -- You cannot open the chest while participating in the moogle event.
CHEST_ILLUSION = 7312; -- The chest was but an illusion...
CHEST_LOCKED = 7313; -- The chest appears to be locked.
-- Other dialog
NOTHING_OUT_OF_ORDINARY = 6398; -- There is nothing out of the ordinary here.
SENSE_OF_FOREBODING = 6399; -- You are suddenly overcome with a sense of foreboding...
DOOR_FIRMLY_SHUT = 7314; -- The door is firmly shut.
POOL_OF_WATER = 7346; -- It is a pool of water.
YOU_FIND_NOTHING = 7349; -- You find nothing.
SOMETHING_IS_BURIED = 7354; -- Something is buried in this fallen pillar.
-- conquest Base
CONQUEST_BASE = 7045; -- Tallying conquest results...
| gpl-3.0 |
tartina/ardour | share/scripts/_insert_region_gaps.lua | 4 | 1655 | ardour {
["type"] = "EditorAction",
name = "Insert Gaps",
license = "MIT",
author = "Ardour Team",
description = [[Insert gaps between all regions on selected tracks]]
}
function action_params ()
return
{
["gap"] = { title = "Gap size (in sec)", default = "2" },
}
end
function factory () return function ()
-- get configuration
local p = params or {}
local gap = p["gap"] or 2
if gap <= 0 then gap = 2 end
local sel = Editor:get_selection () -- get current selection
local add_undo = false -- keep track of changes
Session:begin_reversible_command ("Insert Gaps")
-- iterate over all selected tracks
for route in sel.tracks:routelist ():iter () do
local track = route:to_track ()
if track:isnil () then goto continue end
-- get track's playlist
local playlist = track:playlist ()
local offset = 0
-- iterate over all regions in the playlist
for region in playlist:region_list():iter() do
-- preare for undo operation
region:to_stateful ():clear_changes ()
-- move region
region:set_position (region:position() + offset, 0)
offset = offset + Session:nominal_sample_rate () * gap
-- create a diff of the performed work, add it to the session's undo stack
-- and check if it is not empty
if not Session:add_stateful_diff_command (region:to_statefuldestructible ()):empty () then
add_undo = true
end
end
::continue::
end
-- all done, commit the combined Undo Operation
if add_undo then
-- the 'nil' Command here mean to use the collected diffs added above
Session:commit_reversible_command (nil)
else
Session:abort_reversible_command ()
end
end end
| gpl-2.0 |
AlexandreCA/darkstar | scripts/zones/Meriphataud_Mountains_[S]/Zone.lua | 12 | 1788 | -----------------------------------
--
-- Zone: Meriphataud_Mountains_[S] (97)
--
-----------------------------------
package.loaded["scripts/zones/Meriphataud_Mountains_[S]/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Meriphataud_Mountains_[S]/TextIDs");
require("scripts/globals/settings");
require("scripts/globals/status");
-----------------------------------
-- 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(-454.135,28.409,657.79,49);
end
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onGameHour
-----------------------------------
function onGameHour()
local GameHour = 150; -- Seconds per VanadielHour
local npc = GetNPCByID(17175338); -- Indescript Markings
if (npc ~= nil) then
if (VanadielHour() == 17) then
npc:setStatus(STATUS_DISAPPEAR);
end
if (VanadielHour() == 7) then
npc:setStatus(STATUS_NORMAL);
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 |
AlexandreCA/update | scripts/zones/Sea_Serpent_Grotto/npcs/_4w3.lua | 17 | 2702 | -----------------------------------
-- Area: Sea Serpent Grotto
-- NPC: Mythril Beastcoin Door
-- @zone 176
-- @pos 40 8.6 20.012
-----------------------------------
package.loaded["scripts/zones/Sea_Serpent_Grotto/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/zones/Sea_Serpent_Grotto/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (trade:hasItemQty(749,1) and trade:getItemCount() == 1) then
if (player:getVar("SSG_MythrilDoor") == 7) then
npc:openDoor(5) --Open the door if a mythril beastcoin has been traded after checking the door the required number of times
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
X = player:getXPos();
Z = player:getZPos();
MythrilDoorCheck = player:getVar("SSG_MythrilDoor");
if (X >= 40 and Z >= 15) then
if (MythrilDoorCheck == 0) then --Door has never been checked
player:messageSpecial(FIRST_CHECK);
player:setVar("SSG_MythrilDoor",1);
elseif (MythrilDoorCheck == 1) then --Door has been checked once
player:messageSpecial(SECOND_CHECK);
player:setVar("SSG_MythrilDoor",2);
elseif (MythrilDoorCheck == 2) then --Door has been checked twice
player:messageSpecial(THIRD_CHECK);
player:setVar("SSG_MythrilDoor",3);
elseif (MythrilDoorCheck == 3) then --Door has been checked three times
player:messageSpecial(FOURTH_CHECK);
player:setVar("SSG_MythrilDoor",4);
elseif (MythrilDoorCheck == 4) then --Door has been checked four times
player:messageSpecial(FIFTH_CHECK);
player:setVar("SSG_MythrilDoor",5);
elseif (MythrilDoorCheck == 5) then --Door has been checked five times
player:messageSpecial(MYTHRIL_CHECK);
player:setVar("SSG_MythrilDoor",6);
elseif (MythrilDoorCheck == 6 or MythrilDoorCheck == 7) then --Door has been checked six or more times
player:messageSpecial(COMPLETED_CHECK,749);
player:setVar("SSG_MythrilDoor",7);
end
return 1 --Keep the door closed
elseif (X < 40 and Z < 24) then
return -1 --Open the door if coming from the "inside"
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 |
boundary/luvit | tests/test-buffer.lua | 3 | 1734 | --[[
Copyright 2012 The Luvit Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--]]
local os = require("os")
if (os.type() == "win32") then
print("buffer is broken on win32, need to not ffi into malloc")
return
end
require("helper")
local Buffer = require('buffer').Buffer
local buf = Buffer:new(4)
buf[1] = 0xFB
buf[2] = 0x04
buf[3] = 0x23
buf[4] = 0x42
assert(buf:readUInt8(1) == 0xFB)
assert(buf:readUInt8(2) == 0x04)
assert(buf:readUInt8(3) == 0x23)
assert(buf:readUInt8(4) == 0x42)
assert(buf:readInt8(1) == -0x05)
assert(buf:readInt8(2) == 0x04)
assert(buf:readInt8(3) == 0x23)
assert(buf:readInt8(4) == 0x42)
assert(buf:readUInt16BE(1) == 0xFB04)
assert(buf:readUInt16LE(1) == 0x04FB)
assert(buf:readUInt16BE(2) == 0x0423)
assert(buf:readUInt16LE(2) == 0x2304)
assert(buf:readUInt16BE(3) == 0x2342)
assert(buf:readUInt16LE(3) == 0x4223)
assert(buf:readUInt32BE(1) == 0xFB042342)
assert(buf:readUInt32LE(1) == 0x422304FB)
assert(buf:readInt32BE(1) == -0x04FBDCBE)
assert(buf:readInt32LE(1) == 0x422304FB)
local buf2 = Buffer:new('abcd')
assert(tostring(buf2) == 'abcd')
assert(buf2:toString(1, 2) == 'ab')
assert(buf2:toString(2, 3) == 'bc')
assert(buf2:toString(3) == 'cd')
assert(buf2:toString() == 'abcd')
| apache-2.0 |
dannysmc95/EclipseOS | eclipse.lua | 1 | 25016 | --[[
Name: Eclipse Operating System
Author: DannySMc (dannysmc95)
Description: Eclipse is my newest OS, with multiple ways to customise and design your environment. Eclipse has support for multiple features, including multitasking, plugins, apps, Discover App Store, themes, an awesome option of 3 environments to work in, a nicely designed file manager.
Features:
+ Multitasking
+ HTTP Support
+ Built-in App Store (Powered By Discover)
+ All-in-one File Manager (Copy, Paste, Move, Download, Edit, Create)
+ Secure Rednet Transfer Protocol (RTP & SRTP) (Base64 -> Binary)
+ Apps Folder to see all your apps,
+ Plugins that will automatically add more to your OS,
+ A choice of 3 environments: Desktop, X-Cross Media Bar, Dashboard,
+ Traverse: An alpha version of my new web browser,
+ Design: An alpha version of my new image editor,
+ Typer: An alpha version of my new word editor,
+ Transmit: Computer to Computer Connections Manager,
+ Crawler: A rednet crawler that will scour your rednet networks and attempt to get as much information as possible, bringing it back as a nice GUI.
+ Monitor Support,
+ Pocket PC Support,
+ Turtle Support,
]]
-- Get Command Line Arguments (If any)
local tArgs = {...}
-- Eclipse Dependent Variables
osdata = {
["name"] = "Eclipse";
["version"] = 0.1;
["build"] = 1;
["state"] = "Pre-Alpha";
["author"] = "DannySMc";
["url"] = "https://ccsystems.dannysmc.com/ccsystems.php";
["folders"] = {".eclipse/", ".eclipse/settings", ".eclipse/apps", ".eclipse/apps/config", ".eclipse/data", ".eclipse/data/updates", ".eclipse/data/logs", ".eclipse/data/system", ".eclipse/plugins", ".eclipse/plugins/config"},
["apps"] = {"luaide", "ink", "sketch"},
}
local nTries = 0
userdata = {
["username"] = false;
["password"] = false;
["loggedin"] = false;
["realtime"] = false;
["timezone"] = "Europe/London";
["notifications"] = {};
}
periphs = {
["modem"] = false;
["monitor"] = false;
["drive"] = false;
["printer"] = false;
}
globalvars = {}
local osimages = {
["usericon"] = {{"19:19: ","19:19: ","19:19: ","19:19: ","19:19: ","19:19: ","19:19: ",},{"19:19: ","19:19: ","12:12: ","12:12: ","12:12: ","19:19: ","19:19: ",},{"19:19: ","12:12: ","19:19: ","19:19: ","19:19: ","12:12: ","19:19: ",},{"19:19: ","19:19: ","19:19: ","19:19: ","19:19: ","12:12: ","19:19: ",},{"19:19: ","19:19: ","19:19: ","19:19: ","19:19: ","12:12: ","19:19: ",},{"19:19: ","19:19: ","19:19: ","19:19: ","12:12: ","19:19: ","19:19: ",},{"19:19: ","19:19: ","19:19: ","12:12: ","19:19: ","19:19: ","19:19: ",},{"19:19: ","19:19: ","19:19: ","12:12: ","19:19: ","19:19: ","19:19: ",},{"19:19: ","19:19: ","19:19: ","19:19: ","19:19: ","19:19: ","19:19: ",},{"19:19: ","19:19: ","19:19: ","12:12: ","19:19: ","19:19: ","19:19: ",},};
[""] = {};
}
local tHelp = {
["User Data"] = "User data is a stored variable in Eclipse which stores a lot of data about your settings. Some of the things stored are: Username, Password, Timezone, LoggedIn, Real Time, and Notifications. These are also saved to disk when you click shut down, if possible can you please use the given Shut down, Reboot functions, to make sure that the system saves all recent data.";
["Apps"] = "Apps are just another name of storing programs, apps can be downloaded via the App Store, URL (Raw file download), or you can use Pastebin. These can be launched via the Apps manager or you can create a desktop icon to add them to the desktop. Apps can access a config file inside the apps folder, please make sure to save apps to: .eclipse/apps/ folder so they can use the given config folder.";
["Plugins"] = "Plugins are a new way of editing the OS, these can also be downloaded via Pastebin, or RAW file download. There will be a plugins manager that can help shape more new features into the OS. This includes support for the Minecraft Environment or even help apps interface with the OS. Plugins are also controlled by a Plugin Manager. Plugins do not run interfaces they just run in the background.";
["Credits"] = "I would like to say thank you to MKlegoman357 for helping me learn Multitasking, and to all my beta testers. The system was an idea I have had for a long whil ebut never bothered to make because I could not get Multitasking, now with my knowledge I wanted to make something that interacts more and is useful for everyone.";
["Author"] = "Hello, My name is Danny, of course, and I am a Web Developer and C++ Programmer. I am very keen with Lua and love making new things that will help the community. If I have made something that helps you +1 my post! Questions? Contact me at: danny.smc95@gmail.com or use Esper IRC: #shinexusuk. Want to meet me in-game? Come to ShinexusUK Server.";
["System"] = "The system runs on a nice multitasking bases that allows routines to run in the background and in the foreground. It makes it very easy to build and create awesome new designs. To view the current software versions and build number, please go to settings -> system.";
["Future"] = "There are many new plans for Eclipse, as this will hopefully be the only OS I will be using and updating. Therefore it will be updated a lot with new features and more interactive help. This has took me over 3 months to build due to on and off programming and the pure fact of trying to make a system that works.";
["CL Interface"] = "Eclipse comes with a nice command line interface that allows you to run the OS in a minimal view, this still supports CraftOS's command operations but also supports some extra commands I integrated to make it more appealing.";
["App Store"] = "The App Store is powered by Discover (which is the new name for my App Store), it uses a database with over 105 apps, submitted by awesome programmers. The plan is to allow people to have a more independant app store that they can use to allow them to output files to everyone via my database, making it easier to distribute new plugins and updates.";
["Want to help?"] = "As part of a new idea, I plan to allow people to create their own fixes, and have a small team to work on it, this will of course be on github. I would love other players to play a part in dveoloping new apps, plugins for the OS, to make it a more user oriented OS. If you are interested in helping email me at: danny.smc95@gmail.com.";
}
-- Set Funcion Naming
ec = {}
ec.__index = ec
ec.core = {}
ec.core.__index = ec.core
ec.draw = {}
ec.draw.__index = ec.draw
ec.boot = {}
ec.boot.__index = ec.boot
ec.cli = {}
ec.cli.__index = ec.cli
ec.apps = {}
ec.apps.__index = ec.apps
ec.kernal = {}
ec.kernal.__index = ec.kernal
ec.info = {}
ec.info.__index = ec.info
-- Run Screen Clearing:
term.clear()
term.setCursorPos(1,1)
-- Request API:
function ec.boot.api()
local ok, err = pcall(function()
if http then
aa = aa or {}
local a = http.get("https://vault.dannysmc.com/lua/api/dannysmcapi.lua")
a = a.readAll()
local env = {}
a = loadstring(a)
local env = getfenv()
setfenv(a,env)
local status, err = pcall(a, unpack(aa))
if (not status) and err then
printError("Error loading api")
return false
end
local returned = err
env = env
_G["progutils"] = env
if #tArgs >= 1 then
ec.cli.boot()
else
ec.core.catchall()
end
else
ec.core.crash("HTTP needs to be enabled")
end
end)
if not ok then
if nTries == 3 then
sleep(0.01)
ec.core.crash(err)
else
nTries = nTries + 1
sleep(0.01)
ec.boot.api()
end
end
end
function ec.core.catchall()
local status, err = pcall(function()
ec.core.desktop()
--ec.boot.init()
end)
if not status then
ec.core.crash(err)
end
end
function ec.kernal.running()
col.screen("white")
ec.draw.bar("Processes")
draw.texta("Total Processes: "..#threads, 1, 19, false, "lightGrey", "white")
for i=1, 15 do
if i <= #threads then
draw.texta(i..":", 1, i+2, false, "red", "white")
draw.texta(threads[i].name, 4, i+2, false, "cyan", "white")
draw.texta("("..coroutine.status(threads[1].co)..")", 42, i+2, false, "lightGrey", "white")
end
end
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
ec.draw.bar("Processes")
elseif args[1] == "mouse_click" then
if args[2] == 1 then
-- Left Click
if (args[3] >= 1 and args[3] <= 51) and (args[4] >= 3 and args[4] <= 17) then
end
elseif args[2] == 2 then
-- Right Click
if (args[3] >= 1 and args[3] <= 51) and (args[4] >= 3 and args[4] <= 17) then
end
end
end
end
end
function ec.draw.bar(screenname)
draw.box(1, 51, 1, 1, " ", "grey", "grey")
draw.texta(misc.time(), 47, 1, false, "lime", "grey")
draw.texta("Eclipse:", 1, 1, false, "cyan", "grey")
draw.texta(screenname, 10, 1, false, "white", "grey")
draw.texta("<", 45, 1, false, "lightBlue", "grey")
if #userdata.notifications > 0 then
draw.texta("N", 43, 1, false, "red", "grey")
else
draw.texta("N", 43, 1, false, "lightGrey", "grey")
end
end
function ec.core.crash(err)
col.screen("white")
ec.draw.bar("Crashed")
draw.box(8, 36, 3, 1, " ", "cyan", "cyan")
draw.texta("1. Restart Eclipse", 9, 3, false, "white", "cyan")
draw.box(8, 36, 5, 1, " ", "cyan", "cyan")
draw.texta("2. Restart Computer", 9, 5, false, "white", "cyan")
draw.box(8, 36, 7, 1, " ", "cyan", "cyan")
draw.texta("3. Remove Startup File", 9, 7, false, "white", "cyan")
draw.box(8, 36, 9, 1, " ", "cyan", "cyan")
draw.texta("4. Shutdown Computer", 9, 9, false, "white", "cyan")
draw.box(8, 36, 11, 1, " ", "cyan", "cyan")
draw.texta("5. Submit a Bug Report", 9, 11, false, "white", "cyan")
for k,v in ipairs(data.wordwrap(err, 47)) do
draw.texta(v, 3, k+13, false, "red", "white")
end
draw.textc("-< Please click an option in the cyan boxes >-", 19, false, "lightGrey", "white")
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
ec.draw.bar("Crashed")
elseif args[1] == "mouse_click" then
if (args[3] >= 8 and args[3] <= 47) and (args[4] == 3) then
ec.boot.main()
elseif (args[3] >= 8 and args[3] <= 47) and (args[4] == 5) then
os.reboot()
elseif (args[3] >= 8 and args[3] <= 47) and (args[4] == 7) then
if fs.exists("startup") then
fs.delete("startup")
end
elseif (args[3] >= 8 and args[3] <= 47) and (args[4] == 9) then
os.reboot()
elseif (args[3] >= 8 and args[3] <= 47) and (args[4] == 11) then
ec.core.submitbug(err)
end
end
end
end
function ec.boot.init()
-- This needs to load all the systems, start running the processes.
col.screen("black")
sleep(0.01)
col.screen("grey")
sleep(0.01)
col.screen("lightGrey")
draw.textc("Eclipse Operating System", 8, false, "black", "lightGrey")
draw.textc("Created By DannySMc", 9, false, "white", "lightGrey")
sleep(1)
-- Check for install
if fs.exists(".eclipse/settings/install.lua") then
draw.box(1, 51, 19, 1, " ", "lightGrey", "lightGrey")
draw.textc("--< Running Installer >--", 19, false, "red", "lightGrey")
sleep(0.5)
ec.core.install()
col.screen("black")
sleep(0.01)
col.screen("grey")
sleep(0.01)
col.screen("lightGrey")
draw.textc("Eclipse Operating System", 8, false, "black", "lightGrey")
draw.textc("Created By DannySMc", 9, false, "white", "lightGrey")
sleep(1)
end
-- Load User Data
draw.box(1, 51, 19, 1, " ", "lightGrey", "lightGrey")
draw.textc("--< Loading User Data >--", 19, false, "red", "lightGrey")
sleep(0.25)
if fs.exists(".eclipse/settings/user.lua") then
local conf = config.load(".eclipse/settings/user.lua")
userdata["username"] = conf.username;
userdata["password"] = conf.password;
userdata["realtime"] = conf.realtime;
userdata["timezone"] = conf.timezone;
if userdata.username then
local req = http.post(osdata.url, "ccsys=user&cccmd=login&username="..textutils.urlEncode(tostring(userdata.username)).."&password="..textutils.urlEncode(tostring(userdata.password)))
req = req.readAll()
if req == "true" then
userdata["loggedin"] = true
else
userdata["loggedin"] = false
table.insert(userdata.notifications, "Login: "..req)
end
end
end
-- Check for Peripherals
draw.box(1, 51, 19, 1, " ", "lightGrey", "lightGrey")
draw.textc("--< Connecting peripherals >--", 19, false, "red", "lightGrey")
sleep(0.25)
for k,v in pairs(periphs) do
p = misc.find(k)
if not p or p == '' then
periphs[k] = p
end
end
local function loadplugin(fpath, name)
if not name then
local ranlet = {"a","b","c","d","e","f"}
n = {}
for i=1, 8 do
table.insert(n, ranlet[math.ceil(math.random(5))])
end
name = table.concat(n, "")
end
aa = aa or {}
if fpath then
if fs.exists(fpath) then
local f = fs.open(fpath, "r")
a = f.readAll()
f.close()
return "No exising file at: "..fpath
end
return "Missing file path"
end
a = a.readAll()
local env = {}
a = loadstring(a)
local env = getfenv()
setfenv(a,env)
local status, err = pcall(a, unpack(aa))
if (not status) and err then
printError("Error loading api")
return false
end
local returned = err
env = env
_G[name] = env
end
-- Initialising Plugins / API's From Registry
draw.box(1, 51, 19, 1, " ", "lightGrey", "lightGrey")
draw.textc("--< Initialising Plugins >--", 19, false, "red", "lightGrey")
local count = 0
if fs.exists(".eclipse/settings/registry.lua") then
reg = config.load(".eclipse/settings/registry.lua")
for k,v in pairs(reg) do
count = count + 1
local ok, err = pcall(function()
loadplugin(v, k)
end)
if ok then
draw.box(1, 51, 19, 1, " ", "lightGrey", "lightGrey")
draw.textc("--< Initialised: "..count.."/"..#reg.." >--", 19, false, "red", "lightGrey")
else
draw.box(1, 51, 19, 1, " ", "lightGrey", "lightGrey")
draw.textc("--< Failed to Initialise: " ..v.." >--", 19, false, "red", "lightGrey")
end
end
end
ec.core.login()
end
function ec.core.install()
col.screen("lightBlue")
sleep(0.01)
draw.textc("Welcome to Eclipse", 7, false, "white", "lightBlue")
sleep(0.25)
draw.textc("Let's get you set up!", 9, false, "white", "lightBlue")
sleep(0.5)
for i=19, 1 do
draw.box(1, 51, i, 1, " ", "white", "white")
sleep(0.01)
end
sleep(0.05)
draw.box(1, 51, 1, 1, " ", "grey", "grey")
draw.textc("Installer (1/5)", 1, false, "white", "grey")
sleep(0.05)
col.set("cyan", "white")
term.setCursorPos(1,3)
print("> Creating folders...")
for k,v in ipairs(osdata.folders) do
fs.makeDir(v)
sleep(0.01)
draw.texta("("..k.."/"..#osdata.folders..")", 45, 3, false, "red", "white")
end
draw.texta("Finished", 44, 3, false, "red", "white")
draw.texta("> Getting apps...", 1, 5, false, "cyan", "white")
for k,v in ipairs(osdata.apps) do
baseurl = "http://projects.dannysmc.com/eclipse/apps"
local req = http.get(baseurl.."/"..v..".lua")
local f = fs.open(".eclipse/apps/"..v..".lua", "w")
f.write(req.readAll())
f.close()
req = nil
draw.texta("("..k.."/"..#osdata.apps..")", 45, 5, false, "red", "white")
end
draw.texta("Finished", 44, 5, false, "red", "white")
dtaw.texta("All done!", 1, 7, false, "cyan", "white")
sleep(1)
end
function ec.core.uninstall()
-- Do not do until finished the OS.
end
function ec.core.submitbug(err)
end
function ec.core.login()
col.screen("white")
ec.draw.bar("Login")
local function drawlogin()
for i=2, 19 do
draw.box(1, 21, i, 1, " ", "lightGrey", "lightGrey")
end
local stext = "Please use the buttons above to login/register. Eclipse uses the CCSystems Database which powers the Discover App Store and More!"
for k,v in ipairs(data.wordwrap(stext, 20)) do
draw.texta(v, 2, k+11, false, "white", "lightGrey")
end
draw.box(2, 19, 4, 1, " ", "lightBlue", "lightBlue")
draw.box(2, 19, 6, 1, " ", "lightBlue", "lightBlue")
draw.box(2, 19, 8, 1, " ", "lightBlue", "lightBlue")
draw.texta("1. Login", 3, 4, false, "white", "lightBlue")
draw.texta("2. Register", 3, 6, false, "white", "lightBlue")
draw.texta("3. CCSystems", 3, 8, false, "white", "lightBlue")
draw.texta("Username:", 24, 4, false, "grey", "white")
draw.box(24, 26, 5, 1, false, "cyan", "cyan")
draw.texta("Password:", 24, 8, false, "grey", "white")
draw.box(24, 26, 9, 1, false, "cyan", "cyan")
draw.texta("Reset", 24, 18, false, "grey", "white")
draw.texta("Login", 45, 18, false, "grey", "white")
end
drawlogin()
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
ec.draw.bar("Login")
elseif args[1] == "mouse_click" then
if args[2] == 1 then
if (args[3] >= 2 and args[3] <= 19) and (args[4] == 4) then
--ec.core.login()
draw.texta("Username:", 24, 4, false, "grey", "white")
draw.box(24, 26, 5, 1, false, "cyan", "cyan")
draw.texta("Password:", 24, 8, false, "grey", "white")
draw.box(24, 26, 9, 1, false, "cyan", "cyan")
username = nil
password = nil
elseif (args[3] >= 2 and args[3] <= 19) and (args[4] == 6) then
local user, pass = ec.core.register()
if user and pass then
userdata.username = user
userdata.password = pass
userdata.loggedin = true
break
else
popup.alert(":397: Expected string, got nil")
sleep(1.5)
drawlogin()
end
elseif (args[3] >= 2 and args[3] <= 19) and (args[4] == 6) then
ec.info.ccsystems()
elseif (args[3] >= 24 and args[4] <= 49) and (args[4] == 5) then
-- Username
draw.box(24, 26, 5, 1, false, "cyan", "cyan")
username = nil
col.set("white", "cyan")
term.setCursorPos(24, 5)
write(": ")
username = tostring(read())
elseif (args[3] >= 24 and args[4] <= 49) and (args[4] == 9) then
-- Password
draw.box(24, 26, 9, 1, false, "cyan", "cyan")
password = nil
col.set("white", "cyan")
term.setCursorPos(24, 9)
write(": ")
password = crypt.sha256(tostring(read("*")))
elseif (args[3] >= 24 and args[3] <= 28) and (args[4] == 18) then
-- Reset Form
draw.texta("Username:", 24, 4, false, "grey", "white")
draw.box(24, 26, 5, 1, false, "cyan", "cyan")
draw.texta("Password:", 24, 8, false, "grey", "white")
draw.box(24, 26, 9, 1, false, "cyan", "cyan")
username = nil
password = nil
elseif (args[3] >= 45 and args[3] <= 49) and (args[4] == 18) then
-- Login
local req = http.post(osdata.url, "ccsys=user&cccmd=login&username="..textutils.urlEncode(tostring(username)).."&password="..textutils.urlEncode(tostring(password)))
req = req.readAll()
if req == "true" then
userdata.username = username
userdata.password = password
userdata.loggedin = true
popup.alert("Logged in, Loading Desktop...")
sleep(1)
break
else
popup.alert(req)
sleep(1.5)
draw.texta("Username:", 24, 4, false, "grey", "white")
draw.box(24, 26, 5, 1, false, "cyan", "cyan")
draw.texta("Password:", 24, 8, false, "grey", "white")
draw.box(24, 26, 9, 1, false, "cyan", "cyan")
username = nil
password = nil
end
end
end
end
end
thread:create("Desktop", ec.core.desktop)
thread:switch("Desktop")
thread:run()
end
function ec.core.register()
col.screen("white")
ec.draw.bar("Register")
while true do
local args = { os.pullEvent() }
if args[1] == "char" then
if args[2] == "1" then
return unpack({true, "danny", "dan"})
end
end
end
end
function ec.core.desktop()
col.screen("white")
ec.draw.bar("Desktop")
local function drawicons()
local intxy = {{4,14,25,34,44,4,14,25,34,44,4,14,25,34,44},{3,3,3,3,3,8,8,8,8,8,13,13,13,13,13}}
tiles = config.load(".eclipse/settings/tiles.lua")
if type(tiles) == "table" then
for i, tile in ipairs(tiles) do
draw.texta(tile.name, intxy[1][i]-1, intxy[2][i]+3, false, "grey", "white")
image.draw(tile.icon, intxy[1][i], intxy[2][i])
end
end
end
drawicons()
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
ec.draw.bar("Desktop")
elseif args[1] == "mouse_click" then
if args[2] == 1 then
-- Stuff here
end
end
end
end
--[[ Icons have to be 6 x 3, OVERALL: 5 x 3 ]]
--[[###################################################
###################################################
## 000000 ## 000000 ## 000000 ## 000000 ## 000000 #
## 000000 ## 000000 ## 000000 ## 000000 ## 000000 #
## 000000 ## 000000 ## 000000 ## 000000 ## 000000 #
## xPlore ##AppStore##Transmit## Draw ## Writer #
###################################################
##0################################################
##0################################################
##0################################################
##0################################################
###################################################
##0################################################
##0################################################
##0################################################
##0################################################
###################################################
###################################################
###################################################]]
--[[
TODO:
+ Desktop
+ Task Manager
+ Installer
+ Create folders,
+ Download APIs,
+ Get any external apps,
+ UNinstaller
+ Login
+ Register
+ Transmit
+ Discover
+ Traverse
+ xPlore
+ Download Manager
+ HTTP Controller
.eclipse
settings
registry.lua
install.lua
user.lua
desktop.lua
apps
config
plugins
config
data
updates
logs
system
]]
-- Start System
ec.boot.api() | epl-1.0 |
incinirate/Riko4 | scripts/home/demos/grav.lua | 1 | 3087 | local gpp = dofile("/lib/gpp.lua")
local rif = dofile("/lib/rif.lua")
local width, height = gpu.width, gpu.height
local curs = rif.createImage("curs.rif")
local underlay = image.newImage(width, height)
local running = true
local mouseX, mouseY = -5, -5
local particles = {}
particles[1] = {80, height / 2, -18}
particles[2] = {width - 80, height / 2, 6}
-- particles[3] = {width / 2, 40, -3}
-- particles[1] = {width / 2 + 20, 130, 6}
local fieldParticles = {}
-- Force = K * (q1 * q2) / d^2
local K = .1-- * 10 ^ 9
local function calculateForces()
for _ = 1, 10 do
for i = #fieldParticles, 1, -1 do
fieldParticles[i][1] = fieldParticles[i][1] + fieldParticles[i][4][1]
fieldParticles[i][2] = fieldParticles[i][2] + fieldParticles[i][4][2]
local force = {0, 0}
local still = true
for j = 1, #particles do
local delta = {particles[j][1] - fieldParticles[i][1], particles[j][2] - fieldParticles[i][2]}
local norm = math.sqrt(delta[1] * delta[1] + delta[2] * delta[2])
if norm < math.abs(particles[j][3]) or norm > 500 then
table.remove(fieldParticles, i)
still = false
break
end
local dir = {delta[1] / norm, delta[2] / norm}
local iforc = K * (fieldParticles[i][3] * particles[j][3]) / norm
force[1] = force[1] + dir[1] * iforc
force[2] = force[2] + dir[2] * iforc
end
if still then
fieldParticles[i][4][1] = force[1]
fieldParticles[i][4][2] = force[2]
local tx, ty = fieldParticles[i][1], fieldParticles[i][2]
fieldParticles[i][1] = fieldParticles[i][1] + fieldParticles[i][4][1]
fieldParticles[i][2] = fieldParticles[i][2] + fieldParticles[i][4][2]
if math.floor(tx) ~= math.floor(fieldParticles[i][1]) or math.floor(ty) ~= math.floor(fieldParticles[i][2]) then
underlay:drawPixel(math.floor(fieldParticles[i][1]), math.floor(fieldParticles[i][2]), fieldParticles[i][3] > 0 and 8 or 4)
end
end
end
end
underlay:flush()
end
local function drawContent()
underlay:render(0, 0)
for i = 1, #particles do
gpp.fillCircle(particles[i][1], particles[i][2], math.abs(particles[i][3]), 7)
end
for i = 1, #fieldParticles do
gpp.fillCircle(fieldParticles[i][1], fieldParticles[i][2], math.abs(fieldParticles[i][3]), 16)
end
curs:render(mouseX, mouseY)
end
local function processEvent(e, ...)
if e == "key" then
local k = ...
if k == "escape" then
running = false
end
elseif e == "mouseMoved" then
local x, y = ...
mouseX, mouseY = x, y
elseif e == "mousePressed" then
local x, y, b = ...
fieldParticles[#fieldParticles + 1] = {x, y, b == 1 and -2 or 2, {1, 0}}
end
end
local eventQueue = {}
while running do
while true do
local e = {coroutine.yield()}
if #e == 0 then break end
eventQueue[#eventQueue + 1] = e
end
while #eventQueue > 0 do
processEvent(unpack(
table.remove(eventQueue, 1)))
end
calculateForces()
gpu.clear()
drawContent()
gpu.swap()
end
| mit |
AlexandreCA/update | scripts/zones/Bastok_Markets/Zone.lua | 28 | 2870 | -----------------------------------
--
-- Zone: Bastok_Markets (235)
--
-----------------------------------
package.loaded["scripts/zones/Bastok_Markets/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/chocobo");
require("scripts/globals/events/harvest_festivals");
require("scripts/globals/settings");
require("scripts/globals/zone");
require("scripts/zones/Bastok_Markets/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
applyHalloweenNpcCostumes(zone:getID())
setChocoboPrices();
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 = 0x00;
end
player:setPos(-280,-12,-91,15);
player:setHomePoint();
end
-- MOG HOUSE EXIT
if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then
position = math.random(1,5) - 33;
player:setPos(-177,-8,position,127);
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)
end;
-----------------------------------
-- onGameDay
-----------------------------------
function onGameDay()
-- Removes daily the bit mask that tracks the treats traded for Harvest Festival.
if (isHalloweenEnabled() ~= 0) then
clearVarFromAll("harvestFestTreats");
clearVarFromAll("harvestFestTreats2");
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 == 0x00) then
player:messageSpecial(ITEM_OBTAINED,0x218);
elseif (csid == 0x7534 and option == 0) then
player:setHomePoint();
player:messageSpecial(HOMEPOINT_SET);
end
end; | gpl-3.0 |
chourobin/kong | kong/dao/schemas_validation.lua | 12 | 7571 | local utils = require "kong.tools.utils"
local stringy = require "stringy"
local POSSIBLE_TYPES = {
id = true,
table = true,
array = true,
string = true,
number = true,
boolean = true,
url = true,
timestamp = true
}
local custom_types_validation = {
["id"] = function(v) return type(v) == "string" end,
["timestamp"] = function(v) return type(v) == "number" end,
["url"] = function(v)
if v and type(v) == "string" then
local parsed_url = require("socket.url").parse(v)
return parsed_url and parsed_url.path and parsed_url.host and parsed_url.scheme
end
end,
["array"] = function(v) return utils.is_array(v) end
}
local function validate_type(field_type, value)
if custom_types_validation[field_type] then
return custom_types_validation[field_type](value)
end
return type(value) == field_type
end
local _M = {}
-- Validate a table against a given schema
-- @param `t` Entity to validate, as a table.
-- @param `schema` Schema against which to validate the entity.
-- @param `options`
-- `dao_insert` A function called foe each field with a `dao_insert_value` property.
-- `is_update` For an entity update, check immutable fields. Set to true.
-- @return `valid` Success of validation. True or false.
-- @return `errors` A list of encountered errors during the validation.
function _M.validate_entity(t, schema, options)
if not options then options = {} end
local errors
if not options.partial_update and not options.full_update then
for column, v in pairs(schema.fields) do
-- [DEFAULT] Set default value for the field if given
if t[column] == nil and v.default ~= nil then
if type(v.default) == "function" then
t[column] = v.default(t)
else
t[column] = v.default
end
end
-- [INSERT_VALUE]
if v.dao_insert_value and type(options.dao_insert) == "function" then
t[column] = options.dao_insert(v)
end
end
end
-- Check the given table against a given schema
for column, v in pairs(schema.fields) do
-- [IMMUTABLE] check immutability of a field if updating
if (options.partial_update or options.full_update) and t[column] ~= nil and v.immutable and not v.required then
errors = utils.add_error(errors, column, column.." cannot be updated")
end
-- [TYPE] Check if type is valid. Boolean and Numbers as strings are accepted and converted
if t[column] ~= nil and v.type ~= nil then
local is_valid_type
-- ALIASES: number, timestamp, boolean and array can be passed as strings and will be converted
if type(t[column]) == "string" then
t[column] = stringy.strip(t[column])
if v.type == "number" or v .type == "timestamp" then
t[column] = tonumber(t[column])
is_valid_type = t[column] ~= nil
elseif v.type == "boolean" then
local bool = t[column]:lower()
is_valid_type = bool == "true" or bool == "false"
t[column] = bool == "true"
elseif v.type == "array" then
t[column] = stringy.strip(t[column]) == "" and {} or stringy.split(t[column], ",") -- Handling empty arrays
for arr_k, arr_v in ipairs(t[column]) do
t[column][arr_k] = stringy.strip(arr_v)
end
is_valid_type = validate_type(v.type, t[column])
else -- if string
is_valid_type = validate_type(v.type, t[column])
end
else
is_valid_type = validate_type(v.type, t[column])
end
if not is_valid_type and POSSIBLE_TYPES[v.type] then
errors = utils.add_error(errors, column, column.." is not a "..v.type)
end
end
-- [ENUM] Check if the value is allowed in the enum.
if t[column] ~= nil and v.enum then
local found = true
local wrong_value = t[column]
if v.type == "array" then
for _, array_value in ipairs(t[column]) do
if not utils.table_contains(v.enum, array_value) then
found = false
wrong_value = array_value
break
end
end
else
found = utils.table_contains(v.enum, t[column])
end
if not found then
errors = utils.add_error(errors, column, string.format("\"%s\" is not allowed. Allowed values are: \"%s\"", wrong_value, table.concat(v.enum, "\", \"")))
end
end
-- [REGEX] Check field against a regex if specified
if t[column] ~= nil and v.regex then
if not ngx.re.match(t[column], v.regex) then
errors = utils.add_error(errors, column, column.." has an invalid value")
end
end
-- [SCHEMA] Validate a sub-schema from a table or retrieved by a function
if v.schema then
local sub_schema, err
if type(v.schema) == "function" then
sub_schema, err = v.schema(t)
if err then -- could not retrieve sub schema
errors = utils.add_error(errors, column, err)
end
else
sub_schema = v.schema
end
if sub_schema then
-- Check for sub-schema defaults and required properties in advance
if t[column] == nil then
for sub_field_k, sub_field in pairs(sub_schema.fields) do
if sub_field.default ~= nil then -- Sub-value has a default, be polite and pre-assign the sub-value
t[column] = {}
elseif sub_field.required then -- Only check required if field doesn't have a default
errors = utils.add_error(errors, column, column.."."..sub_field_k.." is required")
end
end
end
if t[column] and type(t[column]) == "table" then
-- Actually validating the sub-schema
local s_ok, s_errors = _M.validate_entity(t[column], sub_schema, options)
if not s_ok then
for s_k, s_v in pairs(s_errors) do
errors = utils.add_error(errors, column.."."..s_k, s_v)
end
end
end
end
end
if not options.partial_update or t[column] ~= nil then
-- [REQUIRED] Check that required fields are set.
-- Now that default and most other checks have been run.
if v.required and (t[column] == nil or t[column] == "") then
errors = utils.add_error(errors, column, column.." is required")
end
if type(v.func) == "function" and (errors == nil or errors[column] == nil) then
-- [FUNC] Check field against a custom function
-- only if there is no error on that field already.
local ok, err, new_fields = v.func(t[column], t, column)
if ok == false and err then
errors = utils.add_error(errors, column, err)
elseif new_fields then
for k, v in pairs(new_fields) do
t[k] = v
end
end
end
end
end
-- Check for unexpected fields in the entity
for k in pairs(t) do
if schema.fields[k] == nil then
errors = utils.add_error(errors, k, k.." is an unknown field")
end
end
if errors == nil and type(schema.self_check) == "function" then
local ok, err = schema.self_check(schema, t, options.dao, (options.partial_update or options.full_update))
if ok == false then
return false, nil, err
end
end
return errors == nil, errors
end
local digit = "[0-9a-f]"
local uuid_pattern = "^"..table.concat({ digit:rep(8), digit:rep(4), digit:rep(4), digit:rep(4), digit:rep(12) }, '%-').."$"
function _M.is_valid_uuid(uuid)
return uuid and uuid:match(uuid_pattern) ~= nil
end
return _M
| mit |
AlexandreCA/update | scripts/globals/spells/armys_paeon_ii.lua | 31 | 1390 | -----------------------------------------
-- Spell: Army's Paeon II
-- Gradually restores target's HP.
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
local sLvl = caster:getSkillLevel(SKILL_SNG); -- Gets skill level of Singing
local iLvl = caster:getWeaponSkillLevel(SLOT_RANGED);
local power = 2;
if (sLvl+iLvl > 150) then
power = power + 1;
end
local iBoost = caster:getMod(MOD_PAEON_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);
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_PAEON,power,0,duration,caster:getID(), 0, 2)) then
spell:setMsg(75);
end
return EFFECT_PAEON;
end; | gpl-3.0 |
AlexandreCA/darkstar | scripts/globals/abilities/eagle_eye_shot.lua | 26 | 2067 | -----------------------------------
-- Ability: Eagle Eye Shot
-- Delivers a powerful and accurate ranged attack.
-- Obtained: Ranger Level 1
-- Recast Time: 1:00:00
-- Duration: Instant
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/weaponskills");
-----------------------------------
-- onAbilityCheck
-----------------------------------
function onAbilityCheck(player,target,ability)
local ranged = player:getStorageItem(0, 0, SLOT_RANGED);
local ammo = player:getStorageItem(0, 0, SLOT_AMMO);
if ranged and ranged:isType(ITEM_WEAPON) then
local skilltype = ranged:getSkillType();
if skilltype == SKILL_ARC or skilltype == SKILL_MRK or skilltype == SKILL_THR then
if ammo and (ammo:isType(ITEM_WEAPON) or skilltype == SKILL_THR) then
return 0, 0;
end;
end;
end;
return MSGBASIC_NO_RANGED_WEAPON, 0;
end;
-----------------------------------
-- onUseAbility
-----------------------------------
function onUseAbility(player,target,ability,action)
if (player:getWeaponSkillType(SLOT_RANGED) == SKILL_MRK) then
action:animation(target:getID(), action:animation(target:getID()) + 1);
end
local params = {};
params.numHits = 1;
local ftp = 5
params.ftp100 = ftp; params.ftp200 = ftp; params.ftp300 = ftp;
params.str_wsc = 0.0; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0;
params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0;
params.canCrit = true;
params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0;
params.atkmulti = 1
params.enmityMult = 0.5
local damage, criticalHit, tpHits, extraHits = doRangedWeaponskill(player, target, 0, params, 0, true)
if not (tpHits + extraHits > 0) then
ability:setMsg(MSGBASIC_USES_BUT_MISSES)
action:speceffect(target:getID(), 0)
end
return damage;
end;
| gpl-3.0 |
adamsumm/ZeldANN | Torch/model/GRU.lua | 6 | 2058 |
local GRU = {}
--[[
Creates one timestep of one GRU
Paper reference: http://arxiv.org/pdf/1412.3555v1.pdf
]]--
function GRU.gru(input_size, rnn_size, n, dropout)
dropout = dropout or 0
-- there are n+1 inputs (hiddens on each layer and x)
local inputs = {}
table.insert(inputs, nn.Identity()()) -- x
for L = 1,n do
table.insert(inputs, nn.Identity()()) -- prev_h[L]
end
function new_input_sum(insize, xv, hv)
local i2h = nn.Linear(insize, rnn_size)(xv)
local h2h = nn.Linear(rnn_size, rnn_size)(hv)
return nn.CAddTable()({i2h, h2h})
end
local x, input_size_L
local outputs = {}
for L = 1,n do
local prev_h = inputs[L+1]
-- the input to this layer
if L == 1 then
x = OneHot(input_size)(inputs[1])
input_size_L = input_size
else
x = outputs[(L-1)]
if dropout > 0 then x = nn.Dropout(dropout)(x) end -- apply dropout, if any
input_size_L = rnn_size
end
-- GRU tick
-- forward the update and reset gates
local update_gate = nn.Sigmoid()(new_input_sum(input_size_L, x, prev_h))
local reset_gate = nn.Sigmoid()(new_input_sum(input_size_L, x, prev_h))
-- compute candidate hidden state
local gated_hidden = nn.CMulTable()({reset_gate, prev_h})
local p2 = nn.Linear(rnn_size, rnn_size)(gated_hidden)
local p1 = nn.Linear(input_size_L, rnn_size)(x)
local hidden_candidate = nn.Tanh()(nn.CAddTable()({p1,p2}))
-- compute new interpolated hidden state, based on the update gate
local zh = nn.CMulTable()({update_gate, hidden_candidate})
local zhm1 = nn.CMulTable()({nn.AddConstant(1,false)(nn.MulConstant(-1,false)(update_gate)), prev_h})
local next_h = nn.CAddTable()({zh, zhm1})
table.insert(outputs, next_h)
end
-- set up the decoder
local top_h = outputs[#outputs]
if dropout > 0 then top_h = nn.Dropout(dropout)(top_h) end
local proj = nn.Linear(rnn_size, input_size)(top_h)
local logsoft = nn.LogSoftMax()(proj)
table.insert(outputs, logsoft)
return nn.gModule(inputs, outputs)
end
return GRU
| mit |
AlexandreCA/update | scripts/globals/abilities/celerity.lua | 28 | 1156 | -----------------------------------
-- Ability: Celerity
-- Reduces the casting time and the recast time of your next white magic spell by 50%.
-- Obtained: Scholar Level 25
-- Recast Time: Stratagem Charge
-- Duration: 1 white magic spell or 60 seconds, whichever occurs first.
--
-- Level |Charges |Recharge Time per Charge
-- ----- -------- ---------------
-- 10 |1 |4:00 minutes
-- 30 |2 |2:00 minutes
-- 50 |3 |1:20 minutes
-- 70 |4 |1:00 minute
-- 90 |5 |48 seconds
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
-----------------------------------
-- onAbilityCheck
-----------------------------------
function onAbilityCheck(player,target,ability)
if player:hasStatusEffect(EFFECT_CELERITY) then
return MSGBASIC_EFFECT_ALREADY_ACTIVE, 0;
end
return 0,0;
end;
-----------------------------------
-- onUseAbility
-----------------------------------
function onUseAbility(player,target,ability)
player:addStatusEffect(EFFECT_CELERITY,1,0,60);
return EFFECT_CELERITY;
end; | gpl-3.0 |
AlexandreCA/update | scripts/zones/East_Ronfaure_[S]/npcs/Logging_Point.lua | 29 | 1113 | -----------------------------------
-- Area: East Ronfaure [S]
-- NPC: Logging Point
-----------------------------------
package.loaded["scripts/zones/East_Ronfaure_[S]/TextIDs"] = nil;
-------------------------------------
require("scripts/globals/logging");
require("scripts/zones/East_Ronfaure_[S]/TextIDs");
-----------------------------------
-- onTrade
-----------------------------------
function onTrade(player,npc,trade)
startLogging(player,player:getZoneID(),npc,trade,0x0385);
end;
-----------------------------------
-- onTrigger
-----------------------------------
function onTrigger(player,npc)
player:messageSpecial(LOGGING_IS_POSSIBLE_HERE,1021);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end; | gpl-3.0 |
techtonik/wesnoth | data/ai/micro_ais/cas/ca_forest_animals_move.lua | 2 | 6904 | local H = wesnoth.require "lua/helper.lua"
local W = H.set_wml_action_metatable {}
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local LS = wesnoth.require "lua/location_set.lua"
local function get_forest_animals(cfg)
-- We want the deer/rabbits to move first, tuskers afterward
local deer_type = cfg.deer_type or "no_unit_of_this_type"
local rabbit_type = cfg.rabbit_type or "no_unit_of_this_type"
local forest_animals = AH.get_units_with_moves {
side = wesnoth.current.side,
type = deer_type .. ',' .. rabbit_type
}
local tusker_type = cfg.tusker_type or "no_unit_of_this_type"
local all_tuskers = wesnoth.get_units { side = wesnoth.current.side, type = tusker_type }
for _,tusker in ipairs(all_tuskers) do
if (tusker.moves > 0) then table.insert(forest_animals, tusker) end
end
-- Tusklets get moved by this CA if there are no tuskers left
if not all_tuskers[1] then
local tusklet_type = cfg.tusklet_type or "no_unit_of_this_type"
local tusklets = wesnoth.get_units { side = wesnoth.current.side, type = tusklet_type }
for _,tusklet in ipairs(tusklets) do
if (tusklet.moves > 0) then table.insert(forest_animals, tusklet) end
end
end
return forest_animals
end
local ca_forest_animals_move = {}
function ca_forest_animals_move:evaluation(ai, cfg)
if get_forest_animals(cfg)[1] then return cfg.ca_score end
return 0
end
function ca_forest_animals_move:execution(ai, cfg)
-- These animals run from any enemy
local forest_animals = get_forest_animals(cfg)
local enemies = wesnoth.get_units { { "filter_side", { { "enemy_of", {side = wesnoth.current.side } } } } }
-- Get the locations of all the rabbit holes
W.store_items { variable = 'holes_wml' }
local all_items = H.get_variable_array('holes_wml')
W.clear_variable { name = 'holes_wml' }
-- If cfg.rabbit_hole_img is set, only items with that image or halo count as holes
local holes
if cfg.rabbit_hole_img then
for _,item in ipairs(all_items) do
if (item.image == cfg.rabbit_hole_img) or (item.halo == cfg.rabbit_hole_img) then
table.insert(holes, item)
end
end
else
holes = all_items
end
local hole_map = LS.create()
for _,hole in ipairs(holes) do hole_map:insert(hole.x, hole.y, 1) end
-- Each unit moves independently
for _,unit in ipairs(forest_animals) do
-- Behavior is different depending on whether a predator is close or not
local close_enemies = {}
for _,enemy in ipairs(enemies) do
if (H.distance_between(unit.x, unit.y, enemy.x, enemy.y) <= unit.max_moves+1) then
table.insert(close_enemies, enemy)
end
end
-- If no close enemies, do a random move
local wander_terrain = cfg.filter_location or {}
if (not close_enemies[1]) then
local reach = AH.get_reachable_unocc(unit)
local wander_locs = wesnoth.get_locations(wander_terrain)
local locs_map = LS.of_pairs(wander_locs)
local reachable_wander_terrain = {}
reach:iter( function(x, y, v)
if locs_map:get(x,y) then
table.insert(reachable_wander_terrain, {x, y})
end
end)
-- Choose one of the possible locations at random
if reachable_wander_terrain[1] then
local rand = math.random(#reachable_wander_terrain)
-- This is not a full move, as running away might happen next
if (unit.x ~= reachable_wander_terrain[rand][1]) or (unit.y ~= reachable_wander_terrain[rand][2]) then
AH.checked_move(ai, unit, reachable_wander_terrain[rand][1], reachable_wander_terrain[rand][2])
end
else -- Or if no close reachable terrain was found, move toward the closest
local min_dist, best_hex = 9e99
for _,loc in ipairs(wander_locs) do
local dist = H.distance_between(loc[1], loc[2], unit.x, unit.y)
if dist < min_dist then
best_hex, min_dist = loc, dist
end
end
if (best_hex) then
local x,y = wesnoth.find_vacant_tile(best_hex[1], best_hex[2], unit)
local next_hop = AH.next_hop(unit, x, y)
if (unit.x ~= next_hop[1]) or (unit.y ~= next_hop[2]) then
AH.checked_move(ai, unit, next_hop[1], next_hop[2])
end
end
end
end
-- Now we check for close enemies again, as we might just have moved within reach of some
local close_enemies = {}
if unit and unit.valid then
for _,enemy in ipairs(enemies) do
if (H.distance_between(unit.x, unit.y, enemy.x, enemy.y) <= unit.max_moves+1) then
table.insert(close_enemies, enemy)
end
end
end
-- If there are close enemies, run away (and rabbits disappear into holes)
local rabbit_type = cfg.rabbit_type or "no_unit_of_this_type"
if close_enemies[1] then
-- Calculate the hex that maximizes distance of unit from enemies
-- Returns nil if the only hex that can be reached is the one the unit is on
local farthest_hex = AH.find_best_move(unit, function(x, y)
local rating = 0
for _,enemy in ipairs(close_enemies) do
local dist = H.distance_between(enemy.x, enemy.y, x, y)
rating = rating - 1 / dist^2
end
-- If this is a rabbit, try to go for holes
if (unit.type == rabbit_type) and hole_map:get(x, y) then
rating = rating + 1000
-- But if possible, go to another hole if unit is on one
if (x == unit.x) and (y == unit.y) then rating = rating - 10 end
end
return rating
end)
AH.movefull_stopunit(ai, unit, farthest_hex)
-- If this is a rabbit ending on a hole -> disappears
if unit and unit.valid
and (unit.type == rabbit_type) and hole_map:get(farthest_hex[1], farthest_hex[2])
then
local command = "wesnoth.put_unit(x1, y1)"
ai.synced_command(command, farthest_hex[1], farthest_hex[2])
end
end
-- Finally, take moves away, as only partial move might have been done
-- Also take attacks away, as these units never attack
if unit and unit.valid then AH.checked_stopunit_all(ai, unit) end
end
end
return ca_forest_animals_move
| gpl-2.0 |
AlexandreCA/update | scripts/zones/RuAun_Gardens/Zone.lua | 28 | 15340 | -----------------------------------
--
-- Zone: RuAun_Gardens (130)
--
-----------------------------------
package.loaded["scripts/zones/RuAun_Gardens/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/missions");
require("scripts/globals/conquest");
require("scripts/zones/RuAun_Gardens/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
local manuals = {17310100,17310101,17310102,17310103,17310104,17310105};
SetFieldManual(manuals);
-- Blue portal timers (2 minutes)
-- counterclockwise
SetServerVariable("Main-to-Seiryu-BlueTeleport",0);
SetServerVariable("Seiryu-to-Genbu-BlueTeleport",0);
SetServerVariable("Genbu-to-Byakko-BlueTeleport",0);
SetServerVariable("Byakko-to-Suzaku-BlueTeleport",0);
SetServerVariable("Suzaku-to-Main-BlueTeleport",0);
-- clockwise
SetServerVariable("Main-to-Suzaku-BlueTeleport",0);
SetServerVariable("Suzaku-to-Byakko-BlueTeleport",0);
SetServerVariable("Byakko-to-Genbu-BlueTeleport",0);
SetServerVariable("Genbu-to-Seiryu-BlueTeleport",0);
SetServerVariable("Seiryu-to-Main-BlueTeleport",0);
------------------------------
-- Red teleports
------------------------------
zone:registerRegion(1,-3,-54,-583,1,-50,-579);
zone:registerRegion(2,147,-26,-449,151,-22,-445);
zone:registerRegion(3,186,-43,-405,190,-39,-401);
zone:registerRegion(4,272,-42,-379,276,-38,-375);
zone:registerRegion(5,306,-39,-317,310,-35,-313);
zone:registerRegion(6,393,-39,193,397,-35,197);
zone:registerRegion(7,62,-39,434,66,-35,438);
zone:registerRegion(8,-2,-42,464,2,-38,468);
zone:registerRegion(9,-65,-39,434,-61,-35,438);
zone:registerRegion(10,-397,-39,193,-393,-35,197);
zone:registerRegion(11,-445,-42,142,-441,-38,146);
zone:registerRegion(12,-276,-42,-379,-272,-38,-375);
zone:registerRegion(13,-191,-43,-405,-187,-39,-401);
zone:registerRegion(14,-151,-26,-449,-147,-22,-445);
zone:registerRegion(15,543,-73,-19,547,-69,-15);
zone:registerRegion(16,182,-73,511,186,-69,515);
zone:registerRegion(17,-432,-73,332,-428,-69,336);
zone:registerRegion(18,-453,-73,-308,-449,-69,-304);
zone:registerRegion(19,-436,-39,71,-432,-35,75);
zone:registerRegion(20,-310,-39,-317,-306,-35,-313);
zone:registerRegion(21,441,-42,142,445,-38,146);
zone:registerRegion(22,432,-39,71,436,-35,75);
------------------------------
-- Blue teleports
------------------------------
zone:registerRegion(23,162.5,-31,-353.5,168.5,-30,-347.5); -- Main To Seriyu
zone:registerRegion(24,374.5,-25,61.5,380.5,-24,67.5); -- Seriyu to Genbu
zone:registerRegion(25,52.5,-25,376.5,58.5,-24,382.5); -- Genbu to Byakko
zone:registerRegion(26,-346.5,-25,166.5,-340.5,-24,172.5); -- Byakko to Suzaku
zone:registerRegion(27,-270.5,-25,-277.5,-264.5,-24,-271.5); -- Suzaku to Main
zone:registerRegion(28,-170,-31,-354.4,-162,-30,-347.2); -- Main to Suzaku
zone:registerRegion(29,-381,-25,61.5,-374.5,-24,67.5); -- Suzaku to Byakko
zone:registerRegion(30,-58,-25,376.5,-52,-24,382.5); -- Byakko to Genbu
zone:registerRegion(31,340.5,-25,166.5,346.5,-24,172.5); --Genbu to Seriyu
zone:registerRegion(32,264.5,-25,-277.5,270.5,-24,-271.5); -- Seriyu to Main
------------------------------
-- Yellow teleports
------------------------------
zone:registerRegion(33,454,-5,-149,456,-3,-147);
zone:registerRegion(34,278,-5,383,281,-3,386);
zone:registerRegion(35,-283,-5,386,-280,-3,389);
zone:registerRegion(36,-456,-5,-149,-454,-3,-147);
---432,-72,335,-429,-70,333
------------------------------
-- Green teleports
------------------------------
zone:registerRegion(37,-145,-41,-156,-142,-39,-153);
zone:registerRegion(38,142,-41,-156,145,-39,-153 );
UpdateTreasureSpawnPoint(17310020);
SetRegionalConquestOverseers(zone:getRegionID())
end;
-----------------------------------
-- onConquestUpdate
-----------------------------------
function onConquestUpdate(zone, updatetype)
local players = zone:getPlayers();
for name, player in pairs(players) do
conquestUpdate(zone, player, updatetype, CONQUEST_BASE);
end
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then
player:setPos(333.017,-44.896,-458.35,164);
end
if (player:getCurrentMission(ZILART) == THE_GATE_OF_THE_GODS and player:getVar("ZilartStatus") == 1) then
cs = 0x0033;
end
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
switch (region:GetRegionID()): caseof
{
---------------------------------
[1] = function (x) -- Portal --
---------------------------------
player:startEvent(0x0000);
end,
---------------------------------
[2] = function (x) -- Portal --
---------------------------------
player:startEvent(0x0001);
end,
---------------------------------
[3] = function (x) -- Portal --
---------------------------------
player:startEvent(0x0002);
end,
---------------------------------
[4] = function (x) -- Portal --
---------------------------------
if (math.random(0,1) == 0) then
player:startEvent(0x0004);
else
player:startEvent(0x0005);
end
end,
---------------------------------
[5] = function (x) -- Portal --
---------------------------------
player:startEvent(0x0006);
end,
---------------------------------
[6] = function (x) -- Portal --
---------------------------------
player:startEvent(0x0009);
end,
---------------------------------
[7] = function (x) -- Portal --
---------------------------------
player:startEvent(0x0010);
end,
---------------------------------
[8] = function (x) -- Portal --
---------------------------------
if (math.random(0,1) == 0) then
player:startEvent(0x0012);
else
player:startEvent(0x0013);
end
end,
---------------------------------
[9] = function (x) -- Portal --
---------------------------------
player:startEvent(0x0014);
end,
---------------------------------
[10] = function (x) -- Portal --
---------------------------------
player:startEvent(0x0017);
end,
---------------------------------
[11] = function (x) -- Portal --
---------------------------------
if (math.random(0,1) == 0) then
player:startEvent(0x0019);
else
player:startEvent(0x001A);
end
end,
---------------------------------
[12] = function (x) -- Portal --
---------------------------------
if (math.random(0,1) == 0) then
player:startEvent(0x0020);
else
player:startEvent(0x0021);
end
end,
---------------------------------
[13] = function (x) -- Portal --
---------------------------------
player:startEvent(0x0022);
end,
---------------------------------
[14] = function (x) -- Portal --
---------------------------------
player:startEvent(0x0024);
end,
---------------------------------
[15] = function (x) -- Portal --
---------------------------------
player:startEvent(0x0025);
end,
---------------------------------
[16] = function (x) -- Portal --
---------------------------------
player:startEvent(0x0026);
end,
---------------------------------
[17] = function (x) -- Portal --
---------------------------------
player:startEvent(0x0027);
end,
---------------------------------
[18] = function (x) -- Portal --
---------------------------------
player:startEvent(0x0028);
end,
---------------------------------
[19] = function (x) -- Portal --
---------------------------------
player:startEvent(0x001B);
end,
---------------------------------
[20] = function (x) -- Portal --
---------------------------------
player:startEvent(0x001E);
end,
---------------------------------
[21] = function (x) -- Portal --
---------------------------------
if (math.random(0,1) == 0) then
player:startEvent(0x000B);
else
player:startEvent(0x000C);
end
end,
---------------------------------
[22] = function (x) -- Portal --
---------------------------------
player:startEvent(0x0009);
end,
----------- BLUE portals --------------
---------------------------------
[23] = function (x) -- Portal -- Main To Seriyu
---------------------------------
if (GetNPCByID(17310054):getAnimation() == 8) then
player:startEvent(0x0003);
end
end,
---------------------------------
[24] = function (x) -- Portal -- Seriyu to Genbu
---------------------------------
if (GetNPCByID(17310057):getAnimation() == 8) then
player:startEvent(0x000A);
end
end,
---------------------------------
[25] = function (x) -- Portal -- Genbu to Byakko
---------------------------------
if (GetNPCByID(17310060):getAnimation() == 8) then
player:startEvent(0x0011);
end
end,
---------------------------------
[26] = function (x) -- Portal -- Byakko to Suzaku
---------------------------------
if (GetNPCByID(17310063):getAnimation() == 8) then
player:startEvent(0x0018);
end
end,
---------------------------------
[27] = function (x) -- Portal -- Suzaku to Main
---------------------------------
if (GetNPCByID(17310066):getAnimation() == 8) then
player:startEvent(0x001F);
end
end,
---------------------------------
[28] = function (x) -- Portal -- Main to Suzaku
---------------------------------
if (GetNPCByID(17310067):getAnimation() == 8) then
player:startEvent(0x0023);
end
end,
---------------------------------
[29] = function (x) -- Portal -- Suzaku to Byakko
---------------------------------
if (GetNPCByID(17310064):getAnimation() == 8) then
player:startEvent(0x001C);
end
end,
---------------------------------
[30] = function (x) -- Portal -- Byakko to Genbu
---------------------------------
if (GetNPCByID(17310061):getAnimation() == 8) then
player:startEvent(0x0015);
end
end,
---------------------------------
[31] = function (x) -- Portal -- Genbu to Seriyu
---------------------------------
if (GetNPCByID(17310058):getAnimation() == 8) then
player:startEvent(0x000E);
end
end,
---------------------------------
[32] = function (x) -- Portal -- Seriyu to Main
---------------------------------
if (GetNPCByID(17310055):getAnimation() == 8) then
player:startEvent(0x0007);
end
end,
---------------------------------
[33] = function (x) -- Seiryu's Portal --
---------------------------------
player:startEvent(0x0008);
end,
---------------------------------
[34] = function (x) -- Genbu's Portal --
---------------------------------
player:startEvent(0x000f);
end,
---------------------------------
[35] = function (x) -- Byakko's Portal --
---------------------------------
player:startEvent(0x0016);
end,
---------------------------------
[36] = function (x) -- Suzaku's Portal --
---------------------------------
player:startEvent(0x001d);
end,
---------------------------------
[37] = function (x)
---------------------------------
if (player:getVar("skyShortcut") == 1) then
player:startEvent(0x002a);
else
title = player:getTitle();
if (title == 401) then
player:startEvent(0x0029,title);
else
player:startEvent(0x002b,title);
end
end
end,
---------------------------------
[38] = function (x)
---------------------------------
if (player:getVar("skyShortcut") == 1) then
player:startEvent(0x002a);
else
title = player:getTitle();
if (title == 401) then
player:startEvent(0x0029,title);
else
player:startEvent(0x002b,title);
end
end
end,
default = function (x)
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 == 0x0029 and option ~= 0) then
player:setVar("skyShortcut",1);
elseif (csid == 0x0033) then
player:setVar("ZilartStatus",0);
player:completeMission(ZILART,THE_GATE_OF_THE_GODS);
player:addMission(ZILART,ARK_ANGELS);
end
end; | gpl-3.0 |
AlexandreCA/darkstar | scripts/globals/logging.lua | 14 | 6438 | -------------------------------------------------
-- Logging functions
-- Info from:
-- http://wiki.ffxiclopedia.org/wiki/Logging
-------------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
-------------------------------------------------
-- npcid and drop by zone
-------------------------------------------------
-- Zone, {npcid,npcid,npcid,..}
local npcid = {2, {16785769,16785770,16785771,16785772}, -- Carpenter's Landing
24, {16875879,16875880,16875881,16875882,16875883,16875884}, -- Lufaise Meadows
25, {16879968,16879969,16879970,16879971,16879972,16879973}, -- Misareaux Coast
65, {17044010,17044011,17044012,17044013,17044014,17044015}, -- Mamook
79, {17101314,17101315,17101316,17101317,17101318,17101319}, -- Caedarva Mire
81, {17109782,17109783,17109784,17109785,17109786,17109787}, -- East Ronfaure [S]
82, {17113901,17113902,17113903,17113904,17113905,17113906}, -- Jugner Forest [S]
96, {17171239,17171240,17171241,17171242,17171243,17171244}, -- Fort Karugo-Narugo [S]
101,{17191526,17191527,17191528,17191529,17191530,17191531}, -- East Ronfaure
104,{17203860,17203861,17203862,17203863,17203864,17203865}, -- Jugner Forest
118,{17261171,17261172,17261173,17261174,17261175,17261176}, -- Buburimu Peninsula
123,{17281626,17281627,17281628,17281629,17281630,17281631}, -- Yuhtunga Jungle
124,{17285671,17285672,17285673,17285674,17285675,17285676}, -- Yhoator Jungle
140,{17350970,17350971,17350972,17350973}}; -- Ghelsba Outpost
-- Zone, {itemid,drop rate,itemid,drop rate,..}
-- Must be in ascending order by drop rate
local drop = {2, {0x1198,0.0900,0x02B0,0.1800,0x02BA,0.2700,0x039B,0.3600,0x02B7,0.4500,0x02B5,0.7050,0x02B8,0.9600,0x02BB,1.0000},
24, {0x02B5,0.0950,0x110B,0.1900,0x02B0,0.4400,0x02B3,0.6900,0x02BA,0.9400,0x02B2,0.9600,0x02BB,0.9800,0x1198,1.0000},
25, {0x02B0,0.4000,0x02B5,0.4700,0x02B3,0.5400,0x110B,0.7400,0x02BA,0.9400,0x02B2,0.9600,0x02BB,0.9800,0x1198,1.0000},
65, {0x15BE,0.2300,0x08A5,0.4600,0x02B6,0.5100,0x02BE,0.5600,0x02B1,0.6100,0x02BD,0.6590,0x09C7,0.7660,0x02D7,0.8730,0x02B0,0.9800,0x02D9,1.0000},
79, {0x02D9,0.0392,0x02B6,0.0944,0x02BE,0.1666,0x02BD,0.2388,0x02B0,0.3590,0x08A5,0.4952,0x02B1,0.6474,0x09C7,0.8156,0x02D7,1.0000},
81, {0x09E6,0.0030,0x09E4,0.0330,0x02BB,0.0660,0x023E,0.1110,0x02B5,0.1740,0x02B6,0.2640,0x027F,0.3810,0x02BA,0.5130,0x161D,0.6450,0x02B3,0.7950,0x02B0,1.0000},
82, {0x02B0,0.1800,0x02BA,0.3600,0x02B5,0.5400,0x02B7,0.7200,0x02BB,0.7700,0x09E4,0.8200,0x1198,0.9000,0x161D,0.9800,0x09E6,1.0000},
96, {0x46FF,0.0040,0x04D4,0.0240,0x034F,0.1630,0x11DA,0.3140,0x161E,0.4810,0x1612,0.7080,0x103A,1.0000},
101,{0x02B6,0.0500,0x02B8,0.1130,0x023E,0.1760,0x02B6,0.2640,0x02B3,0.4760,0x02B0,0.7380,0x02BA,1.0000},
104,{0x02BB,0.0120,0x1198,0.0600,0x039B,0.1320,0x02BA,0.2590,0x02B0,0.4220,0x02B7,0.5970,0x02B8,0.7900,0x02B5,1.0000},
118,{0x02BC,0.0170,0x02BD,0.0430,0x02BE,0.0770,0x023E,0.1290,0x039B,0.2070,0x02B9,0.3020,0x1197,0.4050,0x115D,0.5600,0x02B0,0.7580,0x02B1,1.0000},
123,{0x02B0,0.2350,0x02D1,0.4650,0x04A8,0.0500,0x02B1,0.7000,0x02B9,0.7700,0x03AC,0.8400,0x0390,0.9100,0x02BD,0.9400,0x02BE,0.9700,0x04D5,1.0000},
124,{0x02BE,0.0120,0x04A8,0.0500,0x02BC,0.0520,0x03AC,0.0920,0x039B,0.1620,0x0390,0.3070,0x02B1,0.4780,0x02B0,0.7290,0x02D1,0.9800,0x04D5,1.0000},
140,{0x02B9,0.0530,0x02B2,0.1060,0x02B7,0.2050,0x02B3,0.4400,0x02BA,0.6950,0x02B0,1.0000}};
function startLogging(player,zone,npc,trade,csid)
if (trade:hasItemQty(1021,1) and trade:getItemCount() == 1) then
local broke = hatchetBreak(player,trade);
local item = getLoggingItem(player,zone);
if (player:getFreeSlotsCount() == 0) then
full = 1;
else
full = 0;
end
player:startEvent(csid,item,broke,full);
if (item ~= 0 and full == 0) then
player:addItem(item);
SetServerVariable("[LOGGING]Zone "..zone,GetServerVariable("[LOGGING]Zone "..zone) + 1);
end
if (GetServerVariable("[LOGGING]Zone "..zone) >= 3) then
getNewLoggingPositionNPC(player,npc,zone);
end
else
player:messageSpecial(LOGGING_IS_POSSIBLE_HERE,1021);
end
end
-----------------------------------
-- Determine if Hatchet breaks
-----------------------------------
function hatchetBreak(player,trade)
local broke = 0;
local hatchetbreak = math.random();
hatchetbreak = hatchetbreak + (player:getMod(MOD_LOGGING_RESULT) / 1000);
if (hatchetbreak < LOGGING_BREAK_CHANCE) then
broke = 1;
player:tradeComplete();
end
return broke;
end
-----------------------------------
-- Get an item
-----------------------------------
function getLoggingItem(player,zone)
local Rate = math.random();
for zon = 1, table.getn(drop), 2 do
if (drop[zon] == zone) then
for itemlist = 1, table.getn(drop[zon + 1]), 2 do
if (Rate <= drop[zon + 1][itemlist + 1]) then
item = drop[zon + 1][itemlist];
break;
end
end
break;
end
end
--------------------
-- Determine chance of no item mined
-- Default rate is 50%
--------------------
Rate = math.random();
if (Rate <= (1 - LOGGING_RATE)) then
item = 0;
end
return item;
end
-----------------------------------------
-- After 3 items he change the position
-----------------------------------------
function getNewLoggingPositionNPC(player,npc,zone)
local newnpcid = npc:getID();
for u = 1, table.getn(npcid), 2 do
if (npcid[u] == zone) then
nbNPC = table.getn(npcid[u + 1]);
while newnpcid == npc:getID() do
newnpcid = math.random(1,nbNPC);
newnpcid = npcid[u + 1][newnpcid];
end
break;
end
end
npc:setStatus(2);
GetNPCByID(newnpcid):setStatus(0);
SetServerVariable("[LOGGING]Zone "..zone,0);
end | gpl-3.0 |
exercism/xlua | exercises/practice/crypto-square/.meta/example.lua | 3 | 1231 | local function normalized_plaintext(plaintext)
return plaintext:lower():gsub('%p*%s*', '')
end
local function size(plaintext)
return math.ceil(math.sqrt(#normalized_plaintext(plaintext)))
end
local function segments(plaintext)
local normalized_plaintext = normalized_plaintext(plaintext)
local segment_size = size(plaintext)
local segments = {}
while #normalized_plaintext > 0 do
table.insert(segments, normalized_plaintext:sub(1, segment_size))
normalized_plaintext = normalized_plaintext:sub(segment_size + 1)
end
return segments
end
local function normalized_ciphertext(plaintext)
local normalized_ciphertext = ''
local segments = segments(plaintext)
for i = 1, size(plaintext) do
for _, segment in ipairs(segments) do
normalized_ciphertext = normalized_ciphertext .. segment:sub(i, i)
end
normalized_ciphertext = normalized_ciphertext .. ' '
end
return normalized_ciphertext:gsub('%s+$', '')
end
local function ciphertext(plaintext)
return normalized_ciphertext(plaintext):gsub('%s', '')
end
return {
normalized_plaintext = normalized_plaintext,
size = size,
segments = segments,
ciphertext = ciphertext,
normalized_ciphertext = normalized_ciphertext
}
| mit |
AlexandreCA/darkstar | scripts/globals/mobskills/Lethe_Arrows.lua | 29 | 1094 | ---------------------------------------------
-- Lethe Arrows
--
-- Description: Deals a ranged attack to target. Additional effect: Knockback, Bind, and Amnesia
-- Type: Ranged
-- Utsusemi/Blink absorb: Ignores Utsusemi
-- Range: Unknown
-- Notes:
---------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------
function onMobSkillCheck(target,mob,skill)
return 0;
end;
function onMobWeaponSkill(target, mob, skill)
local typeEffect = EFFECT_BIND;
MobStatusEffectMove(mob, target, typeEffect, 1, 0, 120);
typeEffect = EFFECT_AMNESIA;
MobStatusEffectMove(mob, target, typeEffect, 1, 0, 120);
local numhits = 1;
local accmod = 3;
local dmgmod = 4;
local info = MobPhysicalMove(mob,target,skill,numhits,accmod,dmgmod,TP_DMG_VARIES,1,2,3);
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_RANGED,MOBPARAM_PIERCE,MOBPARAM_IGNORE_SHADOWS);
target:delHP(dmg);
return dmg;
end;
| gpl-3.0 |
mobinantispam/test-bot | plugins/bugzilla.lua | 611 | 3983 | do
local BASE_URL = "https://bugzilla.mozilla.org/rest/"
local function bugzilla_login()
local url = BASE_URL.."login?login=" .. _config.bugzilla.username .. "&password=" .. _config.bugzilla.password
print("accessing " .. url)
local res,code = https.request( url )
local data = json:decode(res)
return data
end
local function bugzilla_check(id)
-- data = bugzilla_login()
local url = BASE_URL.."bug/" .. id .. "?api_key=" .. _config.bugzilla.apikey
-- print(url)
local res,code = https.request( url )
local data = json:decode(res)
return data
end
local function bugzilla_listopened(email)
local url = BASE_URL.."bug?include_fields=id,summary,status,whiteboard,resolution&email1=" .. email .. "&email2=" .. email .. "&emailassigned_to2=1&emailreporter1=1&emailtype1=substring&emailtype2=substring&f1=bug_status&f2=bug_status&n1=1&n2=1&o1=equals&o2=equals&resolution=---&v1=closed&v2=resolved&api_key=" .. _config.bugzilla.apikey
local res,code = https.request( url )
print(res)
local data = json:decode(res)
return data
end
local function run(msg, matches)
local response = ""
if matches[1] == "status" then
local data = bugzilla_check(matches[2])
vardump(data)
if data.error == true then
return "Sorry, API failed with message: " .. data.message
else
response = "Bug #"..matches[1]..":\nReporter: "..data.bugs[1].creator
response = response .. "\n Last update: "..data.bugs[1].last_change_time
response = response .. "\n Status: "..data.bugs[1].status.." "..data.bugs[1].resolution
response = response .. "\n Whiteboard: "..data.bugs[1].whiteboard
response = response .. "\n Access: https://bugzilla.mozilla.org/show_bug.cgi?id=" .. matches[1]
print(response)
end
elseif matches[1] == "list" then
local data = bugzilla_listopened(matches[2])
vardump(data)
if data.error == true then
return "Sorry, API failed with message: " .. data.message
else
-- response = "Bug #"..matches[1]..":\nReporter: "..data.bugs[1].creator
-- response = response .. "\n Last update: "..data.bugs[1].last_change_time
-- response = response .. "\n Status: "..data.bugs[1].status.." "..data.bugs[1].resolution
-- response = response .. "\n Whiteboard: "..data.bugs[1].whiteboard
-- response = response .. "\n Access: https://bugzilla.mozilla.org/show_bug.cgi?id=" .. matches[1]
local total = table.map_length(data.bugs)
print("total bugs: " .. total)
local response = "There are " .. total .. " number of bug(s) assigned/reported by " .. matches[2]
if total > 0 then
response = response .. ": "
for tableKey, bug in pairs(data.bugs) do
response = response .. "\n #" .. bug.id
response = response .. "\n Status: " .. bug.status .. " " .. bug.resolution
response = response .. "\n Whiteboard: " .. bug.whiteboard
response = response .. "\n Summary: " .. bug.summary
end
end
end
end
return response
end
-- (table)
-- [bugs] = (table)
-- [1] = (table)
-- [status] = (string) ASSIGNED
-- [id] = (number) 927704
-- [whiteboard] = (string) [approved][full processed]
-- [summary] = (string) Budget Request - Arief Bayu Purwanto - https://reps.mozilla.org/e/mozilla-summit-2013/
-- [2] = (table)
-- [status] = (string) ASSIGNED
-- [id] = (number) 1049337
-- [whiteboard] = (string) [approved][full processed][waiting receipts][waiting report and photos]
-- [summary] = (string) Budget Request - Arief Bayu Purwanto - https://reps.mozilla.org/e/workshop-firefox-os-pada-workshop-media-sosial-untuk-perubahan-1/
-- total bugs: 2
return {
description = "Lookup bugzilla status update",
usage = "/bot bugzilla [bug number]",
patterns = {
"^/bugzilla (status) (.*)$",
"^/bugzilla (list) (.*)$"
},
run = run
}
end | gpl-2.0 |
exercism/xlua | exercises/practice/anagram/anagram_spec.lua | 3 | 1975 | local Anagram = require('anagram')
describe('anagram', function()
it('no result', function()
local detector = Anagram:new('diaper')
local result = detector:match({ 'hello', 'world', 'zombies', 'pants' })
local expected = {}
assert.are.same(expected, result)
end)
it('detects simple anagram', function()
local detector = Anagram:new('ant')
local result = detector:match({ 'tan', 'stand', 'at' })
local expected = { 'tan' }
assert.are.same(expected, result)
end)
it('does not detect false positives', function()
local detector = Anagram:new('galea')
local result = detector:match({ 'eagle' })
local expected = {}
assert.are.same(expected, result)
end)
it('detects multiple anagrams', function()
local detector = Anagram:new('master')
local result = detector:match({ 'stream', 'pigeon', 'maters' })
local expected = { 'stream', 'maters' }
assert.are.same(expected, result)
end)
it('does not detect anagram subsets', function()
local detector = Anagram:new('good')
local result = detector:match({'dog', 'goody'})
local expected = {}
assert.are.same(expected, result)
end)
it('detects anagram', function()
local detector = Anagram:new('listen')
local result = detector:match({ 'enlists', 'google', 'inlets', 'banana' })
local expected = { 'inlets' }
assert.are.same(expected, result)
end)
it('detects multiple anagrams', function()
local detector = Anagram:new('allergy')
local result = detector:match({ 'gallery', 'ballerina', 'regally', 'clergy', 'largely', 'leading' })
local expected = { 'gallery', 'regally', 'largely' }
assert.are.same(expected, result)
end)
it('detects anagrams case-insensitively', function()
local detector = Anagram:new('Orchestra')
local result = detector:match({ 'cashregister', 'Carthorse', 'radishes' })
local expected = { 'Carthorse' }
assert.are.same(expected, result)
end)
end)
| mit |
AlexandreCA/update | scripts/commands/cnation.lua | 26 | 1234 | ---------------------------------------------------------------------------------------------------
-- func: @cnation <target> <campaign allegiance>
-- desc: check or alter target characters campaign allegiance
---------------------------------------------------------------------------------------------------
cmdprops =
{
permission = 1,
parameters = "si"
};
function onTrigger(player, target, nation)
if (target == nil) then
player:PrintToPlayer("You must specify an online player by name.");
else
local targ = GetPlayerByName( target )
if (targ == nil) then
player:PrintToPlayer( string.format( "Player named '%s' not found!", target ) );
else
if (nation == nil) then
player:PrintToPlayer(string.format("Current Campaign Allegiance: %i", targ:getCampaignAllegiance()));
else
player:PrintToPlayer(string.format("Previous Campaign Allegiance: %i", targ:getCampaignAllegiance()));
targ:setCampaignAllegiance(nation);
player:PrintToPlayer(string.format("New Campaign Allegiance: %i", targ:getCampaignAllegiance()));
end
end
end
end; | gpl-3.0 |
AlexandreCA/darkstar | scripts/zones/Dynamis-Buburimu/mobs/Goblin_Replica.lua | 6 | 1164 | -----------------------------------
-- Area: Dynamis Buburimu
-- MOB: Goblin Replica
-----------------------------------
package.loaded["scripts/zones/Dynamis-Buburimu/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/dynamis");
require("scripts/zones/Dynamis-Buburimu/TextIDs");
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
mob:setMobMod(MOBMOD_SUPERLINK, mob:getShortID());
end;
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
dynamis.spawnGroup(mob, BuburimuGoblinList);
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob,killer,ally)
local mobID = mob:getID();
if ( mobID == 16941383 or mobID == 16941395) then --hp
ally:messageBasic(024,(ally:getMaxHP()-ally:getHP()));
ally:restoreHP(3000);
elseif (mobID ==16941396 or mobID == 16941397) then --mp
ally:messageBasic(025,(ally:getMaxMP()-ally:getMP()));
ally:restoreMP(3000);
end
end;
| gpl-3.0 |
AlexandreCA/darkstar | scripts/globals/conquest.lua | 13 | 45210 | -----------------------------------
--
-- Functions for Conquest system
--
-----------------------------------
require("scripts/globals/common");
require("scripts/globals/missions");
-----------------------------------
-- convenience constants
-----------------------------------
SANDORIA = 0;
BASTOK = 1;
WINDURST = 2;
BEASTMEN = 3;
OTHER = 4;
RONFAURE = 0;
ZULKHEIM = 1;
NORVALLEN = 2;
GUSTABERG = 3;
DERFLAND = 4;
SARUTABARUTA = 5;
KOLSHUSHU = 6;
ARAGONEU = 7;
FAUREGANDI = 8;
VALDEAUNIA = 9;
QUFIMISLAND = 10;
LITELOR = 11;
KUZOTZ = 12;
VOLLBOW = 13;
ELSHIMOLOWLANDS = 14;
ELSHIMOUPLANDS = 15;
TULIA = 16;
MOVALPOLOS = 17;
TAVNAZIANARCH = 18;
CONQUEST_TALLY_START = 0;
CONQUEST_TALLY_END = 1;
CONQUEST_UPDATE = 2;
nationAlly = 3;
-----------------------------------
-- San d'Oria inventory
-- {Option,CP,Item}
-----------------------------------
SandInv = {0x80A1,0x000A,0x1055,0x80A0,0x0007,0x1056,0x80A3,0x2328,0x3CB5,
0x80A2,0x09C4,0x3CB6,0x80A5,0x01F4,0x3D91,0x80A6,0x03E8,0x3D92,
0x80A7,0x07D0,0x3D93,0x8002,0x03E8,0x30DE,0x8003,0x03E8,0x31D1,
0x8004,0x03E8,0x32CC,0x8006,0x03E8,0x3596,0x8001,0x03E8,0x40A0,
0x8005,0x03E8,0x4133,0x8000,0x03E8,0x430F,0x8011,0x07D0,0x3156,
0x8012,0x07D0,0x3252,0x8014,0x07D0,0x32F5,0x8010,0x07D0,0x41D4,
0x8013,0x07D0,0x43D7,0x8022,0x0FA0,0x308F,0x8023,0x0FA0,0x318F,
0x8024,0x0FA0,0x328F,0x8021,0x0FA0,0x3330,0x8027,0x0FA0,0x34B7,
0x8025,0x0FA0,0x4168,0x8020,0x0FA0,0x41CC,0x8026,0x0FA0,0x42FE,
0x8034,0x1F40,0x3030,0x8031,0x1F40,0x310F,0x8032,0x1F40,0x320F,
0x8033,0x1F40,0x3597,0x8030,0x1F40,0x40D9,0x8042,0x3E80,0x3018,
0x8043,0x3E80,0x3019,0x8046,0x3E80,0x318E,0x8047,0x3E80,0x328E,
0x8045,0x3E80,0x3331,0x8044,0x3E80,0x3333,0x8048,0x3E80,0x33A4,
0x8049,0x3E80,0x3598,0x8041,0x3E80,0x40BB,0x8040,0x3E80,0x41D3,
0x8056,0x5DC0,0x3021,0x8052,0x5DC0,0x308E,0x8054,0x5DC0,0x310E,
0x8055,0x5DC0,0x320E,0x8051,0x5DC0,0x3332,0x8050,0x5DC0,0x350C,
0x8053,0x5DC0,0x359A,0x8058,0x5DC0,0x40D7,0x8059,0x5DC0,0x41A5,
0x8057,0x5DC0,0x42AB,0x8062,0x7D00,0x34F5,0x8061,0x7D00,0x41F6,
0x8060,0x7D00,0x4932,0x8072,0x9C40,0x3354,0x8070,0x9C40,0x36BD,
0x8071,0x9C40,0x36BE,0x8083,0xBB80,0x41FD,0x8080,0xBB80,0x4239,
0x8082,0xBB80,0x4432,0x8081,0xBB80,0x460E,0x8090,0xDAC0,0x385C,
0x80A4,0x1388,0x44AF};
-----------------------------------
-- Bastok inventory
-- {Option,CP,Item}
-----------------------------------
BastInv = {0x80A1,0x000A,0x1055,0x80A0,0x0007,0x1056,0x80A3,0x2328,0x3CB5,
0x80A2,0x09C4,0x3CB6,0x80A5,0x01F4,0x3D91,0x80A6,0x03E8,0x3D92,
0x80A7,0x07D0,0x3D93,0x8003,0x03E8,0x30DD,0x8004,0x03E8,0x31D0,
0x8005,0x03E8,0x32CB,0x8000,0x03E8,0x4031,0x8002,0x03E8,0x4108,
0x8007,0x03E8,0x418C,0x8006,0x03E8,0x42E8,0x8001,0x03E8,0x4347,
0x8014,0x07D0,0x3031,0x8011,0x07D0,0x3155,0x8012,0x07D0,0x3251,
0x8013,0x07D0,0x4169,0x8010,0x07D0,0x4298,0x8022,0x0FA0,0x3096,
0x8023,0x0FA0,0x3116,0x8024,0x0FA0,0x3196,0x8025,0x0FA0,0x3216,
0x8026,0x0FA0,0x3296,0x8021,0x0FA0,0x332A,0x8029,0x0FA0,0x34B9,
0x8028,0x0FA0,0x3606,0x8020,0x0FA0,0x4148,0x8027,0x0FA0,0x41A6,
0x8031,0x1F40,0x3086,0x8032,0x1F40,0x3186,0x8033,0x1F40,0x3286,
0x8034,0x1F40,0x3599,0x8030,0x1F40,0x4084,0x8035,0x1F40,0x4383,
0x8042,0x3E80,0x3106,0x8043,0x3E80,0x3206,0x8041,0x3E80,0x332B,
0x8040,0x3E80,0x4091,0x8044,0x3E80,0x42E9,0x8045,0x3E80,0x4365,
0x8053,0x5DC0,0x3010,0x8055,0x5DC0,0x3308,0x8050,0x5DC0,0x332C,
0x8051,0x5DC0,0x350E,0x8052,0x5DC0,0x40AD,0x8054,0x5DC0,0x42FF,
0x8062,0x7D00,0x34F6,0x8060,0x7D00,0x3E55,0x8061,0x7D00,0x458F,
0x8072,0x9C40,0x3355,0x8071,0x9C40,0x3638,0x8070,0x9C40,0x36BF,
0x8080,0xBB80,0x419F,0x8081,0xBB80,0x4431,0x8083,0xBB80,0x44F7,
0x8082,0xBB80,0x4714,0x8090,0xDAC0,0x385D,0x80A4,0x1388,0x44B0};
-----------------------------------
-- Windurst inventory
-- {Option,CP,Item}
-----------------------------------
WindInv = {0x80A1,0x000A,0x1055,0x8044,0x3E80,0x31BE,0x8025,0x0FA0,0x32B6,
0x80A0,0x0007,0x1056,0x8045,0x3E80,0x323E,0x8027,0x0FA0,0x33A5,
0x80A3,0x2328,0x3CB5,0x8046,0x3E80,0x32BE,0x8028,0x0FA0,0x34B8,
0x80A2,0x09C4,0x3CB6,0x8041,0x3E80,0x332E,0x8026,0x0FA0,0x416B,
0x80A5,0x01F4,0x3D91,0x8047,0x3E80,0x41AA,0x8020,0x0FA0,0x4188,
0x80A6,0x03E8,0x3D92,0x8048,0x3E80,0x4136,0x8033,0x1F40,0x3146,
0x80A7,0x07D0,0x3D93,0x8040,0x3E80,0x42BA,0x8034,0x1F40,0x31C7,
0x8003,0x03E8,0x3273,0x8050,0x5DC0,0x332F,0x8035,0x1F40,0x3246,
0x8002,0x03E8,0x403A,0x8051,0x5DC0,0x350D,0x8036,0x1F40,0x32C6,
0x8001,0x03E8,0x4284,0x8053,0x5DC0,0x41A8,0x8032,0x1F40,0x332D,
0x8004,0x03E8,0x42EA,0x8054,0x5DC0,0x41A9,0x8030,0x1F40,0x404F,
0x8000,0x03E8,0x4307,0x8052,0x5DC0,0x42C6,0x8038,0x1F40,0x411D,
0x8011,0x07D0,0x30C4,0x8061,0x7D00,0x304B,0x8037,0x1F40,0x41A7,
0x8012,0x07D0,0x316D,0x8062,0x7D00,0x34F7,0x8031,0x1F40,0x4382,
0x8013,0x07D0,0x31AF,0x8060,0x7D00,0x3E56,0x8042,0x3E80,0x30BE,
0x8014,0x07D0,0x3237,0x8072,0x9C40,0x3356,0x8043,0x3E80,0x313E,
0x8015,0x07D0,0x32AF,0x8070,0x9C40,0x36C0,0x80A4,0x1388,0x44B1,
0x8016,0x07D0,0x416A,0x8071,0x9C40,0x36C1,0x8024,0x0FA0,0x3236,
0x8017,0x07D0,0x4222,0x8082,0xBB80,0x4464,0x8090,0xDAC0,0x385E,
0x8010,0x07D0,0x42CF,0x8081,0xBB80,0x447A,0x8023,0x0FA0,0x31B6,
0x8021,0x0FA0,0x30B6,0x8083,0xBB80,0x44D1,0x8080,0xBB80,0x46E1,
0x8022,0x0FA0,0x3136};
-----------------------------------
-- Crystal Donate Array
-- Conquest Point Required for recharged the ring + charge
-- CP Reward for Supply Quest
-- TP Fees
-----------------------------------
DonateCrys = {4096,4097,4098,4099,4100,4101,4102,4103,4238,4239,4240,4241,4242,4243,4244,4245};
XpRing = {350,700,600}; RingCharg = {7,7,3};
supplyReward = {10,30,40,10,40,10,40,40,70,50,60,40,70,70,70,70,70,70,70};
tpFees = { 100, 100, 150, 100, 150, 100, 100, 150, 350, 400, 150, 250, 300, 500, 250, 350, 500, 0, 300 }
----------------------------------------------------------------
-- function tradeConquestGuard()
-----------------------------------------------------------------
function tradeConquestGuard(player,npc,trade,guardnation,guardtype)
-- Nation: -- SANDORIA, BASTOK, WINDURST, OTHER(Jeuno)
-- Type: 1: city, 2: foreign, 3: outpost, 4: border
local myCP = player:getCP();
local item = trade:getItem();
local AddPoints = 0;
if (player:getNation() == guardnation or guardnation == OTHER) then
if (guardtype ~= 3 and guardtype ~= 4) then -- all guard can trade crystal except outpost and border.
if (item >= 4096 and item <= 4103 or item >= 4238 and item <= 4245) then
for Crystal = 1,table.getn(DonateCrys),1 do
local tcount = trade:getItemQty(DonateCrys[Crystal])
if (tcount > 0 and trade:hasItemQty(DonateCrys[Crystal],tcount)) then
if (player:getRank() == 1) then
player:showText(npc,CONQUEST - 7);
break;
elseif (player:getRankPoints() == 4000) then
player:showText(npc,CONQUEST + 43);
break;
elseif (DonateCrys[Crystal] == 4102 or DonateCrys[Crystal] == 4103 or DonateCrys[Crystal] == 4244 or DonateCrys[Crystal] == 4245) then
AddPoints = AddPoints + tcount * math.floor(4000 / (player:getRank() * 12 - 16));
else
AddPoints = AddPoints + tcount * math.floor(4000 / (player:getRank() * 12 - 12));
end
end
end
if (player:getRank() ~= 1 and player:getRankPoints() < 4000) then
if (AddPoints + player:getRankPoints() >= 4000) then
newpoint = (AddPoints + player:getRankPoints()) - 4000;
player:addCP(newpoint);
player:setRankPoints(4000);
player:showText(npc,CONQUEST + 44);
else
--printf("point: %u",AddPoints);
player:addRankPoints(AddPoints);
player:showText(npc,CONQUEST + 45);
end
player:tradeComplete();
end
end
end
if (item >= 15761 and item <= 15763) then -- All guard can recharge ring - I can't read number of charge atm
if (trade:hasItemQty(item,1) and trade:getItemCount() == 1 and player:getVar("CONQUEST_RING_RECHARGE") < os.time() and
(ALLOW_MULTIPLE_EXP_RINGS == 1 or checkConquestRing(player) < 2)) then
if (myCP >= XpRing[item - 15760]) then
player:delCP(XpRing[item - 15760]);
player:tradeComplete();
player:addItem(item);
player:setVar("CONQUEST_RING_RECHARGE",getConquestTally());
player:showText(npc,CONQUEST + 58,item,XpRing[item - 15760],RingCharg[(item - 15760)]);
else
player:showText(npc,CONQUEST + 55,item,XpRing[item - 15760]);
end
else
-- TODO: Verify that message is retail correct.
-- This gives feedback on a failure at least, and is grouped with the recharge messages. Confident enough for a commit.
player:showText(npc,CONQUEST+56,item); -- "Please be aware that you can only purchase or recharge <item> once during the period between each conquest results tally.
end
end
end
end;
-------------------------------------------------------------------------
-- function suppliesFresh(player) [NEED COMMAND] 0: delete old supply after weekly conquest tally
-------------------------------------------------------------------------
function supplyRunFresh(player)
local fresh = player:getVar("supplyQuest_fresh");
local started = player:getVar("supplyQuest_started");
local region = player:getVar("supplyQuest_region");
if ((fresh <= os.time() and (region > 0 or player:hasKeyItem(75))) or
started <= 400) then -- Legacy support to remove supplies from the old system, otherwise they'd never go away.
return 0;
else
return 1;
end;
end;
----------------------------------------------------------------
-- function getArg1(player)
-----------------------------------------------------------------
windurst_bastok_ally = 0;
sandy_windurst_ally = 0;
sandy_bastok_ally = 0;
function getArg1(guardnation,player)
local pNation = player:getNation();
local output = 0;
local signet = 0;
if (guardnation == WINDURST) then
output = 33;
elseif (guardnation == SANDORIA) then
output = 1;
elseif (guardnation == BASTOK) then
output = 17;
end
if (guardnation == pNation) then
signet = 0;
elseif (pNation == WINDURST) then
if (guardnation == BASTOK and windurst_bastok_ally == 1) or (guardnation == SANDORIA and sandy_windurst_ally == 1) then
signet = 1;
else
signet = 7;
end
elseif (pNation == BASTOK) then
if (guardnation == WINDURST and windurst_bastok_ally == 1) or (guardnation == SANDORIA and sandy_bastok_ally == 1) then
signet = 2;
else
signet = 7;
end
elseif (pNation == SANDORIA) then
if (guardnation == WINDURST and sandy_windurst_ally == 1) or (guardnation == BASTOK and sandy_bastok_ally == 1) then
signet = 4;
else
signet = 7;
end
end
if (guardnation == OTHER) then
output = (pNation * 16) + (3 * 256) + 65537;
else
output = output + 256 * signet;
end
return output;
end;
------------------------------------------------
-- function getExForceAvailable(guardnation,player) Expeditionary Force Menu [NOT IMPLEMENTED]
------------------------------------------------
function getExForceAvailable(guardnation,player)
return 0;
end;
------------------------------------------------
-- function conquest_ranking() computes part of argument 3 for gate guard events.
-- it represents the conquest standing of the 3 nations. Verified.
------------------------------------------------
function conquestRanking()
return getNationRank(SANDORIA) + 4 * getNationRank(BASTOK) + 16 * getNationRank(WINDURST);
end;
----------------------------------------------------------------
-- function getSupplyAvailable(nation,player) produces the supply quest mask for the nation based on the current conquest standings.
----------------------------------------------------------------
function getSupplyAvailable(nation,player)
local mask = 2130706463;
if (player:getVar("supplyQuest_started") == vanaDay()) then
mask = 4294967295; -- Need to wait 1 vanadiel day
end
for nb = 0,15 do
if (player:hasKeyItem(getSupplyKey(nb))) then
mask = -1; -- if you have supply run already activated
end
end
if (player:hasKeyItem(getSupplyKey(18))) then -- we need to skip 16 and 17 for now
mask = -1;
end
if (mask ~= -1 and mask ~= 4294967295) then
for i = 0,18 do
if (GetRegionOwner(i) ~= nation or
i == 16 or
(i == 18 and player:hasCompletedMission(COP,DARKNESS_NAMED) == false)) then
mask = mask + 2^(i + 5);
end
end
end
return mask;
end;
----------------------------------------------------------------
-- function getArg6(player) computes argument 6 for gate guard events. This number encodes a player's rank and nationality:
-- bits 1-4 encode the rank of the player (verified that bit 4 is part of the rank number so ranks could have gone up to 31.)
-- bits 5-6 seem to encode the citizenship as below. This part needs more testing and verification.
-----------------------------------------------------------------
function getArg6(player)
local output = player:getRank();
local nation = player:getNation();
if (nation == SANDORIA) then
return output;
elseif (nation == BASTOK) then
return output + 32;
elseif (nation == WINDURST) then
return output + 64;
end
end;
------------------------------------------------
-- function getRewardExForce(guardnation,player) Expeditionary Force Reward [NOT IMPLEMENTED]
------------------------------------------------
function getRewardExForce(guardnation,player)
return 0;
end;
------------------------------------------------
-- function getKeySupply(region)
------------------------------------------------
function getSupplyKey(region)
if (region <= 9) then
return 75 + region;
elseif (region == 10) then
return 124;
elseif (region <= 13) then
return 74 + region;
elseif (region <= 15) then
return 248 + region;
elseif (region == 18) then
return 620;
end
end;
-----------------------------------------------------------------
-- giltosetHP(player) returns the amount of gil it costs a player to set a homepoint at a foreign outpost/border guard.
-----------------------------------------------------------------
function giltosetHP(guardnation,player)
local rank = player:getRank();
if (getArg1(guardnation,player) < 0x700) then -- determine ifplayer is in same or allied nation as guard
HPgil = 0;
else
if (rank <= 5) then
HPgil = 100 * 2^(rank - 1);
else
HPgil = 800 * rank - 2400;
end
end
return HPgil;
end;
-----------------------------------------------------------------
-- function hasOutpost(player, region) returns 1 ifthe player has the outpost of the indicated region under current allegiance.
-----------------------------------------------------------------
function hasOutpost(player, region)
local nation = player:getNation()
local bit = {};
if (nation == BASTOK) then
supply_quests = player:getNationTeleport(BASTOK);
elseif (nation == SANDORIA) then
supply_quests = player:getNationTeleport(SANDORIA);
elseif (nation == WINDURST) then
supply_quests = player:getNationTeleport(WINDURST);
end;
for i = 23,5,-1 do
twop = 2^i
if (supply_quests >= twop) then
bit[i]=1;
supply_quests = supply_quests - twop;
else
bit[i]=0;
end;
--printf("bit %u: %u \n",i,bit[i]);
end;
return bit[region];
end;
-----------------------------------------------------------------
-- function OP_TeleFee(player,region)
-----------------------------------------------------------------
function OP_TeleFee(player,region)
if (hasOutpost(player, region+5) == 1) then
if (GetRegionOwner(region) == player:getNation()) then
return tpFees[region + 1];
else
return tpFees[region + 1] * 3;
end
else
return 0;
end
end;
-----------------------------------------------------------------
-- Teleport Outpost > Nation
-----------------------------------------------------------------
function toHomeNation(player)
if (player:getNation() == BASTOK) then
player:setPos(89, 0 , -66, 0, 234);
elseif (player:getNation() == SANDORIA) then
player:setPos(49, -1 , 29, 164, 231);
else
player:setPos(193, -12 , 220, 64, 240);
end
end;
-----------------------------------------------------------------
-- function getTeleAvailable(nation)
-----------------------------------------------------------------
function getTeleAvailable(nation)
local mask = 2145386527;
for i = 5,23 do
if (GetRegionOwner(i - 5) ~= nation) then
mask = mask + 2^i;
end;
end
return mask;
end;
---------------------------------
-- Teleport Nation > Outpost
---------------------------------
function toOutpost(player,option)
-- Coordinates marked {R} have been obtained by packet capture from retail. Don't change them.
-- Ronfaure
if (option == 5) then
player:setPos(-437.688, -20.255, -219.227, 124, 100); -- {R}
-- Zulkheim
elseif (option == 6) then
player:setPos(148.231, -7.975 , 93.479, 154, 103); -- {R}
-- Norvallen
elseif (option == 7) then
player:setPos(62.030, 0.463, -2.025, 67, 104); -- {R}
-- Gustaberg
elseif (option == 8) then
player:setPos(-580.161, 39.578, 62.68, 89, 106); -- {R}
-- Derfland
elseif (option == 9) then
player:setPos(465.820, 23.625, 423.164, 29, 109); -- {R}
-- Sarutabaruta
elseif (option == 10) then
player:setPos(-17.921, -13.335, 318.156, 254, 115); -- {R}
-- Kolshushu
elseif (option == 11) then
player:setPos(-480.237, -30.943, 58.079, 62, 118); -- {R}
-- Aragoneu
elseif (option == 12) then
player:setPos(-297.047, 16.988, 418.026, 225, 119); -- {R}
-- Fauregandi
elseif (option == 13) then
player:setPos(-18.690, -60.048, -109.243, 100, 111); -- {R}
-- Valdeaunia
elseif (option == 14) then
player:setPos(211.210, -24.016, -207.338, 160, 112); -- {R}
-- Qufim Island
elseif (option == 15) then
player:setPos(-243.049, -19.983, 306.712, 71, 126); -- {R}
-- Li'Telor
elseif (option == 16) then
player:setPos(-37.669, 0.419, -141.216, 69, 121); -- {R}
-- Kuzotz
elseif (option == 17) then
player:setPos(-249.983, 7.965, -252.976, 122, 114); -- {R}
-- Vollbow
elseif (option == 18) then
player:setPos(-176.360, 7.624, -63.580, 122, 113); -- {R}
-- Elshimo Lowlands
elseif (option == 19) then
player:setPos(-240.860, -0.031, -388.434, 64, 123); -- {R}
-- Elshimo Uplands
elseif (option == 20) then
player:setPos(207.821, -0.128, -86.623, 159, 124); -- {R}
-- Tu'Lia ?!
elseif (option == 21) then
player:setPos(4, -54, -600, 192, 130); -- Dummied out?
-- Tavnazia
elseif (option == 23) then
player:setPos(-535.861, -7.149, -53.628, 122, 24); -- {R}
end;
end;
-----------------------------------
-- Expeditionary Force
-- {Option,Quest,Zone,MenuMask,MinimumLevel,KeyItem} NOT USED
-----------------------------------
EXFORCE = {0x20006,ZULK_EF,0x67,0x000040,0x14,ZULKHEIM_EF_INSIGNIA,
0x20007,NORV_EF,0x68,0x000080,0x19,NORVALLEN_EF_INSIGNIA,
0x20009,DERF_EF,0x6D,0x000200,0x19,DERFLAND_EF_INSIGNIA,
0x2000B,KOLS_EF,0x76,0x000800,0x14,KOLSHUSHU_EF_INSIGNIA,
0x2000C,ARAG_EF,0x77,0x001000,0x19,ARAGONEU_EF_INSIGNIA,
0x2000D,FAUR_EF,0x6F,0x002000,0x23,FAUREGANDI_EF_INSIGNIA,
0x2000E,VALD_EF,0x70,0x004000,0x28,VALDEAUNIA_EF_INSIGNIA,
0x2000F,QUFI_EF,0x7E,0x008000,0x19,QUFIM_EF_INSIGNIA,
0x20010,LITE_EF,0x79,0x010000,0x23,LITELOR_EF_INSIGNIA,
0x20011,KUZO_EF,0x72,0x020000,0x28,KUZOTZ_EF_INSIGNIA,
0x20012,VOLL_EF,0x71,0x040000,0x41,VOLLBOW_EF_INSIGNIA,
0x20013,ELLO_EF,0x7B,0x080000,0x23,ELSHIMO_LOWLANDS_EF_INSIGNIA,
0x20014,ELUP_EF,0x7C,0x100000,0x2D,ELSHIMO_UPLANDS_EF_INSIGNIA};
---------------------------------
--
---------------------------------
function getRegionalConquestOverseers(region)
switch (region): caseof {
---------------------------------
[RONFAURE] = function (x) -- West Ronfaure (100)
---------------------------------
--print("RONFAURE");
local Doladepaiton = 17187553;
npc = {
--
Doladepaiton,SANDORIA, -- Doladepaiton, R.K.
Doladepaiton+7,SANDORIA, -- Ballie, R.K.
Doladepaiton+3,SANDORIA, -- Flag
Doladepaiton+11,SANDORIA, -- Flag
--
Doladepaiton+1,BASTOK, -- Yoshihiro, I.M.
Doladepaiton+8,BASTOK, -- Molting Moth, I.M.
Doladepaiton+4,BASTOK, -- Flag
Doladepaiton+13,BASTOK, -- Flag
--
Doladepaiton+2,WINDURST, -- Kyanta-Pakyanta, W.W.
Doladepaiton+9,WINDURST, -- Tottoto, W.W.
Doladepaiton+5,WINDURST, -- Flag
Doladepaiton+13,WINDURST, -- Flag
--
Doladepaiton+6,BEASTMEN, -- Flag
Doladepaiton+14,BEASTMEN, -- Flag
--
Doladepaiton+10,OTHER, -- Harvetour
}
end,
---------------------------------
[ZULKHEIM] = function (x) -- Valkurm_Dunes (103)
---------------------------------
--print("ZULKHEIM");
local Quanteilleron = 17199705;
npc = {
--
Quanteilleron,SANDORIA, -- Quanteilleron, R.K.
Quanteilleron+7,SANDORIA, -- Prunilla, R.K.
Quanteilleron+3,SANDORIA, -- flag
Quanteilleron+11,SANDORIA, -- flag
--
Quanteilleron+1,BASTOK, -- Tsunashige, I.M.
Quanteilleron+8,BASTOK, -- Fighting Ant, I.M.
Quanteilleron+4,BASTOK, -- flag
Quanteilleron+12,BASTOK, -- flag
--
Quanteilleron+2,WINDURST, -- Nyata-Mobuta, W.W.
Quanteilleron+9,WINDURST, -- Tebubu, W.W.
Quanteilleron+5,WINDURST, -- flag
Quanteilleron+13,WINDURST, -- flag
--
Quanteilleron+6,BEASTMEN, -- flag
Quanteilleron+14,BEASTMEN, -- flag
--
Quanteilleron+10,OTHER, -- Medicine Axe
}
end,
---------------------------------
[NORVALLEN] = function (x) -- Jugner_Forest (104)
---------------------------------
--print("NORVALLEN");
local Chaplion = 17203844;
npc = {
--
Chaplion,SANDORIA, -- Chaplion, R.K.
Chaplion+7,SANDORIA, -- Taumiale, R.K.
Chaplion+3,SANDORIA, -- flag
Chaplion+11,SANDORIA, -- flag
--
Chaplion+1,BASTOK, -- Takamoto, I.M.
Chaplion+8,BASTOK, -- Pure Heart, I.M.
Chaplion+4,BASTOK, -- flag
Chaplion+12,BASTOK, -- flag
--
Chaplion+2,WINDURST, -- Bubchu-Bibinchu, W.W.
Chaplion+9,WINDURST, -- Geruru, W.W.
Chaplion+5,WINDURST, -- flag
Chaplion+13,WINDURST, -- flag
--
Chaplion+6,BEASTMEN, -- flag
Chaplion+14,BEASTMEN, -- flag
--
Chaplion+10,OTHER, -- Mionie
}
end,
---------------------------------
[GUSTABERG] = function (x) -- North_Gustaberg (106)
---------------------------------
--print("GUSTABERG");
local Ennigreaud = 17212056;
npc = {
--
Ennigreaud,SANDORIA, -- Ennigreaud, R.K.
Ennigreaud+7,SANDORIA, -- Quellebie, R.K.
Ennigreaud+3,SANDORIA, -- flag
Ennigreaud+11,SANDORIA, -- flag
--
Ennigreaud+1,BASTOK, -- Shigezane, I.M.
Ennigreaud+8,BASTOK, -- Heavy Fog, I.M.
Ennigreaud+4,BASTOK, -- flag
Ennigreaud+12,BASTOK, -- flag
--
Ennigreaud+2,WINDURST, -- Kuuwari-Aori, W.W.
Ennigreaud+9,WINDURST, -- Butsutsu, W.W.
Ennigreaud+5,WINDURST, -- flag
Ennigreaud+13,WINDURST, -- flag
--
Ennigreaud+6,BEASTMEN, -- flag
Ennigreaud+14,BEASTMEN, -- flag
--
Ennigreaud+10,OTHER, -- Kuleo
}
end,
---------------------------------
[DERFLAND] = function (x) -- Pashhow_Marshlands (109)
---------------------------------
--print("DERFLAND");
local Mesachedeau = 17224322;
npc = {
--
Mesachedeau,SANDORIA, -- Mesachedeau, R.K.
Mesachedeau+7,SANDORIA, -- Ioupie, R.K.
Mesachedeau+3,SANDORIA, -- flag
Mesachedeau+11,SANDORIA, -- flag
--
Mesachedeau+1,BASTOK, -- Souun, I.M.
Mesachedeau+8,BASTOK, -- Sharp Tooth, I.M.
Mesachedeau+4,BASTOK, -- flag
Mesachedeau+12,BASTOK, -- flag
--
Mesachedeau+2,WINDURST, -- Mokto-Lankto, W.W.
Mesachedeau+9,WINDURST, -- Shikoko, W.W.
Mesachedeau+5,WINDURST, -- flag
Mesachedeau+13,WINDURST, -- flag
--
Mesachedeau+6,BEASTMEN, -- flag
Mesachedeau+14,BEASTMEN, -- flag
--
Mesachedeau+10,OTHER, -- Tahmasp
}
end,
---------------------------------
[SARUTABARUTA] = function (x) -- West_Sarutabaruta (115)
---------------------------------
--print("SARUTABARUTA");
local Naguipeillont = 17248853;
npc = {
--
Naguipeillont,SANDORIA, -- Naguipeillont, R.K.
Naguipeillont+7,SANDORIA, -- Banege, R.K.
Naguipeillont+3,SANDORIA, -- flag
Naguipeillont+11,SANDORIA, -- flag
--
Naguipeillont+1,BASTOK, -- Ryokei, I.M.
Naguipeillont+8,BASTOK, -- Slow Axe, I.M.
Naguipeillont+4,BASTOK, -- flag
Naguipeillont+12,BASTOK, -- flag
--
Naguipeillont+2,WINDURST, -- Roshina-Kuleshuna, W.W.
Naguipeillont+9,WINDURST, -- Darumomo, W.W.
Naguipeillont+5,WINDURST, -- flag
Naguipeillont+13,WINDURST, -- flag
--
Naguipeillont+6,BEASTMEN, -- flag
Naguipeillont+14,BEASTMEN, -- flag
--
Naguipeillont+10,OTHER, -- Mahien-Uhien
}
end,
---------------------------------
[KOLSHUSHU] = function (x) -- Buburimu_Peninsula (118)
---------------------------------
--print("KOLSHUSHU");
local Bonbavour = 17261143;
npc = {
--
Bonbavour,SANDORIA, -- Bonbavour, R.K.
Bonbavour+7,SANDORIA, -- Craigine, R.K.
Bonbavour+3,SANDORIA, -- flag
Bonbavour+11,SANDORIA, -- flag
--
Bonbavour+1,BASTOK, -- Ishin, I.M.
Bonbavour+8,BASTOK, -- Wise Turtle, I.M.
Bonbavour+4,BASTOK, -- flag
Bonbavour+12,BASTOK, -- flag
--
Bonbavour+2,WINDURST, -- Ganemu-Punnemu, W.W.
Bonbavour+9,WINDURST, -- Mashasha, W.W.
Bonbavour+5,WINDURST, -- flag
Bonbavour+13,WINDURST, -- flag
--
Bonbavour+6,BEASTMEN, -- flag
Bonbavour+14,BEASTMEN, -- flag
--
Bonbavour+10,OTHER, -- Lobho Ukipturi
}
end,
---------------------------------
[ARAGONEU] = function (x) -- Meriphataud_Mountains (119)
---------------------------------
--print("ARAGONEU");
local Chegourt = 17265267;
npc = {
--
Chegourt,SANDORIA, -- Chegourt, R.K.
Chegourt+7,SANDORIA, -- Buliame, R.K.
Chegourt+3,SANDORIA, -- flag
Chegourt+11,SANDORIA, -- flag
--
Chegourt+1,BASTOK, -- Akane, I.M.
Chegourt+8,BASTOK, -- Three Steps, I.M.
Chegourt+4,BASTOK, -- flag
Chegourt+12,BASTOK, -- flag
--
Chegourt+2,WINDURST, -- Donmo-Boronmo, W.W.
Chegourt+9,WINDURST, -- Daruru, W.W.
Chegourt+5,WINDURST, -- flag
Chegourt+13,WINDURST, -- flag
--
Chegourt+6,BEASTMEN, -- flag
Chegourt+14,BEASTMEN, -- flag
--
Chegourt+10,OTHER, -- Mushosho
}
end,
---------------------------------
[FAUREGANDI] = function (x) -- Beaucedine_Glacier (111)
---------------------------------
--print("FAUREGANDI");
local Parledaire = 17232205;
npc = {
--
Parledaire,SANDORIA, -- Parledaire, R.K.
Parledaire+7,SANDORIA, -- Leaufetie, R.K.
Parledaire+3,SANDORIA, -- flag
Parledaire+11,SANDORIA, -- flag
--
Parledaire+1,BASTOK, -- Akane, I.M.
Parledaire+8,BASTOK, -- Rattling Rain, I.M.
Parledaire+4,BASTOK, -- flag
Parledaire+12,BASTOK, -- flag
--
Parledaire+2,WINDURST, -- Ryunchi-Pauchi, W.W.
Parledaire+9,WINDURST, -- Chopapa, W.W.
Parledaire+5,WINDURST, -- flag
Parledaire+13,WINDURST, -- flag
--
Parledaire+6,BEASTMEN, -- flag
Parledaire+14,BEASTMEN, -- flag
--
Parledaire+10,OTHER, -- Gueriette
}
end,
---------------------------------
[VALDEAUNIA] = function (x) -- Xarcabard (112)
---------------------------------
--print("VALDEAUNIA");
local Jeantelas = 17236286;
npc = {
--
Jeantelas,SANDORIA, -- Jeantelas, R.K.
Jeantelas+7,SANDORIA, -- Pilcha, R.K.
Jeantelas+3,SANDORIA, -- flag
Jeantelas+11,SANDORIA, -- flag
--
Jeantelas+1,BASTOK, -- Kaya, I.M.
Jeantelas+8,BASTOK, -- Heavy Bear, I.M.
Jeantelas+4,BASTOK, -- flag
Jeantelas+12,BASTOK, -- flag
--
Jeantelas+2,WINDURST, -- Magumo-Yagimo, W.W.
Jeantelas+9,WINDURST, -- Tememe, W.W.
Jeantelas+5,WINDURST, -- flag
Jeantelas+13,WINDURST, -- flag
--
Jeantelas+6,BEASTMEN, -- flag
Jeantelas+14,BEASTMEN, -- flag
--
Jeantelas+10,OTHER, -- Pelogrant
}
end,
---------------------------------
[QUFIMISLAND] = function (x) -- Qufim_Island (126)
---------------------------------
--print("QUFIMISLAND");
local Pitoire = 17293712;
npc = {
--
Pitoire,SANDORIA, -- Pitoire, R.K.
Pitoire+7,SANDORIA, -- Matica, R.K.
Pitoire+3,SANDORIA, -- flag
Pitoire+11,SANDORIA, -- flag
--
Pitoire+1,BASTOK, -- Sasa, I.M.
Pitoire+8,BASTOK, -- Singing Blade, I.M.
Pitoire+4,BASTOK, -- flag
Pitoire+12,BASTOK, -- flag
--
Pitoire+2,WINDURST, -- Tsonga-Hoponga, W.W.
Pitoire+9,WINDURST, -- Numumu, W.W.
Pitoire+5,WINDURST, -- flag
Pitoire+13,WINDURST, -- flag
--
Pitoire+6,BEASTMEN, -- flag
Pitoire+14,BEASTMEN, -- flag
--
Pitoire+10,OTHER, -- Jiwon
}
end,
---------------------------------
[LITELOR] = function (x) -- The_Sanctuary_of_ZiTah (121)
---------------------------------
--print("LITELOR");
local Credaurion = 17273365;
npc = {
--
Credaurion,SANDORIA, -- Credaurion, R.K.
Credaurion+7,SANDORIA, -- Limion, R.K.
Credaurion+3,SANDORIA, -- flag
Credaurion+11,SANDORIA, -- flag
--
Credaurion+1,BASTOK, -- Calliope, I.M.
Credaurion+8,BASTOK, -- Dedden, I.M.
Credaurion+4,BASTOK, -- flag
Credaurion+12,BASTOK, -- flag
--
Credaurion+2,WINDURST, -- Ajimo-Majimo, W.W.
Credaurion+9,WINDURST, -- Ochocho, W.W.
Credaurion+5,WINDURST, -- flag
Credaurion+13,WINDURST, -- flag
--
Credaurion+6,BEASTMEN, -- flag
Credaurion+14,BEASTMEN, -- flag
--
Credaurion+10,OTHER, -- Kasim
}
end,
---------------------------------
[KUZOTZ] = function (x) -- Eastern_Altepa_Desert (114)
---------------------------------
--print("KUZOTZ");
local Eaulevisat = 17244627;
npc = {
--
Eaulevisat,SANDORIA, -- Eaulevisat, R.K.
Eaulevisat+7,SANDORIA, -- Laimeve, R.K.
Eaulevisat+3,SANDORIA, -- flag
Eaulevisat+11,SANDORIA, -- flag
--
Eaulevisat+1,BASTOK, -- Lindgard, I.M.
Eaulevisat+8,BASTOK, -- Daborn, I.M.
Eaulevisat+4,BASTOK, -- flag
Eaulevisat+12,BASTOK, -- flag
--
Eaulevisat+2,WINDURST, -- Variko-Njariko, W.W.
Eaulevisat+9,WINDURST, -- Sahgygy, W.W.
Eaulevisat+5,WINDURST, -- flag
Eaulevisat+13,WINDURST, -- flag
--
Eaulevisat+6,BEASTMEN, -- flag
Eaulevisat+14,BEASTMEN, -- flag
--
Eaulevisat+10,OTHER, -- Sowande
}
end,
---------------------------------
[VOLLBOW] = function (x) -- Cape_Teriggan (113)
---------------------------------
--print("VOLLBOW");
local Salimardi = 17240472;
npc = {
--
Salimardi,SANDORIA, -- Salimardi, R.K.
Salimardi+7,SANDORIA, -- Paise, R.K.
Salimardi+3,SANDORIA, -- flag
Salimardi+11,SANDORIA, -- flag
--
Salimardi+1,BASTOK, -- Sarmistha, I.M.
Salimardi+8,BASTOK, -- Dultwa, I.M.
Salimardi+4,BASTOK, -- flag
Salimardi+12,BASTOK, -- flag
--
Salimardi+2,WINDURST, -- Voranbo-Natanbo, W.W.
Salimardi+9,WINDURST, -- Orukeke, W.W.
Salimardi+5,WINDURST, -- flag
Salimardi+13,WINDURST, -- flag
--
Salimardi+6,BEASTMEN, -- flag
Salimardi+14,BEASTMEN, -- flag
--
Salimardi+10,OTHER, -- Bright Moon
}
end,
---------------------------------
[ELSHIMOLOWLANDS] = function (x) -- Yuhtunga_Jungle (123)
---------------------------------
--print("ELSHIMOLOWLANDS");
local Zorchorevi = 17281600;
npc = {
--
Zorchorevi,SANDORIA, -- Zorchorevi, R.K.
Zorchorevi+7,SANDORIA, -- Mupia, R.K.
Zorchorevi+3,SANDORIA, -- flag
Zorchorevi+11,SANDORIA, -- flag
--
Zorchorevi+1,BASTOK, -- Mahol, I.M.
Zorchorevi+8,BASTOK, -- Bammiro, I.M.
Zorchorevi+4,BASTOK, -- flag
Zorchorevi+12,BASTOK, -- flag
--
Zorchorevi+2,WINDURST, -- Uphra-Kophra, W.W.
Zorchorevi+9,WINDURST, -- Richacha, W.W.
Zorchorevi+5,WINDURST, -- flag
Zorchorevi+13,WINDURST, -- flag
--
Zorchorevi+6,BEASTMEN, -- flag
Zorchorevi+14,BEASTMEN, -- flag
--
Zorchorevi+10,OTHER, -- Robino-Mobino
}
end,
---------------------------------
[ELSHIMOUPLANDS] = function (x) -- Yhoator_Jungle (124)
---------------------------------
--print("ELSHIMOUPLANDS");
local Ilieumort = 17285650;
npc ={
--
Ilieumort,SANDORIA, -- Ilieumort, R.K.
Ilieumort+7,SANDORIA, -- Emila, R.K.
Ilieumort+3,SANDORIA, -- flag
Ilieumort+11,SANDORIA, -- flag
--
Ilieumort+1,BASTOK, -- Mintoo, I.M.
Ilieumort+8,BASTOK, -- Guddal, I.M.
Ilieumort+4,BASTOK, -- flag
Ilieumort+12,BASTOK, -- flag
--
Ilieumort+2,WINDURST, -- Etaj-Pohtaj, W.W.
Ilieumort+9,WINDURST, -- Ghantata, W.W.
Ilieumort+5,WINDURST, -- flag
Ilieumort+13,WINDURST, -- flag
--
Ilieumort+6,BEASTMEN, -- flag
Ilieumort+14,BEASTMEN, -- flag
--
Ilieumort+10,OTHER, -- Mugha Dovajaiho
}
end,
---------------------------------
[TULIA] = function (x) -- RuAun_Gardens (130)
---------------------------------
--print("TULIA");
local RuAun_Banner = 17310076;
npc = {
--
RuAun_Banner,SANDORIA, -- flag
--
RuAun_Banner+1,BASTOK, -- flag
--
RuAun_Banner+2,WINDURST, -- flag
--
RuAun_Banner+3,BEASTMEN, -- flag
}
end,
---------------------------------
[MOVALPOLOS] = function (x) -- Oldton_Movalpolos
---------------------------------
--print("MOVALPOLOS");
local Oldton_Banner_Offset = 16822509;
npc = {
--
Oldton_Banner_Offset,SANDORIA, -- flag
--
Oldton_Banner_Offset+1,BASTOK, -- flag
--
Oldton_Banner_Offset+2,WINDURST, -- flag
--
Oldton_Banner_Offset+3,BEASTMEN, -- flag
}
end,
---------------------------------
[TAVNAZIANARCH] = function (x) -- Lufaise_Meadows
---------------------------------
--print("TAVNAZIA");
local Jemmoquel = 16875861;
npc = {
--
Jemmoquel,SANDORIA, -- Jemmoquel, R.K.
Jemmoquel+7,SANDORIA, -- Chilaumme, R.K.
Jemmoquel+3,SANDORIA, -- flag
Jemmoquel+11,SANDORIA, -- flag
--
Jemmoquel+1,BASTOK, -- Yoram, I.M.
Jemmoquel+8,BASTOK, -- Ghost Talker, I.M.
Jemmoquel+4,BASTOK, -- flag
Jemmoquel+12,BASTOK, -- flag
--
Jemmoquel+2,WINDURST, -- Teldo-Moroldo, W.W.
Jemmoquel+9,WINDURST, -- Cotete, W.W.
Jemmoquel+5,WINDURST, -- flag
Jemmoquel+13,WINDURST, -- flag
--
Jemmoquel+6,BEASTMEN, -- flag
Jemmoquel+14,BEASTMEN, -- flag
--
Jemmoquel+10,OTHER, -- Jersey
}
end,
}
return npc;
end;
-----------------------------------
--
-----------------------------------
function SetRegionalConquestOverseers(region)
local npclist = getRegionalConquestOverseers(region);
local nation = GetRegionOwner(region);
for i = 1, table.getn(npclist), 2 do
local npc = GetNPCByID(npclist[i]);
if (npc ~= nil) then
if (npclist[i+1] == nation) then
npc:setStatus(0);
else
npc:setStatus(2);
end
if (npclist[i+1] == OTHER) then
if (nation ~= BEASTMEN) then
npc:setStatus(0);
else
npc:setStatus(2);
end
end
end
end
end;
-----------------------------------
-- checkConquestRing
-----------------------------------
function checkConquestRing(player)
local count = 0;
-- If not enabled by admin, do a count on Chariot, Empress, and Emperor Band
if (ALLOW_MULTIPLE_EXP_RINGS ~= 1) then
for i=15761,15763 do
if (player:hasItem(i) == true) then
count = count + 1;
end
end
end
-- One exp ring purchasable per conquest tally
if (BYPASS_EXP_RING_ONE_PER_WEEK ~= 1 and player:getVar("CONQUEST_RING_TIMER") > os.time()) then
count = 3;
end
return count;
end;
-----------------------------------
-- conquestUpdate
-----------------------------------
function conquestUpdate(zone, player, updateType, messageBase)
local ranking = getConquestBalance();
if (updateType == CONQUEST_TALLY_START) then
player:messageText(player, messageBase, 5);
elseif (updateType == CONQUEST_TALLY_END) then
--Tallying conquest results...
player:messageText(player, messageBase+1, 5);
-- This region is currently under x control.
local owner = GetRegionOwner(zone:getRegionID());
if (owner <= 3) then
player:messageText(player, messageBase+2+owner, 5);
else
player:messageText(player, messageBase+6, 5);
end
local offset = 0;
if (bit.band(ranking, 0x03) == 0x01) then
offset = offset + 7; -- 7
if (bit.band(ranking, 0x30) == 0x10) then
offset = offset + 1; -- 8
if (bit.band(ranking, 0x0C) == 0x0C) then
offset = offset + 1; -- 9
end
elseif (bit.band(ranking, 0x0C) == 0x08) then
offset = offset + 3; -- 10
if (bit.band(ranking, 0x30) == 0x30) then
offset = offset + 1; -- 11
end
elseif (bit.band(ranking, 0x0C) == 0x04) then
offset = offset + 6; -- 13
end
elseif (bit.band(ranking, 0x0C) == 0x04) then
offset = offset + 15; -- 15
if (bit.band(ranking, 0x30) == 0x02) then
offset = offset + 3; -- 18
if (bit.band(ranking, 0x03) == 0x03) then
offset = offset + 1; -- 19
end
elseif (bit.band(ranking, 0x30) == 0x10) then
offset = offset + 6; -- 21
end
elseif (bit.band(ranking, 0x30) == 0x10) then
offset = offset + 23; -- 23
if (bit.band(ranking, 0x0C) == 0x08) then
offset = offset + 3; -- 26
if (bit.band(ranking, 0x30) == 0x30) then
offset = offset + 1; -- 27
end
end
end
-- Global balance of power:
player:messageText(player, messageBase+offset, 5);
if (isConquestAlliance()) then
-- have formed an alliance.
if (bit.band(ranking, 0x03) == 0x01) then
player:messageText(player, messageBase+50, 5);
elseif (bit.band(ranking, 0x0C) == 0x04) then
player:messageText(player, messageBase+51, 5);
elseif (bit.band(ranking, 0x30) == 0x10) then
player:messageText(player, messageBase+52, 5);
end
end
elseif (updateType == CONQUEST_UPDATE) then
-- Conquest update: This region is currently under x control.
local owner = GetRegionOwner(zone:getRegionID());
if (owner <= 3) then
player:messageText(player, messageBase+32+owner, 5);
else
player:messageText(player, messageBase+31, 5);
end
local influence = GetRegionInfluence(zone:getRegionID());
if (influence >= 64) then
-- The beastmen are on the rise.
player:messageText(player, messageBase+37, 5);
elseif (influence == 0) then
-- All three nations are at a deadlock.
player:messageText(player, messageBase+36, 5);
else
local sandoria = bit.band(influence, 0x03);
local bastok = bit.rshift(bit.band(influence, 0x0C),2);
local windurst = bit.rshift(bit.band(influence, 0x30),4);
-- Regional influence: San d'Oria
player:messageText(player, messageBase+41 - sandoria, 5);
-- Bastok
player:messageText(player, messageBase+45 - bastok, 5);
-- Windurst
player:messageText(player, messageBase+49 - windurst, 5);
end
if (isConquestAlliance()) then
--are currently allied.
if (bit.band(ranking, 0x03) == 0x01) then
player:messageText(player, messageBase+53, 5);
elseif (bit.band(ranking, 0x0C) == 0x04) then
player:messageText(player, messageBase+54, 5);
elseif (bit.band(ranking, 0x30) == 0x10) then
player:messageText(player, messageBase+55, 5);
end
end
end
end;
| gpl-3.0 |
lucgagnon/ntopng | scripts/lua/modules/top_talkers.lua | 2 | 13306 | --
-- (C) 2013-15 - ntop.org
--
dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
require "persistence"
other_stats_id = "Other"
-- #################################################
function getTop(stats, sort_field_key, max_num_entries, lastdump_dir, lastdump_key, use_threshold)
local _filtered_stats, filtered_stats, counter, total,
threshold, low_threshold
if (use_threshold == nil) then use_threshold = true end
-- stats is a hash of hashes organized as follows:
-- { "id1" : { "key1": "value1", "key2": "value2", ...}, "id2 : { ... } }
-- filter out the needed values
_filtered_stats = {}
for id,content in pairs(stats) do
_filtered_stats[id] = content[sort_field_key]
end
local file_key = sort_field_key
if (lastdump_key ~= nil) then
file_key = file_key.."_"..lastdump_key
end
-- Read the lastdump; the name of the lastdump file has the following
-- format: <lastdump_dir>/.<sort_field_key>_lastdump
lastdump = lastdump_dir .. "/."..file_key.."_lastdump"
last = nil
if(ntop.exists(lastdump)) then
last = persistence.load(lastdump)
end
if(last == nil) then last = {} end
persistence.store(lastdump, _filtered_stats);
for key, value in pairs(_filtered_stats) do
if(last[key] ~= nil) then
v = _filtered_stats[key]-last[key]
if(v < 0) then v = 0 end
_filtered_stats[key] = v
end
end
-- order the filtered stats by using the value (bytes sent/received during
-- the last time interval) as key
filtered_stats = {}
for key, value in pairs(_filtered_stats) do
filtered_stats[value] = key
end
-- Compute traffic
total = 0
for _value,_ in pairsByKeys(filtered_stats, rev) do
total = total + _value
end
threshold = total / 10 -- 10 %
low_threshold = total * 0.05 -- 5%
-- build a new hashtable sorted by the required field
top_stats = {}
other_stats = 0
counter = 0
for _value,_id in pairsByKeys(filtered_stats, rev) do
if (counter < max_num_entries) then
if ((_value == 0) or (use_threshold == true and ((_value < low_threshold or
_value < threshold) and (counter > max_num_entries / 2)))) then
other_stats = other_stats + _value
goto loop_more_top
end
top_stats[_value] = _id -- still keep it in order
counter = counter + 1
else
other_stats = other_stats + _value
end
::loop_more_top::
end
if (other_stats > 0) then
top_stats[other_stats] = other_stats_id
end
return top_stats
end
function filterBy(stats, col, val)
local filtered_by = {}
if (col == "" or col == nil or val == nil) then
return stats
end
for id,content in pairs(stats) do
if (content[col] == val) then
filtered_by[id] = content
end
end
return filtered_by
end
-- #####################################################
function getCurrentTopTalkers(ifid, ifname, filter_col, filter_val, concat, mode, use_threshold, lastdump_key)
local max_num_entries = 10
local rsp = ""
local num = 0
interface.select(ifname)
hosts_stats = interface.getHostsInfo()
hosts_stats = filterBy(hosts_stats, filter_col, filter_val)
talkers_dir = fixPath(dirs.workingdir .. "/" .. ifid .. "/top_talkers")
if(not(ntop.exists(talkers_dir))) then
ntop.mkdir(talkers_dir)
end
if(concat == false and mode == nil) then
rsp = rsp.."{\n"
end
rsp = rsp..'\t"hosts": [\n'
if(mode == nil) then
rsp = rsp .. "{\n"
rsp = rsp .. '\t"senders": ['
end
--print("Hello\n")
if((mode == nil) or (mode == "senders")) then
top_talkers = getTop(hosts_stats, "bytes.sent", max_num_entries, talkers_dir, lastdump_key, use_threshold)
num = 0
other_stats = 0
for value,id in pairsByKeys(top_talkers, rev) do
if (id == other_stats_id) then
other_stats = value
else
if(num > 0) then rsp = rsp .. " }," end
rsp = rsp .. '\n\t\t { "address": "'..id.. '", "label": "'
..hosts_stats[id]["name"]..'", "url": "'
..ntop.getHttpPrefix()..
'/lua/host_details.lua?host='..id..'", "value": '..value..
', "local": "'..tostring(hosts_stats[id]["localhost"])..'"'
num = num + 1
end
end
if (other_stats > 0) then
rsp = rsp .. '},\n\t\t { "address": "'..other_stats_id.. '", "label": "'
..other_stats_id..'", "url": "", "value": '..other_stats..
', "local": "false"'
end
end
if(mode == nil) then
if(num > 0) then rsp = rsp .. " }" end
rsp = rsp .. "\n\t],\n"
rsp = rsp .. '\t"receivers": ['
end
if((mode == nil) or (mode == "receivers")) then
top_listeners = getTop(hosts_stats, "bytes.rcvd", max_num_entries, talkers_dir, lastdump_key, use_threshold)
num = 0
other_stats = 0
for value,id in pairsByKeys(top_listeners, rev) do
if (id == other_stats_id) then
other_stats = value
else
if(num > 0) then rsp = rsp .. " }," end
rsp = rsp .. '\n\t\t { "address": "'..id.. '", "label": "'
..hosts_stats[id]["name"]..'", "url": "'
..ntop.getHttpPrefix()..
'/lua/host_details.lua?host='..id..'", "value": '..value..
', "local": "'..tostring(hosts_stats[id]["localhost"])..'"'
num = num + 1
end
end
if (other_stats > 0) then
rsp = rsp .. '},\n\t\t { "address": "'..other_stats_id.. '", "label": "'
..other_stats_id..'", "url": "", "value": '..other_stats..
', "local": "false"'
end
end
if(mode == nil) then
if(num > 0) then rsp = rsp .. " }" end
rsp = rsp .. "\n\t]\n"
rsp = rsp .. "\n}\n"
else
if(num > 0) then rsp = rsp .. " }\n" end
end
rsp = rsp.."]"
if(concat == false and mode == nil) then
rsp = rsp.."\n}"
end
--print(rsp.."\n")
return(rsp)
end
-- #####################################################
function groupStatsByColumn(ifid, ifname, col)
local _group = {}
local total = 0
-- Group hosts info by the required column
for _key, value in pairs(hosts_stats) do
key = hosts_stats[_key][col]
if ((col == "country" and key == "") or
(col == "local_network_id" and key == -1) or
(col == "os" and key == "")) then goto continue end
if (_group[key] == nil) then
_group[key] = {}
old = 0
else
assert(_group[key][col.."_bytes.sent"] ~= nil)
assert(_group[key][col.."_bytes.rcvd"] ~= nil)
assert(_group[key][col.."_bytes"] ~= nil)
old = _group[key][col.."_bytes"]
end
if (col == "asn") then
if(key == 0) then
_group[key]["name"] = "0 [Local/Unknown]"
else
_group[key]["name"] = key .." ["..hosts_stats[_key]["asname"].."]"
end
elseif (col == "vlan") then
if (key == 0) then
_group[key]["name"] = "No VLAN"
else
_group[key]["name"] = "VLAN"..hosts_stats[_key]["vlan"]
end
elseif (col == "country") then
if (key == "") then
_group[key]["name"] = "Unknown"
else
_group[key]["name"] = key
end
elseif (col == "local_network_id") then
if (key == -1) then
_group[key]["name"] = "[Unknown]"
else
_group[key]["name"] = hosts_stats[_key]["local_network_name"]
end
elseif (col == "os") then
if (key == "") then
_group[key]["name"] = "[Unknown]"
else
_group[key]["name"] = hosts_stats[_key]["os"]
end
end
val = hosts_stats[_key]["bytes.sent"] + hosts_stats[_key]["bytes.rcvd"]
total = total + val
_group[key][col.."_bytes"] = old + val
_group[key][col.."_bytes"] = old + val
_group[key][col.."_bytes.sent"] = ternary(_group[key][col.."_bytes.sent"] ~= nil,
_group[key][col.."_bytes.sent"], 0)
+ hosts_stats[_key]["bytes.sent"]
_group[key][col.."_bytes.rcvd"] = ternary(_group[key][col.."_bytes.rcvd"] ~= nil,
_group[key][col.."_bytes.rcvd"], 0)
+ hosts_stats[_key]["bytes.rcvd"]
::continue::
end
return _group, total
end
function getCurrentTopGroupsSeparated(ifid, ifname, max_num_entries, use_threshold,
use_delta, filter_col, filter_val, col, key, loc, concat, mode, lastdump_key)
max_num_entries = 10
rsp = ""
interface.select(ifname)
hosts_stats = interface.getHostsInfo()
hosts_stats = filterBy(hosts_stats, filter_col, filter_val)
if (loc ~= nil) then
hosts_stats = filterBy(hosts_stats, "localhost", loc)
end
talkers_dir = fixPath(dirs.workingdir .. "/" .. ifid .. "/top_talkers")
if(not(ntop.exists(talkers_dir))) then
ntop.mkdir(talkers_dir)
end
_group, total = groupStatsByColumn(ifid, ifname, col)
if(concat == false and mode == nil) then
rsp = rsp.."{\n"
end
rsp = rsp..'\t"'..key..'": [\n'
if(mode == nil) then
rsp = rsp .. "{\n"
rsp = rsp .. '\t"senders": ['
end
if((mode == nil) or (mode == "senders")) then
top_talkers = getTop(_group, col.."_bytes.sent", max_num_entries, talkers_dir, lastdump_key)
num = 0
other_stats = 0
for value,id in pairsByKeys(top_talkers, rev) do
if (id == other_stats_id) then
other_stats = value
else
if(num > 0) then rsp = rsp .. " }," end
rsp = rsp .. '\n\t\t { "label": "'.._group[id]["name"].. '", "url": "'
..ntop.getHttpPrefix()..
'/lua/hosts_stats.lua?'..col..'='..id..'", "address": "'
..id..'", "value": '..value
num = num + 1
end
end
if (other_stats > 0) then
rsp = rsp .. '},\n\t\t { "address": "'..other_stats_id.. '", "label": "'
..other_stats_id..'", "url": "", "value": '..other_stats..
', "local": "false"'
end
end
if(mode == nil) then
if(num > 0) then rsp = rsp .. " }" end
rsp = rsp .. "\n\t],\n"
rsp = rsp .. '\t"receivers": ['
end
if((mode == nil) or (mode == "receivers")) then
top_listeners = getTop(_group, col.."_bytes.rcvd", max_num_entries, talkers_dir, lastdump_key)
num = 0
other_stats = 0
for value,id in pairsByKeys(top_listeners, rev) do
if (id == other_stats_id) then
other_stats = value
else
if(num > 0) then rsp = rsp .. " }," end
rsp = rsp .. '\n\t\t { "label": "'.._group[id]["name"].. '", "url": "'
..ntop.getHttpPrefix()..
'/lua/hosts_stats.lua?'..col..'='..id..'", "address": "'
..id..'", "value": '..value
num = num + 1
end
end
if (other_stats > 0) then
rsp = rsp .. '},\n\t\t { "address": "'..other_stats_id.. '", "label": "'
..other_stats_id..'", "url": "", "value": '..other_stats..
', "local": "false"'
end
end
if(mode == nil) then
if(num > 0) then rsp = rsp .. " }" end
rsp = rsp .. "\n\t]\n"
rsp = rsp .. "\n}\n"
else
if(num > 0) then rsp = rsp .. " }\n" end
end
rsp = rsp.."]"
if(concat == false and mode == nil) then
rsp = rsp.."\n}"
end
--print(rsp.."\n")
return(rsp)
end
function getCurrentTopGroups(ifid, ifname, max_num_entries, use_threshold,
use_delta, filter_col, filter_val, col, key, concat, mode, lastdump_key)
rsp = ""
--if(ifname == nil) then ifname = "any" end
interface.select(ifname)
hosts_stats = interface.getHostsInfo()
hosts_stats = filterBy(hosts_stats, filter_col, filter_val)
talkers_dir = fixPath(dirs.workingdir .. "/" .. ifid .. "/top_talkers")
if(not(ntop.exists(talkers_dir))) then
ntop.mkdir(talkers_dir)
end
_group, total = groupStatsByColumn(ifid, ifname, col)
if(concat == true) then
rsp = rsp..'"'..key..'": '
end
rsp = rsp .. "[\n"
-- Get top groups
top_groups = getTop(_group, col.."_bytes", max_num_entries, talkers_dir, lastdump_key, use_threshold)
num = 0
other_stats = 0
for _value,_key in pairsByKeys(top_groups, rev) do
if (key == other_stats_id) then
other_stats = value
else
if(num > 0) then rsp = rsp .. " }," end
rsp = rsp .. '\n\t\t { "label": "'.._key..'", "url": "'
..ntop.getHttpPrefix()..
'/lua/hosts_stats.lua?'..col..'='.._key..'", "name": "'
.._group[_key]["name"]..'", "value": '.._value
num = num + 1
end
end
if (other_stats > 0) then
rsp = rsp .. '},\n\t\t { "address": "'..other_stats_id.. '", "label": "'
..other_stats_id..'", "url": "", "value": '..other_stats..
', "local": "false"'
end
if (num > 0) then
rsp = rsp .. " }\n"
end
rsp = rsp .. "\n]"
return(rsp)
end
| gpl-3.0 |
AlexandreCA/update | scripts/globals/mobskills/Core_Meltdown.lua | 18 | 1084 | ---------------------------------------------------
-- Core Meltdown (Ghrah)
-- Reactor core fails and self-destructs, damaging any nearby targets.
-- Note: Very rare, estimated 5% chance
---------------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------------
function onMobSkillCheck(target,mob,skill)
if (mob:isMobType(MOBTYPE_NOTORIOUS)) then
return 1;
elseif (mob:AnimationSub() ~=0) then -- form check
return 1;
elseif (math.random(1,100) >= 5) then -- here's the 95% chance to not blow up
return 1;
else
return 0;
end;
end;
function onMobWeaponSkill(target, mob, skill)
local dmgmod = 1;
local info = MobMagicalMove(mob,target,skill,mob:getWeaponDmg()*math.random(7,15),ELE_NONE,dmgmod,TP_NO_EFFECT);
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_MAGICAL,MOBPARAM_NONE,MOBPARAM_IGNORE_SHADOWS);
mob:setHP(0);
target:delHP(dmg);
return dmg;
end
| gpl-3.0 |
AlexandreCA/update | scripts/zones/Spire_of_Mea/npcs/_0l1.lua | 51 | 1321 | -----------------------------------
-- Area: Spire_of_Mea
-- NPC: web of regret
-----------------------------------
package.loaded["scripts/zones/Spire_of_Mea/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/bcnm");
require("scripts/zones/Spire_of_Mea/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (TradeBCNM(player,player:getZoneID(),trade,npc)) then
return;
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (EventTriggerBCNM(player,npc)) then
return 1;
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("onUpdate CSID: %u",csid);
--printf("onUpdate RESULT: %u",option);
if (EventUpdateBCNM(player,csid,option)) then
return;
end
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
--printf("onFinish CSID: %u",csid);
--printf("onFinish RESULT: %u",option);
if (EventFinishBCNM(player,csid,option)) then
return;
end
end; | gpl-3.0 |
samboy/Oblige | games/hexen/levels.lua | 1 | 4783 | ------------------------------------------------------------------------
-- HEXEN LEVELS
------------------------------------------------------------------------
--
-- Copyright (C) 2006-2011 Andrew Apted
-- Copyright (C) 2011-2012 Jared Blackburn
--
-- 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; either version 2
-- of the License, or (at your option) any later version.
--
------------------------------------------------------------------------
HEXEN.EPISODES =
{
episode1 =
{
theme = "ELEMENTAL"
sky_light = 0.65
}
episode2 =
{
theme = "WILDERNESS"
sky_light = 0.75
}
episode3 =
{
theme = "DUNGEON"
sky_light = 0.65
}
episode4 =
{
theme = "DUNGEON"
sky_light = 0.60
}
episode5 =
{
theme = "DUNGEON"
sky_light = 0.50
}
}
HEXEN.THEME_FOR_MAP =
{
[1] = "hexen_wild4"
[2] = "hexen_dungeon5"
[3] = "hexen_element2"
[4] = "hexen_element1"
[5] = "hexen_element3"
[8] = "hexen_wild4"
[9] = "hexen_wild3"
[10] = "hexen_wild2"
[11] = "hexen_wild1"
[14] = "hexen_dungeon6"
[15] = "hexen_dungeon1"
[16] = "hexen_dungeon1"
[17] = "hexen_wild4"
[18] = "hexen_dungeon1"
[19] = "hexen_dungeon1"
[20] = "hexen_dungeon1"
[21] = "hexen_dungeon1"
[22] = "hexen_dungeon2"
[23] = "hexen_dungeon2"
[24] = "hexen_dungeon1"
[25] = "hexen_dungeon4"
[26] = "hexen_dungeon2"
[27] = "hexen_dungeon2"
[28] = "hexen_dungeon2"
[29] = "hexen_dungeon3"
[30] = "hexen_dungeon3"
[31] = "hexen_dungeon3"
[32] = "hexen_dungeon3"
[35] = "hexen_dungeon2"
}
HEXEN.PREBUILT_LEVELS =
{
}
function HEXEN.get_levels()
local EP_NUM = sel(OB_CONFIG.length == "game", 5, 1)
local MAP_NUM = sel(OB_CONFIG.length == "single", 1, 7)
--?? GAME.original_themes = {}
for ep_index = 1,EP_NUM do
local EPI =
{
levels = {}
}
table.insert(GAME.episodes, EPI)
local ep_info = HEXEN.EPISODES["episode" .. ep_index]
assert(ep_info)
--?? GAME.original_themes[episode] = ep_info.orig_theme
for map = 1,MAP_NUM do
local map_id = (ep_index - 1) * MAP_NUM + map
local ep_along = map / MAP_NUM
if MAP_NUM == 1 then
ep_along = rand.range(0.3, 0.7)
end
local LEV =
{
episode = EPI
name = string.format("MAP%02d", map_id)
--?? patch = string.format("WILV%d%d", ep_index-1, map-1)
map = map_id
next_map = map_id + 1
local_map = map
cluster = ep_index
ep_along = ep_along
game_along = (ep_index - 1 + ep_along) / EP_NUM
sky_light = ep_info.sky_light
name_theme = "GOTHIC"
}
-- make certain levels match original
-- Was not working, so fixed above, BlackJar72
if OB_CONFIG.theme == "original" then
if ep_index == 3 then
LEV.theme_name = "hexen_dungeon1"
elseif ep_index == 4 then
LEV.theme_name = "hexen_dungeon2"
elseif ep_index == 5 then
LEV.theme_name = "hexen_dungeon3"
end -- Specific special levels
LEV.theme_name = HEXEN.THEME_FOR_MAP[map_id]
if LEV.theme_name then
LEV.theme = assert(GAME.LEVEL_THEMES[LEV.theme_name])
end
if map_id == 29 then
LEV.style_list =
{
outdoors = { heaps=100 }
caves = { some=50, heaps=50 }
}
end
end
-- second last map in each episode is a secret level, and
-- last map in each episode is the boss map.
if map == 6 then
LEV.kind = "SECRET"
elseif map == 7 then
LEV.kind = "BOSS"
end
-- very last map of the game?
if ep_index == 5 and map == 7 then
LEV.next_map = nil
end
table.insert( EPI.levels, LEV)
table.insert(GAME.levels, LEV)
end
-- link hub together (unless only making a single level)
if MAP_NUM > 1 then
Hub_connect_levels(EPI, GAME.THEME_DEFAULTS.hub_keys)
Hub_assign_keys(EPI, GAME.THEME_DEFAULTS.keys)
Hub_assign_weapons(EPI)
Hub_assign_pieces(EPI, { "piece1", "piece2", "piece3" })
end
end -- for episode
end
function HEXEN.make_mapinfo()
local mapinfo = {}
local function add(...)
table.insert(mapinfo, string.format(...) .. "\n")
end
each L in GAME.levels do
local desc = string.upper(L.description or L.name)
add("map %d \"%s\"", L.map, desc)
add("warptrans %d", L.map)
add("next %d", L.next_map or 1)
add("cluster %d", L.cluster)
add("sky1 SKY2 0")
add("sky2 SKY3 0")
add("")
end
gui.wad_add_text_lump("MAPINFO", mapinfo)
end
| gpl-2.0 |
paly2/minetest-minetestforfun-server | mods/mesecons/mesecons/oldwires.lua | 8 | 1245 | minetest.register_node("mesecons:mesecon_off", {
drawtype = "raillike",
tiles = {"jeija_mesecon_off.png", "jeija_mesecon_curved_off.png", "jeija_mesecon_t_junction_off.png", "jeija_mesecon_crossing_off.png"},
inventory_image = "jeija_mesecon_off.png",
wield_image = "jeija_mesecon_off.png",
paramtype = "light",
is_ground_content = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5},
},
groups = {dig_immediate=3, mesecon=1, mesecon_conductor_craftable=1},
description="Mesecons",
mesecons = {conductor={
state = mesecon.state.off,
onstate = "mesecons:mesecon_on"
}}
})
minetest.register_node("mesecons:mesecon_on", {
drawtype = "raillike",
tiles = {"jeija_mesecon_on.png", "jeija_mesecon_curved_on.png", "jeija_mesecon_t_junction_on.png", "jeija_mesecon_crossing_on.png"},
paramtype = "light",
is_ground_content = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5},
},
groups = {dig_immediate=3, not_in_creaive_inventory=1, mesecon=1},
drop = "mesecons:mesecon_off 1",
light_source = default.LIGHT_MAX-11,
mesecons = {conductor={
state = mesecon.state.on,
offstate = "mesecons:mesecon_off"
}}
})
| unlicense |
AlexandreCA/darkstar | scripts/globals/abilities/pets/judgment_bolt.lua | 34 | 1127 | ---------------------------------------------------
-- Judgment Bolt
---------------------------------------------------
require("/scripts/globals/settings");
require("/scripts/globals/status");
require("/scripts/globals/monstertpmoves");
require("/scripts/globals/magic");
---------------------------------------------------
function onAbilityCheck(player, target, ability)
local level = player:getMainLvl() * 2;
if(player:getMP()<level) then
return 87,0;
end
return 0,0;
end;
function onPetAbility(target, pet, skill, master)
local dINT = math.floor(pet:getStat(MOD_INT) - target:getStat(MOD_INT));
local level = pet:getMainLvl()
local damage = 48 + (level * 8);
damage = damage + (dINT * 1.5);
damage = MobMagicalMove(pet,target,skill,damage,ELE_LIGHTNING,1,TP_NO_EFFECT,0);
damage = mobAddBonuses(pet, nil, target, damage.dmg, ELE_LIGHTNING);
damage = AvatarFinalAdjustments(damage,pet,skill,target,MOBSKILL_MAGICAL,MOBPARAM_NONE,1);
master:setMP(0);
target:delHP(damage);
target:updateEnmityFromDamage(pet,damage);
return damage;
end | gpl-3.0 |
AlexandreCA/update | scripts/zones/Southern_San_dOria/npcs/Blendare.lua | 5 | 1909 | -----------------------------------
-- Area: Southern San d'Oria
-- NPC: Blendare
-- Type: Standard NPC
-- @zone: 230
-- @pos 33.033 0.999 -30.119
--
-- Auto-Script: Requires Verification (Verified by Brawndo)
-----------------------------------
package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil;
-----------------------------------
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE) ==QUEST_ACCEPTED) then
if (trade:hasItemQty(532,1) and trade:getItemCount() == 1 and player:getVar("tradeBlendare") == 0) then
player:messageSpecial(BLENDARE_DIALOG);
player:setVar("FFR",player:getVar("FFR") - 1);
player:setVar("tradeBlendare",1);
player:messageSpecial(FLYER_ACCEPTED);
player:tradeComplete();
elseif (player:getVar("tradeBlendare") ==1) then
player:messageSpecial(FLYER_ALREADY);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x025e) -- my brother always takes my sweets
-- player:startEvent(0x0256) --did nothing no speech or text
-- player:startEvent(0x03b1) --black screen and hang
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 == 0x025e) then
player:setVar("BrothersCS", 1)
end
end;
| gpl-3.0 |
AlexandreCA/darkstar | scripts/zones/Lower_Jeuno/npcs/Vhana_Ehgaklywha.lua | 13 | 3545 | -----------------------------------
-- Area: Lower Jeuno
-- NPC: Vhana Ehgaklywha
-- Standard Info NPC
-- @pos -122.853 0.000 -195.605
-----------------------------------
package.loaded["scripts/zones/Lower_Jeuno/TextIDs"] = nil;
require("scripts/zones/Lower_Jeuno/TextIDs");
package.loaded["scripts/globals/pathfind"] = nil;
require("scripts/globals/pathfind");
path = {
0.932, 0, 19.065,
-2.84, 0, 13.676,
-5, 0, 13,
-7.833, 0, 12.263,
-8.782, 0, 12.736, -- lamp 1, path 5
-9.938, 0, 10.595,
-18, 0, 14.855,
-25, 0, 3,
-19, 0, -0.644,
-17.24, 0, -2.052,
-18.11, 0, -4.691,
-18.83, 0, -4.346, -- lamp 2, path 12
-19.34, 0, -7.971,
-30.38, 0, -26.50,
-32.38, 0, -28.52,
-32.76, 0, -28.63,
-32.98, 0, -28.60, -- lamp 3, path 17
-31.93, 0, -38.83,
-34.78, 0, -43.10,
-45.12, 0, -47.10, -- lamp 4, path 20
-52.76, 0, -60.53, -- lamp 5, path 21
-41.77, 0, -48.81,
-41.14, 0, -48.66,
-40.34, 0, -48.79,
-39.83, 0, -49.20,
-39.92, 0, -49.83,
-45.65, 6, -62.83,
-49.97, 6, -70.32,
-57.87, 6, -75.37,
-60.87, 6, -74.87, -- lamp 6, path 30
-61.05, 6, -83.40,
-66.38, 6, -92.58,
-72.88, 6, -95.78, -- lamp 7, path 33
-75.42, 6, -112.4,
-77.24, 5.9, -115.7,
-82.75, 0.7, -125.1,
-84.13, 0, -127.1,
-85.94, 0, -126.2,
-81.08, 0, -110.5, -- lamp 8, path 39
-88.57, 0, -123.3, -- lamp 9, path 40
-88.20, 0, -134.2,
-88.31, 0, -134.9,
-92.52, 0, -142.7,
-100.4, 0, -144.3, -- lamp 10, path 44
-108.6, 0, -158.0, -- lamp 11, path 45
-116.7, 0, -171.8, -- lamp 12, path 46
-114.8, 0, -182.0,
-122.8, 0, -195.6, -- end
}
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc, 7160);
end;
-----------------------------------
-- onPath
-----------------------------------
function onPath(npc)
local pathpoints = { 5, 12, 17, 20, 21, 30, 33, 39, 40, 44, 45, 46};
for _, v in pairs(pathpoints) do
-- local lampOffset = 17780881;
if (npc:atPoint(pathfind.get(path,v))) then
npc:setPos(npc:getXPos(), npc:getYPos(), npc:getZPos(), 150);
npc:wait(5300);
print("Waiting..");
--GetNPCByID(lampOffset):openDoor(3);
--printf("%s lamp reached | ID is: %i",GetNPCByID(lampOffset):getName(), lampOffset);
return;
else
if (npc:atPoint(pathfind.get(path,48))) then
npc:wait(1000);
npc:setStatus(2);
end
end
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end; | gpl-3.0 |
AlexandreCA/update | scripts/zones/Selbina/npcs/Vobo.lua | 17 | 1507 | -----------------------------------
-- Area: Selbina
-- NPC: Vobo
-- Involved in Quest: Riding on the Clouds
-- @pos 37 -14 81 248
-----------------------------------
package.loaded["scripts/zones/Selbina/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Selbina/TextIDs");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:getQuestStatus(JEUNO,RIDING_ON_THE_CLOUDS) == QUEST_ACCEPTED and player:getVar("ridingOnTheClouds_3") == 2) then
if (trade:hasItemQty(1127,1) and trade:getItemCount() == 1) then -- Trade Kindred seal
player:setVar("ridingOnTheClouds_3",0);
player:tradeComplete();
player:addKeyItem(SOMBER_STONE);
player:messageSpecial(KEYITEM_OBTAINED,SOMBER_STONE);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x02C6);
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/Outer_Horutoto_Ruins/npcs/_ne4.lua | 13 | 2994 | -----------------------------------
-- Area: Outer Horutoto Ruins
-- NPC: Strange Apparatus
-- @pos: -574 0 739 194
-----------------------------------
package.loaded["scripts/zones/Outer_Horutoto_Ruins/TextIDs"] = nil;
require("scripts/zones/Outer_Horutoto_Ruins/TextIDs");
require("scripts/globals/strangeapparatus");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
local trade = tradeToStrApp(player, trade);
if (trade ~= nil) then
if ( trade == 1) then -- good trade
local drop = player:getLocalVar("strAppDrop");
local dropQty = player:getLocalVar("strAppDropQty");
local docStatus = 0; -- Assistant
if (hasStrAppDocStatus(player)) then
docStatus = 1; -- Doctor
end
player:startEvent(0x0042, drop, dropQty, INFINITY_CORE, 0, 0, 0, docStatus, 0);
else -- wrong chip, spawn elemental nm
spawnElementalNM(player);
delStrAppDocStatus(player);
player:messageSpecial(SYS_OVERLOAD);
player:messageSpecial(YOU_LOST_THE, trade);
end
else -- Invalid trade, lose doctor status
delStrAppDocStatus(player);
player:messageSpecial(DEVICE_NOT_WORKING);
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local docStatus = 0; -- Assistant
if (hasStrAppDocStatus(player)) then
docStatus = 1; -- Doctor
else
player:setLocalVar( "strAppPass", 1);
end
player:startEvent(0x0040, docStatus, 0, INFINITY_CORE, 0, 0, 0, 0, player:getZoneID());
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u", option);
if (csid == 0x0040) then
if (hasStrAppDocStatus(player) == false) then
local docStatus = 1; -- Assistant
if ( option == strAppPass(player)) then -- Good password
docStatus = 0; -- Doctor
giveStrAppDocStatus(player);
end
player:updateEvent(docStatus, 0, INFINITY_CORE, 0, 0, 0, 0, 0);
end
end
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0042) then
local drop = player:getLocalVar("strAppDrop");
local dropQty = player:getLocalVar("strAppDropQty");
if (drop ~= 0) then
if ( dropQty == 0) then
dropQty = 1;
end
player:addItem(drop, dropQty);
player:setLocalVar("strAppDrop", 0);
player:setLocalVar("strAppDropQty", 0);
end
end
end; | gpl-3.0 |
asce1062/MAHDI-ROM_external_skia | tools/lua/bitmap_statistics.lua | 207 | 1862 | function string.startsWith(String,Start)
return string.sub(String,1,string.len(Start))==Start
end
function string.endsWith(String,End)
return End=='' or string.sub(String,-string.len(End))==End
end
local canvas = nil
local num_perspective_bitmaps = 0
local num_affine_bitmaps = 0
local num_scaled_bitmaps = 0
local num_translated_bitmaps = 0
local num_identity_bitmaps = 0
local num_scaled_up = 0
local num_scaled_down = 0
function sk_scrape_startcanvas(c, fileName)
canvas = c
end
function sk_scrape_endcanvas(c, fileName)
canvas = nil
end
function sk_scrape_accumulate(t)
-- dump the params in t, specifically showing the verb first, which we
-- then nil out so it doesn't appear in tostr()
if (string.startsWith(t.verb,"drawBitmap")) then
matrix = canvas:getTotalMatrix()
matrixType = matrix:getType()
if matrixType.perspective then
num_perspective_bitmaps = num_perspective_bitmaps + 1
elseif matrixType.affine then
num_affine_bitmaps = num_affine_bitmaps + 1
elseif matrixType.scale then
num_scaled_bitmaps = num_scaled_bitmaps + 1
if matrix:getScaleX() > 1 or matrix:getScaleY() > 1 then
num_scaled_up = num_scaled_up + 1
else
num_scaled_down = num_scaled_down + 1
end
elseif matrixType.translate then
num_translated_bitmaps = num_translated_bitmaps + 1
else
num_identity_bitmaps = num_identity_bitmaps + 1
end
end
end
function sk_scrape_summarize()
io.write( "identity = ", num_identity_bitmaps,
", translated = ", num_translated_bitmaps,
", scaled = ", num_scaled_bitmaps, " (up = ", num_scaled_up, "; down = ", num_scaled_down, ")",
", affine = ", num_affine_bitmaps,
", perspective = ", num_perspective_bitmaps,
"\n")
end
| bsd-3-clause |
AlexandreCA/darkstar | scripts/zones/Windurst_Waters/npcs/Fuepepe.lua | 12 | 3846 | -----------------------------------
-- Area: Windurst Waters
-- NPC: Fuepepe
-- Starts and Finishes Quest: Teacher's Pet
-- Involved in Quest: Making the grade, Class Reunion
-- @zone = 238
-- @pos = 161 -2 161
-----------------------------------
package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Windurst_Waters/TextIDs");
require("scripts/globals/settings");
require("scripts/globals/quests");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:getQuestStatus(WINDURST,MAKING_THE_GRADE) == QUEST_ACCEPTED and player:getVar("QuestMakingTheGrade_prog") == 0) then
if (trade:hasItemQty(544,1) and trade:getItemCount() == 1 and trade:getGil() == 0) then
player:startEvent(0x01c7); -- Quest Progress: Test Papers Shown and told to deliver them to principal
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local gradestatus = player:getQuestStatus(WINDURST,MAKING_THE_GRADE);
local prog = player:getVar("QuestMakingTheGrade_prog");
-- 1 = answers found
-- 2 = gave test answers to principle
-- 3 = spoke to chomoro
if (player:getQuestStatus(WINDURST,TEACHER_S_PET) == QUEST_COMPLETED and gradestatus == QUEST_AVAILABLE and player:getFameLevel(WINDURST) >=3 and player:getQuestStatus(WINDURST,LET_SLEEPING_DOGS_LIE) ~= QUEST_ACCEPTED) then
player:startEvent(0x01ba); -- Quest Start
elseif (gradestatus == QUEST_ACCEPTED) then
if (prog == 0) then
player:startEvent(0x01bb); -- Get Test Sheets Reminder
elseif (prog == 1) then
player:startEvent(0x01c8); -- Deliver Test Sheets Reminder
elseif (prog == 2 or prog == 3) then
player:startEvent(0x01ca); -- Quest Finish
end
elseif (gradestatus == QUEST_COMPLETED and player:needToZone() == true) then
player:startEvent(0x01cb); -- After Quest
-------------------------------------------------------
-- Class Reunion
elseif (player:getQuestStatus(WINDURST,CLASS_REUNION) == QUEST_ACCEPTED and player:getVar("ClassReunionProgress") >= 3 and player:getVar("ClassReunion_TalkedToFupepe") ~= 1) then
player:startEvent(0x0331); -- he tells you about Uran-Mafran
-------------------------------------------------------
else
player:startEvent(0x1a7); -- Standard Conversation
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x01ba and option == 1) then -- Quest Start
player:addQuest(WINDURST,MAKING_THE_GRADE);
elseif (csid == 0x01c7) then -- Quest Progress: Test Papers Shown and told to deliver them to principal
player:setVar("QuestMakingTheGrade_prog",1);
elseif (csid == 0x01ca) then -- Quest Finish
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,4855);
else
player:completeQuest(WINDURST,MAKING_THE_GRADE);
player:addFame(WINDURST,75);
player:addItem(4855);
player:messageSpecial(ITEM_OBTAINED,4855);
player:setVar("QuestMakingTheGrade_prog",0);
player:needToZone(true);
end
elseif (csid == 0x0331) then
player:setVar("ClassReunion_TalkedToFupepe",1);
end
end;
| gpl-3.0 |
gaodayihao/XBurner | Libs/DiesalGUI-1.0/Objects/DropDown.lua | 2 | 9823 | -- $Id: DropDown.lua 53 2016-07-12 21:56:30Z diesal2010 $
local DiesalGUI = LibStub('DiesalGUI-1.0')
-- ~~| Libraries |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local DiesalTools = LibStub('DiesalTools-1.0')
-- ~~| Lua Upvalues |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local tsort = table.sort
local sub, format, lower, upper,gsub = string.sub, string.format, string.lower, string.upper, string.gsub
-- ~~| WoW Upvalues |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~| Dropdown |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local Type = 'Dropdown'
local Version = 2
-- ~~| Dropdown StyleSheets |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local styleSheet = {
['frame-color'] = {
type = 'texture',
layer = 'BACKGROUND',
gradient = 'VERTICAL',
color = '263037',
colorEnd = '2d3b45',
offset = 0,
},
['frame-outline'] = {
type = 'outline',
layer = 'BORDER',
color = '000000',
offset = 0,
},
['frame-inline'] = {
type = 'outline',
layer = 'BORDER',
gradient = 'VERTICAL',
color = 'ffffff',
alpha = .02,
alphaEnd = .09,
offset = -1,
},
['frame-hover'] = {
type = 'texture',
layer = 'HIGHLIGHT',
color = 'ffffff',
alpha = .1,
offset = 0,
},
['frame-arrow'] = {
type = 'texture',
layer = 'BORDER',
texFile = 'DiesalGUIcons',
texCoord = {2,1,16,256,128},
alpha = .5,
offset = {nil,-5,-7,nil},
height = 3,
width = 5,
},
['text-color'] = {
type = 'Font',
color = 'b8c2cc',
},
['dropdown-background'] = {
type = 'texture',
layer = 'BACKGROUND',
color = '000000',
},
['dropdown-inline'] = {
type = 'outline',
layer = 'BORDER',
color = 'ffffff',
alpha = .1,
offset = -1,
},
['dropdown-highlight'] = {
type = 'texture',
layer = 'BORDER',
color = 'ffffff',
gradient = 'VERTICAL',
alpha = .02,
alphaEnd = .07,
offset = -1,
height = 10,
},
['dropdown-shadow'] = {
type = 'shadow',
},
}
-- ~~| Dropdown Locals |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local function compare(a,b)
return a.value < b.value
end
local function sortList(list,orderedKeys)
if orderedKeys then return orderedKeys end
local sortedList = {}
local orderedKeys = {}
for key,value in pairs(list) do
sortedList[#sortedList + 1] = {key=key,value=value}
end
tsort(sortedList,compare)
for i,value in ipairs(sortedList) do
orderedKeys[#orderedKeys + 1] = value.key
end
return orderedKeys
end
-- ~~| Dropdown Methods |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local methods = {
['OnAcquire'] = function(self)
self:ApplySettings()
self:AddStyleSheet(styleSheet)
-- self:AddStyleSheet(wireFrameSheet)
self:Show()
end,
['OnRelease'] = function(self)
end,
['ApplySettings'] = function(self)
local settings = self.settings
local content = self.content
local frame = self.frame
local children = self.children
local dropdown = self.dropdown
frame:SetWidth(settings.width)
frame:SetHeight(settings.height)
content:SetPoint("TOPLEFT",settings.dropdownPadLeft,-settings.dropdownPadTop)
content:SetPoint("BOTTOMRIGHT",-settings.dropdownPadRight,settings.dropdownPadBottom)
local menuHeight = 0
for i=1 , #children do
menuHeight = menuHeight + children[i].frame:GetHeight()
end
dropdown:SetHeight(settings.dropdownPadTop + menuHeight + settings.dropdownPadBottom)
end,
['SetList'] = function(self,list,orderedKeys)
self:ReleaseChildren()
self:SetText('')
local settings = self.settings
local orderedKeys = sortList(list,orderedKeys)
settings.list = list
for position, key in ipairs(orderedKeys) do
local dropdownItem = DiesalGUI:Create('DropdownItem')
self:AddChild(dropdownItem)
dropdownItem:SetParentObject(self)
dropdownItem:SetSettings({
key = key,
value = list[key],
position = position,
},true)
end
self:ApplySettings()
end,
['SetValue'] = function(self,key)
local selectionTable = {}
local selectedKey, dropdownText, selectedValue
if key ~='CLEAR' then
if self.settings.multiSelect then
for i=1,#self.children do
if self.children[i].settings.key == key then selectedKey = key; self.children[i]:SetSelected(true) end
if self.children[i].settings.selected then
if dropdownText then
dropdownText = format('%s, %s',dropdownText,self.children[i].settings.value)
else
dropdownText = self.children[i].settings.value
end
selectionTable[#selectionTable+1] = self.children[i].settings.key
end
end
else
for i=1,#self.children do
self.children[i]:SetSelected(false)
if self.children[i].settings.key == key then
self.children[i]:SetSelected(true)
dropdownText = self.children[i].settings.value
selectionTable = {key}
selectedKey = key
selectedValue = value
end
end
end
else
self:ClearSelection()
end
if selectedKey then
self:SetText(dropdownText)
self:FireEvent("OnValueChanged",selectedKey,selectedValue,selectionTable)
else
self:SetText('')
self:FireEvent("OnValueChanged",selectedKey,selectedValue,selectionTable)
end
end,
['ClearSelection'] = function(self)
for i=1,#self.children do
self.children[i]:SetSelected(false)
end
self:SetText('')
end,
['SetValueTable'] = function(self,keyTable)
if not self.settings.multiSelect or type(keyTable) ~='table' then return end
local dropdownItems = self.children
local selectionTable = {}
local selectedKey
local dropdownText
for i=1,#dropdownItems do
local dropdownItem = dropdownItems[i]
dropdownItem:SetSelected(false)
for _,key in ipairs(keyTable) do
if dropdownItem.settings.key == key then
dropdownItem:SetSelected(true)
if dropdownText then
dropdownText = format('%s, %s',dropdownText,dropdownItem.settings.value)
else
dropdownText = dropdownItem.settings.value
end
selectionTable[#selectionTable+1] = dropdownItem.settings.key
end
end
end
self:FireEvent("OnValueChanged",nil,nil,selectionTable)
self:SetText(dropdownText)
end,
['SetMultiSelect'] = function(self,state)
self.settings.multiSelect = state
end,
['SetText'] = function(self,text)
self.text:SetText(text)
end,
['SetFocus'] = function(self)
DiesalGUI:SetFocus(self)
end,
['ClearFocus'] = function(self)
self.dropdown:Hide()
end,
['EnableMouse'] = function(self,state)
self.frame:EnableMouse(state)
end,
["RegisterForClicks"] = function(self,...)
self.frame:RegisterForClicks(...)
end,
['SetJustifyV'] = function(self,justify)
self.text:SetJustifyV(justify)
end,
['SetJustifyH'] = function(self,justify)
self.text:SetJustifyH(justify)
end,
}
-- ~~| Dropdown Constructor |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local function Constructor()
local self = DiesalGUI:CreateObjectBase(Type)
local frame = CreateFrame('Button',nil,UIParent)
self.frame = frame
self.defaults = {
dropdownPadLeft = 4,
dropdownPadRight = 4,
dropdownPadTop = 4,
dropdownPadBottom = 4,
itemHeight = 16,
width = 100,
height = 16,
}
-- ~~ Registered Events ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- OnValueChanged(event,selectedKey,selectedValue,selectionTable)
-- OnValueSelected(event,selectedKey,selectedValue,selectionTable)
-- OnEnter, OnLeave
-- ~~ Construct ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
frame:SetScript("OnMouseUp", function(this, button)
if button == 'LeftButton' then
local dropdown = self.dropdown
local visible = dropdown:IsVisible()
DiesalGUI:OnMouse(this,button)
dropdown[visible and "Hide" or 'Show'](dropdown)
end
end)
frame:SetScript("OnClick", function(this, ...)
self:FireEvent("OnClick", ...)
end)
frame:SetScript("OnEnter",function(this,...)
self:FireEvent("OnEnter",...)
end)
frame:SetScript("OnLeave", function(this,...)
self:FireEvent("OnLeave",...)
end)
local text = self:CreateRegion("FontString", 'text', frame)
text:ClearAllPoints()
text:SetPoint("TOPLEFT", 4, -1)
text:SetPoint("BOTTOMRIGHT", -14, 1)
text:SetJustifyV("MIDDLE")
text:SetJustifyH("LEFT")
local dropdown = self:CreateRegion("Frame", 'dropdown', frame)
dropdown:SetFrameStrata("FULLSCREEN_DIALOG")
dropdown:SetPoint('TOPRIGHT',frame,'BOTTOMRIGHT',0,-2)
dropdown:SetPoint('TOPLEFT',frame,'BOTTOMLEFT',0,-2)
dropdown:SetScript("OnShow", function(this) self:SetFocus() end)
dropdown:Hide()
self:CreateRegion("Frame", 'content', dropdown)
-- ~~ Methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for method, func in pairs(methods) do self[method] = func end
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
return self
end
DiesalGUI:RegisterObjectConstructor(Type,Constructor,Version)
| mit |
lancehilliard/TGNS | mods/tgns/output/lua/shine/extensions/td/td.lua | 1 | 23851 | local TdMapName = "ns2_tgns_td"
local NetworkMessageNames = {WaveInProgress = "td_WaveInProgress", RecentlyWelded = "td_RecentlyWelded"}
local waveInProgress
local recentlyWeldedTime = {}
local recentWeldTimespanInSeconds = 3
local recentWeldEffectEnabled
-- kCatPackDuration = 60
TGNS.RegisterNetworkMessage(NetworkMessageNames.WaveInProgress, {i="boolean"})
TGNS.RegisterNetworkMessage(NetworkMessageNames.RecentlyWelded, {i="integer", t="float"})
local function wasRecentlyWelded(player)
local result = false
if player and player.GetTeamNumber and player.GetClientIndex then
result = player:GetTeamNumber() == kMarineTeamType and Shared.GetTime() - (recentlyWeldedTime[player:GetClientIndex()] or 0) < recentWeldTimespanInSeconds
end
return result
end
Event.Hook("MapPostLoad", function()
if Shared.GetMapName() == TdMapName then
local originalMarineSetOrigin
originalMarineSetOrigin = Class_ReplaceMethod("Marine", "SetOrigin", function(marineSelf, newOrigin)
if not waveInProgress then
originalMarineSetOrigin(marineSelf, newOrigin)
end
end)
-- local originalLOSMixinOnUpdate
-- originalLOSMixinOnUpdate = Class_ReplaceMethod("LOSMixin", "OnUpdate", function(losMixinSelf, deltaTime)
-- losMixinSelf.sighted = true
-- originalLOSMixinOnUpdate(marineSelf, deltaTime)
-- end)
Grenade.kMinLifeTime = 0
Class_ReplaceMethod("Player", "GetCanTakeDamageOverride", function(playerSelf)
return false
end)
local originalMarineOnUpdateAnimationInput = Marine.OnUpdateAnimationInput
Marine.OnUpdateAnimationInput = function(marineSelf, modelMixin)
local originalMarineSelfCatpackboost = marineSelf.catpackboost
marineSelf.catpackboost = true
originalMarineOnUpdateAnimationInput(marineSelf, modelMixin)
marineSelf.catpackboost = originalMarineSelfCatpackboost
end
local originalLOSMixinOnUpdate = LOSMixin.OnUpdate
LOSMixin.OnUpdate = function(losMixinSelf, deltaTime)
if originalLOSMixinOnUpdate then
if losMixinSelf.GetIsAlive and losMixinSelf:GetIsAlive() then
losMixinSelf.sighted = true
end
originalLOSMixinOnUpdate(losMixinSelf, deltaTime)
end
end
local originalFlamethrowerFirePrimary = Flamethrower.FirePrimary
Flamethrower.FirePrimary = function(flamethrowerSelf, player, bullets, range, penetration)
local originalGetRange = flamethrowerSelf.GetRange
flamethrowerSelf.GetRange = function(flamethrowerSelfSelf)
local result = originalGetRange(flamethrowerSelfSelf)
if wasRecentlyWelded(player) then
result = result * 2
end
return result
end
originalFlamethrowerFirePrimary(flamethrowerSelf, player, bullets, range, penetration)
flamethrowerSelf.GetRange = originalGetRange
end
local originalBuildTechData = BuildTechData
BuildTechData = function()
local result = originalBuildTechData()
TGNS.DoFor(result, function(d)
if d[kTechDataId] == kTechId.Sentry then
d[kTechDataBuildRequiresMethod] = function(techId, origin, normal, commander) return true end
d[kTechDataSupply] = 5
elseif d[kTechDataId] == kTechId.SentryBattery then
d[kTechDataBuildRequiresMethod] = function(techId, origin, normal, commander) return true end
-- d[kTechDataCostKey] = 1
end
if not TGNS.Has({kTechId.MedPack, kTechId.AmmoPack, kTechId.CatPack}, d[kTechDataId]) then
local originalBuildRequiresMethod = d[kTechDataBuildRequiresMethod]
d[kTechDataBuildRequiresMethod] = function()
local result = originalBuildRequiresMethod and originalBuildRequiresMethod() or true
if result and waveInProgress then
result = false
end
return result
end
end
end)
return result
end
kTechData = nil
ClearCachedTechData()
local originalLookupTechData = LookupTechData
LookupTechData = function(techId, fieldName, default)
local result
if fieldName == kTechDataBuildMethodFailedMessage and waveInProgress then
result = "Wave in progress."
else
result = originalLookupTechData(techId, fieldName, default)
end
return result
end
if Client then
local originalMarineOutlineMixinOnUpdate = MarineOutlineMixin.OnUpdate
MarineOutlineMixin.OnUpdate = function(marineOutlineMixinSelf, deltaTime)
-- Shared.Message("marineOutlineMixinSelf:GetRenderModel(): " .. tostring(marineOutlineMixinSelf:GetRenderModel()))
local originalClientGetOutlinePlayers = Client.GetOutlinePlayers
local originalClientGetLocalClientTeamNumber = Client.GetLocalClientTeamNumber
local originalkEquipmentOutlineColorTSFBlue = kEquipmentOutlineColor.TSFBlue
--local originalMarineOutlineMixinSelfGetRenderModel = marineOutlineMixinSelf.GetRenderModel
if wasRecentlyWelded(marineOutlineMixinSelf) then
-- Shared.Message("wasRecentlyWelded(marineOutlineMixinSelf): " .. tostring(wasRecentlyWelded(marineOutlineMixinSelf)))
Client.GetOutlinePlayers = function()
return true
end
Client.GetLocalClientTeamNumber = function()
return kSpectatorIndex
end
kEquipmentOutlineColor.TSFBlue = kEquipmentOutlineColor.Yellow
-- marineOutlineMixinSelf.GetRenderModel = function(marineOutlineMixinSelfSelf)
-- return marineOutlineMixinSelfSelf:GetActiveWeapon():GetRenderModel()
-- end
end
originalMarineOutlineMixinOnUpdate(marineOutlineMixinSelf, deltaTime)
Client.GetOutlinePlayers = originalClientGetOutlinePlayers
Client.GetLocalClientTeamNumber = originalClientGetLocalClientTeamNumber
kEquipmentOutlineColor.TSFBlue = originalkEquipmentOutlineColorTSFBlue
--marineOutlineMixinSelf.GetRenderModel = originalMarineOutlineMixinSelfGetRenderModel
-- Shared.Message("Shared.GetTime(): " .. tostring(Shared.GetTime()))
end
end
end
end)
if Predict or Client then
TGNS.HookNetworkMessage(NetworkMessageNames.WaveInProgress, function(message)
waveInProgress = message.i
end)
TGNS.HookNetworkMessage(NetworkMessageNames.RecentlyWelded, function(message)
recentlyWeldedTime[message.i] = message.t
end)
end
if Server or Client then
local Plugin = {}
local TD = {}
if Client then
end
if Server then
Plugin.HasConfig = true
Plugin.ConfigName = "td.json"
end
local function OnClientInitialise()
function Plugin:Think(deltaTime)
if recentlyWeldedTime[Client.GetLocalClientIndex()] then
local recentlyWelded = wasRecentlyWelded(Client.GetLocalPlayer())
if recentlyWelded ~= recentWeldEffectEnabled then
Player.screenEffects.darkVision = Player.screenEffects.darkVision or Client.CreateScreenEffect("shaders/Blur.screenfx")
Player.screenEffects.darkVision:SetActive(recentlyWelded)
recentWeldEffectEnabled = recentlyWelded
end
end
end
end
local function OnServerInitialise()
Server.SetConfigSetting("force_even_teams_on_join", false)
local WaveTextChannelId = 72
local waveStartDelayInSeconds = 25
local structures = {}
local allWaveStructuresDeployed = {}
local currentGameStartWhen = 0
local function markPlayerAsRecentlyWelded(player)
recentlyWeldedTime[player:GetClientIndex()] = Shared.GetTime()
TGNS.DoFor(TGNS.GetPlayerList(), function(p)
TGNS.SendNetworkMessageToPlayer(p, NetworkMessageNames.RecentlyWelded, {i=player:GetClientIndex(), t=Shared.GetTime()})
end)
end
function Plugin:Think()
-- if math.floor(Shared.GetTime()) % 5 == 0 then
-- TGNS.DoFor(TGNS.GetPlayerList(), function(p)
-- if Shared.GetTime() - (recentlyWeldedTime[p:GetClientIndex()] or 0) > recentWeldTimespanInSeconds then
-- markPlayerAsRecentlyWelded(p)
-- end
-- end)
-- end
end
local originalWelderPerformWeld = Welder.PerformWeld
Welder.PerformWeld = function(welderSelf, player)
local originalCheckMeleeCapsule = CheckMeleeCapsule
CheckMeleeCapsule = function(weapon, player, damage, range, optionalCoords, traceRealAttack, scale, priorityFunc, filter, mask)
local didHit, target, endPoint, direction, surface = originalCheckMeleeCapsule(weapon, player, damage, range, optionalCoords, traceRealAttack, scale, priorityFunc, filter, mask)
if didHit and target and target.GetClientIndex then
markPlayerAsRecentlyWelded(target)
end
return didHit, target, endPoint, direction, surface
end
originalWelderPerformWeld(welderSelf, player)
CheckMeleeCapsule = originalCheckMeleeCapsule
end
local function limitationAdvisoryText(c, waveNumber)
local result = ""
if TGNS.ClientIsMarine(c) then
result = string.format("\n\nYou %s during waves!%s", TGNS.IsClientCommander(c) and "can only drop ammo\nand catpacks" or "cannot move", waveNumber < 5 and "\nKill the moving structures!" or "")
end
return result
end
local function getWaveData(n)
local waveInfo = Shine.Plugins.td.Config.Waves[n]
if not TGNS.IsProduction() then
-- waveInfo = "Test|Whip,0,1,5|1"
end
local waveData = TGNS.Split("|", waveInfo)
local waveDamageModifier = waveData[3]
local waveTitle = string.format("%s (Weapons Strength: %s%s)", waveData[1], math.floor(100 * waveDamageModifier), "%%")
local structureInfos = TGNS.Select(TGNS.Split(";", waveData[2]), function(d)
local structureData = TGNS.Split(",", d)
return {type=structureData[1],delay=structureData[2],count=structureData[3],speed=structureData[4],damageModifier=waveDamageModifier}
end)
return {title=waveTitle, structures=structureInfos}
end
function TD.PrepareNextWave(chair, hive, waveNumber)
waveInProgress = false
-- local lastStructureKilledWaveNumber = waveNumber
if #Shine.Plugins.td.Config.Waves >= waveNumber then
local nextWaveData = getWaveData(waveNumber)
local startDelayInSeconds = waveNumber - 1 % 5 == 0 and waveStartDelayInSeconds * 2 or waveStartDelayInSeconds
TGNS.DoTimes(startDelayInSeconds, function(i)
local secondsUntilWaveStart = startDelayInSeconds - i
TGNS.ScheduleAction(startDelayInSeconds - secondsUntilWaveStart, function()
-- if TGNS.IsGameInProgress() and chair and hive and (lastStructureKilledWaveNumber == waveNumber) then
if TGNS.IsGameInProgress() and chair and hive then
-- Shared.Message("secondsUntilWaveStart: " .. tostring(secondsUntilWaveStart))
if secondsUntilWaveStart > 0 then
TGNS.DoFor(TGNS.GetHumanClientList(), function(c)
if secondsUntilWaveStart == startDelayInSeconds - 1 then
TGNS.SendNetworkMessageToPlayer(TGNS.GetPlayer(c), NetworkMessageNames.WaveInProgress, {i=waveInProgress})
end
local teamRgb = TGNS.GetTeamRgb(TGNS.GetClientTeamNumber(c))
Shine.ScreenText.Add(WaveTextChannelId, {X = 0.5, Y = 0.6, Text = string.format("Next: Wave %s - %s%s", waveNumber, nextWaveData.title, TGNS.ClientIsMarine(c) and string.format("\nStarting %s\nPrepare and take positions.%s", secondsUntilWaveStart >= 3 and string.format("in %s seconds...", secondsUntilWaveStart + 1) or "now!", limitationAdvisoryText(c, waveNumber)) or ""), Duration = 600, R = teamRgb.R, G = teamRgb.G, B = teamRgb.B, Alignment = TGNS.ShineTextAlignmentCenter, Size = 3, FadeIn = 0, IgnoreFormat = true}, c)
end)
else
TGNS.DoFor(TGNS.GetMarinePlayers(TGNS.GetPlayerList()), function(p)
TGNS.AddPlayerResources(p, 10)
local weapons = p:GetWeapons()
TGNS.DoFor(weapons, function(w)
if w.GiveAmmo then
w:GiveAmmo(AmmoPack.kNumClips, true)
end
end)
end)
TD.SendWave(chair, hive, waveNumber)
end
end
end)
end)
else
if chair and chair:GetIsAlive() then
hive:Kill()
TGNS.DestroyEntity(hive)
end
end
end
function TD.SendWave(chair, hive, waveNumber)
-- Shared.Message("waveNumber: " ..tostring(waveNumber))
local types = {}
types.Whip = Whip.kMapName
types.Shift = Shift.kMapName
types.Crag = Crag.kMapName
types.Drifter = Drifter.kMapName
types.Shade = Shade.kMapName
waveInProgress = true
local waveData = getWaveData(waveNumber)
TGNS.DoFor(TGNS.GetHumanClientList(), function(c)
local teamRgb = TGNS.GetTeamRgb(TGNS.GetClientTeamNumber(c))
Shine.ScreenText.Add(WaveTextChannelId, {X = 0.5, Y = 0.6, Text = string.format("Wave %s%s", string.format("%s - %s", waveNumber, waveData.title), limitationAdvisoryText(c, waveNumber)), Duration = 600, R = teamRgb.R, G = teamRgb.G, B = teamRgb.B, Alignment = TGNS.ShineTextAlignmentCenter, Size = 3, FadeIn = 0, IgnoreFormat = true}, c)
TGNS.SendNetworkMessageToPlayer(TGNS.GetPlayer(c), NetworkMessageNames.WaveInProgress, {i=waveInProgress})
end)
local waveCurrentGameStartWhen = currentGameStartWhen
TGNS.DoFor(waveData.structures, function(s, i)
-- Shared.Message(string.format("type: %s, delay: %s, count: %s, speed: %s", s.type, s.delay, s.count, s.speed))
TGNS.ScheduleAction(s.delay, function()
local theseStructuresAreIntendedForCurrentGame = waveCurrentGameStartWhen == currentGameStartWhen
if theseStructuresAreIntendedForCurrentGame then
TGNS.DoTimes(s.count, function()
if TGNS.IsGameInProgress() and chair and hive then
-- check to make sure current round is the round for which these structures were spawned
local structure = CreateEntity(types[s.type], hive:GetOrigin(), kAlienTeamType)
table.insert(structures, structure)
-- local playingHumansCount = #TGNS.GetPlayingClients(TGNS.GetPlayerList())
-- if playingHumansCount > 1 then
-- structure.damageModifier = s.damageModifier
-- end
structure.damageModifier = s.damageModifier
if structure.SetConstructionComplete then
structure:SetConstructionComplete()
end
local modifier = s.speed
local fireSpeedModifier = function(entity) return entity:GetIsOnFire() and .5 or 1 end
local originalGetMaxSpeed = structure.GetMaxSpeed
structure.GetMaxSpeed = function(structureSelf)
local result = originalGetMaxSpeed(structureSelf)
return result * modifier * fireSpeedModifier(structureSelf)
end
local originalDrifterkMoveSpeed = Drifter.kMoveSpeed
local originalDrifterOnUpdate = Drifter.OnUpdate
structure.kDrifterMoveSpeed = originalDrifterkMoveSpeed * modifier
Drifter.OnUpdate = function(drifterSelf, deltaTime)
Drifter.kMoveSpeed = drifterSelf.kDrifterMoveSpeed * fireSpeedModifier(drifterSelf)
originalDrifterOnUpdate(drifterSelf, deltaTime)
Drifter.kMoveSpeed = originalDrifterkMoveSpeed
end
if structure.SetMature then
structure:SetMature()
end
structure:SetMaxHealth(structure:GetMaxHealth() * modifier)
structure:SetMaxArmor(structure:GetMaxArmor() * modifier)
local targetHealth = structure:GetMaxHealth()
local targetArmor = structure:GetMaxArmor()
if structure.matureMaxHealth then
structure.matureMaxHealth = structure.matureMaxHealth * modifier
structure.matureMaxArmor = structure.matureMaxArmor * modifier
targetHealth = structure.matureMaxHealth
targetArmor = structure.matureMaxArmor
end
structure:SetHealth(targetHealth)
structure:SetArmor(targetArmor)
structure:GiveOrder(kTechId.Move, chair:GetId(), chair:GetOrigin(), nil, true, true)
local originalStructureOnKill = structure.OnKill
structure.OnKill = function(structureSelf, attacker, doer, point, direction)
originalStructureOnKill(structureSelf, attacker, doer, point, direction)
-- TGNS.DestroyEntity(structureSelf)
TGNS.RemoveAllMatching(structures, structure)
if waveNumber and allWaveStructuresDeployed[waveNumber] and #structures == 0 then
-- Shared.Message(string.format("------------------------------------------------------------------------------------------------------- allWaveStructuresDeployed[%s] == true", waveNumber))
TD.PrepareNextWave(chair, hive, waveNumber + 1)
end
GetGamerules():GetTeam(kMarineTeamType):AddTeamResources(15)
if attacker and attacker:isa("Marine") then
TGNS.AddPlayerResources(attacker, 5)
local weapons = attacker:GetWeapons()
TGNS.DoFor(weapons, function(w)
if w.GiveAmmo then
w:GiveAmmo(AmmoPack.kNumClips, true)
end
end)
end
end
local originalStructureCompletedCurrentOrder = structure.CompletedCurrentOrder
structure.CompletedCurrentOrder = function(structureSelf)
originalStructureCompletedCurrentOrder(structureSelf)
if chair then
local lengthFromChair = (structureSelf:GetOrigin() - chair:GetOrigin()):GetLength()
-- Shared.Message("lengthFromChair: " .. tostring(lengthFromChair))
if lengthFromChair > 5 then
TGNS.DoFor(TGNS.GetPlayingClients(TGNS.GetPlayerList()), function(c)
Shine.ScreenText.Add(70, {X = 0.5, Y = 0.4, Text = "Blocked structures damage the chair and then die!", Duration = 6, R = 255, G = 0, B = 0, Alignment = TGNS.ShineTextAlignmentCenter, Size = 3, FadeIn = 0, IgnoreFormat = true}, c)
end)
end
chair:DeductHealth(chair:GetMaxHealth() * .05)
end
structure:Kill()
-- TGNS.ScheduleAction(5, function()
-- TGNS.DestroyEntity(structure)
-- end)
end
end
end)
if i == #waveData.structures then
-- Shared.Message(string.format("------------------------------------------------------------------------------------------------------- allWaveStructuresDeployed[%s] = true", waveNumber))
allWaveStructuresDeployed[waveNumber] = true
end
end
end)
end)
end
TGNS.DisableUweGameReporting()
local md = TGNSMessageDisplayer.Create("TD")
function Plugin:JoinTeam(gamerules, player, newTeamNumber, force, shineForce)
local cancel = false
if not (force or shineForce) then
if newTeamNumber == kAlienTeamType then
md:ToPlayerNotifyError(player, "TD is played on the Marine team.")
cancel = true
end
if cancel then
return false
end
end
end
function Plugin:PostJoinTeam(gamerules, player, oldTeamNumber, newTeamNumber, force, shineForce)
local client = TGNS.GetClient(player)
if TGNS.ClientIsMarine(client) then
TGNS.ScheduleAction(0, function()
if client and Shine:IsValidClient(client) and TGNS.ClientIsMarine(client) and not TGNS.IsGameInProgress() then
TGNS.ForceGameStart()
end
end)
gamerules:RespawnPlayer(player)
end
end
function Plugin:EndGame(gamerules, winningTeam)
Shine.ScreenText.End(WaveTextChannelId)
end
function Plugin:ClientConnect(client)
TGNS.ScheduleAction(0, function()
if not TGNS.IsProduction() then
TGNS.SendToTeam(TGNS.GetPlayer(client), kMarineTeamType)
end
Shine.ScreenText.Add(82, {X = .5, Y = 0.95, Text = "\nTD BETA - TGNS FORUMS FOR CHANGELOG", Duration = 120, R = 255, G = 255, B = 255, Alignment = TGNS.ShineTextAlignmentCenter, Size = 1, FadeIn = 0, IgnoreFormat = true}, c)
end)
end
lastNoAttackNoticeTimes = {}
lastNoWeldNoticeTimes = {}
function Plugin:TakeDamage( Ent, Damage, Attacker, Inflictor, Point, Direction, ArmourUsed, HealthUsed, DamageType, PreventAlert )
if Ent and Ent:GetTeamNumber() == kAlienTeamType then
if Ent:isa("Hive") or not Inflictor then
Damage = 0
ArmourUsed = 0
HealthUsed = 0
if Ent:isa("Hive") then
local client = TGNS.GetClient(Attacker)
if client and (lastNoAttackNoticeTimes[client] == nil or lastNoAttackNoticeTimes[client] < Shared.GetTime() - 1) and (Attacker:GetOrigin() - Ent:GetOrigin()):GetLength() < kHitEffectRelevancyDistance then
local teamRgb = TGNS.GetTeamRgb(Attacker:GetTeamNumber())
Shine.ScreenText.Add(70, {X = 0.5, Y = 0.4, Text = "You cannot damage the Hive. Attack the moving structures!", Duration = 6, R = teamRgb.R, G = teamRgb.G, B = teamRgb.B, Alignment = TGNS.ShineTextAlignmentCenter, Size = 3, FadeIn = 0, IgnoreFormat = true}, client)
lastNoAttackNoticeTimes[client] = Shared.GetTime()
end
end
else
if Ent.damageModifier then
Damage = Damage * Ent.damageModifier
ArmourUsed = ArmourUsed * Ent.damageModifier
HealthUsed = HealthUsed * Ent.damageModifier
end
end
end
return Damage, ArmourUsed, HealthUsed
-- return 0, 0, 0
end
TGNS.RegisterEventHook("GameStarted", function()
currentGameStartWhen = Shared.GetTime()
local chair = GetEntitiesForTeam( "CommandStation", kMarineTeamType )[1]
local hive = GetEntitiesForTeam( "Hive", kAlienTeamType )[1]
hive:SetMature()
hive:SetHealth(hive:GetMatureMaxHealth())
hive:SetArmor(hive:GetMatureMaxArmor())
chair.GetCanBeWeldedOverride = function(chairSelf, doer)
local client = TGNS.GetClient(doer)
if client and (lastNoWeldNoticeTimes[client] == nil or Shared.GetTime() - lastNoWeldNoticeTimes[client] > 1) then
local teamRgb = TGNS.GetTeamRgb(doer:GetTeamNumber())
Shine.ScreenText.Add(71, {X = 0.5, Y = 0.4, Text = "You cannot weld the Chair. The game ends when the Chair dies. Attack the moving structures!", Duration = 6, R = teamRgb.R, G = teamRgb.G, B = teamRgb.B, Alignment = TGNS.ShineTextAlignmentCenter, Size = 3, FadeIn = 0, IgnoreFormat = true}, client)
lastNoWeldNoticeTimes[client] = Shared.GetTime()
end
return false, false
end
TD.PrepareNextWave(chair, hive, 1)
end)
local originalNS2GamerulesCheckGameEnd = NS2Gamerules.CheckGameEnd
NS2Gamerules.CheckGameEnd = function(gameRulesSelf)
local chairDestroyed = gameRulesSelf:GetTeam(kTeam1Index):GetNumAliveCommandStructures() == 0
local hiveDestroyed = gameRulesSelf:GetTeam(kTeam2Index):GetNumAliveCommandStructures() == 0
if chairDestroyed or hiveDestroyed then
TGNS.DoFor(structures, function(s) s:Kill() end)
-- explode all the eggs
local originalGameRulesSelfTeam1GetHasTeamLost = gameRulesSelf.team1.GetHasTeamLost
local originalGameRulesSelfTeam2GetHasTeamLost = gameRulesSelf.team2.GetHasTeamLost
gameRulesSelf.team1.GetHasTeamLost = function(team1Self) return chairDestroyed end
gameRulesSelf.team2.GetHasTeamLost = function(team1Self) return hiveDestroyed end
originalNS2GamerulesCheckGameEnd(gameRulesSelf)
gameRulesSelf.team1.GetHasTeamLost = originalGameRulesSelfTeam1GetHasTeamLost
gameRulesSelf.team2.GetHasTeamLost = originalGameRulesSelfTeam2GetHasTeamLost
end
end
local originalNS2GamerulesGetCanSpawnImmediately = NS2Gamerules.GetCanSpawnImmediately
NS2Gamerules.GetCanSpawnImmediately = function() return true end
-- local parent, OldSpawnInfantryPortal = LocateUpValue( MarineTeam.SpawnInitialStructures, "SpawnInfantryPortal", { LocateRecurse = true } )
-- function SpawnInfantryPortal( marineTeamSelf, techPoint )
-- end
-- ReplaceUpValue( parent, "SpawnInfantryPortal", SpawnInfantryPortal, { LocateRecurse = true } )
local parent, OldCheckForNoIPs = LocateUpValue( MarineTeam.Update, "CheckForNoIPs", { LocateRecurse = true } )
function CheckForNoIPs( marineTeamSelf, timePassed )
end
ReplaceUpValue( parent, "CheckForNoIPs", CheckForNoIPs, { LocateRecurse = true } )
end
function Plugin:Initialise()
self.Enabled = true
function init()
if Shared.GetMapName() == "" then
Shine.Timer.Simple(0, init)
elseif Shared.GetMapName() == TdMapName then
if Client then OnClientInitialise() end
if Server then OnServerInitialise() end
end
end
init()
return true
end
function Plugin:Cleanup()
--Cleanup your extra stuff like timers, data etc.
self.BaseClass.Cleanup( self )
end
Shine:RegisterExtension("td", Plugin )
end | mit |
AlexandreCA/darkstar | scripts/zones/Metalworks/npcs/HomePoint#1.lua | 13 | 1255 | -----------------------------------
-- Area: Metalworks
-- NPC: HomePoint#1
-- @pos: 46 -14 -19 237
-----------------------------------
package.loaded["scripts/zones/Metalworks/TextIDs"] = nil;
require("scripts/globals/settings");
require("scripts/zones/Metalworks/TextIDs");
require("scripts/globals/homepoint");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
homepointMenu( player, 0x21fc, 16);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x21fc) then
if (option == 1) then
player:setHomePoint();
player:messageSpecial(HOMEPOINT_SET);
else
hpTeleport( player, option);
end
end
end; | gpl-3.0 |
AlexandreCA/update | scripts/globals/items/dish_of_spaghetti_ortolana.lua | 36 | 1406 | -----------------------------------------
-- ID: 5658
-- Item: Dish of Spafhetti Ortolana
-- Food Effect: 30 Mins, All Races
-----------------------------------------
-- Agility 2
-- Vitality 2
-- HP +30% Cap 70
-- StoreTP +6
-----------------------------------------
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,3600,5658);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_VIT, 2);
target:addMod(MOD_AGI, 2);
target:addMod(MOD_FOOD_HPP, 30);
target:addMod(MOD_FOOD_HP_CAP, 70);
target:addMod(MOD_STORETP, 6);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_VIT, 2);
target:delMod(MOD_AGI, 2);
target:delMod(MOD_FOOD_HPP, 30);
target:delMod(MOD_FOOD_HP_CAP, 70);
target:delMod(MOD_STORETP, 6);
end;
| gpl-3.0 |
lucgagnon/ntopng | scripts/lua/modules/sqlite_utils.lua | 10 | 8666 | --
-- (C) 2014-15 - ntop.org
--
-- This file contains the description of all functions
-- used to interact with sqlite
dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
require "lua_utils"
require "template"
local j = require ("dkjson")
local SqliteClass = {} -- the table representing the class, which will double as the metatable for the instances
SqliteClass.__index = SqliteClass -- failed table lookups on the instances should fallback to the class table, to get methods
-- syntax equivalent to "SqliteClass.new = function..."
function SqliteClass.new(init)
local self = setmetatable({}, SqliteClass)
self.debug = false
self.class_benchmark = os.clock()
self.query_benchmark = os.clock()
self.flows_benchmark = os.clock()
-- Template
self.flow_template = {
["IPV4_SRC_ADDR"] = function (table,val) table["cli.ip"] = val end,
["L4_SRC_PORT"] = function (table,val) table["cli.port"] = tonumber(val) end,
["IPV4_DST_ADDR"] = function (table,val) table["srv.ip"] = val end,
["L4_DST_PORT"] = function (table,val) table["srv.port"] = tonumber(val) end,
["PROTOCOL"] = function (table,val)
if (l4_template[tonumber(val)] ~= nil ) then
table["proto.l4"] = l4_template[tonumber(val)]
else
table["proto.l4"] = val
end
end,
-- ["SRC_VLAN"] = function (table,val) table["vlan"] = tonumber(val) end,
-- ["DST_VLAN"] = function (table,val) table["vlan"] = tonumber(val) end,
["L7_PROTO_NAME"] = function (table,val) table["proto.ndpi"] = val end,
["TCP_FLAGS"] = function (table,val) table["tcp_flags"] = tonumber(val) end,
["OUT_PKTS"] = function (table,val) table["cli2srv.packets"] = tonumber(val) end,
["OUT_BYTES"] = function (table,val) table["cli2srv.bytes"] = tonumber(val) end,
["IN_PKTS"] = function (table,val) table["srv2cli.packets"] = tonumber(val) end,
["IN_BYTES"] = function (table,val) table["srv2cli.bytes"] = tonumber(val) end,
}
-- Query
self.response = nil
self.db = nil;
self.query = nil;
self.number_rows = 0;
-- Flows
self.flows = nil
self.flows_num = 0
return self
end
-- ###################################
-- Getter and setter
function SqliteClass.setDebug(self, bool)
if (bool == nil) then bool = false end
self.debug = bool
return self.debug
end
function SqliteClass.getDebug(self) return self.debug end
function SqliteClass.getFlows(self) return self.flows end
function SqliteClass.getFlowsNum(self) return self.flows_num end
function SqliteClass.getResponse(self) return self.response end
function SqliteClass.getDB(self) return self.db end
function SqliteClass.getQuery(self) return self.query end
-- ###################################
function SqliteClass.execQuery(self, db ,query)
if (db == nil) then return -1 end
if (query == nil) then return -2 end
self.db = db;
self.query = query;
self.query_benchmark = os.clock()
-- io.write(dirs.workingdir ..db..'\n')
self.response = ntop.execQuery(dirs.workingdir ..db , query)
n_rows = ntop.execQuery(dirs.workingdir ..db , "SELECT COUNT (*) as rows_number FROM flows")
if (n_rows ~= nil) then
self.number_rows = n_rows[1]["rows_number"]
end
Sqlite:benchmark("query",os.clock())
return self.response
end
-- ###################################
function SqliteClass.getFlows(self)
if (self.response == nil) then return nil end
-- Init some parameters
self.flows_benchmark = os.clock()
self.flows = {}
num = 0
for _k,_v in pairs(self.response) do
-- init table of table
self.flows[num] = {}
self.flows[num]["ID"] = tonumber(self.response[_k]["ID"])
self.flows[num]["vlan"] = tonumber(self.response[_k]["vlan_id"])
self.flows[num]["bytes"] = tonumber(self.response[_k]["bytes"])
self.flows[num]["duration"] = tonumber(self.response[_k]["duration"])
-- Throughput
-- io.write((self.flows[num]["bytes"] / self.flows[num]["duration"])..'\n')
self.flows[num]["throughput_bps"] = (self.flows[num]["bytes"] / 8 ) / (self.flows[num]["duration"])
self.flows[num]["throughput_trend_bps"] = 3
local info, pos, err = j.decode(self.response[_k]["json"], 1, nil)
if (info == nil) then
traceError(TRACE_ERROR,TRACE_CONSOLE,"Impossible read json form sqlite: ".. err)
else
for key,val in pairs(info) do
label_key = nil
-- Check if the option --jsonlabes is active
if (rtemplate[tonumber(key)] ~= nil) then label_key = rtemplate[tonumber(key)] end
if (template[key] ~= nil) then label_key = key end
-- Convert template id into template name
if (label_key ~= nil) then
if (self.flow_template[label_key] ~= nil) then
-- Call conversion function in order to convert some value to number if it is necessary
self.flow_template[label_key](self.flows[num],val)
else
-- Leave the default key and value
self.flows[num][key] = val
end
end
end -- info loop
-- Custom parameters
if (self.flows[num]["proto.ndpi"] == nil) then
self.flows[num]["proto.ndpi"] = "Unknown"
end
end -- info == nil
num = num + 1
end -- for
-- self.writeFlows(self)
self.flows_num = num
Sqlite:benchmark("flows",os.clock())
return self.flows
end
-- ###################################
function SqliteClass.getRowsNumber(self)
return (self.number_rows);
end
-- ###################################
-- Utils
function SqliteClass.benchmark(self,type,time)
if ((time ~= nil) and (self.debug))then
bk_text = "class"
bk = self.class_benchmark
if (type == "query") then
bk = self.query_benchmark
bk_text = type
elseif (type == "flows") then
bk = self.flows_benchmark
bk_text = type
end
traceError(TRACE_DEBUG,TRACE_CONSOLE,string.format(bk_text .. ": elapsed time: %.4f", time - bk))
end
end
---------------------------------------
function SqliteClass.writeFlows(self)
if (self.flows ~= nil) then
for key,val in pairs(self.flows) do
traceError(TRACE_DEBUG,TRACE_CONSOLE,'Flow: '..key)
for k,v in pairs(self.flows[key]) do
traceError(TRACE_DEBUG,TRACE_CONSOLE,'\t'..k..' - '..v)
end
end
end
end
function getParameters(datetime,action)
datetime_tbl = cleanDateTime(datetime, action)
datetime_tbl["displayed"] = os.date("%m/%d/%Y %I:%M %p",datetime_tbl["epoch"])
traceError(TRACE_DEBUG,TRACE_CONSOLE,'Displayed: ['..datetime_tbl["displayed"] .. ']')
datetime_tbl["query"] = os.date("/%Y/%m/%d/%H/%M",datetime_tbl["epoch"])
traceError(TRACE_DEBUG,TRACE_CONSOLE,'query: ['..datetime_tbl["query"] .. ']')
return datetime_tbl
end
function cleanDateTime(datetime,action)
if (datetime == nil) then return {} end
traceError(TRACE_DEBUG,TRACE_CONSOLE,'Initial date and time: '..datetime)
tbl = split(datetime," ")
q_date = tbl[1]
q_time = tbl[2]
q_type = tbl[3]
traceError(TRACE_DEBUG,TRACE_CONSOLE,'Default value: ['..q_date..']['..q_time .. '][' .. q_type..']')
date_tbl = split(q_date,"/")
q_month = tonumber(date_tbl[1])
q_day = tonumber(date_tbl[2])
q_year = tonumber(date_tbl[3])
traceError(TRACE_DEBUG,TRACE_CONSOLE,'Default value: ['..q_day..']['..q_month .. '][' .. q_year..']')
time_tbl = split(q_time,":")
q_hour = tonumber(time_tbl[1])
q_min = tonumber(time_tbl[2])
if (q_type == "PM") then q_hour = q_hour + 12 end
traceError(TRACE_DEBUG,TRACE_CONSOLE,'Default value: ['..q_hour..']['..q_min .. ']')
q_epoch = os.time({year=q_year, month=q_month, day=q_day, hour=q_hour, min=q_min})
traceError(TRACE_DEBUG,TRACE_CONSOLE,'epoch: ['.. q_epoch ..']')
if (action ~= nil) then
if (action == "newer") then
q_epoch = q_epoch + 300 -- plus 5 min
else
q_epoch = q_epoch - 300 -- min 5 min
end
end
mktime = os.date("%m/%d/%Y %I:%M %p", q_epoch)
traceError(TRACE_DEBUG,TRACE_CONSOLE,'time: ['.. mktime ..']')
ret_tbl = {}
ret_tbl["year"] = q_year
ret_tbl["month"] = month
ret_tbl["day"] = q_day
ret_tbl["q_hour"] = q_q_hour
ret_tbl["q_min"] = q_q_min
ret_tbl["epoch"] = q_epoch
return ret_tbl
end
-- ###################################
-- Don't remove below line
Sqlite = SqliteClass.new()
-- Sqlite:benchmark(os.clock())
Sqlite:setDebug(false)
| gpl-3.0 |
AlexandreCA/update | scripts/commands/addallspells.lua | 3 | 5066 | ---------------------------------------------------------------------------------------------------
-- func: addallspells
-- desc: Adds all valid spells to the given target. If no target; then to the current player.
---------------------------------------------------------------------------------------------------
cmdprops =
{
permission = 1,
parameters = "s"
};
local ValidSpells = {
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,
38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,
72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,
105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,
131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,
157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,
183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,
209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,
235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,
261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,
287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,
313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,
339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,
365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,
391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,
417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,
443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,
469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,
495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,515,517,519,521,522,524,527,
529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,547,548,549,551,554,555,557,560,561,
563,564,565,567,569,570,572,573,574,575,576,577,578,579,581,582,584,585,587,588,589,591,592,593,594,595,
596,597,598,599,603,604,605,606,608,610,611,612,613,614,615,616,617,618,620,621,622,623,626,628,629,631,
632,633,634,636,637,638,640,641,642,643,644,645,646,647,648,649,650,651,652,653,654,655,656,657,658,659,
660,661,662,663,664,665,666,667,668,669,670,671,672,673,674,675,676,677,678,679,680,681,682,683,684,685,
686,687,688,689,690,691,692,693,694,695,696,697,698,699,700,701,702,703,704,705,706,707,708,709,710,711,
712,713,714,715,716,717,718,719,720,721,722,723,724,725,726,727,728,736,737,738,739,740,741,742,743,744,
745,746,747,748,749,768,769,770,771,772,773,774,775,776,777,778,779,780,781,782,783,784,785,786,787,788,
789,790,791,792,793,794,795,796,797,798,799,800,801,802,803,804,805,806,807,808,809,810,811,812,813,814,
815,816,817,818,819,820,821,822,823,824,825,826,827,828,829,830,831,832,833,834,835,836,837,838,839,840,
841,842,843,844,845,846,847,848,849,850,851,852,853,854,855,856,857,858,859,860,861,862,863,864,865,866,
867,868,869,870,871,872,873,874,875,876,877,878,879,880,881,882,883,884,885,886,887,888,889,890,891,892,
893,894,895
--trusts are causing client crashes when flagged in char spells packets sent outside of zone/log in
--896,897,898,899,900,901,902,903,904,905,906,907,908,909,910,911,912,913,914,915,916,917,918,919,920,921,
--922,923,924,925,926,927,928,929,930,931,932,933,934,935,936,937,938,939,940,941,942,943,944,945,946,947,
--948,949,950,951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,
--974,975,976,977,978,979,980,981,982,983,984,985,986,987,1004,1005,1006,1007,1008,1009,1010,1011,1012,1013,1014,1015,1016
};
local function AddAllSpells(player)
local save = true;
local silent = true; -- prevent packet spam
for i = 1, #ValidSpells do
if i == #ValidSpells then
silent = false;
end
player:addSpell(ValidSpells[i], silent, save);
end
end;
function onTrigger(player, target)
if (target == nil) then
AddAllSpells(player);
else
local targ = GetPlayerByName(target);
if (targ == nil) then
player:PrintToPlayer(string.format( "Player named '%s' not found!", target ));
else
AddAllSpells(targ);
end
end
end
| gpl-3.0 |
AlexandreCA/update | scripts/zones/Metalworks/npcs/HomePoint#2.lua | 19 | 1185 | -----------------------------------
-- Area: Metalworks
-- NPC: HomePoint#2
-- @pos: -78 2 2 237
-----------------------------------
package.loaded["scripts/zones/Metalworks/TextIDs"] = nil;
require("scripts/globals/settings");
require("scripts/zones/Metalworks/TextIDs");
require("scripts/globals/homepoint");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
homepointMenu( player, 0x21fd, 102);
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 |
AlexandreCA/update | scripts/zones/Temenos/mobs/Temenos_Cleaner.lua | 16 | 1289 | -----------------------------------
-- Area: Temenos Central 1floor
-- NPC: Temenos_Cleaner
-----------------------------------
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(16929046)==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/globals/spells/bluemagic/actinic_burst.lua | 18 | 1492 | -----------------------------------------
-- Spell: Actinic Burst
-- Greatly lowers the accuracy of enemies within range for a brief period of time
-- Spell cost: 24 MP
-- Monster Type: Luminions
-- Spell Type: Magical (Light)
-- Blue Magic Points: 4
-- Stat Bonus: CHR+2, HP+20
-- Level: 74
-- Casting Time: 0.5 seconds
-- Recast Time: 60 seconds
-- Effect Time: About 15 seconds
-- Magic Bursts on: Transfixion, Fusion, and Light
-- Combos: Auto Refresh
-----------------------------------------
require("scripts/globals/status");
require("scripts/globals/magic");
require("scripts/globals/bluemagic");
-----------------------------------------
-- OnMagicCastingCheck
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onSpellCast(caster,target,spell)
local typeEffect = EFFECT_FLASH;
local dINT = (caster:getStat(MOD_MND) - target:getStat(MOD_MND));
local resist = applyResistance(caster,spell,target,dINT,BLUE_SKILL, 150);
local duration = 20 * resist;
local power = 200;
if (resist > 0.0625) then -- Do it!
if (target:addStatusEffect(typeEffect,power,0,duration)) then
spell:setMsg(236);
else
spell:setMsg(75);
end
else
spell:setMsg(85);
end;
return typeEffect;
end;
| gpl-3.0 |
AlexandreCA/update | scripts/zones/Windurst_Waters/npcs/Amagusa-Chigurusa.lua | 38 | 1418 | -----------------------------------
-- Area: Windurst Waters
-- NPC: Amagusa-Chigurusa
-- Type: Standard NPC
-- @pos -28.746 -4.5 61.954 238
-----------------------------------
package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/zones/Windurst_Waters/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local WildcatWindurst = player:getVar("WildcatWindurst");
if (player:getQuestStatus(WINDURST,LURE_OF_THE_WILDCAT_WINDURST) == QUEST_ACCEPTED and player:getMaskBit(WildcatWindurst,12) == false) then
player:startEvent(0x03a9);
else
player:startEvent(0x0232);
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 == 0x03a9) then
player:setMaskBit(player:getVar("WildcatWindurst"),"WildcatWindurst",12,true);
end
end;
| gpl-3.0 |
abbasgh12345/extremenewedit | plugins/plugins.lua | 88 | 6304 | do
-- Returns the key (index) in the config.enabled_plugins table
local function plugin_enabled( name )
for k,v in pairs(_config.enabled_plugins) do
if name == v then
return k
end
end
-- If not found
return false
end
-- Returns true if file exists in plugins folder
local function plugin_exists( name )
for k,v in pairs(plugins_names()) do
if name..'.lua' == v then
return true
end
end
return false
end
local function list_all_plugins(only_enabled)
local text = ''
local nsum = 0
for k, v in pairs( plugins_names( )) do
-- ✔ enabled, ❌ disabled
local status = '❌'
nsum = nsum+1
nact = 0
-- Check if is enabled
for k2, v2 in pairs(_config.enabled_plugins) do
if v == v2..'.lua' then
status = '✔'
end
nact = nact+1
end
if not only_enabled or status == '✔' then
-- get the name
v = string.match (v, "(.*)%.lua")
text = text..nsum..'. '..v..' '..status..'\n'
end
end
local text = text..'\nThere are '..nsum..' plugins installed.\n'..nact..' plugins enabled and '..nsum-nact..' disabled'
return text
end
local function list_plugins(only_enabled)
local text = ''
local nsum = 0
for k, v in pairs( plugins_names( )) do
-- ✔ enabled, ❌ disabled
local status = '❌'
nsum = nsum+1
nact = 0
-- Check if is enabled
for k2, v2 in pairs(_config.enabled_plugins) do
if v == v2..'.lua' then
status = '✔'
end
nact = nact+1
end
if not only_enabled or status == '✔' then
-- get the name
v = string.match (v, "(.*)%.lua")
text = text..v..' '..status..'\n'
end
end
local text = text..'\n'..nact..' plugins enabled from '..nsum..' plugins installed.'
return text
end
local function reload_plugins( )
plugins = {}
load_plugins()
return list_plugins(true)
end
local function enable_plugin( plugin_name )
print('checking if '..plugin_name..' exists')
-- Check if plugin is enabled
if plugin_enabled(plugin_name) then
return 'Plugin '..plugin_name..' is enabled'
end
-- Checks if plugin exists
if plugin_exists(plugin_name) then
-- Add to the config table
table.insert(_config.enabled_plugins, plugin_name)
print(plugin_name..' added to _config table')
save_config()
-- Reload the plugins
return reload_plugins( )
else
return 'Plugin '..plugin_name..' does not exists'
end
end
local function disable_plugin( name, chat )
-- Check if plugins exists
if not plugin_exists(name) then
return 'Plugin '..name..' does not exists'
end
local k = plugin_enabled(name)
-- Check if plugin is enabled
if not k then
return 'Plugin '..name..' not enabled'
end
-- Disable and reload
table.remove(_config.enabled_plugins, k)
save_config( )
return reload_plugins(true)
end
local function disable_plugin_on_chat(receiver, plugin)
if not plugin_exists(plugin) then
return "Plugin doesn't exists"
end
if not _config.disabled_plugin_on_chat then
_config.disabled_plugin_on_chat = {}
end
if not _config.disabled_plugin_on_chat[receiver] then
_config.disabled_plugin_on_chat[receiver] = {}
end
_config.disabled_plugin_on_chat[receiver][plugin] = true
save_config()
return 'Plugin '..plugin..' disabled on this chat'
end
local function reenable_plugin_on_chat(receiver, plugin)
if not _config.disabled_plugin_on_chat then
return 'There aren\'t any disabled plugins'
end
if not _config.disabled_plugin_on_chat[receiver] then
return 'There aren\'t any disabled plugins for this chat'
end
if not _config.disabled_plugin_on_chat[receiver][plugin] then
return 'This plugin is not disabled'
end
_config.disabled_plugin_on_chat[receiver][plugin] = false
save_config()
return 'Plugin '..plugin..' is enabled again'
end
local function run(msg, matches)
-- Show the available plugins
if matches[1] == '!plugins' and is_sudo(msg) then --after changed to moderator mode, set only sudo
return list_all_plugins()
end
-- Re-enable a plugin for this chat
if matches[1] == 'enable' and matches[3] == 'chat' then
local receiver = get_receiver(msg)
local plugin = matches[2]
print("enable "..plugin..' on this chat')
return reenable_plugin_on_chat(receiver, plugin)
end
-- Enable a plugin
if matches[1] == 'enable' and is_sudo(msg) then --after changed to moderator mode, set only sudo
local plugin_name = matches[2]
print("enable: "..matches[2])
return enable_plugin(plugin_name)
end
-- Disable a plugin on a chat
if matches[1] == 'disable' and matches[3] == 'chat' then
local plugin = matches[2]
local receiver = get_receiver(msg)
print("disable "..plugin..' on this chat')
return disable_plugin_on_chat(receiver, plugin)
end
-- Disable a plugin
if matches[1] == 'disable' and is_sudo(msg) then --after changed to moderator mode, set only sudo
if matches[2] == 'plugins' then
return 'This plugin can\'t be disabled'
end
print("disable: "..matches[2])
return disable_plugin(matches[2])
end
-- Reload all the plugins!
if matches[1] == 'reload' and is_sudo(msg) then --after changed to moderator mode, set only sudo
return reload_plugins(true)
end
end
return {
description = "Plugin to manage other plugins. Enable, disable or reload.",
usage = {
moderator = {
"!plugins disable [plugin] chat : disable plugin only this chat.",
"!plugins enable [plugin] chat : enable plugin only this chat.",
},
sudo = {
"!plugins : list all plugins.",
"!plugins enable [plugin] : enable plugin.",
"!plugins disable [plugin] : disable plugin.",
"!plugins reload : reloads all plugins." },
},
patterns = {
"^!plugins$",
"^!plugins? (enable) ([%w_%.%-]+)$",
"^!plugins? (disable) ([%w_%.%-]+)$",
"^!plugins? (enable) ([%w_%.%-]+) (chat)",
"^!plugins? (disable) ([%w_%.%-]+) (chat)",
"^!plugins? (reload)$" },
run = run,
moderated = true, -- set to moderator mode
--privileged = true
}
end
--Copyright and edit; @behroozyaghi
--Persian Translate; @behroozyaghi
--ch : @nod32team
--کپی بدون ذکر منبع حرام است
| gpl-2.0 |
AlexandreCA/update | scripts/zones/Mount_Zhayolm/npcs/_1p3.lua | 31 | 3553 | -----------------------------------
-- Area: Mount Zhayolm
-- Door: Runic Seal
-- @pos 703 -18 382 61
-----------------------------------
package.loaded["scripts/zones/Mount_Zhayolm/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/keyitems");
require("scripts/globals/missions");
require("scripts/globals/besieged");
require("scripts/zones/Mount_Zhayolm/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:hasKeyItem(LEBROS_ASSAULT_ORDERS)) then
local assaultid = player:getCurrentAssault();
local recommendedLevel = getRecommendedAssaultLevel(assaultid);
local armband = 0;
if (player:hasKeyItem(ASSAULT_ARMBAND)) then
armband = 1;
end
player:startEvent(0x00CB, assaultid, -4, 0, recommendedLevel, 2, armband);
else
player:messageSpecial(NOTHING_HAPPENS);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option,target)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
local assaultid = player:getCurrentAssault();
local cap = bit.band(option, 0x03);
if (cap == 0) then
cap = 99;
elseif (cap == 1) then
cap = 70;
elseif (cap == 2) then
cap = 60;
else
cap = 50;
end
player:setVar("AssaultCap", cap);
local party = player:getParty();
if (party ~= nil) then
for i,v in ipairs(party) do
if (not (v:hasKeyItem(LEBROS_ASSAULT_ORDERS) and v:getCurrentAssault() == assaultid)) then
player:messageText(target,MEMBER_NO_REQS, false);
player:instanceEntry(target,1);
return;
elseif (v:getZoneID() == player:getZoneID() and v:checkDistance(player) > 50) then
player:messageText(target,MEMBER_TOO_FAR, false);
player:instanceEntry(target,1);
return;
end
end
end
player:createInstance(player:getCurrentAssault(), 63);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option,target)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0xD0 or (csid == 0xCB and option == 4)) then
player:setPos(0,0,0,0,63);
end
end;
-----------------------------------
-- onInstanceLoaded
-----------------------------------
function onInstanceCreated(player,target,instance)
if (instance) then
instance:setLevelCap(player:getVar("AssaultCap"));
player:setVar("AssaultCap", 0);
player:setInstance(instance);
player:instanceEntry(target,4);
player:delKeyItem(LEBROS_ASSAULT_ORDERS);
player:delKeyItem(ASSAULT_ARMBAND);
if (party ~= nil) then
for i,v in ipairs(party) do
if v:getID() ~= player:getID() and v:getZoneID() == player:getZoneID() then
v:setInstance(instance);
v:startEvent(0xD0, 2);
v:delKeyItem(LEBROS_ASSAULT_ORDERS);
end
end
end
else
player:messageText(target,CANNOT_ENTER, false);
player:instanceEntry(target,3);
end
end; | gpl-3.0 |
AlexandreCA/update | scripts/zones/Kazham/npcs/Hari_Pakhroib.lua | 17 | 2838 | -----------------------------------
-- Area: Kazham
-- NPC: Hari Pakhroib
-- Starts and Finishes Quest: Greetings to the Guardian
-----------------------------------
package.loaded["scripts/zones/Kazham/TextIDs"] = nil;
require("scripts/globals/settings");
require("scripts/globals/quests");
require("scripts/globals/titles");
require("scripts/zones/Kazham/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
Guardian = player:getQuestStatus(OUTLANDS,GREETINGS_TO_THE_GUARDIAN);
Pamamas = player:getVar("PamamaVar");
pfame = player:getFameLevel(KAZHAM)
needToZone = player:needToZone();
if (Guardian == QUEST_ACCEPTED) then
if (Pamamas == 1) then
player:startEvent(0x0047); --Finish Quest
else
player:startEvent(0x0045,0,4596); --Reminder Dialogue
end
elseif (Guardian == QUEST_AVAILABLE and pfame >= 7) then
player:startEvent(0x0044,4596,4596,4596); --Start Quest
elseif (Guardian == QUEST_COMPLETED and needToZone == false) then
if (Pamamas == 2) then
player:startEvent(0x0047); --Finish quest dialogue (no different csid between initial and repeats)
else
player:startEvent(0x0048); --Dialogue for after completion of quest
end
elseif (Guardian == QUEST_COMPLETED and needToZone == true) then
player:startEvent(0x0048);
else
player:startEvent(0x0054); --Standard Dialogue
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x0044 and option == 1) then
player:addQuest(OUTLANDS,GREETINGS_TO_THE_GUARDIAN);
player:setVar("PamamaVar",0);
elseif (csid == 0x0047) then
if (Pamamas == 1) then --First completion of quest; set title, complete quest, and give higher fame
player:addGil(GIL_RATE*5000);
player:messageSpecial(GIL_OBTAINED, 5000);
player:completeQuest(OUTLANDS,GREETINGS_TO_THE_GUARDIAN);
player:addFame(WINDURST,WIN_FAME*100);
player:addTitle(KAZHAM_CALLER);
player:setVar("PamamaVar",0);
player:needToZone(true);
elseif (Pamamas == 2) then --Repeats of quest; give only gil and less fame
player:addGil(GIL_RATE*5000);
player:messageSpecial(GIL_OBTAINED, 5000);
player:addFame(WINDURST,WIN_FAME*30);
player:setVar("PamamaVar",0);
player:needToZone(true);
end
end
end;
| gpl-3.0 |
AlexandreCA/darkstar | scripts/zones/Lower_Jeuno/npcs/_l02.lua | 13 | 1556 | -----------------------------------
-- Area: Lower Jeuno
-- NPC: Streetlamp
-- Involved in Quests: Community Service
-- @zone 245
-- @pos -89.022 -0 -123.317
-----------------------------------
package.loaded["scripts/zones/Lower_Jeuno/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/quests");
require("scripts/zones/Lower_Jeuno/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local hour = VanadielHour();
if (hour >= 18 and hour < 21) then
if (player:getQuestStatus(JEUNO,COMMUNITY_SERVICE) == QUEST_ACCEPTED) then
if (player:getVar("cService") == 9) then
player:setVar("cService",10);
end
elseif (hour >= 18 and hour < 21) then
if (player:getQuestStatus(JEUNO,COMMUNITY_SERVICE) == QUEST_COMPLETED) then
if (player:getVar("cService") == 22) then
player:setVar("cService",23);
end
end
end
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end; | gpl-3.0 |
AlexandreCA/update | scripts/zones/Dynamis-Xarcabard/mobs/Animated_Dagger.lua | 16 | 1481 | -----------------------------------
-- Area: Dynamis Xarcabard
-- NPC: Animated Dagger
-----------------------------------
require("scripts/globals/status");
require("scripts/zones/Dynamis-Xarcabard/TextIDs");
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
if (mob:AnimationSub() == 3) then
SetDropRate(103,1572,1000);
else
SetDropRate(103,1572,0);
end
target:showText(mob,ANIMATED_DAGGER_DIALOG);
SpawnMob(17330306,120):updateEnmity(target);
SpawnMob(17330307,120):updateEnmity(target);
SpawnMob(17330308,120):updateEnmity(target);
SpawnMob(17330316,120):updateEnmity(target);
SpawnMob(17330317,120):updateEnmity(target);
SpawnMob(17330318,120):updateEnmity(target);
end;
-----------------------------------
-- onMobFight Action
-----------------------------------
function onMobFight(mob,target)
-- TODO: add battle dialog
end;
-----------------------------------
-- onMobDisengage
-----------------------------------
function onMobDisengage(mob)
mob:showText(mob,ANIMATED_DAGGER_DIALOG+2);
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob,killer)
killer:showText(mob,ANIMATED_DAGGER_DIALOG+1);
DespawnMob(17330306);
DespawnMob(17330307);
DespawnMob(17330308);
DespawnMob(17330316);
DespawnMob(17330317);
DespawnMob(17330318);
end; | gpl-3.0 |
AlexandreCA/darkstar | scripts/zones/Lower_Jeuno/npcs/Adelflete.lua | 13 | 1374 | -----------------------------------
-- Area: Lower Jeuno
-- NPC: Adelflete
-- Standard Merchant NPC
-----------------------------------
require("scripts/globals/shop");
package.loaded["scripts/zones/Lower_Jeuno/TextIDs"] = nil;
require("scripts/zones/Lower_Jeuno/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,ADELFLETE_SHOP_DIALOG);
stock = {0x0326,1863, -- Tourmaline
0x0327,1863, -- Sardonyx
0x0320,1863, -- Amethyst
0x032E,1863, -- Amber
0x031B,1863, -- Lapis Lazuli
0x0329,1863, -- Clear Topaz
0x031F,1863, -- Onyx
0x031C,1863, -- Light Opal
0x340F,1250, -- Silver Earring
0x3490,1250} -- Silver Ring
showShop(player, STATIC, stock);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
KAISER1350/KAISER | plugins/inrealm.lua | 850 | 25085 | -- data saved to moderation.json
-- check moderation plugin
do
local function create_group(msg)
-- superuser and admins only (because sudo are always has privilege)
if is_sudo(msg) or is_realm(msg) and is_admin(msg) then
local group_creator = msg.from.print_name
create_group_chat (group_creator, group_name, ok_cb, false)
return 'Group [ '..string.gsub(group_name, '_', ' ')..' ] has been created.'
end
end
local function create_realm(msg)
-- superuser and admins only (because sudo are always has privilege)
if is_sudo(msg) or is_realm(msg) and is_admin(msg) then
local group_creator = msg.from.print_name
create_group_chat (group_creator, group_name, ok_cb, false)
return 'Realm [ '..string.gsub(group_name, '_', ' ')..' ] has been created.'
end
end
local function killchat(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function killrealm(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function get_group_type(msg)
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
if not data[tostring(msg.to.id)]['group_type'] then
return 'No group type available.'
end
local group_type = data[tostring(msg.to.id)]['group_type']
return group_type
else
return 'Chat type not found.'
end
end
local function callbackres(extra, success, result)
--vardump(result)
local user = result.id
local name = string.gsub(result.print_name, "_", " ")
local chat = 'chat#id'..extra.chatid
send_large_msg(chat, user..'\n'..name)
return user
end
local function set_description(msg, data, target, about)
if not is_admin(msg) then
return "For admins only!"
end
local data_cat = 'description'
data[tostring(target)][data_cat] = about
save_data(_config.moderation.data, data)
return 'Set group description to:\n'..about
end
local function set_rules(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local data_cat = 'rules'
data[tostring(target)][data_cat] = rules
save_data(_config.moderation.data, data)
return 'Set group rules to:\n'..rules
end
-- lock/unlock group name. bot automatically change group name when locked
local function lock_group_name(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'yes' then
return 'Group name is already locked'
else
data[tostring(target)]['settings']['lock_name'] = 'yes'
save_data(_config.moderation.data, data)
rename_chat('chat#id'..target, group_name_set, ok_cb, false)
return 'Group name has been locked'
end
end
local function unlock_group_name(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'no' then
return 'Group name is already unlocked'
else
data[tostring(target)]['settings']['lock_name'] = 'no'
save_data(_config.moderation.data, data)
return 'Group name has been unlocked'
end
end
--lock/unlock group member. bot automatically kick new added user when locked
local function lock_group_member(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'yes' then
return 'Group members are already locked'
else
data[tostring(target)]['settings']['lock_member'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Group members has been locked'
end
local function unlock_group_member(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'no' then
return 'Group members are not locked'
else
data[tostring(target)]['settings']['lock_member'] = 'no'
save_data(_config.moderation.data, data)
return 'Group members has been unlocked'
end
end
--lock/unlock group photo. bot automatically keep group photo when locked
local function lock_group_photo(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_photo_lock = data[tostring(target)]['settings']['lock_photo']
if group_photo_lock == 'yes' then
return 'Group photo is already locked'
else
data[tostring(target)]['settings']['set_photo'] = 'waiting'
save_data(_config.moderation.data, data)
end
return 'Please send me the group photo now'
end
local function unlock_group_photo(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_photo_lock = data[tostring(target)]['settings']['lock_photo']
if group_photo_lock == 'no' then
return 'Group photo is not locked'
else
data[tostring(target)]['settings']['lock_photo'] = 'no'
save_data(_config.moderation.data, data)
return 'Group photo has been unlocked'
end
end
local function lock_group_flood(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'yes' then
return 'Group flood is locked'
else
data[tostring(target)]['settings']['flood'] = 'yes'
save_data(_config.moderation.data, data)
return 'Group flood has been locked'
end
end
local function unlock_group_flood(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'no' then
return 'Group flood is not locked'
else
data[tostring(target)]['settings']['flood'] = 'no'
save_data(_config.moderation.data, data)
return 'Group flood has been unlocked'
end
end
-- show group settings
local function show_group_settings(msg, data, target)
local data = load_data(_config.moderation.data, data)
if not is_admin(msg) then
return "For admins only!"
end
local settings = data[tostring(target)]['settings']
local text = "Group settings:\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member
return text
end
local function returnids(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..''
for k,v in pairs(result.members) do
if v.print_name then
local username = ""
text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n"
end
end
send_large_msg(receiver, text)
local file = io.open("./groups/lists/"..result.id.."memberlist.txt", "w")
file:write(text)
file:flush()
file:close()
end
local function returnidsfile(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..''
for k,v in pairs(result.members) do
if v.print_name then
local username = ""
text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n"
end
end
local file = io.open("./groups/lists/"..result.id.."memberlist.txt", "w")
file:write(text)
file:flush()
file:close()
send_document("chat#id"..result.id,"./groups/lists/"..result.id.."memberlist.txt", ok_cb, false)
end
local function admin_promote(msg, admin_id)
if not is_sudo(msg) then
return "Access denied!"
end
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
if data[tostring(admins)][tostring(admin_id)] then
return admin_name..' is already an admin.'
end
data[tostring(admins)][tostring(admin_id)] = admin_id
save_data(_config.moderation.data, data)
return admin_id..' has been promoted as admin.'
end
local function admin_demote(msg, admin_id)
if not is_sudo(msg) then
return "Access denied!"
end
local data = load_data(_config.moderation.data)
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
if not data[tostring(admins)][tostring(admin_id)] then
return admin_id..' is not an admin.'
end
data[tostring(admins)][tostring(admin_id)] = nil
save_data(_config.moderation.data, data)
return admin_id..' has been demoted from admin.'
end
local function admin_list(msg)
local data = load_data(_config.moderation.data)
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
local message = 'List for Realm admins:\n'
for k,v in pairs(data[tostring(admins)]) do
message = message .. '- (at)' .. v .. ' [' .. k .. '] ' ..'\n'
end
return message
end
local function groups_list(msg)
local data = load_data(_config.moderation.data)
local groups = 'groups'
if not data[tostring(groups)] then
return 'No groups at the moment'
end
local message = 'List of groups:\n'
for k,v in pairs(data[tostring(groups)]) do
local settings = data[tostring(v)]['settings']
for m,n in pairs(settings) do
if m == 'set_name' then
name = n
end
end
local group_owner = "No owner"
if data[tostring(v)]['set_owner'] then
group_owner = tostring(data[tostring(v)]['set_owner'])
end
local group_link = "No link"
if data[tostring(v)]['settings']['set_link'] then
group_link = data[tostring(v)]['settings']['set_link']
end
message = message .. '- '.. name .. ' (' .. v .. ') ['..group_owner..'] \n {'..group_link.."}\n"
end
local file = io.open("./groups/lists/groups.txt", "w")
file:write(message)
file:flush()
file:close()
return message
end
local function realms_list(msg)
local data = load_data(_config.moderation.data)
local realms = 'realms'
if not data[tostring(realms)] then
return 'No Realms at the moment'
end
local message = 'List of Realms:\n'
for k,v in pairs(data[tostring(realms)]) do
local settings = data[tostring(v)]['settings']
for m,n in pairs(settings) do
if m == 'set_name' then
name = n
end
end
local group_owner = "No owner"
if data[tostring(v)]['admins_in'] then
group_owner = tostring(data[tostring(v)]['admins_in'])
end
local group_link = "No link"
if data[tostring(v)]['settings']['set_link'] then
group_link = data[tostring(v)]['settings']['set_link']
end
message = message .. '- '.. name .. ' (' .. v .. ') ['..group_owner..'] \n {'..group_link.."}\n"
end
local file = io.open("./groups/lists/realms.txt", "w")
file:write(message)
file:flush()
file:close()
return message
end
local function admin_user_promote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
if not data['admins'] then
data['admins'] = {}
save_data(_config.moderation.data, data)
end
if data['admins'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is already as admin.')
end
data['admins'][tostring(member_id)] = member_username
save_data(_config.moderation.data, data)
return send_large_msg(receiver, '@'..member_username..' has been promoted as admin.')
end
local function admin_user_demote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
if not data['admins'] then
data['admins'] = {}
save_data(_config.moderation.data, data)
end
if not data['admins'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is not an admin.')
end
data['admins'][tostring(member_id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Admin '..member_username..' has been demoted.')
end
local function username_id(cb_extra, success, result)
local mod_cmd = cb_extra.mod_cmd
local receiver = cb_extra.receiver
local member = cb_extra.member
local text = 'No user @'..member..' in this group.'
for k,v in pairs(result.members) do
vusername = v.username
if vusername == member then
member_username = member
member_id = v.id
if mod_cmd == 'addadmin' then
return admin_user_promote(receiver, member_username, member_id)
elseif mod_cmd == 'removeadmin' then
return admin_user_demote(receiver, member_username, member_id)
end
end
end
send_large_msg(receiver, text)
end
local function set_log_group(msg)
if not is_admin(msg) then
return
end
local log_group = data[tostring(groups)][tostring(msg.to.id)]['log_group']
if log_group == 'yes' then
return 'Log group is already set'
else
data[tostring(groups)][tostring(msg.to.id)]['log_group'] = 'yes'
save_data(_config.moderation.data, data)
return 'Log group has been set'
end
end
local function unset_log_group(msg)
if not is_admin(msg) then
return
end
local log_group = data[tostring(groups)][tostring(msg.to.id)]['log_group']
if log_group == 'no' then
return 'Log group is already disabled'
else
data[tostring(groups)][tostring(msg.to.id)]['log_group'] = 'no'
save_data(_config.moderation.data, data)
return 'log group has been disabled'
end
end
local function help()
local help_text = tostring(_config.help_text_realm)
return help_text
end
function run(msg, matches)
--vardump(msg)
local name_log = user_print_name(msg.from)
if matches[1] == 'log' and is_owner(msg) then
savelog(msg.to.id, "log file created by owner")
send_document("chat#id"..msg.to.id,"./groups/"..msg.to.id.."log.txt", ok_cb, false)
end
if matches[1] == 'who' and is_momod(msg) then
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested member list ")
local receiver = get_receiver(msg)
chat_info(receiver, returnidsfile, {receiver=receiver})
end
if matches[1] == 'wholist' and is_momod(msg) then
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested member list in a file")
local receiver = get_receiver(msg)
chat_info(receiver, returnids, {receiver=receiver})
end
if matches[1] == 'creategroup' and matches[2] then
group_name = matches[2]
group_type = 'group'
return create_group(msg)
end
if not is_sudo(msg) or not is_admin(msg) and not is_realm(msg) then
return --Do nothing
end
if matches[1] == 'createrealm' and matches[2] then
group_name = matches[2]
group_type = 'realm'
return create_realm(msg)
end
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
if matches[2] then if data[tostring(matches[2])] then
local settings = data[tostring(matches[2])]['settings']
if matches[1] == 'setabout' and matches[2] then
local target = matches[2]
local about = matches[3]
return set_description(msg, data, target, about)
end
if matches[1] == 'setrules' then
rules = matches[3]
local target = matches[2]
return set_rules(msg, data, target)
end
if matches[1] == 'lock' then --group lock *
local target = matches[2]
if matches[3] == 'name' then
return lock_group_name(msg, data, target)
end
if matches[3] == 'member' then
return lock_group_member(msg, data, target)
end
if matches[3] == 'photo' then
return lock_group_photo(msg, data, target)
end
if matches[3] == 'flood' then
return lock_group_flood(msg, data, target)
end
end
if matches[1] == 'unlock' then --group unlock *
local target = matches[2]
if matches[3] == 'name' then
return unlock_group_name(msg, data, target)
end
if matches[3] == 'member' then
return unlock_group_member(msg, data, target)
end
if matches[3] == 'photo' then
return unlock_group_photo(msg, data, target)
end
if matches[3] == 'flood' then
return unlock_group_flood(msg, data, target)
end
end
if matches[1] == 'settings' and data[tostring(matches[2])]['settings'] then
local target = matches[2]
return show_group_settings(msg, data, target)
end
if matches[1] == 'setname' and is_realm(msg) then
local new_name = string.gsub(matches[2], '_', ' ')
data[tostring(msg.to.id)]['settings']['set_name'] = new_name
save_data(_config.moderation.data, data)
local group_name_set = data[tostring(msg.to.id)]['settings']['set_name']
local to_rename = 'chat#id'..msg.to.id
rename_chat(to_rename, group_name_set, ok_cb, false)
savelog(msg.to.id, "Realm { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]")
end
if matches[1] == 'setgpname' and is_admin(msg) then
local new_name = string.gsub(matches[3], '_', ' ')
data[tostring(matches[2])]['settings']['set_name'] = new_name
save_data(_config.moderation.data, data)
local group_name_set = data[tostring(matches[2])]['settings']['set_name']
local to_rename = 'chat#id'..matches[2]
rename_chat(to_rename, group_name_set, ok_cb, false)
savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]")
end
end
end
if matches[1] == 'help' and is_realm(msg) then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help")
return help()
end
if matches[1] == 'set' then
if matches[2] == 'loggroup' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set as log group")
return set_log_group(msg)
end
end
if matches[1] == 'kill' and matches[2] == 'chat' then
if not is_admin(msg) then
return nil
end
if is_realm(msg) then
local receiver = 'chat#id'..matches[3]
return modrem(msg),
print("Closing Group: "..receiver),
chat_info(receiver, killchat, {receiver=receiver})
else
return 'Error: Group '..matches[3]..' not found'
end
end
if matches[1] == 'kill' and matches[2] == 'realm' then
if not is_admin(msg) then
return nil
end
if is_realm(msg) then
local receiver = 'chat#id'..matches[3]
return realmrem(msg),
print("Closing realm: "..receiver),
chat_info(receiver, killrealm, {receiver=receiver})
else
return 'Error: Realm '..matches[3]..' not found'
end
end
if matches[1] == 'chat_add_user' then
if not msg.service then
return "Are you trying to troll me?"
end
local user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
if not is_admin(msg) then
chat_del_user(chat, user, ok_cb, true)
end
end
if matches[1] == 'addadmin' then
if string.match(matches[2], '^%d+$') then
local admin_id = matches[2]
print("user "..admin_id.." has been promoted as admin")
return admin_promote(msg, admin_id)
else
local member = string.gsub(matches[2], "@", "")
local mod_cmd = "addadmin"
chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member})
end
end
if matches[1] == 'removeadmin' then
if string.match(matches[2], '^%d+$') then
local admin_id = matches[2]
print("user "..admin_id.." has been demoted")
return admin_demote(msg, admin_id)
else
local member = string.gsub(matches[2], "@", "")
local mod_cmd = "removeadmin"
chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member})
end
end
if matches[1] == 'type'then
local group_type = get_group_type(msg)
return group_type
end
if matches[1] == 'list' and matches[2] == 'admins' then
return admin_list(msg)
end
if matches[1] == 'list' and matches[2] == 'groups' then
if msg.to.type == 'chat' then
groups_list(msg)
send_document("chat#id"..msg.to.id, "./groups/lists/groups.txt", ok_cb, false)
return "Group list created" --group_list(msg)
elseif msg.to.type == 'user' then
groups_list(msg)
send_document("user#id"..msg.from.id, "./groups/lists/groups.txt", ok_cb, false)
return "Group list created" --group_list(msg)
end
end
if matches[1] == 'list' and matches[2] == 'realms' then
if msg.to.type == 'chat' then
realms_list(msg)
send_document("chat#id"..msg.to.id, "./groups/lists/realms.txt", ok_cb, false)
return "Realms list created" --realms_list(msg)
elseif msg.to.type == 'user' then
realms_list(msg)
send_document("user#id"..msg.from.id, "./groups/lists/realms.txt", ok_cb, false)
return "Realms list created" --realms_list(msg)
end
end
if matches[1] == 'res' and is_momod(msg) then
local cbres_extra = {
chatid = msg.to.id
}
local username = matches[2]
local username = username:gsub("@","")
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /res "..username)
return res_user(username, callbackres, cbres_extra)
end
end
return {
patterns = {
"^[!/](creategroup) (.*)$",
"^[!/](createrealm) (.*)$",
"^[!/](setabout) (%d+) (.*)$",
"^[!/](setrules) (%d+) (.*)$",
"^[!/](setname) (.*)$",
"^[!/](setgpname) (%d+) (.*)$",
"^[!/](setname) (%d+) (.*)$",
"^[!/](lock) (%d+) (.*)$",
"^[!/](unlock) (%d+) (.*)$",
"^[!/](setting) (%d+)$",
"^[!/](wholist)$",
"^[!/](who)$",
"^[!/](type)$",
"^[!/](kill) (chat) (%d+)$",
"^[!/](kill) (realm) (%d+)$",
"^[!/](addadmin) (.*)$", -- sudoers only
"^[!/](removeadmin) (.*)$", -- sudoers only
"^[!/](list) (.*)$",
"^[!/](log)$",
"^[!/](help)$",
"^!!tgservice (.+)$",
},
run = run
}
end
| gpl-2.0 |
AlexandreCA/update | scripts/zones/Norg/npcs/Mamaulabion.lua | 17 | 7918 | -----------------------------------
-- Area: Norg
-- NPC: Mamaulabion
-- Starts and finishes Quest: Mama Mia
-- @zone 252
-- @pos -57 -9 68 (88)
--CSIDs for Mamaulabion
--0x005D / 93 = Standard
--0x00BF / 191 = start quest
--0x00C0 / 192 = quest accepted
--0x00C1 / 193 = given an item
--0x00C2 / 194 = given an item you already gave
--0x00C3 / 195 = all 7 items given
--0x00C4 / 196 = after 7 items, but need more time until reward is given
--0x00C5 / 197 = reward
--0x00C6 / 198 = after quest is complete
--0x00F3 / 243 = get new ring if you dropped yours
--I did alot of copy/pasting, so you may notice a reduncency on comments XD
--But it can make it easier to follow aswell.
--"Mamaulabion will inform you of the items delivered thus far, as of the May 2011 update."
--i have no clue where this event is, so i have no idea how to add this (if this gets scripted, please remove this comment)
--"Upon completion of this quest, the above items no longer appear in the rewards list for defeating the Prime Avatars."
--will require changing other avatar quests and making a variable for it all. (if this gets scripted, please remove this comment)
-----------------------------------
package.loaded["scripts/zones/Norg/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/quests");
require("scripts/zones/Norg/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:getQuestStatus(OUTLANDS,MAMA_MIA) == QUEST_ACCEPTED) then
local tradesMamaMia = player:getVar("tradesMamaMia")
if (trade:hasItemQty(1202,1) and trade:getItemCount() == 1) then -- Trade Bubbly water
wasSet = player:getMaskBit(tradesMamaMia,0)
tradesMamaMia = player:setMaskBit(tradesMamaMia,"tradesMamaMia",0,true)
if (player:isMaskFull(tradesMamaMia,7) == true) then
player:startEvent(0x00C3); -- Traded all seven items
elseif (wasSet) then
player:startEvent(0x00C2); -- Traded an item you already gave
else
player:startEvent(0x00C1); -- Traded an item
end
elseif (trade:hasItemQty(1203,1) and trade:getItemCount() == 1) then -- Trade Egil's torch
wasSet = player:getMaskBit(tradesMamaMia,1)
tradesMamaMia = player:setMaskBit(tradesMamaMia,"tradesMamaMia",1,true)
if (player:isMaskFull(tradesMamaMia,7) == true) then
player:startEvent(0x00C3); -- Traded all seven items
elseif (wasSet) then
player:startEvent(0x00C2); -- Traded an item you already gave
else
player:startEvent(0x00C1); -- Traded an item
end
elseif (trade:hasItemQty(1204,1) and trade:getItemCount() == 1) then -- Trade Eye of mept
wasSet = player:getMaskBit(tradesMamaMia,2)
tradesMamaMia = player:setMaskBit(tradesMamaMia,"tradesMamaMia",2,true)
if (player:isMaskFull(tradesMamaMia,7) == true) then
player:startEvent(0x00C3); -- Traded all seven items
elseif (wasSet) then
player:startEvent(0x00C2); -- Traded an item you already gave
else
player:startEvent(0x00C1); -- Traded an item
end
elseif (trade:hasItemQty(1205,1) and trade:getItemCount() == 1) then -- Trade Desert Light
wasSet = player:getMaskBit(tradesMamaMia,3)
tradesMamaMia = player:setMaskBit(tradesMamaMia,"tradesMamaMia",3,true)
if (player:isMaskFull(tradesMamaMia,7) == true) then
player:startEvent(0x00C3); -- Traded all seven items
elseif (wasSet) then
player:startEvent(0x00C2); -- Traded an item you already gave
else
player:startEvent(0x00C1); -- Traded an item
end
elseif (trade:hasItemQty(1206,1) and trade:getItemCount() == 1) then -- Trade Elder Branch
wasSet = player:getMaskBit(tradesMamaMia,4)
tradesMamaMia = player:setMaskBit(tradesMamaMia,"tradesMamaMia",4,true)
if (player:isMaskFull(tradesMamaMia,7) == true) then
player:startEvent(0x00C3); -- Traded all seven items
elseif (wasSet) then
player:startEvent(0x00C2); -- Traded an item you already gave
else
player:startEvent(0x00C1); -- Traded an item
end
elseif (trade:hasItemQty(1207,1) and trade:getItemCount() == 1) then -- Trade Rust 'B' Gone
wasSet = player:getMaskBit(tradesMamaMia,5)
tradesMamaMia = player:setMaskBit(tradesMamaMia,"tradesMamaMia",5,true)
if (player:isMaskFull(tradesMamaMia,7) == true) then
player:startEvent(0x00C3); -- Traded all seven items
elseif (wasSet) then
player:startEvent(0x00C2); -- Traded an item you already gave
else
player:startEvent(0x00C1); -- Traded an item
end
elseif (trade:hasItemQty(1208,1) and trade:getItemCount() == 1) then -- Trade Ancients' Key
wasSet = player:getMaskBit(tradesMamaMia,6)
tradesMamaMia = player:setMaskBit(tradesMamaMia,"tradesMamaMia",6,true)
if (player:isMaskFull(tradesMamaMia,7) == true) then
player:startEvent(0x00C3); -- Traded all seven items
elseif (wasSet) then
player:startEvent(0x00C2); -- Traded an item you already gave
else
player:startEvent(0x00C1); -- Traded an item
end
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local MamaMia = player:getQuestStatus(OUTLANDS,MAMA_MIA);
local moonlitPath = player:getQuestStatus(WINDURST,THE_MOONLIT_PATH);
local EvokersRing = player:hasItem(14625);
local realday = tonumber(os.date("%j")); -- %M for next minute, %j for next day
local questday = player:getVar("MamaMia_date")
if (MamaMia == QUEST_AVAILABLE and player:getFameLevel(NORG) >= 4 and moonlitPath == QUEST_COMPLETED) then
player:startEvent(0x00BF); -- Start Quest "Mama Mia"
elseif (MamaMia == QUEST_ACCEPTED) then
local tradesMamaMia = player:getVar("tradesMamaMia")
local maskFull = player:isMaskFull(tradesMamaMia,7)
if (maskFull) then
if (realday == questday) then
player:startEvent(0x00C4); --need to wait longer for reward
elseif (questday ~= 0) then
player:startEvent(0x00C5); --Reward
end
else
player:startEvent(0x00C0); -- During Quest "Mama Mia"
end
elseif (MamaMia == QUEST_COMPLETED and EvokersRing) then
player:startEvent(0x00C6); -- New standard dialog after "Mama Mia" is complete
elseif (MamaMia == QUEST_COMPLETED and EvokersRing == false) then
player:startEvent(0x00F3); -- Quest completed, but dropped ring
else
player:startEvent(0x005D); -- 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 == 0x00BF) then
player:addQuest(OUTLANDS,MAMA_MIA);
elseif (csid == 0x00C1) then
player:tradeComplete();
elseif (csid == 0x00C3) then
player:tradeComplete();
player:setVar("MamaMia_date", os.date("%j")); -- %M for next minute, %j for next day
elseif (csid == 0x00C5) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,14625); -- Evokers Ring
else
player:addItem(14625); -- Evokers Ring
player:messageSpecial(ITEM_OBTAINED,14625); -- Evokers Ring
player:addFame(OUTLANDS,NORG_FAME*30); --idk how much fame the quest adds, just left at 30 which the levi quest gave.
player:completeQuest(OUTLANDS,MAMA_MIA);
player:setVar("tradesMamaMia",0)
end
elseif (csid == 0x00F3) then
if (option == 1) then
player:delQuest(OUTLANDS,MAMA_MIA);
player:addQuest(OUTLANDS,MAMA_MIA);
end
end
end; | gpl-3.0 |
zhoukk/skynet | service/launcher.lua | 51 | 3199 | local skynet = require "skynet"
local core = require "skynet.core"
require "skynet.manager" -- import manager apis
local string = string
local services = {}
local command = {}
local instance = {} -- for confirm (function command.LAUNCH / command.ERROR / command.LAUNCHOK)
local function handle_to_address(handle)
return tonumber("0x" .. string.sub(handle , 2))
end
local NORET = {}
function command.LIST()
local list = {}
for k,v in pairs(services) do
list[skynet.address(k)] = v
end
return list
end
function command.STAT()
local list = {}
for k,v in pairs(services) do
local stat = skynet.call(k,"debug","STAT")
list[skynet.address(k)] = stat
end
return list
end
function command.KILL(_, handle)
handle = handle_to_address(handle)
skynet.kill(handle)
local ret = { [skynet.address(handle)] = tostring(services[handle]) }
services[handle] = nil
return ret
end
function command.MEM()
local list = {}
for k,v in pairs(services) do
local kb, bytes = skynet.call(k,"debug","MEM")
list[skynet.address(k)] = string.format("%.2f Kb (%s)",kb,v)
end
return list
end
function command.GC()
for k,v in pairs(services) do
skynet.send(k,"debug","GC")
end
return command.MEM()
end
function command.REMOVE(_, handle, kill)
services[handle] = nil
local response = instance[handle]
if response then
-- instance is dead
response(not kill) -- return nil to caller of newservice, when kill == false
instance[handle] = nil
end
-- don't return (skynet.ret) because the handle may exit
return NORET
end
local function launch_service(service, ...)
local param = table.concat({...}, " ")
local inst = skynet.launch(service, param)
local response = skynet.response()
if inst then
services[inst] = service .. " " .. param
instance[inst] = response
else
response(false)
return
end
return inst
end
function command.LAUNCH(_, service, ...)
launch_service(service, ...)
return NORET
end
function command.LOGLAUNCH(_, service, ...)
local inst = launch_service(service, ...)
if inst then
core.command("LOGON", skynet.address(inst))
end
return NORET
end
function command.ERROR(address)
-- see serivce-src/service_lua.c
-- init failed
local response = instance[address]
if response then
response(false)
instance[address] = nil
end
services[address] = nil
return NORET
end
function command.LAUNCHOK(address)
-- init notice
local response = instance[address]
if response then
response(true, address)
instance[address] = nil
end
return NORET
end
-- for historical reasons, launcher support text command (for C service)
skynet.register_protocol {
name = "text",
id = skynet.PTYPE_TEXT,
unpack = skynet.tostring,
dispatch = function(session, address , cmd)
if cmd == "" then
command.LAUNCHOK(address)
elseif cmd == "ERROR" then
command.ERROR(address)
else
error ("Invalid text command " .. cmd)
end
end,
}
skynet.dispatch("lua", function(session, address, cmd , ...)
cmd = string.upper(cmd)
local f = command[cmd]
if f then
local ret = f(address, ...)
if ret ~= NORET then
skynet.ret(skynet.pack(ret))
end
else
skynet.ret(skynet.pack {"Unknown command"} )
end
end)
skynet.start(function() end)
| mit |
CMLL/wesnoth | data/lua/location_set.lua | 28 | 3736 | local location_set = {}
local function index(x, y)
-- the 2000 bias ensure that the correct x is recovered for negative y
return x * 16384 + y + 2000
end
local invscale = 1 / 16384
local function revindex(p)
local x = math.floor(p * invscale)
return x, p - x * 16384 - 2000
end
local methods = {}
local locset_meta = { __index = methods }
function methods:empty()
return (not next(self.values))
end
function methods:size()
local sz = 0
for p,v in pairs(self.values) do
sz = sz + 1
end
return sz
end
function methods:clear()
self.values = {}
end
function methods:get(x, y)
return self.values[index(x, y)]
end
function methods:insert(x, y, v)
self.values[index(x, y)] = v or true
end
function methods:remove(x, y)
self.values[index(x, y)] = nil
end
function methods:union(s)
local values = self.values
for p,v in pairs(s.values) do
values[p] = v
end
end
function methods:union_merge(s, f)
local values = self.values
for p,v in pairs(s.values) do
local x, y = revindex(p)
values[p] = f(x, y, values[p], v)
end
end
function methods:inter(s)
local values = self.values
local nvalues = {}
for p,v in pairs(s.values) do
nvalues[p] = values[p]
end
self.values = nvalues
end
function methods:inter_merge(s, f)
local values = s.values
local nvalues = {}
for p,v in pairs(self.values) do
local x, y = revindex(p)
nvalues[p] = f(x, y, v, values[p])
end
self.values = nvalues
end
function methods:filter(f)
local nvalues = {}
for p,v in pairs(self.values) do
local x, y = revindex(p)
if f(x, y, v) then nvalues[p] = v end
end
return setmetatable({ values = nvalues }, locset_meta)
end
function methods:iter(f)
for p,v in pairs(self.values) do
local x, y = revindex(p)
f(x, y, v)
end
end
function methods:stable_iter(f)
local indices = {}
for p,v in pairs(self.values) do
table.insert(indices, p)
end
table.sort(indices)
for i,p in ipairs(indices) do
local x, y = revindex(p)
f(x, y)
end
end
function methods:of_pairs(t)
local values = self.values
for i,v in ipairs(t) do
local value_table = {}
local x_index
local y_index
if v.x and v.y then
x_index = "x"
y_index = "y"
else
x_index = 1
y_index = 2
end
for k,val in pairs(v) do
if k ~= x_index and k ~= y_index then
value_table[k] = val
end
end
if next(value_table) then
values[index(v[x_index], v[y_index])] = value_table
else
values[index(v[x_index], v[y_index])] = true
end
end
end
function methods:of_wml_var(name)
local values = self.values
for i = 0, wesnoth.get_variable(name .. ".length") - 1 do
local t = wesnoth.get_variable(string.format("%s[%d]", name, i))
local x, y = t.x, t.y
t.x, t.y = nil, nil
values[index(x, y)] = next(t) and t or true
end
end
function methods:to_pairs()
local res = {}
self:iter(function(x, y) table.insert(res, { x, y }) end)
return res
end
function methods:to_stable_pairs()
local res = {}
self:stable_iter(function(x, y) table.insert(res, { x, y }) end)
return res
end
function methods:to_wml_var(name)
local i = 0
wesnoth.set_variable(name)
self:stable_iter(function(x, y, v)
if type(v) == 'table' then
wesnoth.set_variable(string.format("%s[%d]", name, i), v)
end
wesnoth.set_variable(string.format("%s[%d].x", name, i), x)
wesnoth.set_variable(string.format("%s[%d].y", name, i), y)
i = i + 1
end)
end
function location_set.create()
local w,h,b = wesnoth.get_map_size()
assert(h + 2 * b < 9000)
return setmetatable({ values = {} }, locset_meta)
end
function location_set.of_pairs(t)
local s = location_set.create()
s:of_pairs(t)
return s
end
function location_set.of_wml_var(name)
local s = location_set.create()
s:of_wml_var(name)
return s
end
return location_set
| gpl-2.0 |
JiessieDawn/skynet | lualib/skynet/datasheet/dump.lua | 20 | 6547 | --[[ file format
document :
int32 strtbloffset
int32 n
int32*n index table
table*n
strings
table:
int32 array
int32 dict
int8*(array+dict) type (align 4)
value*array
kvpair*dict
kvpair:
string k
value v
value: (union)
int32 integer
float real
int32 boolean
int32 table index
int32 string offset
type: (enum)
0 nil
1 integer
2 real
3 boolean
4 table
5 string
]]
local ctd = {}
local math = math
local table = table
local string = string
function ctd.dump(root)
local doc = {
table_n = 0,
table = {},
strings = {},
offset = 0,
}
local function dump_table(t)
local index = doc.table_n + 1
doc.table_n = index
doc.table[index] = false -- place holder
local array_n = 0
local array = {}
local kvs = {}
local types = {}
local function encode(v)
local t = type(v)
if t == "table" then
local index = dump_table(v)
return '\4', string.pack("<i4", index-1)
elseif t == "number" then
if math.tointeger(v) and v <= 0x7FFFFFFF and v >= -(0x7FFFFFFF+1) then
return '\1', string.pack("<i4", v)
else
return '\2', string.pack("<f",v)
end
elseif t == "boolean" then
if v then
return '\3', "\0\0\0\1"
else
return '\3', "\0\0\0\0"
end
elseif t == "string" then
local offset = doc.strings[v]
if not offset then
offset = doc.offset
doc.offset = offset + #v + 1
doc.strings[v] = offset
table.insert(doc.strings, v)
end
return '\5', string.pack("<I4", offset)
else
error ("Unsupport value " .. tostring(v))
end
end
for i,v in ipairs(t) do
types[i], array[i] = encode(v)
array_n = i
end
for k,v in pairs(t) do
if type(k) == "string" then
local _, kv = encode(k)
local tv, ev = encode(v)
table.insert(types, tv)
table.insert(kvs, kv .. ev)
else
local ik = math.tointeger(k)
assert(ik and ik > 0 and ik <= array_n)
end
end
-- encode table
local typeset = table.concat(types)
local align = string.rep("\0", (4 - #typeset & 3) & 3)
local tmp = {
string.pack("<i4i4", array_n, #kvs),
typeset,
align,
table.concat(array),
table.concat(kvs),
}
doc.table[index] = table.concat(tmp)
return index
end
dump_table(root)
-- encode document
local index = {}
local offset = 0
for i, v in ipairs(doc.table) do
index[i] = string.pack("<I4", offset)
offset = offset + #v
end
local tmp = {
string.pack("<I4", 4 + 4 + 4 * doc.table_n + offset),
string.pack("<I4", doc.table_n),
table.concat(index),
table.concat(doc.table),
table.concat(doc.strings, "\0"),
"\0",
}
return table.concat(tmp)
end
function ctd.undump(v)
local stringtbl, n = string.unpack("<I4I4",v)
local index = { string.unpack("<" .. string.rep("I4", n), v, 9) }
local header = 4 + 4 + 4 * n + 1
stringtbl = stringtbl + 1
local tblidx = {}
local function decode(n)
local toffset = index[n+1] + header
local array, dict = string.unpack("<I4I4", v, toffset)
local types = { string.unpack(string.rep("B", (array+dict)), v, toffset + 8) }
local offset = ((array + dict + 8 + 3) & ~3) + toffset
local result = {}
local function value(t)
local off = offset
offset = offset + 4
if t == 1 then -- integer
return (string.unpack("<i4", v, off))
elseif t == 2 then -- float
return (string.unpack("<f", v, off))
elseif t == 3 then -- boolean
return string.unpack("<i4", v, off) ~= 0
elseif t == 4 then -- table
local tindex = (string.unpack("<I4", v, off))
return decode(tindex)
elseif t == 5 then -- string
local sindex = string.unpack("<I4", v, off)
return (string.unpack("z", v, stringtbl + sindex))
else
error (string.format("Invalid data at %d (%d)", off, t))
end
end
for i=1,array do
table.insert(result, value(types[i]))
end
for i=1,dict do
local sindex = string.unpack("<I4", v, offset)
offset = offset + 4
local key = string.unpack("z", v, stringtbl + sindex)
result[key] = value(types[array + i])
end
tblidx[result] = n
return result
end
return decode(0), tblidx
end
local function diffmap(last, current)
local lastv, lasti = ctd.undump(last)
local curv, curi = ctd.undump(current)
local map = {} -- new(current index):old(last index)
local function comp(lastr, curr)
local old = lasti[lastr]
local new = curi[curr]
map[new] = old
for k,v in pairs(lastr) do
if type(v) == "table" then
local newv = curr[k]
if type(newv) == "table" then
comp(v, newv)
end
end
end
end
comp(lastv, curv)
return map
end
function ctd.diff(last, current)
local map = diffmap(last, current)
local stringtbl, n = string.unpack("<I4I4",current)
local _, lastn = string.unpack("<I4I4",last)
local existn = 0
for k,v in pairs(map) do
existn = existn + 1
end
local newn = lastn
for i = 0, n-1 do
if not map[i] then
map[i] = newn
newn = newn + 1
end
end
-- remap current
local index = { string.unpack("<" .. string.rep("I4", n), current, 9) }
local header = 4 + 4 + 4 * n + 1
local function remap(n)
local toffset = index[n+1] + header
local array, dict = string.unpack("<I4I4", current, toffset)
local types = { string.unpack(string.rep("B", (array+dict)), current, toffset + 8) }
local hlen = (array + dict + 8 + 3) & ~3
local hastable = false
for _, v in ipairs(types) do
if v == 4 then -- table
hastable = true
break
end
end
if not hastable then
return string.sub(current, toffset, toffset + hlen + (array + dict * 2) * 4 - 1)
end
local offset = hlen + toffset
local pat = "<" .. string.rep("I4", array + dict * 2)
local values = { string.unpack(pat, current, offset) }
for i = 1, array do
if types[i] == 4 then -- table
values[i] = map[values[i]]
end
end
for i = 1, dict do
if types[i + array] == 4 then -- table
values[array + i * 2] = map[values[array + i * 2]]
end
end
return string.sub(current, toffset, toffset + hlen - 1) ..
string.pack(pat, table.unpack(values))
end
-- rebuild
local oldindex = { string.unpack("<" .. string.rep("I4", n), current, 9) }
local index = {}
for i = 1, newn do
index[i] = 0xffffffff
end
for i = 0, #map do
index[map[i]+1] = oldindex[i+1]
end
local tmp = {
string.pack("<I4I4", stringtbl + (newn - n) * 4, newn), -- expand index table
string.pack("<" .. string.rep("I4", newn), table.unpack(index)),
}
for i = 0, n - 1 do
table.insert(tmp, remap(i))
end
table.insert(tmp, string.sub(current, stringtbl+1))
return table.concat(tmp)
end
return ctd
| mit |
boundary/luvit | tests/test-fs-append-file-sync.lua | 6 | 3333 | --[[
Copyright 2012 The Luvit Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License")
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--]]
require("helper")
local FS = require('fs')
local join = require('path').join
local Buffer = require('buffer').Buffer
local currentFileData = 'ABCD'
local num = 220
local data = '南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、' ..
'广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。' ..
'南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。' ..
'前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,' ..
'南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,' ..
'历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,' ..
'它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n'
-- test that empty file will be created and have content added
local filename = join(__dirname, 'fixtures', 'append-sync.txt')
p('appending to ' .. filename)
FS.appendFileSync(filename, data)
local fileData = FS.readFileSync(filename)
assert(fileData == data)
-- test that appends data to a non empty file
local filename2 = join(__dirname, 'fixtures', 'append-sync2.txt')
FS.writeFileSync(filename2, currentFileData)
-- local currentFileData2 = FS.readFileSync(filename2)
-- p('currentFileData2 == ' .. currentFileData2)
-- assert(currentFileData2 == currentFileData)
p('appending to ' .. filename2)
FS.appendFileSync(filename2, data)
local fileData2 = FS.readFileSync(filename2)
-- TODO: fix assertion error here on OSX.
assert(#fileData2 == #currentFileData + #data)
-- test that appendFileSync accepts buffers
local filename3 = join(__dirname, 'fixtures', 'append-sync3.txt')
FS.writeFileSync(filename3, currentFileData)
p('appending to ' .. filename3)
local buf = Buffer:new(data)
FS.appendFileSync(filename3, buf)
local fileData3 = FS.readFileSync(filename3)
assert(#fileData3 == buf.length + #currentFileData)
-- test that appendFile accepts numbers.
local filename4 = join(__dirname, 'fixtures', 'append-sync4.txt')
FS.writeFileSync(filename4, currentFileData)
p('appending to ' .. filename4)
FS.appendFileSync(filename4, num)
local fileData4 = FS.readFileSync(filename4)
assert(#fileData4 == #tostring(num) + #currentFileData)
--exit logic for cleanup
process:on('exit', function()
p('done')
FS.unlinkSync(filename)
FS.unlinkSync(filename2)
FS.unlinkSync(filename3)
FS.unlinkSync(filename4)
end)
| apache-2.0 |
AlexandreCA/darkstar | scripts/zones/Al_Zahbi/npcs/Chayaya.lua | 13 | 1644 | -----------------------------------
-- Area: Al Zahbi
-- NPC: Chayaya
-- Standard Merchant NPC
-----------------------------------
package.loaded["scripts/zones/Al_Zahbi/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/shop");
require("scripts/zones/Al_Zahbi/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,CHAYAYA_SHOP_DIALOG);
stock = {0x439B,10, --Dart
0x439C,60, --Hawkeye
0x43A1,1204, --Grenade
0x43A8,8, --Iron Arrow
0x1565,68000, --Warrior Die
0x1566,22400, --Monk Die
0x1567,5000, --White Mage Die
0x1568,108000, --Black Mage Die
0x1569,62000, --Red Mage Die
0x156A,50400, --Thief Die
0x156B,90750, --Paladin Die
0x156C,2205, --Dark Knight Die
0x156D,26600, --Beastmaster Die
0x156E,12780, --Bard Die
0x156F,1300, --Ranger Die
0x1577,63375, --Dancer Die
0x1578,68250} --Scholar Die
showShop(player, STATIC, stock);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
paly2/minetest-minetestforfun-server | mods/homedecor_modpack/itemframes/init.lua | 9 | 9746 | local tmp = {}
itemframes = {}
screwdriver = screwdriver or {}
minetest.register_entity("itemframes:item",{
hp_max = 1,
visual="wielditem",
visual_size={x=.33,y=.33},
collisionbox = {0,0,0,0,0,0},
physical=false,
textures={"air"},
on_activate = function(self, staticdata)
if tmp.nodename ~= nil and tmp.texture ~= nil then
self.nodename = tmp.nodename
tmp.nodename = nil
self.texture = tmp.texture
tmp.texture = nil
else
if staticdata ~= nil and staticdata ~= "" then
local data = staticdata:split(';')
if data and data[1] and data[2] then
self.nodename = data[1]
self.texture = data[2]
end
end
end
if self.texture ~= nil then
self.object:set_properties({textures={self.texture}})
end
if self.nodename ~= "itemframes:frame" then
self.object:set_properties({automatic_rotate=1})
end
end,
get_staticdata = function(self)
if self.nodename ~= nil and self.texture ~= nil then
return self.nodename .. ';' .. self.texture
end
return ""
end,
})
local facedir = {}
facedir[0] = {x=0,y=0,z=1}
facedir[1] = {x=1,y=0,z=0}
facedir[2] = {x=0,y=0,z=-1}
facedir[3] = {x=-1,y=0,z=0}
local remove_item = function(pos, node)
local objs = nil
if node.name == "itemframes:frame" then
objs = minetest.get_objects_inside_radius(pos, .5)
elseif minetest.get_item_group(node.name, "group:pedestal") then
objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y+1,z=pos.z}, .5)
end
if objs then
for _, obj in ipairs(objs) do
if obj and obj:get_luaentity() and obj:get_luaentity().name == "itemframes:item" then
obj:remove()
end
end
end
end
local update_item = function(pos, node)
remove_item(pos, node)
local meta = minetest.get_meta(pos)
if meta:get_string("item") ~= "" then
if node.name == "itemframes:frame" then
local posad = facedir[node.param2]
if not posad then return end
pos.x = pos.x + posad.x*6.5/16
pos.y = pos.y + posad.y*6.5/16
pos.z = pos.z + posad.z*6.5/16
elseif minetest.get_item_group(node.name, "group:pedestal") then
pos.y = pos.y + 12/16+.33
end
tmp.nodename = node.name
tmp.texture = ItemStack(meta:get_string("item")):get_name()
local e = minetest.add_entity(pos,"itemframes:item")
if node.name == "itemframes:frame" then
local yaw = math.pi*2 - node.param2 * math.pi/2
e:setyaw(yaw)
end
end
end
local drop_item = function(pos, node)
local meta = minetest.get_meta(pos)
if meta:get_string("item") ~= "" then
if node.name == "itemframes:frame" then
minetest.add_item(pos, meta:get_string("item"))
elseif minetest.get_item_group(node.name, "group:pedestal") then
minetest.add_item({x=pos.x,y=pos.y+1,z=pos.z}, meta:get_string("item"))
end
meta:set_string("item","")
end
remove_item(pos, node)
end
minetest.register_node("itemframes:frame",{
description = "Item frame",
drawtype = "nodebox",
node_box = { type = "fixed", fixed = {-0.5, -0.5, 7/16, 0.5, 0.5, 0.5} },
selection_box = { type = "fixed", fixed = {-0.5, -0.5, 7/16, 0.5, 0.5, 0.5} },
tiles = {"itemframes_frame.png"},
inventory_image = "itemframes_frame.png",
wield_image = "itemframes_frame.png",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = { choppy=2,dig_immediate=2 },
legacy_wallmounted = true,
sounds = default.node_sound_defaults(),
on_rotate = screwdriver.disallow,
after_place_node = function(pos, placer, itemstack)
local meta = minetest.get_meta(pos)
meta:set_string("owner",placer:get_player_name())
meta:set_string("infotext","Item frame (owned by "..placer:get_player_name()..")")
end,
on_rightclick = function(pos, node, clicker, itemstack)
if not itemstack then return end
local meta = minetest.get_meta(pos)
if clicker:get_player_name() == meta:get_string("owner") then
drop_item(pos,node)
local s = itemstack:take_item()
meta:set_string("item",s:to_string())
update_item(pos,node)
end
return itemstack
end,
on_punch = function(pos,node,puncher)
local meta = minetest.get_meta(pos)
if puncher:get_player_name() == meta:get_string("owner") then
drop_item(pos, node)
end
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos)
return player:get_player_name() == meta:get_string("owner")
end,
after_destruct = remove_item,
})
function itemframes.register_pedestal(subname, recipeitem, groups, images, description, sounds)
minetest.register_node("itemframes:pedestal_" .. subname, {
description = description,
drawtype = "nodebox",
tiles = images,
node_box = { type = "fixed", fixed = {
{-7/16, -8/16, -7/16, 7/16, -7/16, 7/16}, -- bottom plate
{-6/16, -7/16, -6/16, 6/16, -6/16, 6/16}, -- bottom plate (upper)
{-0.25, -6/16, -0.25, 0.25, 11/16, 0.25}, -- pillar
{-7/16, 11/16, -7/16, 7/16, 12/16, 7/16}, -- top plate
}},
--selection_box = { type = "fixed", fixed = {-7/16, -0.5, -7/16, 7/16, 12/16, 7/16} },
groups = groups,
sounds = sounds,
paramtype = "light",
groups = { cracky=3 },
sounds = default.node_sound_defaults(),
on_rotate = screwdriver.disallow,
after_place_node = function(pos, placer, itemstack)
local meta = minetest.get_meta(pos)
meta:set_string("owner",placer:get_player_name())
meta:set_string("infotext","Pedestal (owned by "..placer:get_player_name()..")")
end,
on_rightclick = function(pos, node, clicker, itemstack)
if not itemstack then return end
local meta = minetest.get_meta(pos)
if clicker:get_player_name() == meta:get_string("owner") then
drop_item(pos,node)
local s = itemstack:take_item()
meta:set_string("item",s:to_string())
update_item(pos,node)
end
return itemstack
end,
on_punch = function(pos,node,puncher)
local meta = minetest.get_meta(pos)
if puncher:get_player_name() == meta:get_string("owner") then
drop_item(pos,node)
end
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos)
return player:get_player_name() == meta:get_string("owner")
end,
after_destruct = remove_item,
})
minetest.register_craft({
output = 'itemframes:pedestal_' .. subname,
recipe = {
{recipeitem, recipeitem, recipeitem},
{'', recipeitem, ''},
{recipeitem, recipeitem, recipeitem},
}
})
end
itemframes.register_pedestal("wood", "default:wood",
{snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3,pedestal=1},
{"default_wood.png"},
"Wooden Pedestal",
default.node_sound_wood_defaults()
)
itemframes.register_pedestal("junglewood", "default:junglewood",
{snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3,pedestal=1},
{"default_junglewood.png"},
"Jungle wood Pedestal",
default.node_sound_wood_defaults()
)
itemframes.register_pedestal("obsidian", "default:obsidian",
{cracky=1,level=2,pedestal=1},
{"default_obsidian.png"},
"Obsidian Pedestal",
default.node_sound_stone_defaults()
)
itemframes.register_pedestal("cloud", "default:cloud",
{cracky=1,level=2,not_in_creative_inventory=1,pedestal=1},
{"default_cloud.png"},
"Cloud Pedestal",
default.node_sound_defaults()
)
itemframes.register_pedestal("stone", "default:stone",
{cracky=3,pedestal=1},
{"default_stone.png"},
"Stone Pedestal",
default.node_sound_stone_defaults()
)
itemframes.register_pedestal("cobble", "default:cobble",
{cracky=3,pedestal=1},
{"default_cobble.png"},
"Cobblestone Pedestal",
default.node_sound_stone_defaults()
)
itemframes.register_pedestal("desert_stone", "default:desert_stone",
{cracky=3,pedestal=1},
{"default_desert_stone.png"},
"Desert Stone Pedestal",
default.node_sound_stone_defaults()
)
itemframes.register_pedestal("desert_cobble", "default:desert_cobble",
{cracky=3,pedestal=1},
{"default_desert_cobble.png"},
"Desert Cobblestone Pedestal",
default.node_sound_stone_defaults()
)
itemframes.register_pedestal("desert_stonebrick", "default:desert_stonebrick",
{cracky=3,pedestal=1},
{"default_desert_stone_brick.png"},
"Desert Stone Brick Pedestal",
default.node_sound_stone_defaults()
)
itemframes.register_pedestal("brick", "default:brick",
{cracky=3,pedestal=1},
{"default_brick.png"},
"Brick Pedestal",
default.node_sound_stone_defaults()
)
itemframes.register_pedestal("sandstone", "default:sandstone",
{crumbly=2,cracky=2,pedestal=1},
{"default_sandstone.png"},
"Sandstone Pedestal",
default.node_sound_stone_defaults()
)
itemframes.register_pedestal("sandstonebrick", "default:sandstonebrick",
{crumbly=2,cracky=2,pedestal=1},
{"default_sandstone_brick.png"},
"Sandstone Brick Pedestal",
default.node_sound_stone_defaults()
)
itemframes.register_pedestal("stonebrick", "default:stonebrick",
{cracky=3,pedestal=1},
{"default_stone_brick.png"},
"Stone Brick Pedestal",
default.node_sound_stone_defaults()
)
-- automatically restore entities lost from
-- frames/pedestals due to /clearobjects or similar
minetest.register_abm({
nodenames = {"itemframes:frame", "group:pedestal"},
interval = 15,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
if #minetest.get_objects_inside_radius(pos, 0.5) > 0 then return end
update_item(pos, node)
end
})
-- crafts
minetest.register_craft({
output = 'itemframes:frame',
recipe = {
{'default:stick', 'default:stick', 'default:stick'},
{'default:stick', 'default:paper', 'default:stick'},
{'default:stick', 'default:stick', 'default:stick'},
}
})
minetest.register_craft({
output = 'itemframes:pedestal',
recipe = {
{'default:stone', 'default:stone', 'default:stone'},
{'', 'default:stone', ''},
{'default:stone', 'default:stone', 'default:stone'},
}
})
-- homedecor/itemframes -> itemframes::stone
-- minetest.register_alias("itemframes:pedestal","itemframes:pedestal_stone")
-- itemframes::stone -> homedecor/itemframes
minetest.register_alias("itemframes:pedestal_stone","itemframes:pedestal")
| unlicense |
AlexandreCA/update | scripts/zones/Lower_Jeuno/npcs/Matoaka.lua | 37 | 1171 | -----------------------------------
-- Area: Lower Jeuno
-- NPC: Matoaka
-- Standard Merchant NPC
-----------------------------------
require("scripts/globals/shop");
package.loaded["scripts/zones/Lower_Jeuno/TextIDs"] = nil;
require("scripts/zones/Lower_Jeuno/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,MATOAKA_SHOP_DIALOG);
stock = {0x340F,1250, -- Silver Earring
0x3490,1250, -- Silver Ring
0x3410,4140} -- Mythril Earring
showShop(player, STATIC, stock);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
AlexandreCA/update | scripts/globals/items/rarab_meatball.lua | 35 | 1731 | -----------------------------------------
-- ID: 4507
-- Item: rarab_meatball
-- Food Effect: 180Min, All Races
-----------------------------------------
-- Health 10
-- Strength 2
-- Vitality 2
-- Intelligence -1
-- Attack % 30
-- Attack Cap 20
-- Ranged ATT % 30
-- Ranged ATT Cap 20
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,10800,4507);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 10);
target:addMod(MOD_STR, 2);
target:addMod(MOD_VIT, 2);
target:addMod(MOD_INT, -1);
target:addMod(MOD_FOOD_ATTP, 30);
target:addMod(MOD_FOOD_ATT_CAP, 20);
target:addMod(MOD_FOOD_RATTP, 30);
target:addMod(MOD_FOOD_RATT_CAP, 20);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 10);
target:delMod(MOD_STR, 2);
target:delMod(MOD_VIT, 2);
target:delMod(MOD_INT, -1);
target:delMod(MOD_FOOD_ATTP, 30);
target:delMod(MOD_FOOD_ATT_CAP, 20);
target:delMod(MOD_FOOD_RATTP, 30);
target:delMod(MOD_FOOD_RATT_CAP, 20);
end;
| gpl-3.0 |
kooiot/packages | net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/rule.lua | 80 | 4829 | -- ------ extra functions ------ --
function ruleCheck() -- determine if rules needs a proper protocol configured
uci.cursor():foreach("mwan3", "rule",
function (section)
local sourcePort = ut.trim(sys.exec("uci -p /var/state get mwan3." .. section[".name"] .. ".src_port"))
local destPort = ut.trim(sys.exec("uci -p /var/state get mwan3." .. section[".name"] .. ".dest_port"))
if sourcePort ~= "" or destPort ~= "" then -- ports configured
local protocol = ut.trim(sys.exec("uci -p /var/state get mwan3." .. section[".name"] .. ".proto"))
if protocol == "" or protocol == "all" then -- no or improper protocol
error_protocol_list = error_protocol_list .. section[".name"] .. " "
end
end
end
)
end
function ruleWarn() -- display warning messages at the top of the page
if error_protocol_list ~= " " then
return "<font color=\"ff0000\"><strong>WARNING: some rules have a port configured with no or improper protocol specified! Please configure a specific protocol!</strong></font>"
else
return ""
end
end
-- ------ rule configuration ------ --
dsp = require "luci.dispatcher"
sys = require "luci.sys"
ut = require "luci.util"
error_protocol_list = " "
ruleCheck()
m5 = Map("mwan3", translate("MWAN Rule Configuration"),
translate(ruleWarn()))
m5:append(Template("mwan/config_css"))
mwan_rule = m5:section(TypedSection, "rule", translate("Traffic Rules"),
translate("Rules specify which traffic will use a particular MWAN policy based on IP address, port or protocol<br />" ..
"Rules are matched from top to bottom. Rules below a matching rule are ignored. Traffic not matching any rule is routed using the main routing table<br />" ..
"Traffic destined for known (other than default) networks is handled by the main routing table. Traffic matching a rule, but all WAN interfaces for that policy are down will be blackholed<br />" ..
"Names may contain characters A-Z, a-z, 0-9, _ and no spaces<br />" ..
"Rules may not share the same name as configured interfaces, members or policies"))
mwan_rule.addremove = true
mwan_rule.anonymous = false
mwan_rule.dynamic = false
mwan_rule.sectionhead = "Rule"
mwan_rule.sortable = true
mwan_rule.template = "cbi/tblsection"
mwan_rule.extedit = dsp.build_url("admin", "network", "mwan", "configuration", "rule", "%s")
function mwan_rule.create(self, section)
TypedSection.create(self, section)
m5.uci:save("mwan3")
luci.http.redirect(dsp.build_url("admin", "network", "mwan", "configuration", "rule", section))
end
src_ip = mwan_rule:option(DummyValue, "src_ip", translate("Source address"))
src_ip.rawhtml = true
function src_ip.cfgvalue(self, s)
return self.map:get(s, "src_ip") or "—"
end
src_port = mwan_rule:option(DummyValue, "src_port", translate("Source port"))
src_port.rawhtml = true
function src_port.cfgvalue(self, s)
return self.map:get(s, "src_port") or "—"
end
dest_ip = mwan_rule:option(DummyValue, "dest_ip", translate("Destination address"))
dest_ip.rawhtml = true
function dest_ip.cfgvalue(self, s)
return self.map:get(s, "dest_ip") or "—"
end
dest_port = mwan_rule:option(DummyValue, "dest_port", translate("Destination port"))
dest_port.rawhtml = true
function dest_port.cfgvalue(self, s)
return self.map:get(s, "dest_port") or "—"
end
proto = mwan_rule:option(DummyValue, "proto", translate("Protocol"))
proto.rawhtml = true
function proto.cfgvalue(self, s)
return self.map:get(s, "proto") or "all"
end
sticky = mwan_rule:option(DummyValue, "sticky", translate("Sticky"))
sticky.rawhtml = true
function sticky.cfgvalue(self, s)
if self.map:get(s, "sticky") == "1" then
stickied = 1
return "Yes"
else
stickied = nil
return "No"
end
end
timeout = mwan_rule:option(DummyValue, "timeout", translate("Sticky timeout"))
timeout.rawhtml = true
function timeout.cfgvalue(self, s)
if stickied then
local timeoutValue = self.map:get(s, "timeout")
if timeoutValue then
return timeoutValue .. "s"
else
return "600s"
end
else
return "—"
end
end
ipset = mwan_rule:option(DummyValue, "ipset", translate("IPset"))
ipset.rawhtml = true
function ipset.cfgvalue(self, s)
return self.map:get(s, "ipset") or "—"
end
use_policy = mwan_rule:option(DummyValue, "use_policy", translate("Policy assigned"))
use_policy.rawhtml = true
function use_policy.cfgvalue(self, s)
return self.map:get(s, "use_policy") or "—"
end
errors = mwan_rule:option(DummyValue, "errors", translate("Errors"))
errors.rawhtml = true
function errors.cfgvalue(self, s)
if not string.find(error_protocol_list, " " .. s .. " ") then
return ""
else
return "<span title=\"No protocol specified\"><img src=\"/luci-static/resources/cbi/reset.gif\" alt=\"error\"></img></span>"
end
end
return m5
| gpl-2.0 |
AlexandreCA/update | scripts/zones/Western_Altepa_Desert/npcs/relic.lua | 38 | 1869 | -----------------------------------
-- Area: Western Altepa Desert
-- NPC: <this space intentionally left blank>
-- @pos -152 -16 20 125
-----------------------------------
package.loaded["scripts/zones/Western_Altepa_Desert/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Western_Altepa_Desert/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") == 18287 and trade:getItemCount() == 4 and trade:hasItemQty(18287,1) and
trade:hasItemQty(1575,1) and trade:hasItemQty(1589,1) and trade:hasItemQty(1451,1)) then
player:startEvent(205,18288);
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 == 205) then
if (player:getFreeSlotsCount() < 2) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,18288);
player:messageSpecial(FULL_INVENTORY_AFTER_TRADE,1450);
else
player:tradeComplete();
player:addItem(18288);
player:addItem(1450,30);
player:messageSpecial(ITEM_OBTAINED,18288);
player:messageSpecial(ITEMS_OBTAINED,1450,30);
player:setVar("RELIC_IN_PROGRESS",0);
end
end
end; | gpl-3.0 |
paly2/minetest-minetestforfun-server | minetestforfun_game/mods/farming/cotton.lua | 1 | 5686 | -- Cotton Seed
--minetest.register_craftitem("farming:seed_cotton", {
-- description = "Cotton Seed",
-- inventory_image = "farming_cotton_seed.png",
-- on_place = function(itemstack, placer, pointed_thing)
-- return farming.place_seed(itemstack, placer, pointed_thing, "farming:cotton_1")
-- end,
--})
minetest.register_node("farming:seed_cotton", {
description = "Cotton Seed",
tiles = {"farming_cotton_seed.png"},
inventory_image = "farming_cotton_seed.png",
wield_image = "farming_cotton_seed.png",
drawtype = "signlike",
groups = {seed = 1, snappy = 3, attached_node = 1},
paramtype = "light",
paramtype2 = "wallmounted",
walkable = false,
sunlight_propagates = true,
selection_box = {type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},},
on_place = function(itemstack, placer, pointed_thing)
return farming.place_seed(itemstack, placer, pointed_thing, "farming:cotton_1")
end,
})
-- Cotton
minetest.register_craftitem("farming:cotton", {
description = "Cotton",
inventory_image = "farming_cotton.png",
})
minetest.register_alias("farming:string", "farming:cotton")
-- String to Wool
minetest.register_craft({
output = "wool:white",
recipe = {
{"farming:string", "farming:string", "farming:string"},
{"farming:string", "farming:string", "farming:string"},
{"farming:string", "farming:string", "farming:string"},
-- ^ /MFF (Mg|05/26/2015)
}
})
-- Define Cotton growth stages
minetest.register_node("farming:cotton_1", {
drawtype = "plantlike",
tiles = {"farming_cotton_1.png"},
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
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:cotton_2", {
drawtype = "plantlike",
tiles = {"farming_cotton_2.png"},
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
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:cotton_3", {
drawtype = "plantlike",
tiles = {"farming_cotton_3.png"},
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
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:cotton_4", {
drawtype = "plantlike",
tiles = {"farming_cotton_4.png"},
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
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:cotton_5", {
drawtype = "plantlike",
tiles = {"farming_cotton_5.png"},
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = {
items = {
{items = {"farming:seed_cotton"},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:cotton_6", {
drawtype = "plantlike",
tiles = {"farming_cotton_6.png"},
paramtype = "light",
waving = 1,
walkable = false,
buildable_to = true,
drop = {
items = {
{items = {"farming:cotton"},rarity=1},
{items = {"farming:cotton"},rarity=2},
}
},
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:cotton_7", {
drawtype = "plantlike",
tiles = {"farming_cotton_7.png"},
paramtype = "light",
waving = 1,
walkable = false,
buildable_to = true,
drop = {
items = {
{items = {"farming:cotton"},rarity=1},
{items = {"farming:cotton"},rarity=2},
{items = {"farming:seed_cotton"},rarity=1},
{items = {"farming:seed_cotton"},rarity=2},
}
},
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(),
})
-- Define last stage of Cotton growth separate and without growing=1 so abm never has to check these
minetest.register_node("farming:cotton_8", {
drawtype = "plantlike",
tiles = {"farming_cotton_8.png"},
paramtype = "light",
waving = 1,
walkable = false,
buildable_to = true,
drop = {
items = {
{items = {"farming:string"},rarity=1},
{items = {"farming:string"},rarity=2},
{items = {"farming:string"},rarity=3},
{items = {"farming:seed_cotton"},rarity=1},
{items = {"farming:seed_cotton"},rarity=2},
{items = {"farming:seed_cotton"},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/zones/Selbina/npcs/Porter_Moogle.lua | 41 | 1520 | -----------------------------------
-- Area: Selbina
-- NPC: Porter Moogle
-- Type: Storage Moogle
-- @zone 248
-- @pos TODO
-----------------------------------
package.loaded["scripts/zones/Selbina/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Selbina/TextIDs");
require("scripts/globals/porter_moogle_util");
local e =
{
TALK_EVENT_ID = 1137,
STORE_EVENT_ID = 1138,
RETRIEVE_EVENT_ID = 1139,
ALREADY_STORED_ID = 1140,
MAGIAN_TRIAL_ID = 1141
};
-----------------------------------
-- 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 |
elfinlazz/melia | system/scripts/npc/field/f_remains_40.lua | 1 | 12065 | addnpc(20118, "QUEST_LV_0100_20150317_000640", "f_remains_40", -502, 304, -2059, 45, "npc_dummy")
addnpc(147473, "QUEST_LV_0100_20150317_000674", "f_remains_40", -242, 311, -1931, -37, "npc_dummy")
addnpc(20156, "QUEST_LV_0100_20150317_000666", "f_remains_40", -645, 304, -1898, 51, "npc_dummy")
addnpc(401641, "ETC_20150317_000246", "f_remains_40", 1330.021, 459.8437, 951.3546, 45, "npc_dummy")
addnpc(147500, "ETC_20150317_001211", "f_remains_40", 3541, 645, 2726, 45, "npc_dummy")
addnpc(47191, "QUEST_20150317_000161", "f_remains_40", -121, 642, -17, -2, "npc_dummy")
addnpc(47191, "QUEST_20150317_000161", "f_remains_40", 867, 596, -273, 47, "npc_dummy")
addnpc(47191, "QUEST_20150317_000161", "f_remains_40", 884, 459, 784, 31.87, "npc_dummy")
addnpc(47191, "QUEST_20150317_000161", "f_remains_40", 2168, 515, 1372, 131, "npc_dummy")
addnpc(47191, "QUEST_20150317_000161", "f_remains_40", 2419, 640, 3792, 2, "npc_dummy")
addnpc(47191, "QUEST_20150317_000168", "f_remains_40", 3660, 645, 2624, 57, "npc_dummy")
addnpc(147473, "QUEST_LV_0100_20150317_000674", "f_remains_40", 1723, 515, 1564, -33, "npc_dummy")
addnpc(20118, "QUEST_LV_0100_20150317_000640", "f_remains_40", 1791, 515, 1195, 45, "npc_dummy")
addnpc(20118, "QUEST_LV_0100_20150317_000640", "f_remains_40", 3016, 645, 2916, 45, "npc_dummy")
addnpc(46212, "ETC_20150317_009434", "f_remains_40", -1716, 340, -800, 134, "npc_dummy")
addnpc(46212, "ETC_20150317_009434", "f_remains_40", -1723, 340, -590, 134, "npc_dummy")
addnpc(46212, "ETC_20150317_009434", "f_remains_40", -1719, 340, -482, 134, "npc_dummy")
addnpc(46212, "ETC_20150317_009434", "f_remains_40", -1414, 340, -517, 134, "npc_dummy")
addnpc(46212, "ETC_20150317_009434", "f_remains_40", -1415, 303, -1087, 134, "npc_dummy")
addnpc(46212, "ETC_20150317_009434", "f_remains_40", -1288, 303, -924, 134, "npc_dummy")
addnpc(46212, "ETC_20150317_009434", "f_remains_40", -1495, 340, -577, 134, "npc_dummy")
addnpc(46212, "ETC_20150317_009434", "f_remains_40", -1042, 340, -768, 134, "npc_dummy")
addnpc(46212, "ETC_20150317_009434", "f_remains_40", -2036, 368, -55, 134, "npc_dummy")
addnpc(46212, "ETC_20150317_009434", "f_remains_40", -1847, 368, -164, 134, "npc_dummy")
addnpc(147449, "QUEST_LV_0100_20150317_000688", "f_remains_40", 3510, 645, 2864, -24.68, "npc_dummy")
addnpc(147366, "ETC_20150317_009233", "f_remains_40", -750.5983, 304.5279, -1727.427, 45, "npc_dummy")
addnpc(147366, "ETC_20150317_009233", "f_remains_40", -433.93, 304.53, -1933.04, 45, "npc_dummy")
addnpc(147366, "ETC_20150317_009233", "f_remains_40", -346.583, 304.5279, -2236.488, 45, "npc_dummy")
addnpc(20026, "ETC_20150317_009437", "f_remains_40", 1051.11, 459.46, 594.89, 45, "npc_dummy")
addnpc(20026, "ETC_20150317_009438", "f_remains_40", 2531.29, 640.27, 3537.32, 45, "npc_dummy")
addnpc(40030, "ETC_20150317_009134", "f_remains_40", -466, 557, 139, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -2087.71, 315.34, -2050.84, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1399.71, 459.53, 746.81, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -653.4018, 557.8442, -465.6677, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", 743.5562, 596.4629, -176.0281, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1846.71, 515.57, 1320.37, 45, "npc_dummy")
addnpc(40080, "QUEST_20150317_000344", "f_remains_40", -2412.68, 315.34, -1452.84, 61, "npc_dummy")
addnpc(147363, "ETC_20150317_009233", "f_remains_40", 1803.6, 515.57, 1196.19, 45, "npc_dummy")
addnpc(147363, "ETC_20150317_009233", "f_remains_40", 1707.659, 515.5719, 1609.589, 45, "npc_dummy")
addnpc(147363, "ETC_20150317_009233", "f_remains_40", 3002.19, 645.74, 2945.29, 45, "npc_dummy")
addnpc(147363, "ETC_20150317_009233", "f_remains_40", 3566.42, 645.74, 2757.88, 45, "npc_dummy")
addnpc(40034, "ETC_20150714_013175", "f_remains_40", 1420.628, 643.3027, 3287.514, 45, "npc_dummy")
addnpc(40034, "ETC_20150714_013175", "f_remains_40", 2203.432, 515.572, 1219.976, 45, "npc_dummy")
addnpc(40034, "ETC_20150714_013175", "f_remains_40", -282.4553, 642.7355, -47.10638, 45, "npc_dummy")
addnpc(40034, "ETC_20150714_013175", "f_remains_40", -2105.21, 315.3375, -3446.359, 45, "npc_dummy")
addnpc(147363, "ETC_20150317_009233", "f_remains_40", 95.11674, 304.5279, -2591.31, 45, "npc_dummy")
addnpc(147363, "ETC_20150317_009233", "f_remains_40", -2405.159, 315.3375, -1360.366, 45, "npc_dummy")
addnpc(147363, "ETC_20150317_009233", "f_remains_40", -60.88457, 304.5279, -2433.459, 45, "npc_dummy")
addnpc(154046, "ETC_20150918_014662", "f_remains_40", 3384.856, 645.7427, 2901.814, -66, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1133.523, 459.4843, 479.8851, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 970.6489, 459.4716, 837.2935, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1425.856, 461.4008, 996.2712, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1676.832, 459.4628, 617.7134, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1791.146, 459.4627, 455.9332, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 2017.997, 459.4627, 610.9912, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1738.998, 459.9403, 860.1713, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1821.686, 459.4627, 679.631, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1948.076, 515.5718, 1122.062, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1713.671, 494.4314, 1053.372, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1715.02, 515.1398, 1138.524, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1258.19, 459.4635, 1309.165, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1591.547, 515.572, 1577.397, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1935.196, 515.572, 1533.173, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 2199.527, 515.572, 1305.252, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1802.602, 515.572, 1538.115, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1490.361, 459.4656, 538.4852, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1202.702, 459.5653, 761.9217, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -2153.792, 315.3375, -1936.252, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -1955.986, 315.3375, -1976.257, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -2001.221, 315.3375, -2136.506, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -1961.109, 315.3375, -2310.663, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -1968.537, 315.3375, -2523.733, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -1318.643, 345.5457, -546.3363, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -695.0215, 557.8442, -285.2332, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -605.64, 557.8442, -579.8836, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -617.6808, 557.8442, -153.5167, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -576.8416, 557.8442, 58.44336, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", 589.3121, 596.4629, -152.8512, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", 400.1012, 596.4629, -149.99, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", 703.0059, 596.4629, -361.5214, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", 895.3282, 596.4629, -461.1287, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", 812.5447, 596.4629, -61.27752, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", 809.8452, 596.463, -306.2185, 45, "npc_dummy")
addnpc(147392, "ETC_20150317_009100", "f_remains_40", -1601.49, 315.44, -3954.92, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -1818.324, 315.3375, -1903.278, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -1766.588, 315.3375, -1816.246, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -1663.847, 315.3375, -1860.109, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -1534.838, 315.3375, -1731.072, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -1497.901, 315.3375, -1805.214, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -1362.623, 315.3375, -1686.876, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", -1681.846, 340.2782, -822.9921, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", -1616.614, 340.2781, -686.6024, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", -1405.943, 340.278, -584.1658, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", -1442.217, 335.9158, -798.7303, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", -1459.224, 312.1803, -873.7049, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", -1435.908, 303.9873, -1005.704, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", -1198.333, 304.366, -926.0526, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", -1255.284, 303.9874, -1098.59, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", -1110.053, 304.1509, -1114.78, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", -1065.692, 304.1204, -965.2524, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", -946.9504, 303.9969, -961.2765, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", -1178.321, 303.9874, -1032.214, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", -1385.351, 340.278, -512.2852, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", -1497.153, 340.2779, -638.2158, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -1077.002, 457.3865, -591.2832, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -783.3957, 557.8443, -527.3703, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -730.9686, 557.8442, -145.5934, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -616.9066, 558.724, -13.48719, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", -733.1245, 557.8442, -371.938, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", 525.1501, 596.4629, -219.9666, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", 672.4518, 596.4629, -56.5371, 45, "npc_dummy")
addnpc(401261, "ETC_20150317_000206", "f_remains_40", 664.8098, 596.4629, -207.0731, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1308.96, 459.4954, 492.5458, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 956.9093, 459.4793, 635.7855, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1215.804, 462.4191, 1052.295, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1524.957, 460.4449, 815.9131, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1665.492, 459.4627, 422.3934, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1913.531, 461.5689, 902.9942, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1619.097, 510.0102, 1241.455, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 1518.582, 515.1982, 1389.236, 45, "npc_dummy")
addnpc(41281, "ETC_20150317_000470", "f_remains_40", 2032.25, 515.572, 1237.551, 45, "npc_dummy")
addnpc(154046, "ETC_20151224_017833", "f_remains_40", 3119.771, 645.7427, 2675.378, 45, "npc_dummy")
| gpl-3.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.