repo_name
stringlengths
6
78
path
stringlengths
4
206
copies
stringclasses
281 values
size
stringlengths
4
7
content
stringlengths
625
1.05M
license
stringclasses
15 values
jshackley/darkstar
scripts/zones/Grand_Palace_of_HuXzoi/mobs/Eo_zdei.lua
8
2998
----------------------------------- -- Area: Grand Palace of Hu'Xzoi -- MOB: Eo'Zdei -- Animation Sub 0 Pot Form -- Animation Sub 1 Pot Form (reverse eye position) -- Animation Sub 2 Bar Form -- Animation Sub 3 Ring Form ----------------------------------- require("scripts/zones/Grand_Palace_of_HuXzoi/MobIDs"); require("scripts/globals/status"); ----------------------------------- -- OnMobSpawn Action -- Set AnimationSub to 0, put it in pot form ----------------------------------- function onMobSpawn(mob) mob:AnimationSub(0); onPath(mob); end; ----------------------------------- -- onPath Action ----------------------------------- function onPath(mob) local spawnPos = mob:getSpawnPos(); mob:pathThrough({spawnPos.x, spawnPos.y, spawnPos.z}); local pos = mob:getPos(); if (spawnPos.x == pos.x and spawnPos.z == pos.z) then mob:setPos(spawnPos.x, spawnPos.y, spawnPos.z, mob:getRotPos() + 16); end end; ----------------------------------- -- onMobFight Action -- Randomly change forms ----------------------------------- function onMobFight(mob) local randomTime = math.random(15,45); local changeTime = mob:getLocalVar("changeTime"); if (mob:AnimationSub() == 0 and mob:getBattleTime() - changeTime > randomTime) then mob:AnimationSub(math.random(2,3)); mob:setLocalVar("changeTime", mob:getBattleTime()); elseif (mob:AnimationSub() == 1 and mob:getBattleTime() - changeTime > randomTime) then mob:AnimationSub(math.random(2,3)); mob:setLocalVar("changeTime", mob:getBattleTime()); elseif (mob:AnimationSub() == 2 and mob:getBattleTime() - changeTime > randomTime) then local aniChance = math.random(0,1); if (aniChance == 0) then mob:AnimationSub(0); mob:setLocalVar("changeTime", mob:getBattleTime()); else mob:AnimationSub(3) mob:setLocalVar("changeTime", mob:getBattleTime()); end elseif (mob:AnimationSub() == 3 and mob:getBattleTime() - changeTime > randomTime) then mob:AnimationSub(math.random(0,2)); mob:setLocalVar("changeTime", mob:getBattleTime()); end end; ----------------------------------- -- onMobDeath Action -- Jailer of Temperance pop ----------------------------------- function onMobDeath(mob,killer,ally) local mobID = mob:getID(); local PH = GetServerVariable("[SEA]Jailer_of_Temperance_PH"); if (PH == mobID) then -- printf("%u is a PH",mobID); -- printf("JoT will pop"); -- We need to set Jailer of Temperance spawn point to where the PH spawns (The platform in the room). local mobSpawnPoint = GetMobByID(mobID):getSpawnPos(); GetMobByID(Jailer_of_Temperance):setSpawn(mobSpawnPoint.x, mobSpawnPoint.y, mobSpawnPoint.z); -- The jailer spawns instantly, so don't need to set respawn time SpawnMob(Jailer_of_Temperance,300):updateEnmity(killer); DeterMob(mobID, true); end end;
gpl-3.0
Ombridride/minetest-minetestforfun-server
mods/plantlife_modpack/nature_classic/global_function.lua
10
2479
-- helper functions local function process_blossom_queue_item() local pos = nature.blossomqueue[1][1] local node = nature.blossomqueue[1][2] local replace = nature.blossomqueue[1][3] if (nature.blossomqueue[1][3] == nature.blossom_node and not nature:is_near_water(pos)) then table.remove(nature.blossomqueue, 1) -- don't grow if it's not near water, pop from queue. return end nature:grow_node(pos, replace) -- now actually grow it. table.remove(nature.blossomqueue, 1) end minetest.register_globalstep(function(dtime) nature.dtime = dtime if #nature.blossomqueue > 0 and dtime < 0.2 then local i = 1 if dtime < 0.1 then i = i + 4 end if dtime < 0.05 then i = i + 10 end while #nature.blossomqueue > 0 and i > 0 do process_blossom_queue_item() i = i - 1 end end end) function nature.enqueue_node(pos, node, replace) local idx = #nature.blossomqueue if idx < nature.blossomqueue_max then local enqueue_prob = 0 if idx < nature.blossomqueue_max * 0.8 then enqueue_prob = 1 else -- Reduce queue growth as it gets closer to its max. enqueue_prob = 1 - (idx - nature.blossomqueue_max * 0.8) / (nature.blossomqueue_max * 0.2) end if enqueue_prob == 1 or math.random(100) <= 100 * enqueue_prob then nature.blossomqueue[idx+1] = {} nature.blossomqueue[idx+1][1] = pos nature.blossomqueue[idx+1][2] = node nature.blossomqueue[idx+1][3] = replace end end end local function set_young_node(pos) local meta = minetest.get_meta(pos) meta:set_int(nature.meta_blossom_time, minetest.get_gametime()) end local function is_not_young(pos) local meta = minetest.get_meta(pos) local blossom_time = meta:get_int(nature.meta_blossom_time) return not (blossom_time and minetest.get_gametime() - blossom_time < nature.blossom_duration) end function nature:grow_node(pos, nodename) if pos ~= nil then local light_enough = (minetest.get_node_light(pos, nil) or 0) >= nature.minimum_growth_light if is_not_young(pos) and light_enough then minetest.set_node(pos, { name = nodename }) set_young_node(pos) minetest.log("info", nodename .. " has grown at " .. pos.x .. "," .. pos.y .. "," .. pos.z) end end end function nature:is_near_water(pos) return nature.distance_from_water == -1 or minetest.find_node_near(pos, nature.distance_from_water, { "default:water_source" }) ~= nil end
unlicense
jshackley/darkstar
scripts/globals/items/dish_of_spaghetti_carbonara.lua
35
1821
----------------------------------------- -- ID: 5190 -- Item: dish_of_spaghetti_carbonara -- Food Effect: 30Min, All Races ----------------------------------------- -- Health % 14 -- Health Cap 175 -- Magic 10 -- Strength 4 -- Vitality 2 -- Intelligence -3 -- Attack % 18 -- Attack Cap 65 -- Store TP 6 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,1800,5190); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_FOOD_HPP, 14); target:addMod(MOD_FOOD_HP_CAP, 175); target:addMod(MOD_MP, 10); target:addMod(MOD_STR, 4); target:addMod(MOD_VIT, 2); target:addMod(MOD_INT, -3); target:addMod(MOD_FOOD_ATTP, 18); target:addMod(MOD_FOOD_ATT_CAP, 65); target:addMod(MOD_STORETP, 6); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_FOOD_HPP, 14); target:delMod(MOD_FOOD_HP_CAP, 175); target:delMod(MOD_MP, 10); target:delMod(MOD_STR, 4); target:delMod(MOD_VIT, 2); target:delMod(MOD_INT, -3); target:delMod(MOD_FOOD_ATTP, 18); target:delMod(MOD_FOOD_ATT_CAP, 65); target:delMod(MOD_STORETP, 6); end;
gpl-3.0
jshackley/darkstar
scripts/zones/Cloister_of_Storms/npcs/Lightning_Protocrystal.lua
17
1923
----------------------------------- -- Area: Cloister of Storms -- NPC: Lightning Protocrystal -- Involved in Quests: Trial by Lightning -- @pos 534.5 -13 492 202 ----------------------------------- package.loaded["scripts/zones/Cloister_of_Storms/TextIDs"] = nil; ------------------------------------- require("scripts/globals/keyitems"); require("scripts/globals/bcnm"); require("scripts/globals/quests"); require("scripts/globals/missions"); require("scripts/zones/Cloister_of_Storms/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 (player:getCurrentMission(ASA) == SUGAR_COATED_DIRECTIVE and player:getVar("ASA4_Violet") == 1) then player:startEvent(0x0002); elseif (EventTriggerBCNM(player,npc)) then return; else player:messageSpecial(PROTOCRYSTAL); 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 (csid==0x0002) then player:delKeyItem(DOMINAS_VIOLET_SEAL); player:addKeyItem(VIOLET_COUNTERSEAL); player:messageSpecial(KEYITEM_OBTAINED,VIOLET_COUNTERSEAL); player:setVar("ASA4_Violet","2"); elseif (EventFinishBCNM(player,csid,option)) then return; end end;
gpl-3.0
Victek/wrt1900ac-aa
veriksystems/luci-0.11/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua
6
8456
--[[ LuCI - Lua Configuration Interface Copyright 2008 Steven Barth <steven@midlink.org> 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 $Id: dhcp.lua 9623 2013-01-18 14:08:37Z jow $ ]]-- local sys = require "luci.sys" m = Map("dhcp", translate("DHCP and DNS"), translate("Dnsmasq is a combined <abbr title=\"Dynamic Host Configuration Protocol" .. "\">DHCP</abbr>-Server and <abbr title=\"Domain Name System\">DNS</abbr>-" .. "Forwarder for <abbr title=\"Network Address Translation\">NAT</abbr> " .. "firewalls")) s = m:section(TypedSection, "dnsmasq", translate("Server Settings")) s.anonymous = true s.addremove = false s:tab("general", translate("General Settings")) s:tab("files", translate("Resolv and Hosts Files")) s:tab("tftp", translate("TFTP Settings")) s:tab("advanced", translate("Advanced Settings")) s:taboption("general", Flag, "domainneeded", translate("Domain required"), translate("Don't forward <abbr title=\"Domain Name System\">DNS</abbr>-Requests without " .. "<abbr title=\"Domain Name System\">DNS</abbr>-Name")) s:taboption("general", Flag, "authoritative", translate("Authoritative"), translate("This is the only <abbr title=\"Dynamic Host Configuration Protocol\">DHCP</" .. "abbr> in the local network")) s:taboption("files", Flag, "readethers", translate("Use <code>/etc/ethers</code>"), translate("Read <code>/etc/ethers</code> to configure the <abbr title=\"Dynamic Host " .. "Configuration Protocol\">DHCP</abbr>-Server")) s:taboption("files", Value, "leasefile", translate("Leasefile"), translate("file where given <abbr title=\"Dynamic Host Configuration Protocol\">DHCP</" .. "abbr>-leases will be stored")) s:taboption("files", Flag, "noresolv", translate("Ignore resolve file")).optional = true rf = s:taboption("files", Value, "resolvfile", translate("Resolve file"), translate("local <abbr title=\"Domain Name System\">DNS</abbr> file")) rf:depends("noresolv", "") rf.optional = true s:taboption("files", Flag, "nohosts", translate("Ignore Hosts files")).optional = true hf = s:taboption("files", DynamicList, "addnhosts", translate("Additional Hosts files")) hf:depends("nohosts", "") hf.optional = true s:taboption("advanced", Flag, "boguspriv", translate("Filter private"), translate("Do not forward reverse lookups for local networks")) s:taboption("advanced", Flag, "filterwin2k", translate("Filter useless"), translate("Do not forward requests that cannot be answered by public name servers")) s:taboption("advanced", Flag, "localise_queries", translate("Localise queries"), translate("Localise hostname depending on the requesting subnet if multiple IPs are available")) s:taboption("general", Value, "local", translate("Local server"), translate("Local domain specification. Names matching this domain are never forwared and resolved from DHCP or hosts files only")) s:taboption("general", Value, "domain", translate("Local domain"), translate("Local domain suffix appended to DHCP names and hosts file entries")) s:taboption("advanced", Flag, "expandhosts", translate("Expand hosts"), translate("Add local domain suffix to names served from hosts files")) s:taboption("advanced", Flag, "nonegcache", translate("No negative cache"), translate("Do not cache negative replies, e.g. for not existing domains")) s:taboption("advanced", Flag, "strictorder", translate("Strict order"), translate("<abbr title=\"Domain Name System\">DNS</abbr> servers will be queried in the " .. "order of the resolvfile")).optional = true bn = s:taboption("advanced", DynamicList, "bogusnxdomain", translate("Bogus NX Domain Override"), translate("List of hosts that supply bogus NX domain results")) bn.optional = true bn.placeholder = "67.215.65.132" s:taboption("general", Flag, "logqueries", translate("Log queries"), translate("Write received DNS requests to syslog")).optional = true df = s:taboption("general", DynamicList, "server", translate("DNS forwardings"), translate("List of <abbr title=\"Domain Name System\">DNS</abbr> " .. "servers to forward requests to")) df.optional = true df.placeholder = "/example.org/10.1.2.3" rp = s:taboption("general", Flag, "rebind_protection", translate("Rebind protection"), translate("Discard upstream RFC1918 responses")) rp.rmempty = false rl = s:taboption("general", Flag, "rebind_localhost", translate("Allow localhost"), translate("Allow upstream responses in the 127.0.0.0/8 range, e.g. for RBL services")) rl:depends("rebind_protection", "1") rd = s:taboption("general", DynamicList, "rebind_domain", translate("Domain whitelist"), translate("List of domains to allow RFC1918 responses for")) rd:depends("rebind_protection", "1") rd.datatype = "host" rd.placeholder = "ihost.netflix.com" pt = s:taboption("advanced", Value, "port", translate("<abbr title=\"Domain Name System\">DNS</abbr> server port"), translate("Listening port for inbound DNS queries")) pt.optional = true pt.datatype = "port" pt.placeholder = 53 qp = s:taboption("advanced", Value, "queryport", translate("<abbr title=\"Domain Name System\">DNS</abbr> query port"), translate("Fixed source port for outbound DNS queries")) qp.optional = true qp.datatype = "port" qp.placeholder = translate("any") lm = s:taboption("advanced", Value, "dhcpleasemax", translate("<abbr title=\"maximal\">Max.</abbr> <abbr title=\"Dynamic Host Configuration " .. "Protocol\">DHCP</abbr> leases"), translate("Maximum allowed number of active DHCP leases")) lm.optional = true lm.datatype = "uinteger" lm.placeholder = translate("unlimited") em = s:taboption("advanced", Value, "ednspacket_max", translate("<abbr title=\"maximal\">Max.</abbr> <abbr title=\"Extension Mechanisms for " .. "Domain Name System\">EDNS0</abbr> packet size"), translate("Maximum allowed size of EDNS.0 UDP packets")) em.optional = true em.datatype = "uinteger" em.placeholder = 1280 cq = s:taboption("advanced", Value, "dnsforwardmax", translate("<abbr title=\"maximal\">Max.</abbr> concurrent queries"), translate("Maximum allowed number of concurrent DNS queries")) cq.optional = true cq.datatype = "uinteger" cq.placeholder = 150 s:taboption("tftp", Flag, "enable_tftp", translate("Enable TFTP server")).optional = true tr = s:taboption("tftp", Value, "tftp_root", translate("TFTP server root"), translate("Root directory for files served via TFTP")) tr.optional = true tr:depends("enable_tftp", "1") tr.placeholder = "/" db = s:taboption("tftp", Value, "dhcp_boot", translate("Network boot image"), translate("Filename of the boot image advertised to clients")) db.optional = true db:depends("enable_tftp", "1") db.placeholder = "pxelinux.0" m:section(SimpleSection).template = "admin_network/lease_status" s = m:section(TypedSection, "host", translate("Static Leases"), translate("Static leases are used to assign fixed IP addresses and symbolic hostnames to " .. "DHCP clients. They are also required for non-dynamic interface configurations where " .. "only hosts with a corresponding lease are served.") .. "<br />" .. translate("Use the <em>Add</em> Button to add a new lease entry. The <em>MAC-Address</em> " .. "indentifies the host, the <em>IPv4-Address</em> specifies to the fixed address to " .. "use and the <em>Hostname</em> is assigned as symbolic name to the requesting host.")) s.addremove = true s.anonymous = true s.template = "cbi/tblsection" name = s:option(Value, "name", translate("Hostname")) name.datatype = "hostname" name.rmempty = true mac = s:option(Value, "mac", translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address")) mac.datatype = "list(macaddr)" mac.rmempty = true ip = s:option(Value, "ip", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Address")) ip.datatype = "ip4addr" sys.net.arptable(function(entry) ip:value(entry["IP address"]) mac:value( entry["HW address"], entry["HW address"] .. " (" .. entry["IP address"] .. ")" ) end) function ip.validate(self, value, section) local m = mac:formvalue(section) or "" local n = name:formvalue(section) or "" if value and #n == 0 and #m == 0 then return nil, translate("One of hostname or mac address must be specified!") end return Value.validate(self, value, section) end return m
gpl-2.0
jshackley/darkstar
scripts/zones/Port_San_dOria/npcs/Nazar.lua
19
1269
----------------------------------- -- Area: Port San d'Oria -- NPC: Nazar -- Type: Standard NPC ----------------------------------- package.loaded["scripts/zones/Port_San_dOria/TextIDs"] = nil; require("scripts/zones/Port_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local vHour = VanadielHour(); local vMin = VanadielMinute(); while vHour >= 3 do vHour = vHour - 6; end if ( vHour == -3) then vHour = 3; elseif ( vHour == -2) then vHour = 4; elseif ( vHour == -1) then vHour = 5; end local seconds = math.floor(2.4 * ((vHour * 60) + vMin)); player:startEvent( 0x02BF, seconds, 0, 0, 0, 0, 0, 0, 0); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
gpl-3.0
hacker44-h44/h44bot
plugins/channels.lua
300
1680
-- Checks if bot was disabled on specific chat local function is_channel_disabled( receiver ) if not _config.disabled_channels then return false end if _config.disabled_channels[receiver] == nil then return false end return _config.disabled_channels[receiver] end local function enable_channel(receiver) if not _config.disabled_channels then _config.disabled_channels = {} end if _config.disabled_channels[receiver] == nil then return 'Channel isn\'t disabled' end _config.disabled_channels[receiver] = false save_config() return "Channel re-enabled" end local function disable_channel( receiver ) if not _config.disabled_channels then _config.disabled_channels = {} end _config.disabled_channels[receiver] = true save_config() return "Channel disabled" end local function pre_process(msg) local receiver = get_receiver(msg) -- If sender is sudo then re-enable the channel if is_sudo(msg) then if msg.text == "!channel enable" then enable_channel(receiver) end end if is_channel_disabled(receiver) then msg.text = "" end return msg end local function run(msg, matches) local receiver = get_receiver(msg) -- Enable a channel if matches[1] == 'enable' then return enable_channel(receiver) end -- Disable a channel if matches[1] == 'disable' then return disable_channel(receiver) end end return { description = "Plugin to manage channels. Enable or disable channel.", usage = { "!channel enable: enable current channel", "!channel disable: disable current channel" }, patterns = { "^!channel? (enable)", "^!channel? (disable)" }, run = run, privileged = true, pre_process = pre_process }
gpl-2.0
jshackley/darkstar
scripts/zones/AlTaieu/mobs/Jailer_of_Love.lua
7
5586
----------------------------------- -- Area: Al'Taieu -- NM: Jailer of Love ----------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) end; ----------------------------------- -- onMobEngaged ----------------------------------- function onMobEngaged(mob, target) mob:hideName(false); mob:untargetable(false); mob:AnimationSub(2); end; ----------------------------------- -- onMobFight Action ----------------------------------- function onMobFight(mob, target) -- Only 9 Qn'xzomit and 9 Qn'hpemde can be summoned. Ru'phuabo (Sharks) are unlimited. local XZOMITS = mob:getLocalVar("JoL_Qn_xzomit_Killed"); local HPEMDES = mob:getLocalVar("JoL_Qn_hpemde_Killed"); -- Increment these by 1 each time they are slain, in that mobs onMobDeath() script. if (mob:getLocalVar("JoL_Regen_Reduction") == 0) then if (mob:getLocalVar("JoL_Qn_xzomit_Killed") == 9 and mob:getLocalVar("JoL_Qn_hpemde_Killed") == 9) then mob:setLocalVar("JoL_Regen_Reduction", 1); mob:addMod(MOD_REGEN, -260) end end local lastPop = mob:getLocalVar("pop_pets"); if (os.time() - lastPop > 150) then local SPAWNS = mob:getLocalVar("SPAWNS"); local phuabo1 = GetMobAction(16912849); local phuabo2 = GetMobAction(16912852); local phuabo3 = GetMobAction(16912855); if (SPAWNS == 0) then -- Spawns first 3 xzomit SpawnMob(16912858, 300):updateEnmity(target); SpawnMob(16912859, 300):updateEnmity(target); SpawnMob(16912860, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); mob:setLocalVar("SPAWNS", 1); elseif (SPAWNS == 1) then -- spawns first 3 hpemde SpawnMob(16912867, 300):updateEnmity(target); SpawnMob(16912868, 300):updateEnmity(target); SpawnMob(16912869, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); mob:setLocalVar("SPAWNS", 2); elseif (SPAWNS == 2) then -- spawns first 3 phuabo SpawnMob(16912849, 300):updateEnmity(target); SpawnMob(16912850, 300):updateEnmity(target); SpawnMob(16912851, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); mob:setLocalVar("SPAWNS", 3); elseif (SPAWNS == 3) then -- Spawns second 3 xzomit SpawnMob(16912861, 300):updateEnmity(target); SpawnMob(16912862, 300):updateEnmity(target); SpawnMob(16912863, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); mob:setLocalVar("SPAWNS", 4); elseif (SPAWNS == 4) then -- spawns second 3 hpemde SpawnMob(16912870, 300):updateEnmity(target); SpawnMob(16912871, 300):updateEnmity(target); SpawnMob(16912872, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); mob:setLocalVar("SPAWNS", 5); elseif (SPAWNS == 5) then -- spawns second 3 phuabo SpawnMob(16912852, 300):updateEnmity(target); SpawnMob(16912853, 300):updateEnmity(target); SpawnMob(16912854, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); mob:setLocalVar("SPAWNS", 6); elseif (SPAWNS == 6) then -- Spawns last 3 xzomit SpawnMob(16912864, 300):updateEnmity(target); SpawnMob(16912865, 300):updateEnmity(target); SpawnMob(16912866, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); mob:setLocalVar("SPAWNS", 7); elseif (SPAWNS == 7) then -- spawns last 3 hpemde SpawnMob(16912873, 300):updateEnmity(target); SpawnMob(16912874, 300):updateEnmity(target); SpawnMob(16912875, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); mob:setLocalVar("SPAWNS", 8); elseif (SPAWNS >= 8) then -- switch to ONLY popping phuabo (still up to 3 at a time) if (phuabo1 == ACTION_NONE or phuabo1 == ACTION_SPAWN) then SpawnMob(16912849, 300):updateEnmity(target); SpawnMob(16912850, 300):updateEnmity(target); SpawnMob(16912851, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); elseif (phuabo2 == ACTION_NONE or phuabo2 == ACTION_SPAWN) then SpawnMob(16912852, 300):updateEnmity(target); SpawnMob(16912853, 300):updateEnmity(target); SpawnMob(16912854, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); elseif (phuabo3 == ACTION_NONE or phuabo3 == ACTION_SPAWN) then SpawnMob(16912855, 300):updateEnmity(target); SpawnMob(16912856, 300):updateEnmity(target); SpawnMob(16912857, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); end end end end; ----------------------------------- -- onMobDespawn ----------------------------------- function onMobDespawn(mob) end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob, killer, ally) local AV_CHANCE = 25; if (AV_CHANCE > math.random(0,99)) then SpawnMob(16912876, 180); end end;
gpl-3.0
jshackley/darkstar
scripts/zones/Attohwa_Chasm/mobs/Alastor_Antlion.lua
1
1888
----------------------------------- -- Area: Attohwa Chasm -- NPC: Alastor Antlion ----------------------------------- require("scripts/globals/titles"); require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------- -- onMobInitialize Action ----------------------------------- function onMobInitialize(mob) mob:setMobMod(MOBMOD_ADD_EFFECT,mob:getShortID()); mob:setMobMod(MOBMOD_GA_CHANCE,50); mob:setMobMod(MOBMOD_MUG_GIL,10000); mob:addMod(MOD_FASTCAST,10); mob:addMod(MOD_BINDRES,40); mob:addMod(MOD_SILENCERES,40); end; ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) mob:setTP(100); end; ----------------------------------- -- onMobEngaged ----------------------------------- function onMobEngaged(mob, killer) mob:useMobAbility(22); -- Pit Ambush end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob, killer, ally) end; ----------------------------------- -- onAdditionalEffect ----------------------------------- function onAdditionalEffect(mob, player) local chance = 25; local resist = applyResistanceAddEffect(mob,player,ELE_EARTH,EFFECT_PETRIFICATION); if (math.random(0,99) >= chance or resist <= 0.5) then return 0,0,0; else local duration = 30; if (mob:getMainLvl() > player:getMainLvl()) then duration = duration + (mob:getMainLvl() - player:getMainLvl()) end duration = utils.clamp(duration,1,45); duration = duration * resist; if (not player:hasStatusEffect(EFFECT_PETRIFICATION)) then player:addStatusEffect(EFFECT_PETRIFICATION, 1, 0, duration); end return SUBEFFECT_PETRIFY, MSGBASIC_ADD_EFFECT_STATUS, EFFECT_PETRIFICATION; end end;
gpl-3.0
jshackley/darkstar
scripts/globals/mobskills/Enervation.lua
13
1280
--------------------------------------------- -- Enervation -- -- Description: Lowers the defense and magical defense of enemies within range. -- Type: Magical (Dark) --------------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/monstertpmoves"); --------------------------------------------- function onMobSkillCheck(target,mob,skill) if(mob:getFamily() == 91) then local mobSkin = mob:getModelId(); if (mobSkin == 1680) then return 0; else return 1; end end return 0; end; function onMobWeaponSkill(target, mob, skill) local typeEffect = EFFECT_DEFENSE_DOWN; local silenced = false; local blinded = false; silenced = MobStatusEffectMove(mob, target, EFFECT_DEFENSE_DOWN, 10, 0, 120); blinded = MobStatusEffectMove(mob, target, EFFECT_MAGIC_DEF_DOWN, 8, 0, 120); skill:setMsg(MSG_ENFEEB_IS); -- display silenced first, else blind if (silenced == MSG_ENFEEB_IS) then typeEffect = EFFECT_DEFENSE_DOWN; elseif (blinded == MSG_ENFEEB_IS) then typeEffect = EFFECT_MAGIC_DEF_DOWN; else skill:setMsg(MSG_MISS); end return typeEffect; end;
gpl-3.0
SpRoXx/GTW-RPG
[resources]/GTWsafeareas/safearea_c.lua
1
3398
--[[ ******************************************************************************** Project owner: RageQuit community Project name: GTW-RPG Developers: Mr_Moose Source code: https://github.com/GTWCode/GTW-RPG/ Bugtracker: http://forum.404rq.com/bug-reports/ Suggestions: http://forum.404rq.com/mta-servers-development/ Version: Open source License: BSD 2-Clause Status: Stable release ******************************************************************************** ]]-- has_been_warned = nil rocket_launchers = { {"jail", -3008.18,2442.19,25.47}, {"jail", -3110.78,2354.36,28.37}, {"jail", -3110.51,2254.5,28.37}, {"jail", -3054.41,2204.34,25.47}, {"jail", -2984.04,2235.65,28.37}, {"jail", -2979.02,2042.44,22.58}, {"jail", -2983.1,2285.03,10}, {"jail", -2983.3,2362.6,30}, {"jail", -3054.7,2304.1,40}, {"jail", -2885.6,2299.8,162}, {"a51",16,1718,30}, {"a51",237,1696,30}, {"a51",354,2028,30}, {"a51",188,2081,30}, } allowed_government_teams = { ["Staff"]=true, ["Government"]=true, ["Emergency service"]=true } function protectPrison() for k,v in pairs(getElementsByType("player")) do local x,y,z = getElementPosition(v) local nx,ny,nz = 0,0,0 local old_dist = 999 for i,rl in pairs(rocket_launchers) do local dist = getDistanceBetweenPoints3D(rl[2],rl[3],rl[4], x,y,z) if dist < 180 and (not getPlayerTeam(v) or not allowed_government_teams[getTeamName(getPlayerTeam(v))]) and rl[1] == "jail" and (isElementInWater(v) or getPedOccupiedVehicle(v) or z > 20) and not getElementData(v, "arrested") then if old_dist > dist then old_dist = dist nx,ny,nz = rl[2],rl[3],rl[4] end -- Make sure none of the occupants are allowed to be there if getPedOccupiedVehicle(v) then local occupants = getVehicleOccupants(getPedOccupiedVehicle(v)) for i,occu in pairs(occupants) do if getPlayerTeam(occu) and allowed_government_teams[ getTeamName(getPlayerTeam(occu))] then -- Theres a law enforcer in this vehicle, don't shoot nx,ny,nz = 0,0,0 end end end end if has_been_warned and dist < 150 and z > 40 and (not getPlayerTeam(v) or not allowed_government_teams[getTeamName(getPlayerTeam(v))]) and rl[1] == "a51" then if old_dist > dist then old_dist = dist nx,ny,nz = rl[2],rl[3],rl[4] end elseif not has_been_warned and dist < 150 and z > 40 and (not getPlayerTeam(v) or not allowed_government_teams[getTeamName(getPlayerTeam(v))]) and rl[1] == "a51" then has_been_warned = true setTimer(reset_warning, 300000, 1) exports.GTWtopbar:dm("This is a restricted area, leave or get shot!", 255, 100, 0) end end -- Fire if there is a nearest rocket if nx == 0 or ny == 0 or nz == 0 then return end createProjectile(v, 20, nx,ny,nz, 1, v) end end function reset_warning() has_been_warned = nil end setTimer(protectPrison, 10000, 0)
bsd-2-clause
10sa/Advanced-Nutscript
nutscript/plugins/recognition/derma/cl_quickrecognition.lua
1
2159
local PANEL = {}; local PLUGIN = PLUGIN or { }; function PANEL:Init() AdvNut.util.DrawBackgroundBlur(self); self:InitDermaMenu(); AdvNut.hook.Add("VGUIMousePressed", "QuickRecognitionMenuMousePressed", PANEL.VGUIMousePressed); end; function PANEL:InitDermaMenu() client = LocalPlayer(); self.menu = DermaMenu(); self.menu:AddOption("바라보고 있는 사람에게 인식", function() client:ConCommand("say /recognition aim") self:Close(); end); self.menu:AddOption("속삭이기 범위 안의 사람에게 인식", function() client:ConCommand("say /recognition whisper") self:Close(); end); self.menu:AddOption("말하기 범위 안의 사람에게 인식", function() client:ConCommand("say /recognition") self:Close(); end); self.menu:AddOption( "외치기 범위 안의 사람에게 인식", function() client:ConCommand("say /recognition yell") self:Close(); end); self.menu:Open() self.menu:SetPos(ScrW()* 0.45, ScrH() *0.45); end; function PANEL:Think() if(!input.IsKeyDown(KEY_F2)) then self:Close(); end; end; function PANEL:Paint(w, h) surface.SetDrawColor(Color(0, 0, 0, 0)); surface.DrawRect(0, 0, w, h); end; function PANEL:VGUIMousePressed(mouseCode) timer.Simple(0.1, function()PLUGIN:GetPluginIdentifier("QuickRecognitionMenu", CLIENT) if (IsValid(nut.gui.QuickRecognition) and nut.gui.QuickRecognition.menu != nil) then nut.gui.QuickRecognition:InitDermaMenu(); end; end); end; function PANEL:Close() AdvNut.util.RemoveBackgroundBlur(self); hook.Remove("VGUIMousePressed", PLUGIN:GetPluginIdentifier("QuickRecognitionMenuMousePressed", CLIENT)); self.menu:Remove(); self:Remove(); end; vgui.Register("AdvNut_QuickRecognition", PANEL, "AdvNut_BaseForm"); function PANEL:PlayerBindPress(bind, pressed) if(bind == "gm_showteam" and AdvNut.hook.Run("PlayerCanOpenQuickRecognitionMenu")) then nut.gui.QuickRecognition = vgui.Create("AdvNut_QuickRecognition"); end end; AdvNut.hook.Add("PlayerBindPress", PLUGIN:GetPluginIdentifier("QuickRecognitionMenu", CLIENT), PANEL.PlayerBindPress); function PLUGIN:PlayerCanOpenQuickRecognitionMenu() return true; end;
mit
lpiob/MTA-TokyoRPG
gamemode/RL_BASE/misc_c.lua
1
6340
function fadeElement(element,fade,destroy) if isElement(element) then if fade == true then -- Chowa element local timer = 50 do if getElementAlpha(element)>1 then setTimer(function () setElementAlpha(element,getElementAlpha(element)-1)end,timer,1) timer = timer + 50 if destroy == true then setTimer(function () destroyElement(element)end,timer+50,1) end end end else if fade == false then -- Odkrywa element do if getElementAlpha(element)<255 then setTimer(function () setElementAlpha(element,getElementAlpha(element)+1)end,timer,1) timer = timer + 50 if destroy == true then setTimer(function () destroyElement(element)end,timer+50,1) else end end end end end end end function convertNumber ( number ) local formatted = number while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if ( k==0 ) then break end end return formatted end function getElementSpeed(element,unit) if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 1.8 * 100 end else outputDebugString("Not an element. Can't get speed") return false end end local width, height = guiGetScreenSize() window = guiCreateWindow(0.21, 0.20, 0.57, 0.61, "Panel Info", true) guiWindowSetSizable(window, false) label = guiCreateLabel(0.26, 0.05, 0.47, 0.03, "Witaj tutaj dowiesz się jak zacząć gre na serwerze.", true, window) guiLabelSetHorizontalAlign(label, "center", false) memo = guiCreateMemo(0.02, 0.09, 0.97, 0.89, " Tutaj wytłumaczymy ci jak zacząć gre na serwerze.\n \n ==Początek==\n \n 1. Wybór auta\n\n Przed spawnem stoją wozy kup jeden z nich nie ważne który.\n\n ( Jeżeli potrzebujesz innych wozów to napisz do jednego z adminów lub mechaników , admin zrobi nastepne auta, mechanik zamówi dane auto)\n \n 2. Pieniądze\n \n Pieniądze, zarabiasz poprzez drift, lub jeżdzenie motorem na jednym kole lub prace\n Możesz je zużywać do kupywania domów aut tunningu itp. \n\n 3. Przydatne komendy i bindy\n \n /dajkase <nick> <ilosc> - przelewanie pieniedzy na cudze konto.\n\n /zamknij - zamykanie domu.\n /otworz - otwieranie domu.\n\n U - bind na czat globalny który wszyscy widzą.\n\n K - bind na zapalenie lub zgaszenie silnika w pojazdach.\n L - bind na zapalenie lub zgaszenie świateł w pojazdach.\n O - bind na zaciągniecie hamulca ręcznego w pojazdach. \n ( nikt nie przepcha waszego pojazdu ani go nie zepsuje)\n\n 4. Pomoc\n \n Jeżeli nadal czegoś nierozumiecie napiszcie do graczy lub adminów na czacie globalnym ( U ) a ktoś wam odpisze.\n\n\n\n Miłej gry życzy Administracja, Tokyo Roleplay.\n ", true, window) guiMemoSetReadOnly(memo,true) function infoTab() if getKeyState("F1")== true then guiSetVisible(window,true) showCursor(true) else guiSetVisible(window,false) showCursor(false) end end addEventHandler("onClientRender",getRootElement(),infoTab) addEventHandler("onClientRender",getRootElement(),function () dxDrawRectangle(659/800*width, 32/600*height, 106/800*width, 16/600*height, tocolor(0, 0, 0, 216), true) dxDrawRectangle(662/800*width, 35/600*height, 100/800*width, 10/600*height, tocolor(2, 107, 0, 162), true) dxDrawRectangle(662/800*width, 35/600*height, getElementHealth(localPlayer)/800*width, 10/600*height, tocolor(4, 205, 0, 216), true) dxDrawText("¥ "..convertNumber(string.format("%09d", getPlayerMoney(localPlayer))), 660/800*width, 49/600*height, 766/800*width, 65/600*height, tocolor(0, 0, 0, 255), 0.70/800*width, 0.70/600*height, "pricedown", "left", "top", false, false, true, false, false) dxDrawText("¥ "..convertNumber(string.format("%09d", getPlayerMoney(localPlayer))), 659/800*width, 48/600*height, 765/800*width, 64/600*height, tocolor(245, 219, 0, 255), 0.70/800*width, 0.70/600*height, "pricedown", "left", "top", false, false, true, false, false) end) addEvent("onNewsMessage",true) addEvent("onNewsMessageEnd",true) function showMessageNews(nick,message) function showIt() lol1 = dxDrawRectangle(192/1024*width, 736/768*height, 638/1024*width, 32/768*height, tocolor(0, 0, 0, 184), true) lol2 = dxDrawText(" Tokyo News: "..message.." ".."( "..nick.." )", 202/1024*width, 743/768*height, 824/1024*width, 758/768*height, tocolor(255, 255, 255, 255), 1.00/1024*width, 1.00/768*height, "default", "left", "top", false, false, true, false, false) end addEventHandler("onClientRender",getRootElement(),showIt) end function sendNews(nick,message) setTimer(function () triggerEvent("onNewsMessageEnd",localPlayer)end,5000,1) showMessageNews(nick,message) end addEventHandler("onNewsMessageEnd",getRootElement(),function () setTimer(function () removeEventHandler("onClientRender",getRootElement(),showIt)end,5000,1) end) addEventHandler("onNewsMessage",getRootElement(),sendNews)
gpl-2.0
jshackley/darkstar
scripts/globals/mobskills/Everyones_Grudge.lua
18
1546
--------------------------------------------- -- Everyones Grudge -- -- Notes: Invokes collective hatred to spite a single target. -- Damage done is 5x the amount of tonberries you have killed! For NM's using this it is 50 x damage. --------------------------------------------- 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; end return 0; end; function onMobWeaponSkill(target, mob, skill) local realDmg = 0; local mobID = mob:getID(); local power = 5; if (target:getID() > 100000) then realDmg = power * math.random(30,100); else realDmg = power * target:getVar("EVERYONES_GRUDGE_KILLS"); -- Damage is 5 times the amount you have killed if (mobID == 17428677 or mobID == 17433008 or mobID == 17433006 or mobID == 17433009 or mobID == 17432994 or mobID == 17433007 or mobID == 17428813 or mobID == 17432659 or mobID == 17432846 or mobID == 17428809) then realDmg = realDmg * 10; -- Sets the Multiplyer to 50 for NM's elseif (mobID == 17432799 or mobID == 17428611 or MobID == 17428554 or mobID == 17428751 or mobID == 17432609 or mobID == 16814432 or mobID == 17432624 or mobID == 17285526 or mobID == 17285460) then realDmg = realDmg * 10; -- Sets the Multiplyer to 50 for NM's , staggered list end end target:delHP(realDmg); return realDmg; end;
gpl-3.0
jshackley/darkstar
scripts/zones/Windurst_Woods/npcs/Kyaa_Taali.lua
53
1807
----------------------------------- -- Area: Windurst Woods -- NPC: Kyaa Taali -- Type: Bonecraft Image Support -- @pos -10.470 -6.25 -141.700 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) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local guildMember = isGuildMember(player,2); local SkillCap = getCraftSkillCap(player,SKILL_BONECRAFT); local SkillLevel = player:getSkillLevel(SKILL_BONECRAFT); if (guildMember == 1) then if (player:hasStatusEffect(EFFECT_BONECRAFT_IMAGERY) == false) then player:startEvent(0x2724,SkillCap,SkillLevel,2,509,player:getGil(),0,0,0); else player:startEvent(0x2724,SkillCap,SkillLevel,2,511,player:getGil(),7147,0,0); end else player:startEvent(0x2724); -- 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 == 0x2724 and option == 1) then player:messageSpecial(IMAGE_SUPPORT,0,6,2); player:addStatusEffect(EFFECT_BONECRAFT_IMAGERY,1,0,120); end end;
gpl-3.0
emadni/telelordteamgimi
plugins/inrealm.lua
228
16974
-- 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 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) 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 local username = "" text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n" end send_large_msg(receiver, text) local file = io.open("./groups/"..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 local username = "" text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n" end local file = io.open("./groups/"..result.id.."memberlist.txt", "w") file:write(text) file:flush() file:close() send_document("chat#id"..result.id,"./groups/"..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 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 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 group_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.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 function run(msg, matches) --vardump(msg) if matches[1] == 'creategroup' and matches[2] then group_name = matches[2] return create_group(msg) end 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 not is_realm(msg) then return 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] == 'setting' 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_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) end 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] == 'list' and matches[2] == 'admins' then return admin_list(msg) end if matches[1] == 'list' and matches[2] == 'groups' then group_list(msg) send_document("chat#id"..msg.to.id, "groups.txt", ok_cb, false) return " Group list created" --group_list(msg) end end return { patterns = { "^[!/](creategroup) (.*)$", "^[!/](setabout) (%d+) (.*)$", "^[!/](setrules) (%d+) (.*)$", "^[!/](setname) (%d+) (.*)$", "^[!/](lock) (%d+) (.*)$", "^[!/](unlock) (%d+) (.*)$", "^[!/](setting) (%d+)$", "^[!/](wholist)$", "^[!/](who)$", "^[!/](addadmin) (.*)$", -- sudoers only "^[!/](removeadmin) (.*)$", -- sudoers only "^[!/](list) (.*)$", "^[!/](log)$", "^!!tgservice (.+)$", }, run = run } end
gpl-2.0
jshackley/darkstar
scripts/globals/items/plate_of_sea_spray_risotto.lua
35
1632
----------------------------------------- -- ID: 4268 -- Item: plate_of_sea_spray_risotto -- Food Effect: 4Hrs, All Races ----------------------------------------- -- HP 45 -- Dexterity 6 -- Agility 3 -- Mind -4 -- HP Recovered While Healing 1 -- Accuracy % 6 (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,14400,4343); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_HP, 45); target:addMod(MOD_DEX, 6); target:addMod(MOD_AGI, 3); target:addMod(MOD_MND, -4); target:addMod(MOD_HPHEAL, 1); target:addMod(MOD_FOOD_ACCP, 6); target:addMod(MOD_FOOD_ACC_CAP, 20); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_HP, 45); target:delMod(MOD_DEX, 6); target:delMod(MOD_AGI, 3); target:delMod(MOD_MND, -4); target:delMod(MOD_HPHEAL, 1); target:delMod(MOD_FOOD_ACCP, 6); target:delMod(MOD_FOOD_ACC_CAP, 20); end;
gpl-3.0
jshackley/darkstar
scripts/zones/Southern_San_dOria/npcs/Maleme.lua
27
1530
----------------------------------- -- Area: Southern San dOria -- NPC: Maleme -- Type: Weather Reporter -- Involved in Quest: Flyers for Regine ----------------------------------- package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/quests"); require("scripts/zones/Southern_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- "Flyers for Regine" conditional script if (player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE) == QUEST_ACCEPTED) then local count = trade:getItemCount(); local MagicFlyer = trade:hasItemQty(532,1); if (MagicFlyer == true and count == 1) then player:messageSpecial(FLYER_REFUSED); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x0278,0,0,0,0,0,0,0,VanadielTime()); 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
jshackley/darkstar
scripts/globals/items/bowl_of_turtle_soup.lua
35
1552
----------------------------------------- -- ID: 4418 -- Item: Turtle Soup -- Food Effect: 3hours, All Races ----------------------------------------- -- HP + 10% (200 Cap) -- Dexterity +4 -- Vitality +6 -- Mind -3 -- HP Recovered 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,10800,4418); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_FOOD_HPP, 10); target:addMod(MOD_FOOD_HP_CAP, 200); target:addMod(MOD_DEX, 4); target:addMod(MOD_VIT, 6); target:addMod(MOD_MND, -3); target:addMod(MOD_HPHEAL, 5); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_FOOD_HPP, 10); target:delMod(MOD_FOOD_HP_CAP, 200); target:delMod(MOD_DEX, 4); target:delMod(MOD_VIT, 6); target:delMod(MOD_MND, -3); target:delMod(MOD_HPHEAL, 5); end;
gpl-3.0
junjiemars/redisql
resources/select-eq.lua
2
1403
local na = #ARGV local m = nil local level = redis.LOG_NOTICE local table_exists = function(t) if (1 == redis.call('sismember', '_T_N_', t)) then return true end return false end local find_pk = function(t) local pkd = string.format('_T_[%s]_C_PK_', t) local cd = redis.call('get', pkd) if (nil == cd) then return nil end local d = string.format('_T_[%s]_C_[%s]_', t, cd) local v = redis.call('hmget', d, 'PRIMARY_KEY', 'TYPE') if (nil == v) then return nil end return {n=cd, pk=v[1], t=v[2]} end if (4 > na) then m = "should provides enough arguments(>=4)" redis.log(level, m) return {-1, m} end local t = ARGV[1] if (not table_exists(t)) then m = string.format('table does not exist', t) redis.log(level, m) return {-00942, m} end local op = ARGV[2] if ('=' ~= op) then m = string.format('unsupported operator: %s', op) redis.log(level, m) return {-30462, m} end local pk = find_pk(t) local c = ARGV[3] if (nil == pk) or (c ~= pk['n']) then m = string.format('%s is not the primary key in table:%s', c, t) redis.log(level, m) return {-02270, m} end local v = ARGV[4] local pkd = string.format('_T_[%s]:[%s]:<%s>_', t, pk['n'], v) local r1 = {} r1[#r1+1] = {0, 1} r1[#r1+1] = redis.call('hgetall', pkd) redis.log(level, string.format('retrived [%s %s]', 0, 1)) return r1;
apache-2.0
Th2Evil/SuperPlus
data/config.lua
1
1479
do local _ = { about_text = "▫️Welcome to @Th2_BOOS v1 For more information Subscribe to the channel @queenlove20 https:github.com/Th2Evil/SuperPlus.git", enabled_plugins = { "addsudo", "admin", "all", "anti_spam", "arabic_lock", "ar-join", "ar-run", "ar-tag", "ar-audio", "badword", "delete", "echo", "get", "getfile", "getlink", "gitbot", "ar-hello", "ar-info", "ingroup", "invite", "isup", "kickall", "kickdeleted", "kickme", "launch", "leave_ban", "leave_bot", "lock_bot", "lock_fwd", "lock_media", "love3", "ar-me", "msg_checks", "ar-name", "ar-gitgroup", "newgroup", "onservice", "owners", "plugins", "ar-Plus", "replay", "res", "run", "Serverinfo", "set", "setwelcome", "short_link", "shut", "ar-dev", "ar-start", "stats", "ar-username", "ar-fwd", "ar-media", "ar-photo", "ar-video", "writer", "ar-supergroup", "ar-banhammer", "@Bedo_Prog", "@Th2_BOOS", "h1", "h2", "h3", "h4", "h5", "h6", "ar-help", "ar-virson", "ar-id", }, help_text = "", help_text_realm = "", help_text_super = "", moderation = { data = "data/moderation.json" }, sudo_users = { 230410522, 262522626, } } return _ end
gpl-2.0
jshackley/darkstar
scripts/zones/Port_Jeuno/npcs/Chaka_Skitimah.lua
17
1281
----------------------------------- -- Area: Port Jeuno -- NPC: Chaka Skitimah -- Standard Info NPC ----------------------------------- package.loaded["scripts/zones/Port_Jeuno/TextIDs"] = nil; require("scripts/zones/Port_Jeuno/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local vHour = VanadielHour(); local vMin = VanadielMinute(); while vHour >= 4 do vHour = vHour - 6; end if ( vHour == -2) then vHour = 4; elseif ( vHour == -1) then vHour = 5; end local seconds = math.floor(2.4 * ((vHour * 60) + vMin)); player:startEvent( 0x0003, seconds, 0, 0, 0, 0, 0, 0, 0); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
gpl-3.0
shagu/pfQuest
db/meta.lua
1
11092
pfDB["meta"] = { ["chests"] = { [-300405] = 0, [-300404] = 0, [-300403] = 0, [-300402] = 0, [-300401] = 0, [-300400] = 0, [-181083] = 0, [-181074] = 0, [-180392] = 0, [-180229] = 0, [-180228] = 0, [-179703] = 0, [-179564] = 0, [-179528] = 0, [-176944] = 0, [-176224] = 0, [-176188] = 0, [-169243] = 0, [-153464] = 0, [-153463] = 0, [-153462] = 0, [-153454] = 0, [-153453] = 0, [-153451] = 0, [-143980] = 0, [-142191] = 0, [-141596] = 0, [-131979] = 0, [-111095] = 0, [-106319] = 0, [-106318] = 0, [-105581] = 0, [-105579] = 0, [-105578] = 0, [-75300] = 0, [-75299] = 0, [-75298] = 0, [-75293] = 0, [-74448] = 0, [-19020] = 0, [-19019] = 0, [-19018] = 0, [-19017] = 0, [-17155] = 0, [-13359] = 0, [-4149] = 0, [-4096] = 0, [-3715] = 0, [-3704] = 0, [-3703] = 0, [-3702] = 0, [-3689] = 0, [-3661] = 0, [-3660] = 0, [-2857] = 0, [-2855] = 0, [-2852] = 0, [-2850] = 0, [-2849] = 0, [-2844] = 0, [-2843] = 0, }, ["flight"] = { [352] = "A", [523] = "A", [931] = "A", [1233] = "A", [1387] = "H", [1571] = "A", [1572] = "A", [1573] = "A", [2226] = "H", [2299] = "A", [2389] = "H", [2409] = "A", [2432] = "A", [2835] = "A", [2851] = "H", [2858] = "H", [2859] = "A", [2861] = "H", [2941] = "A", [2995] = "H", [3305] = "H", [3310] = "H", [3615] = "H", [3838] = "A", [3841] = "A", [4267] = "A", [4312] = "H", [4314] = "H", [4317] = "H", [4319] = "A", [4321] = "A", [4407] = "A", [4551] = "H", [6026] = "H", [6706] = "A", [6726] = "H", [7823] = "A", [7824] = "H", [8018] = "A", [8019] = "A", [8020] = "H", [8609] = "A", [8610] = "H", [10378] = "H", [10583] = "AH", [10897] = "A", [11138] = "A", [11139] = "H", [11899] = "H", [11900] = "H", [11901] = "H", [12577] = "A", [12578] = "A", [12596] = "A", [12616] = "H", [12617] = "A", [12636] = "H", [12740] = "H", [13177] = "H", [14242] = "H", [15177] = "A", [15178] = "H", [16227] = "AH", }, ["herbs"] = { [-180168] = 270, [-180167] = 260, [-180166] = 280, [-180165] = 210, [-180164] = 230, [-176642] = 220, [-176641] = 285, [-176640] = 280, [-176639] = 270, [-176638] = 260, [-176637] = 250, [-176636] = 230, [-176589] = 300, [-176588] = 290, [-176587] = 285, [-176586] = 280, [-176584] = 270, [-176583] = 260, [-142145] = 250, [-142144] = 245, [-142143] = 235, [-142142] = 230, [-142141] = 220, [-142140] = 210, [-3730] = 100, [-3729] = 70, [-3727] = 50, [-3726] = 15, [-3725] = 0, [-3724] = 0, [-2866] = 205, [-2046] = 170, [-2045] = 85, [-2044] = 195, [-2043] = 185, [-2042] = 160, [-2041] = 150, [-1628] = 120, [-1624] = 125, [-1623] = 115, [-1622] = 100, [-1621] = 70, [-1620] = 50, [-1619] = 15, [-1618] = 0, [-1617] = 0, }, ["mines"] = { [-181109] = 155, [-181108] = 230, [-181069] = 305, [-181068] = 305, [-180215] = 275, [-177388] = 275, [-176645] = 175, [-176643] = 245, [-175404] = 275, [-165658] = 230, [-150082] = 245, [-150081] = 230, [-150080] = 155, [-150079] = 175, [-123848] = 245, [-123310] = 175, [-123309] = 230, [-105569] = 75, [-103713] = 0, [-103711] = 65, [-73941] = 155, [-73940] = 75, [-19903] = 150, [-3764] = 65, [-3763] = 0, [-2653] = 75, [-2055] = 0, [-2054] = 65, [-2047] = 230, [-2040] = 175, [-1735] = 125, [-1734] = 155, [-1733] = 75, [-1732] = 65, [-1731] = 0, [-1667] = 65, [-1610] = 65, [-324] = 245, }, ["rares"] = { [61] = 11, [79] = 10, [99] = 10, [100] = 12, [462] = 26, [471] = 10, [472] = 12, [503] = 31, [506] = 18, [507] = 32, [519] = 15, [520] = 19, [521] = 23, [534] = 34, [572] = 19, [573] = 20, [574] = 27, [584] = 27, [596] = 18, [599] = 18, [601] = 16, [616] = 23, [639] = 21, [723] = 44, [763] = 39, [771] = 32, [947] = 26, [1037] = 30, [1063] = 47, [1106] = 37, [1112] = 24, [1119] = 12, [1130] = 12, [1132] = 10, [1137] = 9, [1140] = 31, [1260] = 11, [1361] = 28, [1398] = 22, [1399] = 21, [1424] = 15, [1425] = 15, [1531] = 6, [1533] = 8, [1552] = 45, [1720] = 26, [1837] = 60, [1838] = 61, [1839] = 63, [1841] = 60, [1843] = 62, [1844] = 58, [1847] = 52, [1848] = 56, [1849] = 38, [1850] = 58, [1851] = 62, [1885] = 59, [1910] = 10, [1911] = 12, [1920] = 21, [1936] = 8, [1944] = 22, [1948] = 23, [2090] = 23, [2108] = 29, [2172] = 20, [2175] = 13, [2184] = 17, [2186] = 16, [2191] = 14, [2192] = 19, [2258] = 37, [2283] = 22, [2447] = 44, [2452] = 36, [2453] = 39, [2476] = 22, [2541] = 45, [2598] = 39, [2600] = 34, [2601] = 42, [2602] = 39, [2603] = 36, [2604] = 39, [2605] = 40, [2606] = 37, [2609] = 40, [2744] = 40, [2749] = 40, [2751] = 36, [2752] = 45, [2754] = 45, [2779] = 41, [2850] = 37, [2931] = 55, [3056] = 12, [3068] = 9, [3253] = 24, [3270] = 15, [3295] = 19, [3398] = 20, [3470] = 15, [3535] = 13, [3581] = 50, [3586] = 19, [3651] = 16, [3652] = 19, [3672] = 20, [3718] = 20, [3735] = 22, [3773] = 26, [3792] = 32, [3831] = 1, [3872] = 25, [4015] = 25, [4030] = 30, [4066] = 30, [4132] = 36, [4339] = 45, [4380] = 40, [4425] = 32, [4438] = 29, [4842] = 32, [5343] = 46, [5345] = 45, [5346] = 48, [5347] = 48, [5348] = 55, [5349] = 49, [5350] = 47, [5352] = 43, [5354] = 44, [5356] = 42, [5367] = 35, [5399] = 48, [5400] = 48, [5785] = 11, [5786] = 9, [5787] = 11, [5789] = 10, [5790] = 9, [5793] = 10, [5794] = 10, [5795] = 9, [5796] = 8, [5797] = 25, [5798] = 25, [5799] = 24, [5800] = 24, [5807] = 10, [5808] = 9, [5809] = 9, [5822] = 11, [5823] = 11, [5824] = 11, [5826] = 9, [5827] = 27, [5828] = 23, [5829] = 17, [5830] = 19, [5831] = 21, [5832] = 24, [5834] = 25, [5835] = 19, [5836] = 19, [5837] = 15, [5838] = 17, [5841] = 17, [5842] = 19, [5847] = 24, [5848] = 25, [5849] = 24, [5851] = 27, [5859] = 26, [5863] = 19, [5864] = 22, [5865] = 13, [5912] = 20, [5915] = 29, [5916] = 27, [5928] = 27, [5930] = 28, [5931] = 24, [5932] = 22, [5933] = 31, [5934] = 32, [5935] = 37, [5937] = 35, [6118] = 48, [6228] = 33, [6488] = 33, [6489] = 33, [6490] = 33, [6581] = 50, [6582] = 54, [6583] = 57, [6584] = 60, [6585] = 52, [6646] = 54, [6647] = 51, [6648] = 50, [6649] = 51, [6650] = 51, [6651] = 49, [6652] = 51, [7015] = 16, [7016] = 22, [7017] = 15, [7057] = 38, [7104] = 56, [7137] = 56, [7895] = 36, [8199] = 45, [8200] = 46, [8201] = 50, [8202] = 48, [8203] = 47, [8204] = 50, [8205] = 50, [8206] = 51, [8207] = 46, [8208] = 43, [8210] = 44, [8211] = 42, [8212] = 49, [8213] = 51, [8214] = 49, [8215] = 50, [8216] = 48, [8217] = 52, [8218] = 45, [8219] = 43, [8277] = 48, [8278] = 50, [8279] = 46, [8280] = 47, [8281] = 49, [8282] = 51, [8283] = 50, [8296] = 48, [8297] = 56, [8298] = 54, [8299] = 52, [8300] = 51, [8301] = 53, [8302] = 49, [8303] = 50, [8304] = 57, [8503] = 11, [8660] = 48, [8923] = 57, [8924] = 50, [8976] = 60, [8978] = 57, [8979] = 59, [8981] = 56, [9024] = 52, [9025] = 51, [9041] = 56, [9042] = 55, [9046] = 55, [9217] = 58, [9218] = 58, [9219] = 57, [9417] = 60, [9596] = 59, [9602] = 54, [9604] = 54, [9718] = 59, [9736] = 59, [10077] = 53, [10078] = 55, [10080] = 45, [10081] = 45, [10082] = 45, [10119] = 60, [10196] = 56, [10197] = 55, [10198] = 60, [10199] = 59, [10200] = 57, [10201] = 61, [10202] = 59, [10203] = 62, [10236] = 33, [10237] = 35, [10238] = 35, [10239] = 38, [10263] = 56, [10356] = 10, [10357] = 11, [10358] = 12, [10359] = 13, [10376] = 60, [10393] = 58, [10509] = 59, [10558] = 57, [10559] = 22, [10584] = 60, [10639] = 25, [10640] = 27, [10641] = 25, [10642] = 27, [10643] = 23, [10644] = 22, [10647] = 32, [10808] = 58, [10809] = 60, [10810] = 59, [10817] = 55, [10818] = 43, [10819] = 59, [10820] = 45, [10821] = 57, [10822] = 58, [10823] = 59, [10824] = 60, [10825] = 56, [10826] = 57, [10827] = 56, [10828] = 59, [11447] = 60, [11497] = 60, [11498] = 58, [11580] = 41, [11688] = 43, [12037] = 31, [12116] = 60, [12237] = 48, [12431] = 13, [12432] = 14, [12433] = 15, [13896] = 52, [13977] = 61, [14016] = 61, [14018] = 61, [14019] = 61, [14221] = 36, [14222] = 35, [14223] = 32, [14224] = 41, [14225] = 33, [14226] = 40, [14227] = 37, [14228] = 34, [14229] = 38, [14230] = 38, [14231] = 37, [14232] = 38, [14233] = 39, [14234] = 41, [14235] = 43, [14236] = 44, [14237] = 42, [14266] = 19, [14267] = 19, [14268] = 16, [14269] = 21, [14270] = 19, [14271] = 17, [14272] = 18, [14273] = 25, [14275] = 28, [14276] = 30, [14277] = 33, [14278] = 28, [14279] = 24, [14280] = 27, [14281] = 23, [14339] = 49, [14340] = 54, [14341] = 53, [14342] = 51, [14343] = 52, [14344] = 50, [14345] = 51, [14424] = 25, [14425] = 24, [14426] = 27, [14427] = 28, [14428] = 7, [14429] = 11, [14430] = 9, [14431] = 8, [14432] = 6, [14433] = 30, [14445] = 45, [14446] = 43, [14447] = 43, [14448] = 42, [14471] = 61, [14472] = 57, [14473] = 60, [14474] = 59, [14475] = 57, [14476] = 56, [14477] = 58, [14478] = 58, [14479] = 60, [14487] = 37, [14488] = 38, [14490] = 44, [14491] = 42, [14492] = 42, [14697] = 61, [16379] = 61, [16380] = 61, [17075] = 63, }, }
mit
jshackley/darkstar
scripts/globals/items/galkan_sausage_+2.lua
35
1364
----------------------------------------- -- ID: 5860 -- Item: galkan_sausage_+2 -- Food Effect: 30Min, All Races ----------------------------------------- -- Strength 5 -- Intelligence -6 -- Attack 11 -- Ranged Attack 11 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,1800,5860); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_STR, 5); target:addMod(MOD_INT, -6); target:addMod(MOD_ATT, 11); target:addMod(MOD_RATT, 11); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_STR, 5); target:delMod(MOD_INT, -6); target:delMod(MOD_ATT, 11); target:delMod(MOD_RATT, 11); end;
gpl-3.0
jshackley/darkstar
scripts/zones/Pashhow_Marshlands/npcs/Shikoko_WW.lua
30
3064
----------------------------------- -- Area: Pashhow Marshlands -- NPC: Shikoko, W.W. -- Type: Border Conquest Guards -- @pos 536.291 23.517 694.063 109 ----------------------------------- package.loaded["scripts/zones/Pashhow_Marshlands/TextIDs"] = nil; ----------------------------------- require("scripts/globals/conquest"); require("scripts/zones/Pashhow_Marshlands/TextIDs"); local guardnation = WINDURST; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno local guardtype = 4; -- 1: city, 2: foreign, 3: outpost, 4: border local region = DERFLAND local csid = 0x7ff6; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) tradeConquestGuard(player,npc,trade,guardnation,guardtype); end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:hasKeyItem(getSupplyKey(region)) and player:getNation() == guardnation) then if (supplyRunFresh(player) == 1) then player:startEvent(csid,16,0,0,0,1,0,0,255); -- you have brought us supplies ! else player:showText(npc, CONQUEST - 1); -- "Hmm... These supplies you have brought us are too old to be of any use." player:delKeyItem(getSupplyKey(region)); player:messageSpecial(KEYITEM_OBTAINED + 1, getSupplyKey(region)); player:setVar("supplyQuest_region",0); end else local arg1 = getArg1(guardnation, player) - 1; if (arg1 >= 1792) then -- foreign, non-allied player:startEvent(csid,1808,0,0,0,0,player:getRank(),0,0); else -- citizen or allied player:startEvent(csid,arg1,0,0x3F0000,0,0,getArg6(player),0,0); end end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("OPTION: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("OPTION: %u",option); if (option == 1) then local duration = (player:getRank() + getNationRank(player:getNation()) + 3) * 3600; player:delStatusEffect(EFFECT_SIGIL); player:delStatusEffect(EFFECT_SANCTION); player:delStatusEffect(EFFECT_SIGNET); player:addStatusEffect(EFFECT_SIGNET,0,0,duration); -- Grant Signet elseif (option == 2) then player:delKeyItem(getSupplyKey(region)); player:addCP(supplyReward[region + 1]) player:messageSpecial(CONQUEST); -- "You've earned conquest points!" if (hasOutpost(player, region+5) == 0) then local supply_quests = 2^(region+5); player:addNationTeleport(guardnation,supply_quests); player:setVar("supplyQuest_region",0); end elseif (option == 4) then if (player:delGil(giltosetHP(guardnation,player))) then player:setHomePoint(); player:messageSpecial(CONQUEST + 94); -- "Your home point has been set." else player:messageSpecial(CONQUEST + 95); -- "You do not have enough gil to set your home point here." end end end;
gpl-3.0
jshackley/darkstar
scripts/globals/items/mutton_tortilla.lua
35
1729
----------------------------------------- -- ID: 4506 -- Item: mutton_tortilla -- Food Effect: 30Min, All Races ----------------------------------------- -- Magic 10 -- Strength 3 -- Vitality 1 -- Intelligence -1 -- Attack % 27 -- Attack Cap 30 -- Ranged ATT % 27 -- Ranged ATT Cap 30 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,1800,4506); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_MP, 10); target:addMod(MOD_STR, 3); target:addMod(MOD_VIT, 1); target:addMod(MOD_INT, -1); target:addMod(MOD_FOOD_ATTP, 27); target:addMod(MOD_FOOD_ATT_CAP, 30); target:addMod(MOD_FOOD_RATTP, 27); target:addMod(MOD_FOOD_RATT_CAP, 30); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_MP, 10); target:delMod(MOD_STR, 3); target:delMod(MOD_VIT, 1); target:delMod(MOD_INT, -1); target:delMod(MOD_FOOD_ATTP, 27); target:delMod(MOD_FOOD_ATT_CAP, 30); target:delMod(MOD_FOOD_RATTP, 27); target:delMod(MOD_FOOD_RATT_CAP, 30); end;
gpl-3.0
jshackley/darkstar
scripts/zones/Lower_Jeuno/npcs/Porter_Moogle.lua
41
1537
----------------------------------- -- Area: Lower Jeuno -- NPC: Porter Moogle -- Type: Storage Moogle -- @zone 245 -- @pos TODO ----------------------------------- package.loaded["scripts/zones/Lower_Jeuno/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Lower_Jeuno/TextIDs"); require("scripts/globals/porter_moogle_util"); local e = { TALK_EVENT_ID = 10104, STORE_EVENT_ID = 10105, RETRIEVE_EVENT_ID = 10106, ALREADY_STORED_ID = 10107, MAGIAN_TRIAL_ID = 10108 }; ----------------------------------- -- 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
jshackley/darkstar
scripts/zones/Horlais_Peak/bcnms/dropping_like_flies.lua
19
1705
----------------------------------- -- Area: Horlias peak -- Name: Dropping Like Flies -- BCNM30 ----------------------------------- package.loaded["scripts/zones/Horlais_Peak/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Horlais_Peak/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,10,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
Ombridride/minetest-minetestforfun-server
minetestforfun_game/mods/default/player.lua
8
4647
-- Minetest 0.4 mod: player -- See README.txt for licensing and other information. -- Player animation blending -- Note: This is currently broken due to a bug in Irrlicht, leave at 0 local animation_blend = 0 default.registered_player_models = { } -- Local for speed. local models = default.registered_player_models function default.player_register_model(name, def) models[name] = def end -- Default player appearance default.player_register_model("character.b3d", { animation_speed = 30, textures = {"character.png", }, animations = { -- Standard animations. stand = { x= 0, y= 79, }, lay = { x=162, y=166, }, walk = { x=168, y=187, }, mine = { x=189, y=198, }, walk_mine = { x=200, y=219, }, sit = { x= 81, y=160, }, }, }) -- Player stats and animations local player_model = {} local player_textures = {} local player_anim = {} local player_sneak = {} default.player_attached = {} function default.player_get_animation(player) local name = player:get_player_name() return { model = player_model[name], textures = player_textures[name], animation = player_anim[name], } end -- Called when a player's appearance needs to be updated function default.player_set_model(player, model_name) local name = player:get_player_name() local model = models[model_name] if model then if player_model[name] == model_name then return end player:set_properties({ mesh = model_name, textures = player_textures[name] or model.textures, visual = "mesh", visual_size = model.visual_size or {x=1, y=1}, }) default.player_set_animation(player, "stand") else player:set_properties({ textures = { "player.png", "player_back.png", }, visual = "upright_sprite", }) end player_model[name] = model_name end function default.player_set_textures(player, textures) local name = player:get_player_name() player_textures[name] = textures player:set_properties({textures = textures,}) end function default.player_set_animation(player, anim_name, speed) local name = player:get_player_name() if player_anim[name] == anim_name then return end local model = player_model[name] and models[player_model[name]] if not (model and model.animations[anim_name]) then return end local anim = model.animations[anim_name] player_anim[name] = anim_name player:set_animation(anim, speed or model.animation_speed, animation_blend) end -- Update appearance when the player joins minetest.register_on_joinplayer(function(player) default.player_attached[player:get_player_name()] = false default.player_set_model(player, "character.b3d") player:set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, 30) -- set GUI if not minetest.setting_getbool("creative_mode") then player:set_inventory_formspec(default.gui_survival_form) end player:hud_set_hotbar_image("gui_hotbar.png") player:hud_set_hotbar_selected_image("gui_hotbar_selected.png") end) minetest.register_on_leaveplayer(function(player) local name = player:get_player_name() player_model[name] = nil player_anim[name] = nil player_textures[name] = nil end) -- Localize for better performance. local player_set_animation = default.player_set_animation local player_attached = default.player_attached -- Check each player and apply animations minetest.register_globalstep(function(dtime) for _, player in pairs(minetest.get_connected_players()) do local name = player:get_player_name() local model_name = player_model[name] local model = model_name and models[model_name] if model and not player_attached[name] then local controls = player:get_player_control() local walking = false local animation_speed_mod = model.animation_speed or 30 -- Determine if the player is walking if controls.up or controls.down or controls.left or controls.right then walking = true end -- Determine if the player is sneaking, and reduce animation speed if so if controls.sneak then animation_speed_mod = animation_speed_mod / 2 end -- Apply animations based on what the player is doing if player:get_hp() == 0 then player_set_animation(player, "lay") elseif walking then if player_sneak[name] ~= controls.sneak then player_anim[name] = nil player_sneak[name] = controls.sneak end if controls.LMB then player_set_animation(player, "walk_mine", animation_speed_mod) else player_set_animation(player, "walk", animation_speed_mod) end elseif controls.LMB then player_set_animation(player, "mine") else player_set_animation(player, "stand", animation_speed_mod) end end end end)
unlicense
jshackley/darkstar
scripts/globals/abilities/reward.lua
18
6423
----------------------------------- -- Ability: Reward -- Feeds pet to restore its HP. -- Obtained: Beastmaster Level 12 -- Recast Time: 1:30 -- Duration: Instant ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/pets"); ----------------------------------- -- onAbilityCheck ----------------------------------- function onAbilityCheck(player,target,ability) if (player:getPet() == nil) then return MSGBASIC_REQUIRES_A_PET,0; else local id = player:getEquipID(SLOT_AMMO); if (id >= 17016 and id <= 17023) then player:setBattleSubTarget(player:getPet()); return 0,0; else return MSGBASIC_MUST_HAVE_FOOD,0; end end end; ----------------------------------- -- onUseAbility ----------------------------------- function onUseAbility(player,target,ability) -- 1st need to get the pet food is equipped in the range slot. local rangeObj = player:getEquipID(SLOT_AMMO); local minimumHealing = 0; local totalHealing = 0; local playerMnd = player:getStat(MOD_MND); local rewardHealingMod = player:getMod(MOD_REWARD_HP_BONUS); local regenAmount = 1; -- 1 is the minimum. local regenTime = 180; -- 3 minutes local pet = player:getPet(); local petCurrentHP = pet:getHP(); local petMaxHP = pet:getMaxHP(); -- Need to start to calculate the HP to restore to the pet. -- Please note that I used this as base for the calculations: -- http://wiki.ffxiclopedia.org/wiki/Reward switch (rangeObj) : caseof { [17016] = function (x) -- pet food alpha biscuit -- printf("Food: pet food alpha biscuit."); minimumHealing = 50; regenAmount = 1; totalHealing = math.floor(minimumHealing + 2*(playerMnd-10)); end, [17017] = function (x) -- pet food beta biscuit -- printf("Food: pet food beta biscuit."); minimumHealing = 180; regenAmount = 3; totalHealing = math.floor(minimumHealing + 1*(playerMnd-33)); end, [17018] = function (x) -- pet food gamma biscuit -- printf("Food: pet food gamma biscuit."); minimumHealing = 300; regenAmount = 5; totalHealing = math.floor(minimumHealing + 1*(playerMnd-35)); -- TO BE VERIFIED. end, [17019] = function (x) -- pet food delta biscuit -- printf("Food: pet food delta biscuit."); minimumHealing = 530; regenAmount = 8; totalHealing = math.floor(minimumHealing + 2*(playerMnd-40)); -- TO BE VERIFIED. end, [17020] = function (x) -- pet food epsilon biscuit -- printf("Food: pet food epsilon biscuit."); minimumHealing = 750; regenAmount = 11; totalHealing = math.floor(minimumHealing + 2*(playerMnd-45)); end, [17021] = function (x) -- pet food zeta biscuit -- printf("Food: pet food zeta biscuit."); minimumHealing = 900; regenAmount = 14; totalHealing = math.floor(minimumHealing + 3*(playerMnd-45)); end, [17022] = function (x) -- pet food eta biscuit -- printf("Food: pet food eta biscuit."); minimumHealing = 1200; regenAmount = 17; totalHealing = math.floor(minimumHealing + 4*(playerMnd-50)); end, [17023] = function (x) -- pet food theta biscuit -- printf("Food: pet food theta biscuit."); minimumHealing = 1600; regenAmount = 20; totalHealing = math.floor(minimumHealing + 4*(playerMnd-55)); end, } -- Now calculating the bonus based on gear. local body = player:getEquipID(SLOT_BODY); switch (body) : caseof { [12646] = function (x) -- beast jackcoat -- This will remove Paralyze, Poison and Blind from the pet. -- printf("Beast jackcoat detected."); pet:delStatusEffect(EFFECT_PARALYSIS); pet:delStatusEffect(EFFECT_POISON); pet:delStatusEffect(EFFECT_BLINDNESS); end, [14481] = function (x) -- beast jackcoat +1 -- This will remove Paralyze, Poison, Blind, Weight, Slow and Silence from the pet. -- printf("Beast jackcoat +1 detected."); pet:delStatusEffect(EFFECT_PARALYSIS); pet:delStatusEffect(EFFECT_POISON); pet:delStatusEffect(EFFECT_BLINDNESS); pet:delStatusEffect(EFFECT_WEIGHT); pet:delStatusEffect(EFFECT_SLOW); pet:delStatusEffect(EFFECT_SILENCE); end, [15095] = function (x) -- monster jackcoat -- This will remove Weight, Slow and Silence from the pet. -- printf("Monster jackcoat detected."); pet:delStatusEffect(EFFECT_WEIGHT); pet:delStatusEffect(EFFECT_SLOW); pet:delStatusEffect(EFFECT_SILENCE); end, [14481] = function (x) -- monster jackcoat +1 -- This will remove Paralyze, Poison, Blind, Weight, Slow and Silence from the pet. -- printf("Monster jackcoat +1 detected."); pet:delStatusEffect(EFFECT_PARALYSIS); pet:delStatusEffect(EFFECT_POISON); pet:delStatusEffect(EFFECT_BLINDNESS); pet:delStatusEffect(EFFECT_WEIGHT); pet:delStatusEffect(EFFECT_SLOW); pet:delStatusEffect(EFFECT_SILENCE); end, } -- Adding bonus to the total to heal. if (rewardHealingMod ~= nil and rewardHealingMod > 0) then totalHealing = totalHealing + math.floor(totalHealing * rewardHealingMod / 100); end local diff = petMaxHP - petCurrentHP; if (diff < totalHealing) then totalHealing = diff; end pet:addHP(totalHealing); pet:wakeUp(); -- Apply regen effect. pet:delStatusEffect(EFFECT_REGEN); pet:addStatusEffect(EFFECT_REGEN,regenAmount,3,regenTime); -- 3 = tick, each 3 seconds. return totalHealing; end;
gpl-3.0
drhelius/Gearboy
platforms/ios/dependencies/SDL-2.0.4-9174/premake/projects/testnative.lua
7
1316
-- Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely. -- -- Meta-build system using premake created and maintained by -- Benjamin Henning <b.henning@digipen.edu> --[[ testnative.lua This file defines the testnative test project. It depends on the SDL2main and SDL2 projects. It will not build on iOS or Cygwin. This project has specialized dependencies separate to Windows/MinGW, Mac OS X, and Linux. ]] SDL_project "testnative" SDL_kind "ConsoleApp" SDL_notos "ios|cygwin" SDL_language "C" SDL_sourcedir "../test" SDL_projectLocation "tests" SDL_projectDependencies { "SDL2main", "SDL2" } SDL_files { "/testnative.*" } SDL_copy { "icon.bmp" } SDL_dependency "windows" SDL_os "windows|mingw" SDL_files { "/testnativew32.*" } SDL_dependency "macosx" SDL_os "macosx" SDL_files { "/testnativecocoa.*" } SDL_dependency "linux" SDL_os "linux" SDL_depfunc "X11" SDL_files { "/testnativex11.*" }
gpl-3.0
sugiartocokrowibowo/Algorithm-Implementations
Maximum_Subarray/Lua/Yonaba/maximum_subarray.lua
26
2823
-- Greatest subsequential sum finding algorithms implementation -- See: http://en.wikipedia.org/wiki/Maximum_subarray_problem -- Computes the largest sub-sequential sum using kadanes algorithm -- s : a given sequence -- returns : the sum of the largest subsequence found -- returns : the starting index of the largest subsequence found -- returns : the final index of the largest subsequence found local function kadanes(s) local n = #s if n< 1 then return 0 end local max_ending_here, max_so_far = s[1], s[1] local begin, begin_tmp, last = 1, 1, 1 for i = 2, n do if max_ending_here < 0 then max_ending_here = s[i] begin_tmp = i else max_ending_here = max_ending_here + s[i] end if max_ending_here >= max_so_far then max_so_far = max_ending_here begin = begin_tmp last = i end end return max_so_far, begin, last end -- Computes the largest sub-sequential sum using a brute-force algorithm -- s : a given sequence -- returns : the sum of the largest subsequence found -- returns : the starting index of the largest subsequence found -- returns : the final index of the largest subsequence found local function gss_brute_force(s) local st, ed = 1 local sum , max = s[st], s[st] for i = 1, #s do for j = i, #s do sum = 0 for k = i, j do sum = sum + s[k] end if sum > max then st, ed = i, j max = sum end end end return max, st, ed==nil and st or ed end -- Computes the largest sub-sequential sum by computing sub-sums -- s : a given sequence -- returns : the sum of the largest subsequence found -- returns : the starting index of the largest subsequence found -- returns : the final index of the largest subsequence found local function gss_subsums(s) local st, ed = 1 local sum , max = s[st], s[st] for i = 1, #s do sum = 0 for j = i, #s do sum = sum + s[j] if sum > max then st, ed = i, j max = sum end end end return max, st, ed==nil and st or ed end -- Computes the largest sub-sequential sum with dynamic programming -- s : a given sequence -- returns : the sum of the largest subsequence found -- returns : the starting index of the largest subsequence found -- returns : the final index of the largest subsequence found local function gss_dynamic(a) local s, t = {}, {} s[1], t[1] = a[1], 1 local max = s[1] local st, ed = 1, 1 for i = 2, #a do if s[i-1] > 0 then s[i] = s[i-1] + a[i] t[i] = t[i-1] else s[i] = a[i] t[i] = i end if s[i] > max then st, ed = t[i], i max = s[i] end end return max, st, ed end return { kadanes = kadanes, brute_force = gss_brute_force, subsums = gss_subsums, dynamic = gss_dynamic, }
mit
jshackley/darkstar
scripts/zones/Newton_Movalpolos/npcs/Sleakachiq.lua
32
1794
----------------------------------- -- Area: Newton Movalpolos -- NPC: Sleakachiq -- @pos 162.504 14.999 136.901 12 ----------------------------------- package.loaded["scripts/zones/Newton_Movalpolos/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Newton_Movalpolos/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) local Ypos = player:getYPos(); if (Ypos <= 16.5) then if (trade:getItemCount() == 1 and trade:getGil() == 800) then player:tradeComplete(); player:startEvent(0x001C); end elseif (Ypos >= 19.5) then player:messageSpecial(39966); -- H0000! ... Come closer, can't trade from so far away. end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local Ypos = player:getYPos(); if (Ypos <= 16.5) then player:startEvent(0x001B); elseif (Ypos >= 19.5) then player:startEvent(0x001A); 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 == 0x001C) then if (option == 1) then player:setPos(447.99,-4.092,729.791,96,106); -- To North Gustaberg {R} elseif (option == 2) then player:setPos(-93.657,-119.999,-583.561,232,13); -- To Mine Shaft Entrance {R} end end end;
gpl-3.0
MeGaTG/amirdb
plugins/giverank.lua
43
13862
-------------------------------------------------- -- ____ ____ _____ -- -- | \| _ )_ _|___ ____ __ __ -- -- | |_ ) _ \ | |/ ·__| _ \_| \/ | -- -- |____/|____/ |_|\____/\_____|_/\/\_| -- -- -- -------------------------------------------------- -- -- -- Developers: @Josepdal & @MaSkAoS -- -- Support: @Skneos, @iicc1 & @serx666 -- -- -- -------------------------------------------------- local function index_function(user_id) for k,v in pairs(_config.admin_users) do if user_id == v[1] then print(k) return k end end -- If not found return false end local function admin_by_username(cb_extra, success, result) local chat_type = cb_extra.chat_type local chat_id = cb_extra.chat_id local user_id = result.peer_id local user_name = result.username if is_admin(user_id) then if chat_type == 'chat' then send_msg('chat#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'alreadyAdmin'), ok_cb, false) elseif chat_type == 'channel' then send_msg('channel#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'alreadyAdmin'), ok_cb, false) end else table.insert(_config.admin_users, {tonumber(user_id), user_name}) print(user_id..' added to _config table') save_config() if chat_type == 'chat' then send_msg('chat#id'..chat_id, '🆕 '..lang_text(chat_id, 'newAdmin')..' @'..user_name..' ('..user_id..')', ok_cb, false) elseif chat_type == 'channel' then send_msg('channel#id'..chat_id, '🆕 '..lang_text(chat_id, 'newAdmin')..' @'..user_name..' ('..user_id..')', ok_cb, false) end end end local function mod_by_username(cb_extra, success, result) local chat_type = cb_extra.chat_type local chat_id = cb_extra.chat_id local user_id = result.peer_id local user_name = result.username local hash = 'mod:'..chat_id..':'..user_id if redis:get(hash) then if chat_type == 'chat' then send_msg('chat#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'alreadyMod'), ok_cb, false) elseif chat_type == 'channel' then send_msg('channel#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'alreadyMod'), ok_cb, false) end else redis:set(hash, true) if chat_type == 'chat' then send_msg('chat#id'..chat_id, '🆕 '..lang_text(chat_id, 'newMod')..' @'..user_name..' ('..user_id..')', ok_cb, false) elseif chat_type == 'channel' then send_msg('channel#id'..chat_id, '🆕 '..lang_text(chat_id, 'newMod')..' @'..user_name..' ('..user_id..')', ok_cb, false) end end end local function guest_by_username(cb_extra, success, result) local chat_type = cb_extra.chat_type local chat_id = cb_extra.chat_id local user_id = result.peer_id local user_name = result.username local nameid = index_function(user_id) local hash = 'mod:'..chat_id..':'..user_id if redis:get(hash) then redis:del(hash) end if is_admin(user_id) then table.remove(_config.admin_users, nameid) print(user_id..' added to _config table') save_config() end if chat_type == 'chat' then send_msg('chat#id'..chat_id, 'ℹ️ @'..user_name..' ('..user_id..') '..lang_text(chat_id, 'nowUser'), ok_cb, false) elseif chat_type == 'channel' then send_msg('channel#id'..chat_id, 'ℹ️ @'..user_name..' ('..user_id..') '..lang_text(chat_id, 'nowUser'), ok_cb, false) end end local function set_admin(cb_extra, success, result) local chat_id = cb_extra.chat_id local user_id = cb_extra.user_id local user_name = result.username local chat_type = cb_extra.chat_type if is_admin(tonumber(user_id)) then if chat_type == 'chat' then send_msg('chat#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'alreadyAdmin'), ok_cb, false) elseif chat_type == 'channel' then send_msg('channel#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'alreadyAdmin'), ok_cb, false) end else table.insert(_config.admin_users, {tonumber(user_id), user_name}) print(user_id..' added to _config table') save_config() if cb_extra.chat_type == 'chat' then send_msg('chat#id'..chat_id, '🆕 '..lang_text(chat_id, 'newAdmin')..' @'..user_name..' ('..user_id..')', ok_cb, false) elseif cb_extra.chat_type == 'channel' then send_msg('channel#id'..chat_id, '🆕 '..lang_text(chat_id, 'newAdmin')..' @'..user_name..' ('..user_id..')', ok_cb, false) end end end local function set_mod(cb_extra, success, result) local chat_id = cb_extra.chat_id local user_id = cb_extra.user_id local user_name = result.username local chat_type = cb_extra.chat_type local hash = 'mod:'..chat_id..':'..user_id if redis:get(hash) then if chat_type == 'chat' then send_msg('chat#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'alreadyMod'), ok_cb, false) elseif chat_type == 'channel' then send_msg('channel#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'alreadyMod'), ok_cb, false) end else redis:set(hash, true) if cb_extra.chat_type == 'chat' then send_msg('chat#id'..chat_id, '🆕 '..lang_text(chat_id, 'newMod')..' @'..user_name..' ('..user_id..')', ok_cb, false) elseif cb_extra.chat_type == 'channel' then send_msg('channel#id'..chat_id, '🆕 '..lang_text(chat_id, 'newMod')..' @'..user_name..' ('..user_id..')', ok_cb, false) end end end local function set_guest(cb_extra, success, result) local chat_id = cb_extra.chat_id local user_id = cb_extra.user_id local user_name = result.username local chat_type = cb_extra.chat_type local nameid = index_function(tonumber(user_id)) local hash = 'mod:'..chat_id..':'..user_id if redis:get(hash) then redis:del(hash) end if is_admin(user_id) then table.remove(_config.admin_users, nameid) print(user_id..' added to _config table') save_config() end if cb_extra.chat_type == 'chat' then send_msg('chat#id'..chat_id, 'ℹ️ @'..user_name..' ('..user_id..') '..lang_text(chat_id, 'nowUser'), ok_cb, false) elseif cb_extra.chat_type == 'channel' then send_msg('channel#id'..chat_id, 'ℹ️ @'..user_name..' ('..user_id..') '..lang_text(chat_id, 'nowUser'), ok_cb, false) end end local function admin_by_reply(extra, success, result) local result = backward_msg_format(result) local msg = result local chat_id = msg.to.id local user_id = msg.from.id local chat_type = msg.to.type user_info('user#id'..user_id, set_admin, {chat_type=chat_type, chat_id=chat_id, user_id=user_id}) end local function mod_by_reply(extra, success, result) local result = backward_msg_format(result) local msg = result local chat_id = msg.to.id local user_id = msg.from.id local chat_type = msg.to.type user_info('user#id'..user_id, set_mod, {chat_type=chat_type, chat_id=chat_id, user_id=user_id}) end local function guest_by_reply(extra, success, result) local result = backward_msg_format(result) local msg = result local chat_id = msg.to.id local user_id = msg.from.id local chat_type = msg.to.type user_info('user#id'..user_id, set_guest, {chat_type=chat_type, chat_id=chat_id, user_id=user_id}) end local function members_chat(cb_extra, success, result) local chat_id = cb_extra.chat_id local text = "" for k,v in pairs(result.members) do if v.username then text = text..'@'..v.username..' ' end end return send_large_msg('chat#id'..chat_id, text, ok_cb, true) end local function members_channel(extra, success, result) local chat_id = extra.chat_id local text = "" for k,user in ipairs(result) do if user.username then text = text..'@'..user.username..' ' end end return send_large_msg('channel#id'..chat_id, text, ok_cb, true) end local function members_chat_msg(cb_extra, success, result) local chat_id = cb_extra.chat_id local text = ' ' for k,v in pairs(result.members) do if v.username then text = text..'@'..v.username..' ' end end text = text..'\n\n'..extra.text_msg return send_large_msg('chat#id'..chat_id, text, ok_cb, true) end local function members_channel_msg(extra, success, result) local chat_id = extra.chat_id local text = ' ' for k,user in ipairs(result) do if user.username then text = text..'@'..user.username..' ' end end text = text..'\n\n'..extra.text_msg return send_large_msg('channel#id'..chat_id, text, ok_cb, true) end local function mods_channel(extra, success, result) local chat_id = extra.chat_id local text = '🔆 '..lang_text(chat_id, 'modList')..':\n' local compare = text for k,user in ipairs(result) do hash = 'mod:'..chat_id..':'..user.peer_id if redis:get(hash) then text = text..'🔅 '..user.username..'\n' end end if text == compare then text = text..'🔅 '..lang_text(chat_id, 'modEmpty') end return send_large_msg('channel#id'..chat_id, text, ok_cb, true) end local function mods_chat(extra, success, result) local chat_id = extra.chat_id local text = '🔆 '..lang_text(chat_id, 'modList')..':\n' local compare = text for k,user in ipairs(result.members) do if user.username then hash = 'mod:'..chat_id..':'..user.peer_id if redis:get(hash) then text = text..'🔅 '..user.username..'\n' end end end if text == compare then text = text..'🔅 '..lang_text(chat_id, 'modEmpty') end return send_large_msg('chat#id'..chat_id, text, ok_cb, true) end local function run(msg, matches) user_id = msg.from.id chat_id = msg.to.id if matches[1] == 'rank' then if matches[2] == 'admin' then if permissions(user_id, chat_id, "rank_admin") then if msg.reply_id then get_message(msg.reply_id, admin_by_reply, false) end if is_id(matches[3]) then chat_type = msg.to.type chat_id = msg.to.id user_id = matches[3] user_info('user#id'..user_id, set_admin, {chat_type=chat_type, chat_id=chat_id, user_id=user_id}) else chat_type = msg.to.type chat_id = msg.to.id local member = string.gsub(matches[3], '@', '') resolve_username(member, admin_by_username, {chat_id=chat_id, member=member, chat_type=chat_type}) end else return '🚫 '..lang_text(msg.to.id, 'require_sudo') end end if matches[2] == 'mod' then if permissions(user_id, chat_id, "rank_mod") then if msg.reply_id then get_message(msg.reply_id, mod_by_reply, false) end if is_id(matches[3]) then chat_type = msg.to.type chat_id = msg.to.id user_id = matches[3] user_info('user#id'..user_id, set_mod, {chat_type=chat_type, chat_id=chat_id, user_id=user_id}) else chat_type = msg.to.type chat_id = msg.to.id local member = string.gsub(matches[3], '@', '') resolve_username(member, mod_by_username, {chat_id=chat_id, member=member, chat_type=chat_type}) end else return '🚫 '..lang_text(msg.to.id, 'require_admin') end end if matches[2] == 'guest' then if permissions(user_id, chat_id, "rank_guest") then if msg.reply_id then get_message(msg.reply_id, guest_by_reply, false) end if is_id(matches[3]) then chat_type = msg.to.type chat_id = msg.to.id user_id = matches[3] user_info('user#id'..user_id, set_guest, {chat_type=chat_type, chat_id=chat_id, user_id=user_id}) else chat_type = msg.to.type chat_id = msg.to.id local member = string.gsub(matches[3], '@', '') resolve_username(member, guest_by_username, {chat_id=chat_id, member=member, chat_type=chat_type}) end else return '🚫 '..lang_text(msg.to.id, 'require_sudo') end end elseif matches[1] == 'admins' then if permissions(user_id, chat_id, "admins") then -- Check users id in config local text = '🔆 '..lang_text(msg.to.id, 'adminList')..':\n' local compare = text for v,user in pairs(_config.admin_users) do text = text..'🔅 '..user[2]..' ('..user[1]..')\n' end if compare == text then text = text..'🔅 '..lang_text(chat_id, 'adminEmpty') end return text else return '🚫 '..lang_text(msg.to.id, 'require_mod') end elseif matches[1] == 'members' then if permissions(user_id, chat_id, "members") then local chat_id = msg.to.id if matches[2] then if msg.to.type == 'chat' then local receiver = 'chat#id'..msg.to.id chat_info(receiver, members_chat_msg, {chat_id=chat_id, text_msg=matches[2]}) else local chan = ("%s#id%s"):format(msg.to.type, msg.to.id) channel_get_users(chan, members_channel_msg, {chat_id=chat_id, text_msg=matches[2]}) end delete_msg(msg.id, ok_cb, false) else if msg.to.type == 'chat' then local receiver = 'chat#id'..msg.to.id chat_info(receiver, members_chat, {chat_id=chat_id}) else local chan = ("%s#id%s"):format(msg.to.type, msg.to.id) channel_get_users(chan, members_channel, {chat_id=chat_id}) end end else return '🚫 '..lang_text(msg.to.id, 'require_mod') end elseif matches[1] == 'mods' then if permissions(user_id, chat_id, "mods") then local chat_id = msg.to.id if msg.to.type == 'chat' then local receiver = 'chat#id'..msg.to.id chat_info(receiver, mods_chat, {chat_id=chat_id}) else local chan = ("%s#id%s"):format(msg.to.type, msg.to.id) channel_get_users(chan, mods_channel, {chat_id=chat_id}) end else return '🚫 '..lang_text(msg.to.id, 'require_mod') end end end return { patterns = { "^[!/#](rank) (.*) (.*)$", "^[!/#](rank) (.*)$", "^[!/#](admins)$", "^[!/#](mods)$", "^[!/#](members)$", "^[!/#](members) (.*)$" }, run = run }
gpl-2.0
Victek/wrt1900ac-aa
veriksystems/luci-0.11/libs/lucid/luasrc/lucid/tcpserver.lua
50
6808
--[[ LuCI - Lua Development Framework Copyright 2009 Steven Barth <steven@midlink.org> 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 $Id$ ]] local os = require "os" local fs = require "nixio.fs" local nixio = require "nixio" local lucid = require "luci.lucid" local ipairs, type, require, setmetatable = ipairs, type, require, setmetatable local pairs, print, tostring, unpack = pairs, print, tostring, unpack local pcall = pcall module "luci.lucid.tcpserver" local cursor = lucid.cursor local UCINAME = lucid.UCINAME local tcpsockets = {} --- Prepare a daemon and allocate its resources. (superserver callback) -- @param config configuration table -- @param server LuCId basemodule -- @return binary data function prepare_daemon(config, server) nixio.syslog("info", "Preparing TCP-Daemon " .. config[".name"]) if type(config.address) ~= "table" then config.address = {config.address} end local sockets, socket, code, err = {} local sopts = {reuseaddr = 1} for _, addr in ipairs(config.address) do local host, port = addr:match("(.-):?([^:]*)") if not host then nixio.syslog("err", "Invalid address: " .. addr) return nil, -5, "invalid address format" elseif #host == 0 then host = nil end socket, code, err = prepare_socket(config.family, host, port, sopts) if socket then sockets[#sockets+1] = socket end end nixio.syslog("info", "Sockets bound for " .. config[".name"]) if #sockets < 1 then return nil, -6, "no sockets bound" end nixio.syslog("info", "Preparing publishers for " .. config[".name"]) local publisher = {} for k, pname in ipairs(config.publisher) do local pdata = cursor:get_all(UCINAME, pname) if pdata then publisher[#publisher+1] = pdata else nixio.syslog("err", "Publisher " .. pname .. " not found") end end nixio.syslog("info", "Preparing TLS for " .. config[".name"]) local tls = prepare_tls(config.tls) if not tls and config.encryption == "enable" then for _, s in ipairs(sockets) do s:close() end return nil, -4, "Encryption requested, but no TLS context given" end nixio.syslog("info", "Invoking daemon factory for " .. config[".name"]) local handler, err = config.slave.module.factory(publisher, config) if not handler then for _, s in ipairs(sockets) do s:close() end return nil, -3, err else local pollin = nixio.poll_flags("in") for _, s in ipairs(sockets) do server.register_pollfd({ fd = s, events = pollin, revents = 0, handler = accept, accept = handler, config = config, publisher = publisher, tls = tls }) end return true end end --- Accept a new TCP connection. (server callback) -- @param polle Poll descriptor -- @return handler process id or nil, error code, error message function accept(polle) if not lucid.try_process() then return false end local socket, host, port = polle.fd:accept() if not socket then return nixio.syslog("warning", "accept() failed: " .. port) end socket:setblocking(true) local function thread() lucid.close_pollfds() local inst = setmetatable({ host = host, port = port, interfaces = lucid.get_interfaces() }, {__index = polle}) if polle.config.encryption then socket = polle.tls:create(socket) if not socket:accept() then socket:close() return nixio.syslog("warning", "TLS handshake failed: " .. host) end end return polle.accept(socket, inst) end local stat = {lucid.create_process(thread)} socket:close() return unpack(stat) end --- Prepare a TCP server socket. -- @param family protocol family ["inetany", "inet6", "inet"] -- @param host host -- @param port port -- @param opts table of socket options -- @param backlog socket backlog -- @return socket, final socket family function prepare_socket(family, host, port, opts, backlog) nixio.syslog("info", "Preparing socket for port " .. port) backlog = backlog or 1024 family = family or "inetany" opts = opts or {} local inetany = family == "inetany" family = inetany and "inet6" or family local socket, code, err = nixio.socket(family, "stream") if not socket and inetany then family = "inet" socket, code, err = nixio.socket(family, "stream") end if not socket then return nil, code, err end for k, v in pairs(opts) do socket:setsockopt("socket", k, v) end local stat, code, err = socket:bind(host, port) if not stat then return nil, code, err end stat, code, err = socket:listen(backlog) if not stat then return nil, code, err end socket:setblocking(false) return socket, family end --- Prepare a TLS server context and load keys and certificates. -- May invoke px5g to create keys and certificate on demand if available. -- @param tlskey TLS configuration identifier -- @return TLS server conext or nil function prepare_tls(tlskey) local tls if nixio.tls and tlskey and cursor:get(UCINAME, tlskey) then tls = nixio.tls("server") local make = cursor:get(UCINAME, tlskey, "generate") == "1" local key = cursor:get(UCINAME, tlskey, "key") local xtype = make and "asn1" or cursor:get(UCINAME, tlskey, "type") local cert = cursor:get(UCINAME, tlskey, "cert") local ciphers = cursor:get(UCINAME, tlskey, "ciphers") if make and (not fs.access(key) or not fs.access(cert)) then local CN = cursor:get(UCINAME, tlskey, "CN") local O = cursor:get(UCINAME, tlskey, "O") local bits = 2048 local data = { CN = CN or nixio.uname().nodename, O = not O and "LuCId Keymaster" or #O > 0 and O } local stat, px5g = pcall(require, "px5g") if not stat then return nixio.syslog("err", "Unable to load PX5G Keymaster") end nixio.syslog("warning", "PX5G: Generating private key") local rk = px5g.genkey(bits) local keyfile = nixio.open(key, "w", 600) if not rk or not keyfile or not keyfile:writeall(rk:asn1()) then return nixio.syslog("err", "Unable to generate private key") end keyfile:close() nixio.syslog("warning", "PX5G: Generating self-signed certificate") if not fs.writefile(cert, rk:create_selfsigned(data, os.time(), os.time() + 3600 * 24 * 366 * 15)) then return nixio.syslog("err", "Unable to generate certificate") end end if cert then if not tls:set_cert(cert, xtype) then nixio.syslog("err", "Unable to load certificate: " .. cert) end end if key then if not tls:set_key(key, xtype) then nixio.syslog("err", "Unable to load private key: " .. key) end end if ciphers then if type(ciphers) == "table" then ciphers = table.concat(ciphers, ":") end tls:set_ciphers(ciphers) end end return tls end
gpl-2.0
jshackley/darkstar
scripts/zones/Upper_Jeuno/npcs/Leillaine.lua
37
1276
----------------------------------- -- Area: Upper Jeuno -- NPC: Leillaine -- Standard Merchant NPC ----------------------------------- require("scripts/globals/shop"); package.loaded["scripts/zones/Upper_Jeuno/TextIDs"] = nil; require("scripts/zones/Upper_Jeuno/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc,LEILLAINE_SHOP_DIALOG); stock = {0x119D,10, -- Distilled Water 0x1036,2387, -- Eye Drops 0x1034,290, -- Antidote 0x1037,736, -- Echo Drops 0x1010,837, -- Potion 0x1020,4445, -- Ether 0x103B,22400} -- Remedy 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
jshackley/darkstar
scripts/globals/spells/armys_paeon_v.lua
31
1389
----------------------------------------- -- Spell: Army's Paeon V -- 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 = 5; if (sLvl+iLvl > 350) 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, 5)) then spell:setMsg(75); end return EFFECT_PAEON; end;
gpl-3.0
jshackley/darkstar
scripts/globals/spells/bluemagic/self-destruct.lua
18
1299
----------------------------------------- -- Spell: Self-Destruct -- Sacrifices HP to damage enemies within range. Affects caster with Weakness -- Spell cost: 100 MP -- Monster Type: Arcana -- Spell Type: Magical (Fire) -- Blue Magic Points: 3 -- Stat Bonus: STR+2 -- Level: 50 -- Casting Time: 3.25 seconds -- Recast Time: 21 seconds -- Magic Bursts on: Liquefaction, Fusion, and Light -- Combos: Auto Refresh ----------------------------------------- require("scripts/globals/settings"); require("scripts/globals/magic"); require("scripts/globals/status"); require("scripts/globals/bluemagic"); ----------------------------------------- -- OnMagicCastingCheck ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; ----------------------------------------- -- OnSpellCast ----------------------------------------- function onSpellCast(caster,target,spell) local duration = 300; local playerHP = caster:getHP(); local damage = caster:getHP() -1; if (damage > 0) then target:delHP(playerHP); caster:setHP(1); caster:delStatusEffect(EFFECT_WEAKNESS); caster:addStatusEffect(EFFECT_WEAKNESS,1,0,duration); end return damage; end;
gpl-3.0
Victek/wrt1900ac-aa
veriksystems/luci-0.11/applications/luci-transmission/luasrc/model/cbi/transmission.lua
75
13259
--[[ LuCI - Lua Configuration Interface - Transmission support Copyright 2012 Gabor Varga <vargagab@gmail.com> 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 $Id$ ]]-- require("luci.sys") require("luci.util") require("luci.model.ipkg") local uci = require "luci.model.uci".cursor() local trport = uci:get_first("transmission", "transmission", "rpc_port") or 9091 local running = (luci.sys.call("pidof transmission-daemon > /dev/null") == 0) local webinstalled = luci.model.ipkg.installed("transmission-web") local button = "" if running and webinstalled then button = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"button\" value=\" " .. translate("Open Web Interface") .. " \" onclick=\"window.open('http://'+window.location.hostname+':" .. trport .. "')\"/>" end m = Map("transmission", "Transmission", translate("Transmission daemon is a simple bittorrent client, here you can configure the settings.") .. button) s=m:section(TypedSection, "transmission", translate("Global settings")) s.addremove=false s.anonymous=true enable=s:option(Flag, "enabled", translate("Enabled")) enable.rmempty=false config_dir=s:option(Value, "config_dir", translate("Config file directory")) user=s:option(ListValue, "user", translate("Run daemon as user")) local p_user for _, p_user in luci.util.vspairs(luci.util.split(luci.sys.exec("cat /etc/passwd | cut -f 1 -d :"))) do user:value(p_user) end cache_size_mb=s:option(Value, "cache_size_mb", translate("Cache size in MB")) bandwidth=m:section(TypedSection, "transmission", translate("Bandwidth settings")) bandwidth.anonymous=true alt_speed_enabled=bandwidth:option(Flag, "alt_speed_enabled", translate("Alternative speed enabled")) alt_speed_enabled.enabled="true" alt_speed_enabled.disabled="false" alt_speed_down=bandwidth:option(Value, "alt_speed_down", translate("Alternative download speed"), "KB/s") alt_speed_down:depends("alt_speed_enabled", "true") alt_speed_up=bandwidth:option(Value, "alt_speed_up", translate("Alternative upload speed"), "KB/s") alt_speed_up:depends("alt_speed_enabled", "true") speed_limit_down_enabled=bandwidth:option(Flag, "speed_limit_down_enabled", translate("Speed limit down enabled")) speed_limit_down_enabled.enabled="true" speed_limit_down_enabled.disabled="false" speed_limit_down=bandwidth:option(Value, "speed_limit_down", translate("Speed limit down"), "KB/s") speed_limit_down:depends("speed_limit_down_enabled", "true") speed_limit_up_enabled=bandwidth:option(Flag, "speed_limit_up_enabled", translate("Speed limit up enabled")) speed_limit_up_enabled.enabled="true" speed_limit_up_enabled.disabled="false" speed_limit_up=bandwidth:option(Value, "speed_limit_up", translate("Speed limit up"), "KB/s") speed_limit_up:depends("speed_limit_up_enabled", "true") upload_slots_per_torrent=bandwidth:option(Value, "upload_slots_per_torrent", translate("Upload slots per torrent")) blocklists=m:section(TypedSection, "transmission", translate("Blocklists")) blocklists.anonymous=true blocklist_enabled=blocklists:option(Flag, "blocklist_enabled", translate("Block list enabled")) blocklist_enabled.enabled="true" blocklist_enabled.disabled="false" blocklist_url=blocklists:option(Value, "blocklist_url", translate("Blocklist URL")) blocklist_url:depends("blocklist_enabled", "true") fileslocations=m:section(TypedSection, "transmission", translate("Files and Locations")) fileslocations.anonymous=true download_dir=fileslocations:option(Value, "download_dir", translate("Download directory")) incomplete_dir_enabled=fileslocations:option(Flag, "incomplete_dir_enabled", translate("Incomplete directory enabled")) incomplete_dir_enabled.enabled="true" incomplete_dir_enabled.disabled="false" incomplete_dir=fileslocations:option(Value, "incomplete_dir", translate("Incomplete directory")) incomplete_dir:depends("incomplete_dir_enabled", "true") preallocation=fileslocations:option(ListValue, "preallocation", translate("preallocation")) preallocation:value("0", translate("Off")) preallocation:value("1", translate("Fast")) preallocation:value("2", translate("Full")) prefetch_enabled=fileslocations:option(Flag, "prefetch_enabled", translate("Prefetch enabled")) rename_partial_files=fileslocations:option(Flag, "rename_partial_files", translate("Rename partial files")) rename_partial_files.enableid="true" rename_partial_files.disabled="false" start_added_torrents=fileslocations:option(Flag, "start_added_torrents", translate("Automatically start added torrents")) start_added_torrents.enabled="true" start_added_torrents.disabled="false" trash_original_torrent_files=fileslocations:option(Flag, "trash_original_torrent_files", translate("Trash original torrent files")) trash_original_torrent_files.enabled="true" trash_original_torrent_files.disabled="false" umask=fileslocations:option(Value, "umask", "umask") watch_dir_enabled=fileslocations:option(Flag, "watch_dir_enabled", translate("Enable watch directory")) watch_dir_enabled.enabled="true" watch_dir_enabled.disabled="false" watch_dir=fileslocations:option(Value, "watch_dir", translate("Watch directory")) watch_dir:depends("watch_dir_enabled", "true") misc=m:section(TypedSection, "transmission", translate("Miscellaneous")) misc.anonymous=true dht_enabled=misc:option(Flag, "dht_enabled", translate("DHT enabled")) dht_enabled.enabled="true" dht_enabled.disabled="false" encryption=misc:option(ListValue, "encryption", translate("Encryption")) encryption:value("0", translate("Off")) encryption:value("1", translate("Preferred")) encryption:value("2", translate("Forced")) lazy_bitfield_enabled=misc:option(Flag, "lazy_bitfield_enabled", translate("Lazy bitfield enabled")) lazy_bitfield_enabled.enabled="true" lazy_bitfield_enabled.disabled="false" lpd_enabled=misc:option(Flag, "lpd_enabled", translate("LPD enabled")) lpd_enabled.enabled="true" lpd_enabled.disabled="false" message_level=misc:option(ListValue, "message_level", translate("Message level")) message_level:value("0", translate("None")) message_level:value("1", translate("Error")) message_level:value("2", translate("Info")) message_level:value("3", translate("Debug")) pex_enabled=misc:option(Flag, "pex_enabled", translate("PEX enabled")) pex_enabled.enabled="true" pex_enabled.disabled="false" script_torrent_done_enabled=misc:option(Flag, "script_torrent_done_enabled", translate("Script torrent done enabled")) script_torrent_done_enabled.enabled="true" script_torrent_done_enabled.disabled="false" script_torrent_done_filename=misc:option(Value, "script_torrent_done_filename", translate("Script torrent done filename")) script_torrent_done_filename:depends("script_torrent_done_enabled", "true") idle_seeding_limit_enabled=misc:option(Flag, "idle_seeding_limit_enabled", translate("Idle seeding limit enabled")) idle_seeding_limit_enabled.enabled="true" idle_seeding_limit_enabled.disabled="false" idle_seeding_limit=misc:option(Value, "idle_seeding_limit", translate("Idle seeding limit")) idle_seeding_limit:depends("idle_seeding_limit_enabled", "true") utp_enabled=misc:option(Flag, "utp_enabled", translate("uTP enabled")) utp_enabled.enabled="true" utp_enabled.disabled="false" peers=m:section(TypedSection, "transmission", translate("Peer settings")) peers.anonymous=true bind_address_ipv4=peers:option(Value, "bind_address_ipv4", translate("Binding address IPv4")) bind_address_ipv4.default="0.0.0.0" bind_address_ipv6=peers:option(Value, "bind_address_ipv6", translate("Binding address IPv6")) bind_address_ipv6.default="::" peer_congestion_algorithm=peers:option(Value, "peer_congestion_algorithm", translate("Peer congestion algorithm")) peer_limit_global=peers:option(Value, "peer_limit_global", translate("Global peer limit")) peer_limit_per_torrent=peers:option(Value, "peer_limit_per_torrent", translate("Peer limit per torrent")) peer_socket_tos=peers:option(Value, "peer_socket_tos", translate("Peer socket tos")) peerport=m:section(TypedSection, "transmission", translate("Peer Port settings")) peerport.anonymous=true peer_port=peerport:option(Value, "peer_port", translate("Peer port")) peer_port_random_on_start=peerport:option(Flag, "peer_port_random_on_start", translate("Peer port random on start")) peer_port_random_on_start.enabled="true" peer_port_random_on_start.disabled="false" peer_port_random_high=peerport:option(Value, "peer_port_random_high", translate("Peer port random high")) peer_port_random_high:depends("peer_port_random_on_start", "true") peer_port_random_low=peerport:option(Value, "peer_port_random_low", translate("Peer port random low")) peer_port_random_low:depends("peer_port_random_on_start", "true") port_forwarding_enabled=peerport:option(Flag, "port_forwarding_enabled", translate("Port forwarding enabled")) port_forwarding_enabled.enabled="true" port_forwarding_enabled.disabled="false" rpc=m:section(TypedSection, "transmission", translate("RPC settings")) rpc.anonymous=true rpc_enabled=rpc:option(Flag, "rpc_enabled", translate("RPC enabled")) rpc_enabled.enabled="true" rpc_enabled.disabled="false" rpc_port=rpc:option(Value, "rpc_port", translate("RPC port")) rpc_port:depends("rpc_enabled", "true") rpc_bind_address=rpc:option(Value, "rpc_bind_address", translate("RPC bind address")) rpc_bind_address:depends("rpc_enabled", "true") rpc_url=rpc:option(Value, "rpc_url", translate("RPC URL")) rpc_url:depends("rpc_enabled", "true") rpc_whitelist_enabled=rpc:option(Flag, "rpc_whitelist_enabled", translate("RPC whitelist enabled")) rpc_whitelist_enabled.enabled="true" rpc_whitelist_enabled.disabled="false" rpc_whitelist_enabled:depends("rpc_enabled", "true") rpc_whitelist=rpc:option(Value, "rpc_whitelist", translate("RPC whitelist")) rpc_whitelist:depends("rpc_whitelist_enabled", "true") rpc_authentication_required=rpc:option(Flag, "rpc_authentication_required", translate("RPC authentication required")) rpc_authentication_required.enabled="true" rpc_authentication_required.disabled="false" rpc_authentication_required:depends("rpc_enabled", "true") rpc_username=rpc:option(Value, "rpc_username", translate("RPC username")) rpc_username:depends("rpc_authentication_required", "true") rpc_password=rpc:option(Value, "rpc_password", translate("RPC password")) rpc_password:depends("rpc_authentication_required", "true") rpc_password.password = true scheduling=m:section(TypedSection, "transmission", translate("Scheduling")) scheduling.anonymous=true alt_speed_time_enabled=scheduling:option(Flag, "alt_speed_time_enabled", translate("Alternative speed timing enabled")) alt_speed_time_enabled.enabled="true" alt_speed_time_enabled.disabled="false" alt_speed_time_enabled.default="false" alt_speed_time_enabled:depends("alt_speed_enabled", "true") alt_speed_time_day=scheduling:option(Value, "alt_speed_time_day", translate("Alternative speed time day"), translate("Number/bitfield. Start with 0, then for each day you want the scheduler enabled, add a value. For Sunday - 1, Monday - 2, Tuesday - 4, Wednesday - 8, Thursday - 16, Friday - 32, Saturday - 64")) alt_speed_time_day:depends("alt_speed_time_enabled", "true") alt_speed_time_begin=scheduling:option(Value, "alt_speed_time_begin", translate("Alternative speed time begin"), translate("in minutes from midnight")) alt_speed_time_begin:depends("alt_speed_time_enabled", "true") alt_speed_time_end=scheduling:option(Value, "alt_speed_time_end", translate("Alternative speed time end"), translate("in minutes from midnight")) alt_speed_time_end:depends("alt_speed_time_enabled", "true") ratio_limit_enabled=scheduling:option(Flag, "ratio_limit_enabled", translate("Ratio limit enabled")) ratio_limit_enabled.enabled="true" ratio_limit_enabled.disabled="false" ratio_limit=scheduling:option(Value, "ratio_limit", translate("Ratio limit")) ratio_limit:depends("ratio_limit_enabled", "true") queueing=m:section(TypedSection, "transmission", translate("Queueing")) queueing.anonymous=true download_queue_enabled=queueing:option(Flag, "download_queue_enabled", translate("Download queue enabled")) download_queue_enabled.enabled="true" download_queue_enabled.disabled="false" download_queue_size=queueing:option(Value, "download_queue_size", translate("Download queue size")) download_queue_size:depends("download_queue_enabled", "true") queue_stalled_enabled=queueing:option(Flag, "queue_stalled_enabled", translate("Queue stalled enabled")) queue_stalled_enabled.enabled="true" queue_stalled_enabled.disabled="false" queue_stalled_minutes=queueing:option(Value, "queue_stalled_minutes", translate("Queue stalled minutes")) queue_stalled_minutes:depends("queue_stalled_enabled", "true") seed_queue_enabled=queueing:option(Flag, "seed_queue_enabled", translate("Seed queue enabled")) seed_queue_enabled.enabled="true" seed_queue_enabled.disabled="false" seed_queue_size=queueing:option(Value, "seed_queue_size", translate("Seed queue size")) seed_queue_size:depends("seed_queue_enabled", "true") scrape_paused_torrents_enabled=queueing:option(Flag, "scrape_paused_torrents_enabled", translate("Scrape paused torrents enabled")) scrape_paused_torrents_enabled.enabled="true" scrape_paused_torrents_enabled.disabled="false" return m
gpl-2.0
jshackley/darkstar
scripts/zones/Windurst_Waters_[S]/npcs/Mikhe_Aryohcha.lua
38
1124
----------------------------------- -- Area: Windurst Waters (S) -- NPC: Mikhe Aryohcha -- Type: Standard NPC -- @zone: 94 -- @pos -56.645 -4.5 13.014 -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/Windurst_Waters_[S]/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Windurst_Waters_[S]/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc, MIKHE_ARYOHCHA_DIALOG); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
gpl-3.0
jshackley/darkstar
scripts/globals/items/slice_of_giant_sheep_meat.lua
18
1353
----------------------------------------- -- ID: 4372 -- Item: slice_of_giant_sheep_meat -- Food Effect: 5Min, Galka only ----------------------------------------- -- Strength 2 -- Intelligence -4 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:getRace() ~= 8) then result = 247; end if (target:getMod(MOD_EAT_RAW_MEAT) == 1) then result = 0; end if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,300,4372); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_STR, 2); target:addMod(MOD_INT, -4); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_STR, 2); target:delMod(MOD_INT, -4); end;
gpl-3.0
elbamos/nn
Normalize.lua
4
4599
local Normalize, parent = torch.class('nn.Normalize', 'nn.Module') function Normalize:__init(p,eps) parent.__init(self) assert(p,'p-norm not provided') assert(p > 0, p..'-norm not supported') self.p = p self.eps = eps or 1e-10 end function Normalize:updateOutput(input) assert(input:dim() <= 2, 'only 1d layer supported') local input_size = input:size() if input:dim() == 1 then input = input:view(1,-1) end self._output = self._output or input.new() self.norm = self.norm or input.new() self.buffer = self.buffer or input.new() self._output:resizeAs(input) if self.p == math.huge then -- specialization for the infinity norm self._indices = self._indices or (torch.type(self.output) == 'torch.CudaTensor' and torch.CudaTensor() or torch.LongTensor()) self.buffer:abs(input) torch.max(self.norm, self._indices, self.buffer, 2) self.norm:add(self.eps) else self.normp = self.normp or input.new() if self.p % 2 ~= 0 then self.buffer:abs(input):pow(self.p) else self.buffer:pow(input,self.p) end self.normp:sum(self.buffer,2):add(self.eps) self.norm:pow(self.normp,1/self.p) end self._output:cdiv(input, self.norm:view(-1,1):expandAs(input)) self.output = self._output:view(input_size) return self.output end function Normalize:updateGradInput(input, gradOutput) assert(input:dim() <= 2, 'only 1d layer supported') assert(gradOutput:dim() <= 2, 'only 1d layer supported') local input_size = input:size() if input:dim() == 1 then input = input:view(1,-1) end local n = input:size(1) -- batch size local d = input:size(2) -- dimensionality of vectors self._gradInput = self._gradInput or input.new() self.cross = self.cross or input.new() -- compute diagonal term with gradOutput self._gradInput:resize(n,d) if self.p == math.huge then -- specialization for the inf case self._gradInput:cmul(self.norm:view(n,1,1):expand(n,d,1),gradOutput) self.buffer:resizeAs(input):zero() self.cross:resize(n,1) self.cross:gather(input,2,self._indices) self.cross:cdiv(self.norm) self.buffer:scatter(2,self._indices,self.cross) else self._gradInput:cmul(self.normp:view(n,1):expand(n,d), gradOutput) -- small optimizations for different p -- buffer = input*|input|^(p-2) if self.p % 2 ~= 0 then -- for non-even p, need to add absolute value if self.p < 2 then -- add eps to avoid possible division by 0 self.buffer:abs(input):add(self.eps):pow(self.p-2):cmul(input) else self.buffer:abs(input):pow(self.p-2):cmul(input) end elseif self.p == 2 then -- special case for p == 2, pow(x,0) = 1 self.buffer:copy(input) else -- p is even and > 2, pow(x,p) is always positive self.buffer:pow(input,self.p-2):cmul(input) end end -- compute cross term in two steps self.cross:resize(n,1) -- instead of having a huge temporary matrix (b1*b2), -- do the computations as b1*(b2*gradOutput). This avoids redundant -- computation and also a huge buffer of size n*d^2 self.buffer2 = self.buffer2 or input.new() -- nxd self.buffer2:cmul(input, gradOutput) self.cross:sum(self.buffer2, 2) self.buffer:cmul(self.cross:expandAs(self.buffer)) self._gradInput:add(-1, self.buffer) -- reuse cross buffer for normalization if self.p == math.huge then self.cross:cmul(self.norm,self.norm) else self.cross:cmul(self.normp,self.norm) end self._gradInput:cdiv(self.cross:expand(n,d)) self.gradInput = self._gradInput:view(input_size) return self.gradInput end function Normalize:__tostring__() local s -- different prints if the norm is integer if self.p % 1 == 0 then s = '%s(%d)' else s = '%s(%f)' end return string.format(s,torch.type(self),self.p) end function Normalize:type(type, tensorCache) -- torch.max expects a LongTensor as indices, whereas cutorch.max expects a CudaTensor. if type == 'torch.CudaTensor' then parent.type(self, type, tensorCache) else -- self._indices must be a LongTensor. Setting it to nil temporarily avoids -- unnecessary memory allocations. local indices indices, self._indices = self._indices, nil parent.type(self, type, tensorCache) self._indices = indices and indices:long() or nil end return self end function Normalize:clearState() nn.utils.clear(self, { '_output', '_indices', '_gradInput', 'buffer', 'norm', 'normp', 'cross', }) return parent.clearState(self) end
bsd-3-clause
jshackley/darkstar
scripts/zones/Kamihr_Drifts/Zone.lua
34
1243
----------------------------------- -- -- Zone: Kamihr Drifts -- ----------------------------------- require("scripts/globals/settings"); package.loaded["scripts/zones/Kamihr_Drifts/TextIDs"] = nil; require("scripts/zones/Kamihr_Drifts/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) cs = -1; if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then player:setPos(500,72,-479,191); end return cs; end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
Ombridride/minetest-minetestforfun-server
mods/builtin_falling/rewirting.lua
10
7088
-- -- Falling stuff custom for protected area -- minetest.register_entity(":__builtin:falling_node", { initial_properties = { physical = true, collide_with_objects = false, collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, visual = "wielditem", textures = {}, visual_size = {x=0.667, y=0.667}, owner = "falling", }, node = {}, set_node = function(self, node) self.node = node local stack = ItemStack(node.name) local itemtable = stack:to_table() local itemname = nil if itemtable then itemname = stack:to_table().name end local item_texture = nil local item_type = "" if minetest.registered_items[itemname] then item_texture = minetest.registered_items[itemname].inventory_image item_type = minetest.registered_items[itemname].type end local prop = { is_visible = true, textures = {node.name}, } self.object:set_properties(prop) end, set_owner = function(self, owner) if owner ~= nil then self.owner = "falling" else self.owner = owner end end, get_staticdata = function(self) return self.node.name end, on_activate = function(self, staticdata) self.object:set_armor_groups({immortal=1}) self:set_node({name=staticdata}) end, on_step = function(self, dtime) -- Set gravity self.object:setacceleration({x=0, y=-10, z=0}) -- Turn to actual sand when collides to ground or just move local pos = self.object:getpos() local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z} -- Position of bottom center point local bcn = minetest.get_node(bcp) local bcd = minetest.registered_nodes[bcn.name] -- Note: walkable is in the node definition, not in item groups if not bcd or (bcd.walkable or (minetest.get_item_group(self.node.name, "float") ~= 0 and bcd.liquidtype ~= "none")) then if bcd and bcd.leveled and bcn.name == self.node.name then local addlevel = self.node.level if addlevel == nil or addlevel <= 0 then addlevel = bcd.leveled end if minetest.add_node_level(bcp, addlevel) == 0 then self.object:remove() return end elseif bcd and bcd.buildable_to and (minetest.get_item_group(self.node.name, "float") == 0 or bcd.liquidtype == "none") then minetest.remove_node(bcp) return end local np = {x=bcp.x, y=bcp.y+1, z=bcp.z} -- Check what's here local n2 = minetest.get_node(np) -- If it's not air or liquid, remove node and replace it with -- it's drops if n2.name ~= "air" and (not minetest.registered_nodes[n2.name] or minetest.registered_nodes[n2.name].liquidtype == "none") then minetest.remove_node(np) if minetest.registered_nodes[n2.name].buildable_to == false then -- Add dropped items local drops = minetest.get_node_drops(n2.name, "") local _, dropped_item for _, dropped_item in ipairs(drops) do minetest.add_item(np, dropped_item) end end -- Run script hook local _, callback for _, callback in ipairs(minetest.registered_on_dignodes) do callback(np, n2, nil) end end -- Create node and remove entity if self.owner == nil or self.owner == "falling" and not minetest.is_protected(pos,"") then minetest.add_node(np, self.node) else if not minetest.is_protected(pos,self.owner) then minetest.log("action", self.owner .. " falling node " .. self.node.name .. " at" .. minetest.pos_to_string(pos)) minetest.add_node(np, self.node) else minetest.log("action", self.owner .. " try to falling node " .. self.node.name .. " at protected position " .. minetest.pos_to_string(pos)) minetest.add_item(np, self.node) end end self.object:remove() nodeupdate(np) return end local vel = self.object:getvelocity() if vector.equals(vel, {x=0,y=0,z=0}) then local npos = self.object:getpos() self.object:setpos(vector.round(npos)) end end }) minetest.override_item("default:lava_source", { on_place = function(itemstack, placer, pointed_thing) if not pointed_thing.type == "node" then return itemstack end local pn = placer:get_player_name() if minetest.is_protected(pointed_thing.above, pn) then return itemstack end minetest.add_node(pointed_thing.above, {name=itemstack:get_name()}) local meta = minetest.get_meta(pointed_thing.above) meta:set_string("owner", pn) nodeupdate(pointed_thing.above) if not minetest.setting_getbool("creative_mode") then itemstack:take_item() end return itemstack end, }) minetest.override_item("default:lava_flowing", { on_place = function(itemstack, placer, pointed_thing) if not pointed_thing.type == "node" then return itemstack end local pn = placer:get_player_name() if minetest.is_protected(pointed_thing.above, pn) then return itemstack end minetest.add_node(pointed_thing.above, {name=itemstack:get_name()}) local meta = minetest.get_meta(pointed_thing.above) meta:set_string("owner", pn) nodeupdate(pointed_thing.above) if not minetest.setting_getbool("creative_mode") then itemstack:take_item() end return itemstack end, }) if PROTECT_LAVA_REALTIME == 1 then minetest.register_abm({ nodenames = {"default:lava_source","default:lava_flowing"}, neighbors = {"air"}, interval = 1, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) local meta = minetest.get_meta(pos) if meta:get_string("owner") ~= nil and minetest.is_protected(pos, meta:get_string("owner")) then minetest.add_node(pos,{name="air"}) end end }) end if PROTECT_WATER_REALTIME == 1 then minetest.register_abm({ nodenames = {"default:water_source","default:water_flowing"}, neighbors = {"air"}, interval = 1, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) local meta = minetest.get_meta(pos) if meta:get_string("owner") ~= nil and minetest.is_protected(pos, meta:get_string("owner")) then minetest.add_node(pos,{name="air"}) end end }) end -- More slow >.< --local c_air = minetest.get_content_id("air") --minetest.register_abm({ -- nodenames = {"default:lava_source","default:lava_flowing"}, -- neighbors = {"air"}, -- interval = 2, -- chance = 1, -- action = function(pos, node, active_object_count, active_object_count_wider) -- local vm = minetest.get_voxel_manip() -- local minp, maxp = vm:read_from_map({x = pos.x, y = pos.y , z = pos.z }, -- {x = pos.x , y = pos.y , z = pos.z }) -- local area = VoxelArea:new{MinEdge=minp, MaxEdge=maxp} -- local data = vm:get_data() -- local p_pos = area:index(pos.x, pos.y , pos.z) -- print ("pos: , name :"..minetest.get_name_from_content_id(data[p_pos])) -- local meta = minetest.get_meta(area:position(p_pos)) -- if minetest.get_name_from_content_id(data[p_pos])== "default:lava_source" and meta:get_string("owner") ~= nil and minetest.is_protected(area:position(p_pos), meta:get_string("owner")) then -- data[p_pos] = c_air -- end -- vm:set_data(data) -- vm:write_to_map() -- vm:update_map() -- end --})
unlicense
men232/greencode-framework
lua/greencode/plugins/rp_custommenu/category/cl_jobs.lua
1
4020
--[[ © 2013 GmodLive private project do not share without permission of its author (Andrew Mensky vk.com/men232). --]] local CMENU_PLUGIN = greenCode.plugin:Get("rp_custommenu"); local TER_ONW; local function ChangeJob( command, special, specialcommand ) local menu = DermaMenu(); if special then menu:AddOption("Голосовать", function() gc.Client:ConCommand("darkrp "..command); CMENU_PLUGIN:Close(); end) menu:AddOption("Без голосования", function() gc.Client:ConCommand("darkrp " .. specialcommand); CMENU_PLUGIN:Close(); end) else menu:AddOption("Сменить", function() gc.Client:ConCommand("darkrp " .. command); CMENU_PLUGIN:Close(); end) end; menu:AddOption("Отмена", function() end); menu:Open() end; CMENU_JOBS_CATEGORY = CM_CAT_CLASS:New{ title = "Профессии", priority = 2, callback = function() CMENU_PLUGIN = greenCode.plugin:Get("rp_custommenu"); local bTextMenu, bBlockMenu = CMENU_PLUGIN:IsOpen(); local BlockMenu = CMENU_PLUGIN.BlockMenu; local w = BlockMenu:GetWide() - (BlockMenu.Padding*2); if ( bBlockMenu ) then BlockMenu:Clear( 0.4 ); TER_ONW = TER_ONW or greenCode.plugin:Get("ter_owning"); if ( TER_ONW:HoldingCount( gc.Client ) < 1 ) then local BLOCK = BlockMenu:AddItem{ color = Color(0,0,0), h = 35, w = w }; CMENU_PLUGIN:ApplyTemplate( BLOCK, "simple", { color = Color(200,0,0), title = "Внимание", desc = greenCode.kernel:TextWarp("Для того, чтобы выбрать другие профессии Вам необходимо купить дом или торговую точку (для торговца/повара). Покупку можно осуществить через F4 -> Территории в момент нахождения на оной одним из 3-х способов оплаты. Только после покупки жилья или магазина Вам откроется доступ к списку профессий и их выбору. Заметьте, что при продаже единственной территории Вы будете сняты с занимаемой должности и снова станете обычным гражданином.", w-20, "Default"), }); BLOCK:TurnToogle(); BLOCK:SetDisabled(true); end; for k, v in ipairs(RPExtraTeams) do if gc.Client:Team() == k or !GAMEMODE:CustomObjFitsMap(v) then continue; elseif v.admin == 1 and not gc.Client:IsAdmin() then continue; elseif v.admin > 1 and not gc.Client:IsSuperAdmin() then continue; elseif v.customCheck and not v.customCheck(gc.Client) then continue; elseif (type(v.NeedToChangeFrom) == "number" and gc.Client:Team() ~= v.NeedToChangeFrom) or (type(v.NeedToChangeFrom) == "table" and not table.HasValue(v.NeedToChangeFrom, gc.Client:Team())) then continue; end local BLOCK = BlockMenu:AddItem{ color = Color(0,0,0), h = 62, w = w, callback = function( BLOCK ) BLOCK:TurnToogle() end, callback2 = function( BLOCK ) if (not v.RequiresVote and v.vote) or (v.RequiresVote and v.RequiresVote(gc.Client, k)) then local condition = ((v.admin == 0 and gc.Client:IsAdmin()) or (v.admin == 1 and gc.Client:IsSuperAdmin()) or gc.Client.DarkRPVars["Priv"..v.command]) ChangeJob("/vote"..v.command, condition, "/"..v.command) else ChangeJob("/"..v.command) end end, }; local mdl = type(v.model) == "string" and v.model or v.model[math.random( 1, #v.model )]; CMENU_PLUGIN:ApplyTemplate( BLOCK, "simple", { tooltip = "ЛКМ - Развернуть/Свернуть.\nПКМ - Действия.", mdl = mdl, color = Color( v.color.r+100, v.color.g+100,v.color.b+100 ), title = v.name, desc = v.description } ); BLOCK.turnOnW = w; end; end; end; }:Register();
mit
elbamos/nn
Module.lua
2
10988
local Module = torch.class('nn.Module') function Module:__init() self.gradInput = torch.Tensor() self.output = torch.Tensor() self._type = self.output:type() end function Module:parameters() if self.weight and self.bias then return {self.weight, self.bias}, {self.gradWeight, self.gradBias} elseif self.weight then return {self.weight}, {self.gradWeight} elseif self.bias then return {self.bias}, {self.gradBias} else return end end function Module:updateOutput(input) return self.output end function Module:forward(input) return self:updateOutput(input) end function Module:backward(input, gradOutput, scale) scale = scale or 1 self:updateGradInput(input, gradOutput) self:accGradParameters(input, gradOutput, scale) return self.gradInput end function Module:backwardUpdate(input, gradOutput, lr) self:updateGradInput(input, gradOutput) self:accUpdateGradParameters(input, gradOutput, lr) return self.gradInput end function Module:updateGradInput(input, gradOutput) return self.gradInput end function Module:accGradParameters(input, gradOutput, scale) end function Module:accUpdateGradParameters(input, gradOutput, lr) local gradWeight = self.gradWeight local gradBias = self.gradBias self.gradWeight = self.weight self.gradBias = self.bias self:accGradParameters(input, gradOutput, -lr) self.gradWeight = gradWeight self.gradBias = gradBias end function Module:sharedAccUpdateGradParameters(input, gradOutput, lr) if self:parameters() then self:zeroGradParameters() self:accGradParameters(input, gradOutput, 1) self:updateParameters(lr) end end function Module:zeroGradParameters() local _,gradParams = self:parameters() if gradParams then for i=1,#gradParams do gradParams[i]:zero() end end end function Module:updateParameters(learningRate) local params, gradParams = self:parameters() if params then for i=1,#params do params[i]:add(-learningRate, gradParams[i]) end end end function Module:training() self.train = true end function Module:evaluate() self.train = false end function Module:share(mlp, ...) local arg = {...} for i,v in ipairs(arg) do if self[v] ~= nil then self[v]:set(mlp[v]) self.accUpdateGradParameters = self.sharedAccUpdateGradParameters mlp.accUpdateGradParameters = mlp.sharedAccUpdateGradParameters end end return self end function Module:clone(...) local f = torch.MemoryFile("rw"):binary() f:writeObject(self) f:seek(1) local clone = f:readObject() f:close() if select('#',...) > 0 then clone:share(self,...) end return clone end function Module:type(type, tensorCache) if not type then return self._type end tensorCache = tensorCache or {} -- find all tensors and convert them for key,param in pairs(self) do self[key] = nn.utils.recursiveType(param, type, tensorCache) end self._type = type return self end function Module:float() return self:type('torch.FloatTensor') end function Module:double() return self:type('torch.DoubleTensor') end function Module:cuda() return self:type('torch.CudaTensor') end function Module:reset() end function Module:write(file) -- Write all values in the object as a table. local object = {} for k, v in pairs(self) do object[k] = v end file:writeObject(object) end function Module:read(file) local object = file:readObject() for k, v in pairs(object) do self[k] = v end end -- This function is not easy to understand. It works as follows: -- -- - gather all parameter tensors for this module (and children); -- count all parameter values (floats) -- - create one ginormous memory area (Storage object) with room for all -- parameters -- - remap each parameter tensor to point to an area within the ginormous -- Storage, and copy it there -- -- It has the effect of making all parameters point to the same memory area, -- which is then returned. -- -- The purpose is to allow operations over all parameters (such as momentum -- updates and serialization), but it assumes that all parameters are of -- the same type (and, in the case of CUDA, on the same device), which -- is not always true. Use for_each() to iterate over this module and -- children instead. -- -- Module._flattenTensorBuffer can be used by other packages (e.g. cunn) -- to specify the type of temporary buffers. For example, the temporary -- buffers for CudaTensor could be FloatTensor, to avoid GPU memory usage. -- -- TODO: This logically belongs to torch.Tensor, not nn. Module._flattenTensorBuffer = {} function Module.flatten(parameters) -- returns true if tensor occupies a contiguous region of memory (no holes) local function isCompact(tensor) local sortedStride, perm = torch.sort( torch.LongTensor(tensor:nDimension()):set(tensor:stride()), 1, true) local sortedSize = torch.LongTensor(tensor:nDimension()):set( tensor:size()):index(1, perm) local nRealDim = torch.clamp(sortedStride, 0, 1):sum() sortedStride = sortedStride:narrow(1, 1, nRealDim):clone() sortedSize = sortedSize:narrow(1, 1, nRealDim):clone() local t = tensor.new():set(tensor:storage(), 1, sortedSize:storage(), sortedStride:storage()) return t:isContiguous() end if not parameters or #parameters == 0 then return torch.Tensor() end local Tensor = parameters[1].new local TmpTensor = Module._flattenTensorBuffer[torch.type(parameters[1])] or Tensor -- 1. construct the set of all unique storages referenced by parameter tensors local storages = {} local nParameters = 0 local parameterMeta = {} for k = 1,#parameters do local param = parameters[k] local storage = parameters[k]:storage() local storageKey = torch.pointer(storage) if not storages[storageKey] then storages[storageKey] = {storage, nParameters} nParameters = nParameters + storage:size() end parameterMeta[k] = {storageOffset = param:storageOffset() + storages[storageKey][2], size = param:size(), stride = param:stride()} end -- 2. construct a single tensor that will hold all the parameters local flatParameters = TmpTensor(nParameters):zero() -- 3. determine if there are elements in the storage that none of the -- parameter tensors reference ('holes') local tensorsCompact = true for k = 1,#parameters do local meta = parameterMeta[k] local tmp = TmpTensor():set( flatParameters:storage(), meta.storageOffset, meta.size, meta.stride) tmp:fill(1) tensorsCompact = tensorsCompact and isCompact(tmp) end local maskParameters = flatParameters:byte():clone() local compactOffsets = flatParameters:long():cumsum(1) local nUsedParameters = compactOffsets[-1] -- 4. copy storages into the flattened parameter tensor for _, storageAndOffset in pairs(storages) do local storage, offset = table.unpack(storageAndOffset) flatParameters[{{offset+1,offset+storage:size()}}]:copy(Tensor():set(storage)) end -- 5. allow garbage collection storages = nil for k = 1,#parameters do parameters[k]:set(Tensor()) end -- 6. compact the flattened parameters if there were holes if nUsedParameters ~= nParameters then assert(tensorsCompact, "Cannot gather tensors that are not compact") flatParameters = TmpTensor(nUsedParameters):copy( flatParameters:maskedSelect(maskParameters)) for k = 1,#parameters do parameterMeta[k].storageOffset = compactOffsets[parameterMeta[k].storageOffset] end end if TmpTensor ~= Tensor then flatParameters = Tensor(flatParameters:nElement()):copy(flatParameters) end -- 7. fix up the parameter tensors to point at the flattened parameters for k = 1,#parameters do parameters[k]:set(flatParameters:storage(), parameterMeta[k].storageOffset, parameterMeta[k].size, parameterMeta[k].stride) end return flatParameters end function Module:getParameters() -- get parameters local parameters,gradParameters = self:parameters() local p, g = Module.flatten(parameters), Module.flatten(gradParameters) assert(p:nElement() == g:nElement(), 'check that you are sharing parameters and gradParameters') for i=1,#parameters do assert(parameters[i]:storageOffset() == gradParameters[i]:storageOffset(), 'misaligned parameter at ' .. tostring(i)) end return p, g end function Module:__call__(input, gradOutput) self:forward(input) if gradOutput then self:backward(input, gradOutput) return self.output, self.gradInput else return self.output end end -- Run a callback (called with the module as an argument) in preorder over this -- module and its children. -- function Module:apply(callback) callback(self) if self.modules then for _, module in ipairs(self.modules) do module:apply(callback) end end end function Module:findModules(typename, container) container = container or self local nodes = {} local containers = {} local mod_type = torch.typename(self) if mod_type == typename then nodes[#nodes+1] = self containers[#containers+1] = container end -- Recurse on nodes with 'modules' if (self.modules ~= nil) then if (torch.type(self.modules) == 'table') then for i = 1, #self.modules do local child = self.modules[i] local cur_nodes, cur_containers = child:findModules(typename, self) assert(#cur_nodes == #cur_containers, 'Internal error: incorrect return length') -- This shouldn't happen -- add the list items from our child to our list (ie return a -- flattened table of the return nodes). for j = 1, #cur_nodes do nodes[#nodes+1] = cur_nodes[j] containers[#containers+1] = cur_containers[j] end end end end return nodes, containers end -- returns a list of modules function Module:listModules() local function tinsert(to, from) if torch.type(from) == 'table' then for i=1,#from do tinsert(to,from[i]) end else table.insert(to,from) end end -- include self first local modules = {self} if self.modules then for i=1,#self.modules do local modulas = self.modules[i]:listModules() if modulas then tinsert(modules,modulas) end end end return modules end function Module:clearState() return nn.utils.clear(self, 'output', 'gradInput') end
bsd-3-clause
tridge/ardupilot
libraries/AP_Scripting/examples/param_add.lua
10
1480
-- example for adding parameters to a lua script -- the table key must be used by only one script on a particular flight -- controller. If you want to re-use it then you need to wipe your old parameters -- the key must be a number between 0 and 200. The key is persistent in storage local PARAM_TABLE_KEY = 72 -- create a parameter table with 2 parameters in it. A table can have -- at most 63 parameters. The table size for a particular table key -- cannot increase without a reboot. The prefix "MY_" is used with -- every parameter in the table. This prefix is used to ensure another -- script doesn't use the same PARAM_TABLE_KEY. assert(param:add_table(PARAM_TABLE_KEY, "MY_", 2), 'could not add param table') -- create two parameters. The param indexes (2nd argument) must -- be between 1 and 63. All added parameters are floats, with the given -- default value (4th argument). assert(param:add_param(PARAM_TABLE_KEY, 1, 'TEST', 3.14), 'could not add param1') assert(param:add_param(PARAM_TABLE_KEY, 2, 'TEST2', 5.7), 'could not add param2') gcs:send_text(0, string.format("Added two parameters")) -- bind a parameter to a variable function bind_param(name) local p = Parameter() assert(p:init(name), string.format('could not find %s parameter', name)) return p end local param1 = bind_param("MY_TEST") local param2 = bind_param("MY_TEST2") gcs:send_text(0, string.format("param1=%f", param1:get())) gcs:send_text(0, string.format("param2=%f", param2:get()))
gpl-3.0
jshackley/darkstar
scripts/zones/Windurst_Waters_[S]/npcs/Ponono.lua
38
1047
----------------------------------- -- Area: Windurst Waters (S) -- NPC: Ponono -- Type: Standard NPC -- @zone: 94 -- @pos 156.069 -0.001 -15.667 -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/Windurst_Waters_[S]/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x00c1); 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
jshackley/darkstar
scripts/zones/Windurst_Woods/npcs/Wije_Tiren.lua
36
1496
----------------------------------- -- Area: Windurst Woods -- NPC: Wije Tiren -- Standard Merchant NPC -- Confirmed shop stock, August 2013 ----------------------------------- require("scripts/globals/shop"); package.loaded["scripts/zones/Windurst_Woods/TextIDs"] = nil; require("scripts/zones/Windurst_Woods/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc,WIJETIREN_SHOP_DIALOG); stock = { 0x1034, 290, --Antidote 0x119d, 10, --Distilled Water 0x1037, 728, --Echo Drops 0x1020, 4445, --Ether 0x1036, 2387, --Eye Drops 0x1010, 837, --Potion 0x1396, 98, --Scroll of Herb Pastoral 0x0b30, 9200 --Federation Waystone } showShop(player, WINDURST, stock); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
jshackley/darkstar
scripts/zones/Aht_Urhgan_Whitegate/npcs/Bajahb.lua
34
1274
----------------------------------- -- Area: Aht Urhgan Whitegate -- NPC: Bajahb -- Standard Merchant NPC ----------------------------------- package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs"); require("scripts/globals/shop"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc,BAJAHB_SHOP_DIALOG); stock = {0x3088,10260, --Iron Mask 0x3108,15840, --Chainmail 0x3188,8460, --Chain Mittens 0x3208,12600, --Chain Hose 0x3288,7740} --Greaves 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
botmohammad12344888/bot-888338888
plugins/admin.lua
17
6859
local function set_bot_photo(msg, success, result) local receiver = get_receiver(msg) if success then local file = 'data/photos/bot.jpg' print('File downloaded to:', result) os.rename(result, file) print('File moved to:', file) set_profile_photo(file, ok_cb, false) send_large_msg(receiver, 'Photo changed!', ok_cb, false) redis:del("bot:photo") else print('Error downloading: '..msg.id) send_large_msg(receiver, 'Failed, please try again!', ok_cb, false) end end local function parsed_url(link) local parsed_link = URL.parse(link) local parsed_path = URL.parse_path(parsed_link.path) return parsed_path[2] end local function get_contact_list_callback (cb_extra, success, result) local text = " " for k,v in pairs(result) do if v.print_name and v.id and v.phone then text = text..string.gsub(v.print_name , "_" , " ").." ["..v.id.."] = "..v.phone.."\n" end end local file = io.open("contact_list.txt", "w") file:write(text) file:flush() file:close() send_document("user#id"..cb_extra.target,"contact_list.txt", ok_cb, false)--.txt format local file = io.open("contact_list.json", "w") file:write(json:encode_pretty(result)) file:flush() file:close() send_document("user#id"..cb_extra.target,"contact_list.json", ok_cb, false)--json format end local function user_info_callback(cb_extra, success, result) result.access_hash = nil result.flags = nil result.phone = nil if result.username then result.username = '@'..result.username end result.print_name = result.print_name:gsub("_","") local text = serpent.block(result, {comment=false}) text = text:gsub("[{}]", "") text = text:gsub('"', "") text = text:gsub(",","") if cb_extra.msg.to.type == "chat" then send_large_msg("chat#id"..cb_extra.msg.to.id, text) else send_large_msg("user#id"..cb_extra.msg.to.id, text) end end local function get_dialog_list_callback(cb_extra, success, result) local text = "" for k,v in pairs(result) do if v.peer then if v.peer.type == "chat" then text = text.."group{"..v.peer.title.."}["..v.peer.id.."]("..v.peer.members_num..")" else if v.peer.print_name and v.peer.id then text = text.."user{"..v.peer.print_name.."}["..v.peer.id.."]" end if v.peer.username then text = text.."("..v.peer.username..")" end if v.peer.phone then text = text.."'"..v.peer.phone.."'" end end end if v.message then text = text..'\nlast msg >\nmsg id = '..v.message.id if v.message.text then text = text .. "\n text = "..v.message.text end if v.message.action then text = text.."\n"..serpent.block(v.message.action, {comment=false}) end if v.message.from then if v.message.from.print_name then text = text.."\n From > \n"..string.gsub(v.message.from.print_name, "_"," ").."["..v.message.from.id.."]" end if v.message.from.username then text = text.."( "..v.message.from.username.." )" end if v.message.from.phone then text = text.."' "..v.message.from.phone.." '" end end end text = text.."\n\n" end local file = io.open("dialog_list.txt", "w") file:write(text) file:flush() file:close() send_document("user#id"..cb_extra.target,"dialog_list.txt", ok_cb, false)--.txt format local file = io.open("dialog_list.json", "w") file:write(json:encode_pretty(result)) file:flush() file:close() send_document("user#id"..cb_extra.target,"dialog_list.json", ok_cb, false)--json format end local function run(msg,matches) local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) local group = msg.to.id if not is_admin(msg) then return end if msg.media then if msg.media.type == 'photo' and redis:get("bot:photo") then if redis:get("bot:photo") == 'waiting' then load_photo(msg.id, set_bot_photo, msg) end end end if matches[1] == "setbotphoto" then redis:set("bot:photo", "waiting") return 'Please send me bot photo now' end if matches[1] == "markread" then if matches[2] == "on" then redis:set("bot:markread", "on") return "Mark read > on" end if matches[2] == "off" then redis:del("bot:markread") return "Mark read > off" end return end if matches[1] == "pm" then send_large_msg("user#id"..matches[2],matches[3]) return "Msg sent" end if matches[1] == "block" then if is_admin2(matches[2]) then return "You can't block admins" end block_user("user#id"..matches[2],ok_cb,false) return "User blocked" end if matches[1] == "unblock" then unblock_user("user#id"..matches[2],ok_cb,false) return "User unblocked" end if matches[1] == "import" then--join by group link local hash = parsed_url(matches[2]) import_chat_link(hash,ok_cb,false) end if matches[1] == "contactlist" then get_contact_list(get_contact_list_callback, {target = msg.from.id}) return "I've sent contact list with both json and text format to your private" end if matches[1] == "addcontact" and matches[2] then add_contact(matches[2],matches[3],matches[4],ok_cb,false) return "Number "..matches[2].." add from contact list" end if matches[1] == "delcontact" then del_contact("user#id"..matches[2],ok_cb,false) return "User "..matches[2].." removed from contact list" end if matches[1] == "dialoglist" then get_dialog_list(get_dialog_list_callback, {target = msg.from.id}) return "I've sent dialog list with both json and text format to your private" end if matches[1] == "whois" then user_info("user#id"..matches[2],user_info_callback,{msg=msg}) end return end return { patterns = { "^[#!/](pm) (%d+) (.*)$", "^[#!/](import) (.*)$", "^[#!/](unblock) (%d+)$", "^[#!/](block) (%d+)$", "^[#!/](markread) (on)$", "^[#!/](markread) (off)$", "^[#!/](setbotphoto)$", "%[(photo)%]", "^[#!/](contactlist)$", "^[#!/](dialoglist)$", "^[#!/](delcontact) (%d+)$", "^[#!/](whois) (%d+)$", "^(pm) (%d+) (.*)$", "^(import) (.*)$", "^(unblock) (%d+)$", "^(block) (%d+)$", "^(markread) (on)$", "^(markread) (off)$", "^(setbotphoto)$", "^(addcontact) (%d+) (.+) (.*)", "^(contactlist)$", "^(dialoglist)$", "^(delcontact) (%d+)$", "^(whois) (%d+)$" }, run = run, } --By @imandaneshi :) --https://github.com/SEEDTEAM/TeleSeed/blob/master/plugins/admin.lua
gpl-2.0
jshackley/darkstar
scripts/zones/The_Boyahda_Tree/Zone.lua
9
1831
----------------------------------- -- -- Zone: The_Boyahda_Tree (153) -- ----------------------------------- package.loaded["scripts/zones/The_Boyahda_Tree/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/zone"); require("scripts/zones/The_Boyahda_Tree/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) local tomes = {17404406,17404407,17404408,17404409}; SetGroundsTome(tomes); UpdateTreasureSpawnPoint(17404390); 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(-140.008,3.787,202.715,64); end return cs; end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
jshackley/darkstar
scripts/zones/FeiYin/TextIDs.lua
15
2354
-- Variable TextID Description text -- General Texts ITEM_CANNOT_BE_OBTAINED = 6558; -- You cannot obtain the item <item> come back again after sorting your inventory ITEM_OBTAINED = 6563; -- Obtained: <item> GIL_OBTAINED = 6564; -- Obtained <number> gil KEYITEM_OBTAINED = 6566; -- Obtained key item: <keyitem> FISHING_MESSAGE_OFFSET = 7224; -- You can't fish here HOMEPOINT_SET = 10679; -- Home point set! -- Treasure Coffer/Chest Dialog CHEST_UNLOCKED = 7349; -- You unlock the chest! CHEST_FAIL = 7350; -- Fails to open the chest. CHEST_TRAP = 7351; -- The chest was trapped! CHEST_WEAK = 7352; -- You cannot open the chest when you are in a weakened state. CHEST_MIMIC = 7353; -- The chest was a mimic! CHEST_MOOGLE = 7354; -- You cannot open the chest while participating in the moogle event. CHEST_ILLUSION = 7355; -- The chest was but an illusion... CHEST_LOCKED = 7356; -- The chest appears to be locked. -- Other Dialog SENSE_OF_FOREBODING = 6578; -- You are suddenly overcome with a sense of foreboding... NOTHING_OUT_OF_ORDINARY = 6577; -- There is nothing out of the ordinary here. -- ACP mission MARK_OF_SEED_HAS_VANISHED = 7492; -- The Mark of Seed has vanished without a trace... MARK_OF_SEED_IS_ABOUT_TO_DISSIPATE = 7491; -- The Mark of Seed is about to dissipate entirely! Only a faint outline remains... MARK_OF_SEED_GROWS_FAINTER = 7490; -- The Mark of Seed grows fainter still. Before long, it will fade away entirely... MARK_OF_SEED_FLICKERS = 7489; -- The glow of the Mark of Seed flickers and dims ever so slightly... SCINTILLATING_BURST_OF_LIGHT = 7480; -- As you extend your hand, there is a scintillating burst of light! YOU_REACH_FOR_THE_LIGHT = 7479; -- You reach for the light, but there is no discernable effect... EVEN_GREATER_INTENSITY = 7478; -- The emblem on your hand glows with even greater intensity! THE_LIGHT_DWINDLES = 7477; -- However, the light dwindles and grows dim almost at once... YOU_REACH_OUT_TO_THE_LIGHT = 7476; -- You reach out to the light, and one facet of a curious seed-shaped emblem materializes on the back of your hand. SOFTLY_SHIMMERING_LIGHT = 7475; -- You see a softly shimmering light... -- conquest Base CONQUEST_BASE = 3;
gpl-3.0
Mythikos/Flood-2.0
flood/gamemode/server/sv_roundcontroller.lua
1
4645
util.AddNetworkString("RoundState") GM.GameState = GAMEMODE and GAMEMODE.GameState or 0 -- -- Game States -- 0 = Waiting for players to join -- 1 = Building Phase -- 2 = Flood Phase -- 3 = Fight Phase -- 4 = Reset Phase -- -- function GM:GetGameState() return self.GameState end function GM:SetGameState(state) self.GameState = state end function GM:GetStateStart() return self.StateStart end function GM:GetStateRunningTime() return CurTime() - self.StateStart end local tNextThink = 0 function GM:TimerController() if CurTime() >= tNextThink then if self:GetGameState() == 0 then self:CheckPhase() elseif self:GetGameState() == 1 then self:BuildPhase() elseif self:GetGameState() == 2 then self:FloodPhase() elseif self:GetGameState() == 3 then self:FightPhase() elseif self:GetGameState() == 4 then self:ResetPhase() end local gState = self:GetGameState() -- Because gamestate was nil every other way -_- net.Start("RoundState") net.WriteFloat(gState) net.WriteFloat(Flood_buildTime) net.WriteFloat(Flood_floodTime) net.WriteFloat(Flood_fightTime) net.WriteFloat(Flood_resetTime) net.Broadcast() tNextThink = CurTime() + 1 end end function GM:CheckPhase() local count = 0 for _, v in pairs(player.GetAll()) do if IsValid(v) and v:Alive() then count = count + 1 end end if count >= 2 then -- Time to build self:SetGameState(1) -- Clean the map, game is about to start self:CleanupMap() -- Respawn all the players for _, v in pairs(player.GetAll()) do if IsValid(v) then v:Spawn() end end end end function GM:BuildPhase() if Flood_buildTime <= 0 then -- Time to Flood self:SetGameState(2) -- Nobody can respawn now for _, v in pairs(player.GetAll()) do if IsValid(v) then v:SetCanRespawn(false) end end -- Prep phase two for _, v in pairs(self:GetActivePlayers()) do v:StripWeapons() v:RemoveAllAmmo() v:SetHealth(100) v:SetArmor(0) end -- Remove teh shitty windows that are above players. for _, v in pairs(ents.FindByClass("func_breakable")) do v:Fire("Break", "", 0) end -- Unfreeze everything for _, v in pairs(ents.GetAll()) do if IsValid(v) then local phys = v:GetPhysicsObject() if phys:IsValid() then phys:EnableMotion(true) phys:Wake() end end end -- Raise the water self:RiseAllWaterControllers() else Flood_buildTime = Flood_buildTime - 1 end end function GM:FloodPhase() if Flood_floodTime <= 0 then -- Time to Kill self:SetGameState(3) -- Its time to fight! self:GivePlayerWeapons() else Flood_floodTime = Flood_floodTime - 1 end end function GM:FightPhase() if Flood_fightTime <= 0 then -- Time to Reset self:SetGameState(4) -- Lower Water self:LowerAllWaterControllers() -- Declare winner is nobody because time ran out self:DeclareWinner(3) else Flood_fightTime = Flood_fightTime - 1 self:ParticipationBonus() end end function GM:ResetPhase() if Flood_resetTime <= 0 then -- Time to wait for players (if players exist, should go to build phase) self:SetGameState(0) -- Give people their money self:RefundAllProps() -- Game is over, lets tidy up the players for _, v in pairs(player.GetAll()) do if IsValid(v) then v:SetCanRespawn(true) -- Wait till they respawn timer.Simple(0, function() v:StripWeapons() v:RemoveAllAmmo() v:SetHealth(100) v:SetArmor(0) timer.Simple(0, function() v:Give("gmod_tool") v:Give("weapon_physgun") v:Give("flood_propseller") v:SelectWeapon("weapon_physgun") end) end) end end -- Reset all the round timers self:ResetAllTimers() else Flood_resetTime = Flood_resetTime - 1 end end function GM:InitializeRoundController() Flood_buildTime = GetConVar("flood_build_time"):GetFloat() Flood_floodTime = GetConVar("flood_flood_time"):GetFloat() Flood_fightTime = GetConVar("flood_fight_time"):GetFloat() Flood_resetTime = GetConVar("flood_reset_time"):GetFloat() hook.Add("Think", "Flood_TimeController", function() hook.Call("TimerController", GAMEMODE) end) end function GM:ResetAllTimers() Flood_buildTime = GetConVar("flood_build_time"):GetFloat() Flood_floodTime = GetConVar("flood_flood_time"):GetFloat() Flood_fightTime = GetConVar("flood_fight_time"):GetFloat() Flood_resetTime = GetConVar("flood_reset_time"):GetFloat() end
mit
jshackley/darkstar
scripts/zones/North_Gustaberg/npcs/Cavernous_Maw.lua
29
1494
----------------------------------- -- Area: North Gustaberg -- NPC: Cavernous Maw -- @pos 466 0 479 106 -- Teleports Players to North Gustaberg [S] ----------------------------------- package.loaded["scripts/zones/North_Gustaberg/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/teleports"); require("scripts/globals/campaign"); require("scripts/zones/North_Gustaberg/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (ENABLE_WOTG == 1 and player:hasKeyItem(PURE_WHITE_FEATHER) and hasMawActivated(player,7)) then player:startEvent(0x0387); else player:messageSpecial(NOTHING_HAPPENS); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish Action ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID:",csid); -- printf("RESULT:",option); if (csid == 0x0387 and option == 1) then toMaw(player,11); end end;
gpl-3.0
goksie/newfies-dialer
lua/libs/session.lua
4
3116
-- -- Newfies-Dialer License -- http://www.newfies-dialer.org -- -- This Source Code Form is subject to the terms of the Mozilla Public -- License, v. 2.0. If a copy of the MPL was not distributed with this file, -- You can obtain one at http://mozilla.org/MPL/2.0/. -- -- Copyright (C) 2011-2014 Star2Billing S.L. -- -- The Initial Developer of the Original Code is -- Arezqui Belaid <info@star2billing.com> -- package.path = package.path .. ";/usr/share/newfies-lua/?.lua"; package.path = package.path .. ";/usr/share/newfies-lua/libs/?.lua"; local oo = require "loop.simple" Session = oo.class{ -- default field values myvar = nil, } function Session:__init(timecache) -- self is the class return oo.rawnew(self, { timecache = timecache }) end -- we will simulate the freeswitch Session instances function Session:ready() print("Session:ready") return true end function Session:answer() print("Session:answer") return true end function Session:preAnswer() print("Session:preAnswer") return true end function Session:hangup() print("Session:hangup") return true end function Session:setHangupHook(data) print("Session:setHangupHook -> "..data) return true end function Session:setInputCallback(data) print("Session:setInputCallback -> "..data) return true end function Session:execute(data) print("Session:execute -> "..data) return true end function Session:hangupCause() print("Session:hangupCause") return "ANSWER" end function Session:getVariable(varname) var_value = math.random(100000, 999999) if varname == 'campaign_id' then var_value = 0 elseif varname == 'amd_status' then var_value = 'person' --var_value = 'machine' elseif varname == 'uuid' then var_value = math.random(1000, 9999)..'-'..math.random(1000, 9999)..'-'.. math.random(1000, 9999)..'-'..math.random(1000, 9999) end print("Session:getVariable -> "..varname.." = "..var_value) return var_value end function Session:streamFile(data) print("Session:streamFile -> "..data) return true end function Session:set_tts_parms(engine, voice) print("Session:set_tts_parms -> "..engine.."-"..voice) return true end function Session:speak(data) print("Session:speak -> "..data) return true end function Session:playAndGetDigits(min_digits, max_digits, max_attempts, timeout, terminators, prompt_audio_files, input_error_audio_files, digit_regex, variable_name, digit_timeout, transfer_on_failure) print("Session:playAndGetDigits -> "..prompt_audio_files) local digits repeat io.write("Enter some digits and press Enter ==> ") io.flush() digits=io.read() print(string.len(digits)) until string.len(digits) > 0 return digits end function Session:recordFile(recording_filename, max_len_secs, silence_threshold, silence_secs) print("Session:recordFile -> "..recording_filename) return true end function Session:sayPhrase(data) print("Session:sayPhrase -> "..data) return true end
mpl-2.0
jshackley/darkstar
scripts/zones/Lower_Jeuno/npcs/Sniggnix.lua
19
2175
----------------------------------- -- Area: Lower Jeuno -- NPC: Sniggnix -- Type: Standard NPC -- @zone: 245 -- @pos -45.832 4.498 -135.029 -- -- Auto-Script: Requires Verification (Verfied by Brawndo) ----------------------------------- package.loaded["scripts/zones/Lower_Jeuno/TextIDs"] = nil; ----------------------------------- require("scripts/globals/keyitems"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) thickAsThievesGamblingCS = player:getVar("thickAsThievesGamblingCS"); if (trade:hasItemQty(1092,1) and trade:getItemCount() == 1 and thickAsThievesGamblingCS == 7) then -- Trade Regal die rand1 = math.random(1,700); player:startEvent(0x272a,0,1092,rand1); -- complete gambling side quest for as thick as thieves end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) thickAsThievesGamblingCS = player:getVar("thickAsThievesGamblingCS"); if (thickAsThievesGamblingCS == 1) then rand1 = math.random(1,999); rand2 = math.random(1,999); player:startEvent(0x2728,0,1092,rand1,rand2); elseif (thickAsThievesGamblingCS >= 2 and thickAsThievesGamblingCS <= 6) then player:startEvent(0x2729,0,1092,rand1,rand2); else player:startEvent(0x2727); 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 == 0x2728 and option == 1) then -- player won first dice game player:setVar("thickAsThievesGamblingCS",2); elseif (csid == 0x272a) then player:tradeComplete(); player:setVar("thickAsThievesGamblingCS",8); player:delKeyItem(SECOND_FORGED_ENVELOPE); player:addKeyItem(SECOND_SIGNED_FORGED_ENVELOPE); player:messageSpecial(KEYITEM_OBTAINED,SECOND_SIGNED_FORGED_ENVELOPE); end end;
gpl-3.0
jshackley/darkstar
scripts/zones/Mhaura/npcs/Runito-Monito.lua
34
1472
----------------------------------- -- Area: Mhaura -- NPC: Runito-Monito -- Standard Merchant NPC ----------------------------------- package.loaded["scripts/zones/Mhaura/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Mhaura/TextIDs"); require("scripts/globals/shop"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc,RUNITOMONITO_SHOP_DIALOG); stock = {0x4015,106, --Cat Bagnakhs 0x4017,1554, --Brass Bagnakhs 0x4041,855, --Brass Dagger 0x42a3,92, --Bronze Rod 0x42b9,634, --Brass Rod 0x4093,3601, --Brass Xiphos 0x40c7,2502, --Claymore 0x4140,618, --Butterfly Axe 0x439b,9, --Dart 0x43a6,3, --Wooden Arrow 0x43a7,4, --Bone Arrow 0x43b8,5} --Crossbow Bolts 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
hockeychaos/Core-Scripts-1
CoreScriptsRoot/Modules/ActionBindingsTab.lua
1
14177
local CoreGui = game:GetService("CoreGui") local ContextActionService = game:GetService("ContextActionService") local TweenService = game:GetService("TweenService") local RobloxGui = CoreGui:WaitForChild("RobloxGui") local Utility = require(RobloxGui.Modules.Settings.Utility) local INPUT_TYPE_ROW_HEIGHT = 30 local ACTION_ROW_HEIGHT = 20 local ROW_PADDING = 5 local COLUMN_PADDING = 5 local CORE_SECURITY_COLUMN_COLOR = Color3.new(0.1, 0, 0) local DEV_SECURITY_COLUMN_COLOR = Color3.new(0, 0, 0) local EXPAND_ROTATE_IMAGE_TWEEN_OUT = TweenInfo.new(0.150, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut) local EXPAND_ROTATE_IMAGE_TWEEN_IN = TweenInfo.new(0.150, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut) local ROW_PULSE = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, true, 0) local CONTAINER_SCROLL = TweenInfo.new(0.25, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut) local container = nil local boundInputTypeRows = {} local boundInputTypesByRows = {} local boundInputTypeActionRows = {} local boundActionInfoByRows = {} local inputTypesByActionRows = {} local inputTypesByHeaders = {} local headersByInputTypes = {} local inputTypesExpanded = {} local rowTypePrecedence = { BoundInputType = 3, TableHeader = 2, BoundAction = 1 } local function sortByInputType(a, b) return tostring(a) < tostring(b) end local function getInputType(x) if x.Name == "BoundAction" then return inputTypesByActionRows[x] elseif x.Name == "BoundInputType" then return boundInputTypesByRows[x] elseif x.Name == "TableHeader" then return inputTypesByHeaders[x] end end local function sortActionRows(a, b) if a.Name == "BoundAction" and b.Name == "BoundAction" then local actionA = boundActionInfoByRows[a] local actionB = boundActionInfoByRows[b] if actionA and actionB then local rowInputTypeA = inputTypesByActionRows[a] local rowInputTypeB = inputTypesByActionRows[b] if rowInputTypeA ~= rowInputTypeB then return sortByInputType(rowInputTypeA, rowInputTypeB) end if actionA.isCore and not actionB.isCore then return true elseif not actionA.isCore and actionB.isCore then return false end local stackOrderA = actionA.stackOrder local stackOrderB = actionB.stackOrder if stackOrderA and stackOrderB then return stackOrderA > stackOrderB --descending sort else return true end else return true end else local inputTypeA = getInputType(a) local inputTypeB = getInputType(b) if a.Name == b.Name then return sortByInputType(inputTypeA, inputTypeB) end if inputTypeA == inputTypeB then return rowTypePrecedence[a.Name] > rowTypePrecedence[b.Name] end return sortByInputType(inputTypeA, inputTypeB) end return true end local function createEmptyRow(name, height) local row = Utility:Create("Frame") { Name = name, BackgroundTransparency = 1, ZIndex = 6, Size = UDim2.new(1, 0, 0, height or 0) } local columnList = Utility:Create("UIListLayout") { FillDirection = Enum.FillDirection.Horizontal, SortOrder = Enum.SortOrder.LayoutOrder, Padding = UDim.new(0, COLUMN_PADDING), Parent = row } return row end local function createButtonRow(name, height) local row = Utility:Create("TextButton") { Name = name, BackgroundTransparency = 1, ZIndex = 6, Text = "", Size = UDim2.new(1, 0, 0, height or 0), } local columnList = Utility:Create("UIListLayout") { FillDirection = Enum.FillDirection.Horizontal, SortOrder = Enum.SortOrder.LayoutOrder, Padding = UDim.new(0, COLUMN_PADDING), Parent = row } return row end local function createEmptyColumn(row, columnName) local column = Utility:Create("Frame") { Name = columnName, BackgroundColor3 = Color3.new(0, 0, 0), BackgroundTransparency = 0.75, BorderSizePixel = 0, Size = UDim2.new(1, 0, 1, 0), ZIndex = 6, ClipsDescendants = true, Parent = row } return column end local function createImageColumn(row, columnName, image, aspectRatio, imageSize) local column = createEmptyColumn(row, columnName) local aspectRatioConstraint = Utility:Create("UIAspectRatioConstraint") { AspectRatio = aspectRatio or 1, Parent = column } local imageLabel = Utility:Create("ImageLabel") { Name = "ColumnImage", BackgroundTransparency = 1, Position = UDim2.new(0.5, 0, 0.5, 0), Size = UDim2.new(imageSize or 1, 0, imageSize or 1, 0), AnchorPoint = Vector2.new(0.5, 0.5), ZIndex = 6, Image = image, Parent = column } return column end local function createTextColumn(row, columnName, text) local column = createEmptyColumn(row, columnName) local textLabel = Utility:Create("TextLabel") { Name = "ColumnText", BackgroundTransparency = 1, Position = UDim2.new(0.5, 0, 0.5, 0), Size = UDim2.new(1, -10, 1, -10), AnchorPoint = Vector2.new(0.5, 0.5), ZIndex = 6, Text = text, TextSize = 18, TextColor3 = Color3.new(1, 1, 1), TextXAlignment = Enum.TextXAlignment.Left, Font = Enum.Font.SourceSans, Parent = column } return column end local function createActionColumns(row, backgroundColor) local x = 0 local insetWidth = ACTION_ROW_HEIGHT + (COLUMN_PADDING * 2) local insetCol = createEmptyColumn(row, "Inset") insetCol.LayoutOrder = 0 insetCol.BackgroundTransparency = 1 insetCol.Size = UDim2.new(0, insetWidth, 1, 0) x = x + insetWidth + COLUMN_PADDING local priorityWidth = 80 local priorityCol = createTextColumn(row, "Priority", "Priority") priorityCol.LayoutOrder = 1 priorityCol.BackgroundColor3 = backgroundColor priorityCol.Size = UDim2.new(0, priorityWidth, 1, 0) x = x + priorityWidth + COLUMN_PADDING local securityWidth = 80 local securityCol = createTextColumn(row, "Security", "Security") securityCol.LayoutOrder = 2 securityCol.BackgroundColor3 = backgroundColor securityCol.Size = UDim2.new(0, securityWidth, 1, 0) x = x + securityWidth + COLUMN_PADDING local nameCol = createTextColumn(row, "ActionName", "Action Name") nameCol.LayoutOrder = 3 nameCol.BackgroundColor3 = backgroundColor nameCol.Size = UDim2.new(1/4, 0, 1, 0) local inputTypesCol = createTextColumn(row, "InputTypes", "Input Types") inputTypesCol.LayoutOrder = 4 inputTypesCol.BackgroundColor3 = backgroundColor inputTypesCol.Size = UDim2.new(3/4, -x - COLUMN_PADDING, 1, 0) return insetCol, priorityCol, securityCol, nameCol, inputTypesCol end local function updateContainerCanvas() local y = 0 for _, v in pairs(container:GetChildren()) do if v:IsA("GuiObject") and v.Visible then y = y + v.AbsoluteSize.Y + ROW_PADDING end end container.CanvasSize = UDim2.new(0, 0, 0, y) end local function scrollContainerToRow(row) local scrollOffset = row.AbsolutePosition.Y - container.AbsolutePosition.Y local newCanvasPosition = container.CanvasPosition + Vector2.new(0, scrollOffset) TweenService:Create(container, CONTAINER_SCROLL, { CanvasPosition = newCanvasPosition }):Play() end local ActionBindingsTab = {} function ActionBindingsTab.initializeGui(tabFrame) local scrollingFrame = Utility:Create("ScrollingFrame") { Position = UDim2.new(0.5, 0, 0.5, 0), Size = UDim2.new(1, -10, 1, -10), AnchorPoint = Vector2.new(0.5, 0.5), BorderSizePixel = 0, ScrollBarThickness = 4, BackgroundTransparency = 1, ZIndex = 6, Parent = tabFrame } container = scrollingFrame local listLayout = Utility:Create("UIListLayout") { Padding = UDim.new(0, ROW_PADDING), Parent = scrollingFrame } listLayout:SetCustomSortFunction(sortActionRows) listLayout.SortOrder = Enum.SortOrder.Custom ActionBindingsTab.updateGuis() ContextActionService.BoundActionAdded:connect(function(actionName, createTouchButton, actionInfo, isCore) actionInfo.isCore = isCore ActionBindingsTab.updateActionRows(actionName, actionInfo) end) ContextActionService.BoundActionRemoved:connect(function(actionName, actionInfo, isCore) actionInfo.isCore = isCore ActionBindingsTab.removeActionRows(actionName, actionInfo) end) end function ActionBindingsTab.updateBoundInputTypeRow(inputType) local existingRow = boundInputTypeRows[inputType] if not existingRow then local row = createButtonRow("BoundInputType", INPUT_TYPE_ROW_HEIGHT) local expandImageCol = createImageColumn(row, "ExpandImage", "rbxasset://textures/ui/Icons/DownIndicatorIcon@1080.png", 1, 0.35) expandImageCol.ColumnImage.Rotation = -90 local inputTypeCol = createTextColumn(row, "InputType", tostring(inputType)) inputTypeCol.Size = UDim2.new(1, -INPUT_TYPE_ROW_HEIGHT - COLUMN_PADDING, 1, 0) inputTypeCol.ColumnText.Font = Enum.Font.SourceSansBold local tableHeaderRow = createEmptyRow("TableHeader", ACTION_ROW_HEIGHT) tableHeaderRow.Visible = false local _, priorityCol, securityCol, nameCol, inputTypesCol = createActionColumns(tableHeaderRow, DEV_SECURITY_COLUMN_COLOR) priorityCol.ColumnText.Font = Enum.Font.SourceSansBold securityCol.ColumnText.Font = Enum.Font.SourceSansBold nameCol.ColumnText.Font = Enum.Font.SourceSansBold inputTypesCol.ColumnText.Font = Enum.Font.SourceSansBold boundInputTypeRows[inputType] = row boundInputTypesByRows[row] = inputType inputTypesByHeaders[tableHeaderRow] = inputType headersByInputTypes[inputType] = tableHeaderRow tableHeaderRow.Parent = container row.Parent = container TweenService:Create(inputTypeCol, ROW_PULSE, { BackgroundColor3 = Color3.new(0.5, 0.5, 0.5) }):Play() inputTypesExpanded[inputType] = false row.MouseButton1Click:connect(function() inputTypesExpanded[inputType] = not inputTypesExpanded[inputType] local inputTypeActionRows = boundInputTypeActionRows[inputType] if not inputTypesExpanded[inputType] then TweenService:Create(expandImageCol.ColumnImage, EXPAND_ROTATE_IMAGE_TWEEN_OUT, { Rotation = -90 }):Play() tableHeaderRow.Visible = false if inputTypeActionRows then for _, actionRow in pairs(inputTypeActionRows) do actionRow.Visible = false end end else TweenService:Create(expandImageCol.ColumnImage, EXPAND_ROTATE_IMAGE_TWEEN_IN, { Rotation = 0 }):Play() tableHeaderRow.Visible = true if inputTypeActionRows then for _, actionRow in pairs(inputTypeActionRows) do actionRow.Visible = true end end end updateContainerCanvas() if inputTypesExpanded[inputType] then TweenService:Create(inputTypeCol, ROW_PULSE, { BackgroundColor3 = Color3.new(0.5, 0.5, 0.5) }):Play() scrollContainerToRow(row) end end) end end function ActionBindingsTab.updateActionRowForInputType(actionName, actionInfo, inputType) local inputTypeActionRows = boundInputTypeActionRows[inputType] if not inputTypeActionRows then inputTypeActionRows = {} boundInputTypeActionRows[inputType] = inputTypeActionRows end local existingRow = inputTypeActionRows[actionName] if not existingRow then local row = createEmptyRow("BoundAction", ACTION_ROW_HEIGHT) row.Visible = inputTypesExpanded[inputType] local inputTypeNames = {} for i, inputType in pairs(actionInfo.inputTypes) do inputTypeNames[i] = tostring(inputType) end local insetCol, priorityCol, securityCol, nameCol, inputTypesCol = createActionColumns(row, actionInfo.isCore and CORE_SECURITY_COLUMN_COLOR or DEV_SECURITY_COLUMN_COLOR) priorityCol.ColumnText.Text = actionInfo.priorityLevel or "Default" securityCol.ColumnText.Text = actionInfo.isCore and "Core" or "Developer" nameCol.ColumnText.Text = actionName inputTypesCol.ColumnText.Text = table.concat(inputTypeNames, ", ") if actionInfo.isCore then priorityCol.ColumnText.Font = Enum.Font.SourceSansItalic securityCol.ColumnText.Font = Enum.Font.SourceSansItalic nameCol.ColumnText.Font = Enum.Font.SourceSansItalic inputTypesCol.ColumnText.Font = Enum.Font.SourceSansItalic end inputTypeActionRows[actionName] = row inputTypesByActionRows[row] = inputType boundActionInfoByRows[row] = actionInfo row.Parent = container if row.Visible then TweenService:Create(nameCol, ROW_PULSE, { BackgroundColor3 = Color3.new(0.5, 0.5, 0.5) }):Play() else local inputTypeRow = boundInputTypeRows[inputType] if inputTypeRow then TweenService:Create(inputTypeRow.InputType, ROW_PULSE, { BackgroundColor3 = Color3.new(0.5, 0.5, 0.5) }):Play() end end end end function ActionBindingsTab.updateActionRows(actionName, actionInfo) for _, inputType in pairs(actionInfo.inputTypes) do ActionBindingsTab.updateBoundInputTypeRow(inputType) ActionBindingsTab.updateActionRowForInputType(actionName, actionInfo, inputType) end updateContainerCanvas() end function ActionBindingsTab.removeActionRows(actionName, actionInfo) for _, inputType in pairs(actionInfo.inputTypes) do local inputTypeActionRows = boundInputTypeActionRows[inputType] if inputTypeActionRows then local row = inputTypeActionRows[actionName] row:Destroy() inputTypeActionRows[actionName] = nil --The following code looks weird. It's because Lua has no way to determine --if a table is explicitly empty in both the array and dictionary parts. --This does it though. local isEmpty = true for _, __ in pairs(inputTypeActionRows) do isEmpty = false break end if isEmpty then local inputTypeRow = boundInputTypeRows[inputType] if inputTypeRow then inputTypeRow:Destroy() boundInputTypeRows[inputType] = nil end local tableHeaderRow = headersByInputTypes[inputType] if tableHeaderRow then headersByInputTypes[tableHeaderRow] = nil tableHeaderRow:Destroy() headersByInputTypes[inputType] = nil end end end end updateContainerCanvas() container.UIListLayout:ApplyLayout() end function ActionBindingsTab.updateGuis() local boundCoreActions = ContextActionService:GetAllBoundCoreActionInfo() for actionName, actionInfo in pairs(boundCoreActions) do actionInfo.isCore = true ActionBindingsTab.updateActionRows(actionName, actionInfo) end local boundActions = ContextActionService:GetAllBoundActionInfo() for actionName, actionInfo in pairs(boundActions) do actionInfo.isCore = false ActionBindingsTab.updateActionRows(actionName, actionInfo) end updateContainerCanvas() end return ActionBindingsTab
apache-2.0
JoMiro/arcemu
src/scripts/lua/LuaBridge/Stable Scripts/Outland/Magisters Terrace/UNIT-MagistersTerrace-SunbladeBloodKnight.lua
30
1315
--[[ ******************************** * * * The Moon Project * * * ******************************** This software is provided as free and open source by the staff of The Moon Project, in accordance with the GPL license. This means we provide the software we have created freely and it has been thoroughly tested to work for the developers, but NO GUARANTEE is made it will work for you as well. Please give credit where credit is due, if modifying, redistributing and/or using this software. Thank you. Staff of Moon Project, Feb 2008 ~~End of License Agreement --Moon April 2008]] function SunbladeBloodKnight_OnCombat(Unit, Event) Unit:RegisterAIUpdateEvent(10000) end --[[-- I dont't know how often he does this just set it to 6, 3 sec--]] function SunbladeBloodKnight_HolyLight(Unit, Event) Unit:FullCastSpell(27136) end function SunbladeBloodKnight_LeaveCombat(Unit, Event) Unit:RemoveAIUpdateEvent() end function SunbladeBloodKnight_Died(Unit, Event) Unit:RemoveAIUpdateEvent() end RegisterUnitEvent(27136, 1, "SunbladeBloodKnight_OnCombat") RegisterUnitEvent(27136, 21, "SunbladeBloodKnight_HolyLight") RegisterUnitEvent(27136, 2, "SunbladeBloodKnight_LeaveCombat") RegisterUnitEvent(27136, 4, "SunbladeBloodKnight_Died")
agpl-3.0
sp3ctum/lean
tests/lua/expr3.lua
4
3032
local b1 = binder_info() assert(not b1:is_implicit()) local f = Const("f") local a = Const("a") local t = f(a) assert(t:fn() == f) assert(t:arg() == a) assert(not pcall(function() f:fn() end)) local a1 = Local("a", Prop) local pi1 = Pi(a1, Type) assert(pi1:is_pi()) assert(not pcall(function() f:binding_name() end)) local pi2 = mk_pi("a", Prop, Type, binder_info(true, true)) local pi3 = mk_pi("a", Prop, Type) assert(pi2:binding_info():is_implicit()) assert(not pi3:binding_info():is_implicit()) local l1 = mk_lambda("a", Prop, Var(0)) local l2 = mk_lambda("a", Prop, Var(0), binder_info(true, false)) assert(not l1:binding_info():is_implicit()) assert(l2:binding_info():is_implicit()) local a = Local("a", Prop) local b = Local("b", Prop) local pi3 = Pi(a, b, a) print(pi3) assert(not pcall(function() Pi(a) end)) local pi4 = Pi(a, b, a) print(pi4) assert(pi4:binding_name() == name("a")) assert(pi4:binding_domain() == Prop) assert(pi4:binding_body():is_pi()) assert(f:kind() == expr_kind.Constant) assert(pi3:kind() == expr_kind.Pi) assert(f:is_constant()) assert(Var(0):is_var()) assert(f(a):is_app()) assert(l1:is_lambda()) assert(pi3:is_pi()) assert(l1:is_binding()) assert(pi3:is_binding()) assert(mk_metavar("m", Prop):is_metavar()) assert(mk_local("m", Prop):is_local()) assert(mk_metavar("m", Prop):is_mlocal()) assert(mk_local("m", Prop):is_mlocal()) assert(mk_metavar("m", Prop):is_meta()) assert(mk_metavar("m", Prop)(a):is_meta()) assert(f(mk_metavar("m", Prop)):has_metavar()) assert(f(mk_local("l", Prop)):has_local()) assert(not f(mk_metavar("m", Prop)):has_local()) assert(not f(mk_local("l", Prop)):has_metavar()) assert(f(mk_sort(mk_param_univ("l"))):has_param_univ()) assert(f(Var(0)):has_free_vars()) assert(not f(Var(0)):closed()) assert(f(a):closed()) assert(Var(0):data() == 0) assert(Const("a"):data() == name("a")) assert(mk_sort(mk_param_univ("l")):data() == mk_param_univ("l")) local f1, a1 = f(a):data() assert(f1 == f) assert(a1 == a) local m1, t1 = mk_metavar("a", Prop):data() assert(m1 == name("a")) assert(t1 == Prop) local m1, t1 = mk_local("a", Prop):data() assert(m1 == name("a")) assert(t1 == Prop) local a1, t, b1, bi = mk_pi("a", Prop, Var(0), binder_info(true)):data() assert(a1 == name("a")) assert(t == Prop) assert(b1 == Var(0)) assert(bi:is_implicit()) assert(f:is_constant()) f(f(a)):for_each(function (e, o) print(tostring(e)); return true; end) assert(f(Var(0)):lift_free_vars(1) == f(Var(1))) assert(f(Var(1)):lift_free_vars(1, 1) == f(Var(2))) assert(f(Var(1)):lift_free_vars(2, 1) == f(Var(1))) assert(f(Var(1)):lower_free_vars(1, 1) == f(Var(0))) assert(f(Var(1)):lower_free_vars(4, 1) == f(Var(1))) assert(f(Var(0), Var(1)):instantiate(a) == f(a, Var(0))) assert(f(Var(0), Var(1)):instantiate({a, b}) == f(a, b)) assert(f(a, b):abstract(a) == f(Var(0), b)) assert(f(a, b):abstract({a, b}) == f(Var(1), Var(0))) assert(a:occurs(f(a))) enable_expr_caching(false) assert(not f(a):is_eqp(f(a))) assert(f(a):arg():is_eqp(a)) assert(f(a):weight() == 3) print(f(a):hash())
apache-2.0
FNCxPro/MoarPeripherals
src/main/resources/assets/moarperipherals/lua/note.lua
2
29354
-- +---------------------+------------+---------------------+ -- | | | | -- | | Note API | | -- | | | | -- +---------------------+------------+---------------------+ -- Note Block Song format + conversion tools: David Norgren -- Iron Note Block + NBS loading & playback: TheOriginalBIT -- Music player interface & API structure: Bomb Bloke -- ---------------------------------------------------------- -- Place Note Block Studio NBS files on your ComputerCraft computer, -- then play them back via a MoarPeripheral's Iron Note Block! -- http://www.computercraft.info/forums2/index.php?/topic/19357-moarperipherals -- http://www.minecraftforum.net/topic/136749-minecraft-note-block-studio -- This script can be ran as any other, but it can *also* be loaded as an API! -- Doing so exposes the following functions: -- < note.playSong(fileName) > -- Simply plays the specified NBS file. -- < note.songEngine([fileName]) > -- Plays the optionally specified NBS file, but whether one is specified or not, does -- not return when complete - instead this is intended to run continuously as a background -- process. Launch it via the parallel API and run it alongside your own script! -- While the song engine function is active, it can be manipulated by queuing the -- following events: -- * musicPlay -- Add a filename in as a parameter to start playback, eg: -- os.queueEvent("musicPlay","mySong.nbs") -- * musicPause -- Halts playback. -- * musicResume -- Resumes playback. -- * musicSkipTo -- Add a song position in as a parameter to skip to that segment. Specify the time -- in tenths of a second; for example, to skip a minute in use 600. -- Additionally, whenever the song engine finishes a track, it will automatically -- throw a "musicFinished" event, or a "newTrack" event whenever a new song is loaded. -- **Remember!** The API cannot respond to these events until YOUR code yields! -- Telling it to load a new song or jump to a different position won't take effect -- until you pull an event or something! -- < note.setPeripheral(targetDevice1, [targetDevice2,] ...) > -- By default, upon loading the API attaches itself to any Iron Note Blocks it detects. -- Use this if you have specific note block(s) in mind, or wish to use different blocks -- at different times - perhaps mid-song! Returns true if at least one of the specified -- devices was valid, or false if none were. -- **Note!** The Iron Note Block peripheral can currently play up to five instruments -- at any given moment. Providing multiple blocks to the API will cause it to -- automatically spread the load for those songs that need the extra notes. -- If you provide insufficient blocks, expect some notes to be skipped from -- certain songs. -- Very few songs (if any) require more than two Iron Note Blocks. -- < note.isPlaying() > -- Returns whether the API is currently mid-tune (ignoring whether it's paused or not). -- < note.isPaused() > -- Returns whether playback is paused. -- < note.getSongLength() > -- Returns the song length in "redstone updates". There are ten updates per second, or -- one per two game ticks. -- < note.getSongPosition() > -- Returns the song position in "redstone updates". Time in game ticks is 2 * this. Time -- in seconds is this / 10. -- < note.getSongSeconds() > -- Returns the song length in seconds. -- < note.getSongPositionSeconds() > -- Returns the song position in seconds. -- < note.getSongTempo() > -- Returns the song tempo, representing the "beats per second". -- Eg: 2.5 = one beat per 0.4 seconds. -- 5 = one beat per 0.2 seconds. -- 10 = one beat per 0.1 seconds. -- Must be a factor of ten. -- < note.getRealSongTempo() > -- Returns the tempo the song's NBS file specified it should be played at. -- Should be a power of ten, but for whatever reason a lot of NBS files have invalid tempos. -- < note.getSongName() > -- Returns the name of the song. -- < note.getSongAuthor() > -- Returns the name of the NBS file author. -- < note.getSongArtist() > -- Returns the name of the song artist. -- < note.getSongDescription() > -- Returns the song's description. -- ---------------------------------------------------------- if not shell then -- ----------------------- -- Load as API: -- ----------------------- -- Cranking this value too high will cause crashes: local MAX_INSTRUMENTS_PER_NOTE_BLOCK = 5 local ironnote, paused, cTick, song = {peripheral.find("iron_note")} for i = 1, #ironnote do ironnote[i] = ironnote[i].playNote end local translate = {[0]=0,4,1,2,3} local function assert(cdn, msg, lvl) if not cdn then error(msg or "assertion failed!", (lvl == 0 and 0 or lvl and (lvl + 1) or 2)) end return cdn end -- Returns a string ComputerCraft can render. In case this isn't fixed: -- http://www.computercraft.info/forums2/index.php?/topic/16882-computercraft-beta-versions-bug-reports/page__view__findpost__p__212628 local function safeString(text) local newText = {} for i = 1, #text do local val = text:byte(i) newText[i] = (val > 31 and val < 127) and val or 63 end return string.char(unpack(newText)) end -- Returns the song length. function getSongLength() if type(song) == "table" then return song.length end end -- Returns the song position. function getSongPosition() return cTick end -- Returns the song length in seconds. function getSongSeconds() if type(song) == "table" then return song.length / song.tempo end end -- Returns the song position in seconds. function getSongPositionSeconds() if type(song) == "table" then return cTick / song.tempo end end -- Returns the tempo the song will be played at. function getSongTempo() if type(song) == "table" then return song.tempo end end -- Returns the tempo the song's NBS file specified it should be played at. function getRealSongTempo() if type(song) == "table" then return song.realTempo end end -- Switches to a different playback device. function setPeripheral(...) local newironnote = {} for i=1,#arg do if type(arg[i]) == "string" and peripheral.getType(arg[i]) == "iron_note" then newironnote[#newironnote+1] = peripheral.wrap(arg[i]) elseif type(arg[i]) == "table" and arg[i].playNote then newironnote[#newironnote+1] = arg[i] end end if #newironnote > 0 then ironnote = newironnote for i = 1, #ironnote do ironnote[i] = ironnote[i].playNote end return true else return false end end -- Returns whether music is loaded for playback. function isPlaying() return type(song) == "table" end -- Returns whether playback is paused. function isPaused() return paused end -- Returns the name of the song. function getSongName() if type(song) == "table" then return safeString(song.name) end end -- Returns the name of NBS file author. function getSongAuthor() if type(song) == "table" then return safeString(song.author) end end -- Returns the name of song artist. function getSongArtist() if type(song) == "table" then return safeString(song.originalauthor) end end -- Returns the song's description. function getSongDescription() if type(song) == "table" then return safeString(song.description) end end local function byte_lsb(handle) return assert(handle.read(), "Note NBS loading error: Unexpected EOF (end of file).", 2) end local function byte_msb(handle) local x = byte_lsb(handle) --# convert little-endian to big-endian local y = 0 y = y + bit.blshift(bit.band(x, 0x00), 7) y = y + bit.blshift(bit.band(x, 0x02), 6) y = y + bit.blshift(bit.band(x, 0x04), 5) y = y + bit.blshift(bit.band(x, 0x08), 4) y = y + bit.brshift(bit.band(x, 0x10), 4) y = y + bit.brshift(bit.band(x, 0x20), 5) y = y + bit.brshift(bit.band(x, 0x40), 6) y = y + bit.brshift(bit.band(x, 0x80), 7) return y end local function int16_lsb(handle) return bit.bor(bit.blshift(byte_lsb(handle), 8), byte_lsb(handle)) end local function int16_msb(handle) local x = int16_lsb(handle) --# convert little-endian to big-endian local y = 0 y = y + bit.blshift(bit.band(x, 0x00FF), 8) y = y + bit.brshift(bit.band(x, 0xFF00), 8) return y end local function int32_lsb(handle) return bit.bor(bit.blshift(int16_lsb(handle), 16), int16_lsb(handle)) end local function int32_msb(handle) local x = int32_lsb(handle) --# convert little-endian to big-endian local y = 0 y = y + bit.blshift(bit.band(x, 0x000000FF), 24) y = y + bit.brshift(bit.band(x, 0xFF000000), 24) y = y + bit.blshift(bit.band(x, 0x0000FF00), 8) y = y + bit.brshift(bit.band(x, 0x00FF0000), 8) return y end local function nbs_string(handle) local str = "" for i = 1, int32_msb(handle) do str = str..string.char(byte_lsb(handle)) end return str end local function readNbs(path) assert(fs.exists(path), "Note NBS loading error: File \""..path.."\" not found. Did you forget to specify the containing folder?", 0) assert(not fs.isDir(path), "Note NBS loading error: Specified file \""..path.."\" is actually a folder.", 0) local handle = fs.open(path, "rb") song = { notes = {}; } --# NBS format found on http://www.stuffbydavid.com/nbs --# Part 1: Header song.length = int16_msb(handle) int16_msb(handle) --# layers, this is Note Block Studio meta-data song.name = nbs_string(handle) song.author = nbs_string(handle) song.originalauthor = nbs_string(handle) song.description = nbs_string(handle) song.realTempo = int16_msb(handle)/100 song.tempo = song.realTempo < 20 and (20%song.realTempo == 0 and song.realTempo or math.floor(2000/math.floor(20/song.realTempo+0.5))/100) or 20 byte_lsb(handle) --# auto-saving has been enabled (0 or 1) byte_lsb(handle) --# The amount of minutes between each auto-save (if it has been enabled) (1-60) byte_lsb(handle) --# The time signature of the song. If this is 3, then the signature is 3/4. Default is 4. This value ranges from 2-8 int32_msb(handle) --# The amount of minutes spent on the project int32_msb(handle) --# The amount of times the user has left clicked int32_msb(handle) --# The amount of times the user has right clicked int32_msb(handle) --# The amount of times the user have added a block int32_msb(handle) --# The amount of times the user have removed a block nbs_string(handle) --# If the song has been imported from a .mid or .schematic file, that file name is stored here (Only the name of the file, not the path) --# Part 2: Note Blocks local maxPitch = 24 local notes = song.notes local tick = -1 local jumps = 0 while true do jumps = int16_msb(handle) if jumps == 0 then break end tick = tick + jumps local layer = -1 while true do jumps = int16_msb(handle) if jumps == 0 then break end layer = layer + jumps local inst = byte_lsb(handle) local key = byte_lsb(handle) -- notes[tick] = notes[tick] or {} table.insert(notes[tick], {inst = translate[inst]; pitch = math.max((key-33)%maxPitch,0)}) end end --[[ the rest of the file is useless to us it's specific to Note Block Studio and even so is still optional --]] handle.close() end function songEngine(targetSong) assert(ironnote[1], "Note songEngine failure: No Iron Note Blocks assigned.", 0) local tTick, curPeripheral, delay, notes = os.startTimer(0.1), 1 if targetSong then os.queueEvent("musicPlay",targetSong) end while true do local e, someTime = { os.pullEvent() }, os.clock() if e[1] == "timer" and e[2] == tTick and song and not paused then if notes[cTick] then local curMaxNotes, nowPlaying = (song.tempo == 20 and math.floor(MAX_INSTRUMENTS_PER_NOTE_BLOCK/2) or MAX_INSTRUMENTS_PER_NOTE_BLOCK) * #ironnote, 0 for _,note in pairs(notes[cTick]) do ironnote[curPeripheral](note.inst, note.pitch) curPeripheral = (curPeripheral == #ironnote) and 1 or (curPeripheral + 1) nowPlaying = nowPlaying + 1 if nowPlaying == curMaxNotes then break end end end cTick = cTick + 1 if cTick > song.length then song = nil notes = nil cTick = nil os.queueEvent("musicFinished") end tTick = os.startTimer(delay + (someTime - os.clock())) -- The redundant brackets shouldn't be needed, but it doesn't work without them?? elseif e[1] == "musicPause" then paused = true elseif e[1] == "musicResume" then paused = false tTick = os.startTimer(0.1) elseif e[1] == "musicSkipTo" then cTick = e[2] elseif e[1] == "musicPlay" then readNbs(e[2]) notes = song.notes cTick = 0 tTick = os.startTimer(0.1) paused = false delay = math.floor(100 / song.tempo) / 100 os.queueEvent("newTrack") end end end function playSong(targetSong) parallel.waitForAny(function () songEngine(targetSong) end, function () os.pullEvent("musicFinished") end) end else -- ----------------------- -- Run as jukebox: -- ------------------------------------------------------------ -- Ignore everything below this point if you're only interested -- in the API, unless you want to see example usage. -- ------------------------------------------------------------ sleep(0) -- 'cause ComputerCraft is buggy. local xSize, ySize = term.getSize() if xSize < 50 then print("Wider display required!\n") error() end if ySize < 7 then print("Taller display required!\n") error() end local startDir = shell.resolve(".") os.loadAPI(shell.getRunningProgram()) local playmode, lastSong, marqueePos, myEvent, bump, marquee = 0, {}, 1 local cursor = {{">> "," <<"},{"> > "," < <"},{" >> "," << "},{"> > "," < <"}} local logo = {{"| |","|\\|","| |"},{"+-+","| |","+-+"},{"---"," | "," | "},{"+--","|- ","+--"}} local buttons = {{"| /|","|< |","| \\|"},{"|\\ |","| >|","|/ |"},{"| |","| |","| |"},{"|\\ ","| >","|/ "}} -- Returns whether a click was performed at a given location. -- If one parameter is passed, it checks to see if y is [1]. -- If two parameters are passed, it checks to see if x is [1] and y is [2]. -- If three parameters are passed, it checks to see if x is between [1]/[2] (non-inclusive) and y is [3]. -- If four paramaters are passed, it checks to see if x is between [1]/[2] and y is between [3]/[4] (non-inclusive). local function clickedAt(...) if myEvent[1] ~= "mouse_click" then return false end if #arg == 1 then return (arg[1] == myEvent[4]) elseif #arg == 2 then return (myEvent[3] == arg[1] and myEvent[4] == arg[2]) elseif #arg == 3 then return (myEvent[3] > arg[1] and myEvent[3] < arg[2] and myEvent[4] == arg[3]) else return (myEvent[3] > arg[1] and myEvent[3] < arg[2] and myEvent[4] > arg[3] and myEvent[4] < arg[4]) end end -- Returns whether one of a given set of keys was pressed. local function pressedKey(...) if myEvent[1] ~= "key" then return false end for i=1,#arg do if arg[i] == myEvent[2] then return true end end return false end local function drawPlaymode() term.setBackgroundColour(term.isColour() and colours.lightGrey or colours.black) term.setTextColour(term.isColour() and colours.black or colours.white) term.setCursorPos(bump+34, 1) term.write("[R]epeat ( )") term.setCursorPos(bump+34, 2) term.write("Auto-[N]ext ( )") term.setCursorPos(bump+34, 3) term.write("[M]ix ( )") if playmode ~= 0 then term.setTextColour(term.isColour() and colours.blue or colours.white) term.setCursorPos(bump+47, playmode) term.write("O") end end local function drawInterface() if term.isColour() then -- Header / footer. term.setBackgroundColour(colours.grey) for i = 1, 3 do term.setCursorPos(1,i) term.clearLine() term.setCursorPos(1,ySize-i+1) term.clearLine() end -- Quit button. term.setTextColour(colours.white) term.setBackgroundColour(colours.red) term.setCursorPos(xSize,1) term.write("X") end -- Note logo. term.setTextColour(term.isColour() and colours.blue or colours.white) term.setBackgroundColour(term.isColour() and colours.lightGrey or colours.black) for i = 1, 4 do for j = 1, 3 do term.setCursorPos(bump + (i - 1) * 4, j) term.write(logo[i][j]) end end -- Skip back / forward buttons. term.setTextColour(term.isColour() and colours.lightBlue or colours.white) term.setBackgroundColour(term.isColour() and colours.grey or colours.black) for j = 0, 1 do for i = 1, 3 do term.setCursorPos(bump + 17 + j * 11, i) term.write(buttons[j+1][i]) end end -- Progress bar. term.setCursorPos(2,ySize-1) term.setTextColour(term.isColour() and colours.black or colours.white) term.setBackgroundColour(term.isColour() and colours.lightGrey or colours.black) term.write("|"..string.rep("=",xSize-4).."|") drawPlaymode() end local function startSong(newSong) if #lastSong == 32 then lastSong[32] = nil end table.insert(lastSong,1,newSong) os.queueEvent("musicPlay",newSong) marquee = nil marqueePos = 1 end local function noteMenu() local lastPauseState = "maybe" bump = math.floor((xSize - 49) / 2) + 1 drawInterface() while true do local displayList, position, lastPosition, animationTimer, curCount, gapTimer, lastProgress = {}, 1, 0, os.startTimer(0), 1 if #shell.resolve(".") > 0 then displayList[1] = ".." end do local fullList = fs.list(shell.resolve(".")) table.sort(fullList, function (a, b) return string.lower(a) < string.lower(b) end) for i = 1, #fullList do if fs.isDir(shell.resolve(fullList[i])) then displayList[#displayList + 1] = fullList[i] end end for i = 1, #fullList do if fullList[i]:sub(#fullList[i]-3):lower() == ".nbs" then displayList[#displayList + 1] = fs.getName(fullList[i]) end end end while true do myEvent = {os.pullEvent()} -- Track animations (bouncing, function (a, b) return string.lower(a) < string.lower(b) end cursor + scrolling marquee). if myEvent[1] == "timer" and myEvent[2] == animationTimer then if marquee then marqueePos = marqueePos == #marquee and 1 or (marqueePos + 1) end curCount = curCount == 4 and 1 or (curCount + 1) animationTimer = os.startTimer(0.5) myEvent[1] = "cabbage" -- Queue a new song to start playing, based on the playmode toggles (or if the user clicked the skip-ahead button). elseif (myEvent[1] == "timer" and myEvent[2] == gapTimer and not note.isPlaying()) or (pressedKey(keys.d,keys.right) or clickedAt(bump+27,bump+32,0,4)) then if playmode == 1 then os.queueEvent("musicPlay",lastSong[1]) elseif (playmode == 2 or (playmode == 0 and myEvent[1] ~= "timer")) and not fs.isDir(shell.resolve(displayList[#displayList])) then if shell.resolve(displayList[position]) == lastSong[1] or fs.isDir(shell.resolve(displayList[position])) then repeat position = position + 1 if position > #displayList then position = 1 end until not fs.isDir(shell.resolve(displayList[position])) end startSong(shell.resolve(displayList[position])) elseif playmode == 3 and not fs.isDir(shell.resolve(displayList[#displayList])) then repeat position = math.random(#displayList) until not fs.isDir(shell.resolve(displayList[position])) startSong(shell.resolve(displayList[position])) end gapTimer = nil myEvent[1] = "cabbage" elseif myEvent[1] ~= "timer" then -- Special consideration, bearing in mind that the songEngine is spamming ten such events a second... -- Move down the list. if pressedKey(keys.down,keys.s) or (myEvent[1] == "mouse_scroll" and myEvent[2] == 1) then position = position == #displayList and 1 or (position + 1) -- Move up the list. elseif pressedKey(keys.up,keys.w) or (myEvent[1] == "mouse_scroll" and myEvent[2] == -1) then position = position == 1 and #displayList or (position - 1) -- Start a new song. elseif pressedKey(keys.enter, keys.space) or (clickedAt(bump+22,bump+26,0,4) and not note.isPlaying()) or clickedAt(math.floor(ySize / 2) + 1) then if fs.isDir(shell.resolve(displayList[position])) then shell.setDir(shell.resolve(displayList[position])) break else startSong(shell.resolve(displayList[position])) end -- User clicked somewhere on the file list; move that entry to the currently-selected position. elseif clickedAt(0, xSize + 1, 3, ySize - 2) then position = position + myEvent[4] - math.floor(ySize / 2) - 1 position = position > #displayList and #displayList or position position = position < 1 and 1 or position -- Respond to a screen-resize; triggers a full display redraw. elseif myEvent[1] == "term_resize" then xSize, ySize = term.getSize() bump = math.floor((xSize - 49) / 2) + 1 lastPosition = 0 drawInterface() animationTimer = os.startTimer(0) lastPauseState = "maybe" -- Quit. elseif pressedKey(keys.q, keys.x, keys.t) or clickedAt(xSize, 1) then if myEvent[1] == "key" then os.pullEvent("char") end os.unloadAPI("note") term.setTextColour(colours.white) term.setBackgroundColour(colours.black) term.clear() term.setCursorPos(1,1) print("Thanks for using the Note NBS player!\n") shell.setDir(startDir) error() -- Toggle repeat mode. elseif pressedKey(keys.r) or clickedAt(bump + 33, bump + 49, 1) then playmode = playmode == 1 and 0 or 1 drawPlaymode() -- Toggle auto-next mode. elseif pressedKey(keys.n) or clickedAt(bump + 33, bump + 49, 2) then playmode = playmode == 2 and 0 or 2 drawPlaymode() -- Toggle mix (shuffle) mode. elseif pressedKey(keys.m) or clickedAt(bump + 33, bump + 49, 3) then playmode = playmode == 3 and 0 or 3 drawPlaymode() -- Music finished; wait a second or two before responding. elseif myEvent[1] == "musicFinished" then gapTimer = os.startTimer(2) lastPauseState = "maybe" marquee = "" -- Skip back to start of the song (or to the previous song, if the current song just started). elseif pressedKey(keys.a,keys.left) or clickedAt(bump+16,bump+21,0,4) then if note.isPlaying() and note.getSongPositionSeconds() > 3 then os.queueEvent("musicSkipTo",0) os.queueEvent("musicResume") elseif #lastSong > 1 then table.remove(lastSong,1) startSong(table.remove(lastSong,1)) end -- Toggle pause/resume. elseif note.isPlaying() and (pressedKey(keys.p) or clickedAt(bump+22,bump+26,0,4)) then if note.isPaused() then os.queueEvent("musicResume") else os.queueEvent("musicPause") end -- Tracking bar clicked. elseif note.isPlaying() and clickedAt(1, xSize, ySize - 1) then os.queueEvent("musicSkipTo",math.floor(note.getSongLength()*(myEvent[3]-1)/(xSize-2))) -- Song engine just initiated a new track. elseif myEvent[1] == "newTrack" then marquee = " [Title: " if note.getSongName() ~= "" then marquee = marquee..note.getSongName().."]" else marquee = marquee..fs.getName(lastSong[1]).."]" end if note.getSongArtist() ~= "" then marquee = marquee.." [Artist: "..note.getSongArtist().."]" end if note.getSongAuthor() ~= "" then marquee = marquee.." [NBS Author: "..note.getSongAuthor().."]" end marquee = marquee.." [Tempo: "..note.getSongTempo() marquee = marquee..(note.getSongTempo() == note.getRealSongTempo() and "]" or (" (NBS: "..note.getRealSongTempo()..")]")) if note.getSongDescription() ~= "" then marquee = marquee.." [Description: "..note.getSongDescription().."]" end lastPauseState = "maybe" end end -- Play / pause button. if lastPauseState ~= note.isPaused() then term.setTextColour(term.isColour() and colours.lightBlue or colours.white) term.setBackgroundColour(term.isColour() and colours.grey or colours.black) for i=1,3 do term.setCursorPos(bump + 23,i) term.write(buttons[(note.isPlaying() and not note.isPaused()) and 3 or 4][i]) end lastPauseState = note.isPaused() end -- Update other screen stuff. if myEvent[1] ~= "timer" then term.setTextColour(term.isColour() and colours.black or colours.white) term.setBackgroundColour(term.isColour() and colours.lightGrey or colours.black) -- Clear old progress bar position. if lastProgress then term.setCursorPos(lastProgress,ySize-1) term.write((lastProgress == 2 or lastProgress == xSize - 1) and "|" or "=") lastProgress = nil end -- Song timers. if note.isPlaying() then term.setCursorPos(xSize-5,ySize-2) if term.isColour() and note.getSongTempo() ~= note.getRealSongTempo() then term.setTextColour(colours.red) end local mins = tostring(math.min(99,math.floor(note.getSongSeconds()/60))) local secs = tostring(math.floor(note.getSongSeconds()%60)) term.write((#mins > 1 and "" or "0")..mins..":"..(#secs > 1 and "" or "0")..secs) term.setCursorPos(2,ySize-2) if note.isPaused() and bit.band(curCount,1) == 1 then term.write(" ") else mins = tostring(math.min(99,math.floor(note.getSongPositionSeconds()/60))) secs = tostring(math.floor(note.getSongPositionSeconds()%60)) term.write((#mins > 1 and "" or "0")..mins..":"..(#secs > 1 and "" or "0")..secs) end -- Progress bar position. term.setTextColour(term.isColour() and colours.blue or colours.white) term.setBackgroundColour(colours.black) lastProgress = 2+math.floor(((xSize-3) * note.getSongPosition() / note.getSongLength())) term.setCursorPos(lastProgress,ySize-1) term.write("O") else term.setCursorPos(2,ySize-2) term.write("00:00") term.setCursorPos(xSize-5,ySize-2) term.write("00:00") end -- Scrolling marquee. if marquee then term.setTextColour(term.isColour() and colours.black or colours.white) term.setBackgroundColour(term.isColour() and colours.grey or colours.black) term.setCursorPos(1,ySize) if marquee == "" then term.clearLine() marquee = nil else local thisLine = marquee:sub(marqueePos,marqueePos+xSize-1) while #thisLine < xSize do thisLine = thisLine..marquee:sub(1,xSize-#thisLine) end term.write(thisLine) end end -- File list. term.setBackgroundColour(colours.black) for y = position == lastPosition and (math.floor(ySize / 2)+1) or 4, position == lastPosition and (math.floor(ySize / 2)+1) or (ySize - 3) do local thisLine = y + position - math.floor(ySize / 2) - 1 if displayList[thisLine] then local thisString = displayList[thisLine] thisString = fs.isDir(shell.resolve(thisString)) and "["..thisString.."]" or thisString:sub(1,#thisString-4) if thisLine == position then term.setCursorPos(math.floor((xSize - #thisString - 8) / 2)+1, y) term.clearLine() term.setTextColour(term.isColour() and colours.cyan or colours.black) term.write(cursor[curCount][1]) term.setTextColour(term.isColour() and colours.blue or colours.white) term.write(thisString) term.setTextColour(term.isColour() and colours.cyan or colours.black) term.write(cursor[curCount][2]) else term.setCursorPos(math.floor((xSize - #thisString) / 2)+1, y) term.clearLine() if y == 4 or y == ySize - 3 then term.setTextColour(colours.black) elseif y == 5 or y == ySize - 4 then term.setTextColour(term.isColour() and colours.grey or colours.black) elseif y == 6 or y == ySize - 5 then term.setTextColour(term.isColour() and colours.lightGrey or colours.white) else term.setTextColour(colours.white) end term.write(thisString) end else term.setCursorPos(1,y) term.clearLine() end end lastPosition = position end end end end do local args = {...} for i=1,#args do if args[i]:lower() == "-r" then playmode = 1 elseif args[i]:lower() == "-n" then playmode = 2 elseif args[i]:lower() == "-m" then playmode = 3 elseif fs.isDir(shell.resolve(args[i])) then shell.setDir(shell.resolve(args[i])) elseif fs.isDir(args[i]) then shell.setDir(args[i]) elseif fs.exists(shell.resolve(args[i])) then local filePath = shell.resolve(args[i]) shell.setDir(fs.getDir(filePath)) startSong(filePath) elseif fs.exists(shell.resolve(args[i]..".nbs")) then local filePath = shell.resolve(args[i]..".nbs") shell.setDir(fs.getDir(filePath)) startSong(filePath) elseif fs.exists(args[i]) then shell.setDir(fs.getDir(args[i])) startSong(args[i]) elseif fs.exists(args[i]..".nbs") then shell.setDir(fs.getDir(args[i])) startSong(args[i]..".nbs") end end end if playmode > 1 then os.queueEvent("musicFinished") end term.setBackgroundColour(colours.black) term.clear() parallel.waitForAny(note.songEngine, noteMenu) end
apache-2.0
botmohammad12344888/bot-888338888
plugins/map.lua
2
1677
-- Implement a command !loc [area] which uses -- the static map API to get a location image -- Not sure if this is the proper way -- Intent: get_latlong is in time.lua, we need it here -- loadfile "time.lua" -- Globals -- If you have a google api key for the geocoding/timezone api do local api_key = nil local base_api = "https://maps.googleapis.com/maps/api" function get_staticmap(area) local api = base_api .. "/staticmap?" -- Get a sense of scale local lat,lng,acc,types = get_latlong(area) local scale = types[1] if scale=="locality" then zoom=8 elseif scale=="country" then zoom=4 else zoom = 13 end local parameters = "size=600x300" .. "&zoom=" .. zoom .. "&center=" .. URL.escape(area) .. "&markers=color:red"..URL.escape("|"..area) if api_key ~=nil and api_key ~= "" then parameters = parameters .. "&key="..api_key end return lat, lng, api..parameters end function run(msg, matches) local receiver = get_receiver(msg) local lat,lng,url = get_staticmap(matches[1]) -- Send the actual location, is a google maps link send_location(receiver, lat, lng, ok_cb, false) -- Send a picture of the map, which takes scale into account send_photo_from_url(receiver, url) -- Return a link to the google maps stuff is now not needed anymore return nil end return { description = "(find a area location)دریافت نقشه منطقه!", usage = { "نقشه (name) : دریافت نقشه منطقه", "/map (name) : find a area location", "map (name) : find a area location", }, patterns = { "^نقشه (.*)$", "^map (.*)$", "^[/!]map (.*)$" }, run = run } end
gpl-2.0
jshackley/darkstar
scripts/zones/Promyvion-Mea/mobs/Memory_Receptacle.lua
1
6993
----------------------------------- -- Area: Promyvion-Mea -- MOB: Memory Receptacle -- Todo: clean up disgustingly bad formatting ----------------------------------- package.loaded["scripts/zones/Promyvion-Mea/TextIDs"] = nil; ----------------------------------- require( "scripts/zones/Promyvion-Mea/TextIDs" ); require("scripts/globals/status"); ----------------------------------- -- onMobInitialize Action ----------------------------------- function onMobInitialize(mob) mob:addMod(MOD_REGAIN, 100); -- 10% Regain for now mob:SetAutoAttackEnabled(false); -- Recepticles only use TP moves. end; ----------------------------------- -- onMobFight Action ----------------------------------- function onMobFight(mob, target) local Mem_Recep = mob:getID(); if (Mem_Recep == 16859151) then -- Floor 1 for i = Mem_Recep+1, Mem_Recep+3 do -- Keep pets linked if (GetMobAction(i) == 16) then GetMobByID(i):updateEnmity(target); end end elseif (Mem_Recep == 16859198 or Mem_Recep == 16859205 or Mem_Recep == 16859212 or Mem_Recep == 16859219) then -- Floor 2 for i = Mem_Recep+1, Mem_Recep+5 do if (GetMobAction(i) == 16) then GetMobByID(i):updateEnmity(target); end end elseif (Mem_Recep == 16859273 or Mem_Recep == 16859282 or Mem_Recep == 16859291 or Mem_Recep == 16859349 or Mem_Recep == 16859358 or Mem_Recep == 16859367) then -- Floor 3 for i = Mem_Recep+1, Mem_Recep+7 do if (GetMobAction(i) == 16) then GetMobByID(i):updateEnmity(target); end end end -- Summons a single stray every 30 seconds. if (mob:getBattleTime() % 30 < 3 and mob:getBattleTime() > 3 and (Mem_Recep == 16859151) and mob:AnimationSub() == 2) then -- Floor 1 for i = Mem_Recep+1, Mem_Recep+3 do if (GetMobAction(i) == 0) then -- My Stray is deeaaaaaad! mob:AnimationSub(1); SpawnMob(i):updateEnmity(target); GetMobByID(i):setPos(mob:getXPos()+1, mob:getYPos(), mob:getZPos()+1); -- Set stray x and z position +1 from Recepticle return; end end elseif (mob:getBattleTime() % 30 < 3 and mob:getBattleTime() > 3 and (Mem_Recep == 16859198 or Mem_Recep == 16859205 or Mem_Recep == 16859212 or -- Floor 2 Mem_Recep == 16859219) and mob:AnimationSub() == 2) then for i = Mem_Recep+1, Mem_Recep+5 do if (GetMobAction(i) == 0) then mob:AnimationSub(1); SpawnMob(i):updateEnmity(target); GetMobByID(i):setPos(mob:getXPos()+1, mob:getYPos(), mob:getZPos()+1); return; end end elseif (mob:getBattleTime() % 30 < 3 and mob:getBattleTime() > 3 and (Mem_Recep == 16859273 or Mem_Recep == 16859282 or Mem_Recep == 16859291 or -- Floor 3 Mem_Recep == 16859349 or Mem_Recep == 16859358 or Mem_Recep == 16859367) and mob:AnimationSub() == 2) then for i = Mem_Recep+1, Mem_Recep+7 do if (GetMobAction(i) == 0) then mob:AnimationSub(1); SpawnMob(i):updateEnmity(target); GetMobByID(i):setPos(mob:getXPos()+1, mob:getYPos(), mob:getZPos()+1); return; end end else mob:AnimationSub(2); end end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob,killer,ally) local rand = 0; local mobID = mob:getID(); local difX = ally:getXPos()-mob:getXPos(); local difY = ally:getYPos()-mob:getYPos(); local difZ = ally:getZPos()-mob:getZPos(); local killeranimation = ally:getAnimation(); local Distance = math.sqrt( math.pow(difX,2) + math.pow(difY,2) + math.pow(difZ,2) ); --calcul de la distance entre les "killer" et le memory receptacle --print(mobID); mob:AnimationSub(0); -- Set ani. sub to default or the recepticles wont work properly if (VanadielMinute() % 2 == 1) then ally:setVar("MemoryReceptacle",2); rnd = 2; else ally:setVar("MemoryReceptacle",1); rnd = 1; end switch (mob:getID()) : caseof { [16859151] = function (x) GetNPCByID(16859453):openDoor(180); if (Distance <4 and killeranimation == 0) then ally:startEvent(30); end end, [16859198] = function (x) GetNPCByID(16859456):openDoor(180); if (Distance <4 and killeranimation == 0) then if (rnd == 2) then ally:startEvent(37); -- player:setPos(-167,0,172,38); else ally:startEvent(33); -- player:setPos(68,0,-76,254); end end end, [16859205] = function (x) GetNPCByID(16859460):openDoor(180); if (Distance <4 and killeranimation == 0) then if (rnd == 2) then ally:startEvent(37); -- player:setPos(-167,0,172,38); else ally:startEvent(33); -- player:setPos(68,0,-76,254); end end end, [16859212] = function (x) GetNPCByID(16859461):openDoor(180); if (Distance <4 and killeranimation == 0) then if (rnd == 2) then ally:startEvent(37); -- player:setPos(-167,0,172,38); else ally:startEvent(33); -- player:setPos(68,0,-76,254); end end end, [16859219] = function (x) GetNPCByID(16859462):openDoor(180); if (Distance <4 and killeranimation == 0) then if (rnd == 2) then ally:startEvent(37); -- player:setPos(-167,0,172,38); else ally:startEvent(33); -- player:setPos(68,0,-76,254); end end end, [16859273] = function (x) GetNPCByID(16859454):openDoor(180); if (Distance <4 and killeranimation == 0) then ally:startEvent(31); end end, [16859282] = function (x) GetNPCByID(16859455):openDoor(180); if (Distance <4 and killeranimation == 0) then ally:startEvent(31); end end, [16859291] = function (x) GetNPCByID(16859457):openDoor(180); if (Distance <4 and killeranimation == 0) then ally:startEvent(31); end end, [16859349] = function (x) GetNPCByID(16859458):openDoor(180); if (Distance <4 and killeranimation == 0) then ally:startEvent(31); end end, [16859358] = function (x) GetNPCByID(16859459):openDoor(180); if (Distance <4 and killeranimation == 0) then ally:startEvent(31); end end, [16859367] = function (x) GetNPCByID(16859463):openDoor(180); if (Distance <4 and killeranimation == 0) then ally:startEvent(31); 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 (option==1) then player:setVar("MemoryReceptacle",0); end end;
gpl-3.0
jshackley/darkstar
scripts/zones/Inner_Horutoto_Ruins/TextIDs.lua
22
1317
-- Variable TextID Description text -- General Texts ITEM_CANNOT_BE_OBTAINED = 6548; -- You cannot obtain the item <item>. Come back after sorting your inventory. ITEM_OBTAINED = 6553; -- Obtained: <item>. GIL_OBTAINED = 6554; -- Obtained <number> gil. KEYITEM_OBTAINED = 6556; -- Obtained key item: <keyitem>. NOT_BROKEN_ORB = 7230; -- The Mana Orb in this receptacle is not broken. EXAMINED_RECEPTACLE = 7231; -- You have already examined this receptacle. DOOR_FIRMLY_CLOSED = 7258; -- The door is firmly closed. -- Treasure Coffer/Chest Dialog CHEST_UNLOCKED = 7333; -- You unlock the chest! CHEST_FAIL = 7334; -- Fails to open the chest. CHEST_TRAP = 7335; -- The chest was trapped! CHEST_WEAK = 7336; -- You cannot open the chest when you are in a weakened state. CHEST_MIMIC = 7337; -- The chest was a mimic! CHEST_MOOGLE = 7338; -- You cannot open the chest while participating in the moogle event. CHEST_ILLUSION = 7339; -- The chest was but an illusion... CHEST_LOCKED = 7340; -- The chest appears to be locked. -- Other texts PORTAL_SEALED_BY_3_MAGIC = 8; -- The Sealed Portal is sealed by three kinds of magic. PORTAL_NOT_OPEN_THAT_SIDE = 9; -- The Sealed Portal cannot be opened from this side. -- conquest Base CONQUEST_BASE = 10;
gpl-3.0
jshackley/darkstar
scripts/zones/Al_Zahbi/npcs/Krujaal.lua
38
1024
----------------------------------- -- Area: Al Zahbi -- NPC: Krujaal -- Type: Residence Renter -- @zone: 48 -- @pos 36.522 -1 -63.198 -- -- 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(0x0000); 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
ScottNZ/OpenRA
mods/cnc/maps/nod04a/nod04a.lua
12
10852
NodUnitsBuggy = { 'bggy', 'bggy', 'bggy', 'bggy', 'bggy' } NodUnitsBikes = { 'bike', 'bike', 'bike' } NodUnitsGunner = { 'e1', 'e1', 'e1', 'e1', 'e1', 'e1' } NodUnitsRocket = { 'e3', 'e3', 'e3', 'e3', 'e3', 'e3' } Atk6Units = { 'c1', 'c2', 'c3' } Atk5Units = { 'e1', 'e1', 'e2', 'e2' } Atk1Units = { 'e1', 'e1' } XxxxUnits = { 'jeep' } YyyyUnits = { 'e1', 'e1', 'e2' } ZzzzUnits = { 'e1', 'e1', 'e2', 'e2' } Spawnpoint = { waypoint0.Location } Atk6WaypointsPart1 = { waypoint1.Location, waypoint2.Location, waypoint3.Location, waypoint4.Location } Atk6WaypointsPart2 = { waypoint7.Location, waypoint8.Location, waypoint7.Location } Atk5Waypoints = { waypoint0.Location, waypoint9.Location} Atk3Waypoints = { waypoint0 } Atk2Waypoints = { waypoint6 } GcivWaypoints = { waypoint0, waypoint1, waypoint2, waypoint3, waypoint4 } Atk1Waypoints = { waypoint0, waypoint1, waypoint2, waypoint3, waypoint4, waypoint5, waypoint6 } Atk4Waypoints = { waypoint0, waypoint9 } Atk6ActorTriggerActivator = { Civilian1, Civilian2 } Atk5ActorTriggerActivator = { Soldier1, Soldier2, Soldier3, Actor105 } WinActorTriggerActivator = { GDICiv1, GDICiv2, GDICiv3, GDICiv4, GDICiv5, GDICiv6, GDICiv7, GDICiv8, GDICiv9, GDICiv11, GDICiv12, GDICiv13 } GcivActors = { Gcvi1, Gciv2, GDICiv2, GDICiv9, GDICiv10, GDICiv11 } Atk2CellTriggerActivator = { CPos.New(41,22), CPos.New(40,22), CPos.New(39,22), CPos.New(41,21), CPos.New(40,21), CPos.New(39,21) } Atk3CellTriggerActivator = { CPos.New(18,18), CPos.New(17,18), CPos.New(16,18), CPos.New(15,18), CPos.New(14,18), CPos.New(13,18), CPos.New(12,18), CPos.New(11,18), CPos.New(24,17), CPos.New(23,17), CPos.New(22,17), CPos.New(21,17), CPos.New(20,17), CPos.New(19,17), CPos.New(17,17), CPos.New(16,17), CPos.New(15,17), CPos.New(14,17), CPos.New(13,17), CPos.New(12,17), CPos.New(11,17) } Atk4CellTriggerActivator = { CPos.New(29,28), CPos.New(28,28), CPos.New(29,27), CPos.New(28,27), CPos.New(29,26), CPos.New(28,26), CPos.New(29,25), CPos.New(28,25), CPos.New(29,24), CPos.New(28,24), CPos.New(29,23), CPos.New(28,23), CPos.New(29,22), CPos.New(28,22) } GcivCellTriggerActivator = { CPos.New(51,17), CPos.New(50,17), CPos.New(49,17), CPos.New(48,17), CPos.New(47,17), CPos.New(46,17), CPos.New(45,17), CPos.New(44,17), CPos.New(43,17), CPos.New(42,17), CPos.New(41,17), CPos.New(40,17), CPos.New(39,17), CPos.New(38,17), CPos.New(37,17), CPos.New(36,17), CPos.New(35,17), CPos.New(52,16), CPos.New(51,16), CPos.New(50,16), CPos.New(49,16), CPos.New(48,16), CPos.New(47,16), CPos.New(46,16), CPos.New(45,16), CPos.New(44,16), CPos.New(43,16), CPos.New(42,16), CPos.New(41,16), CPos.New(40,16), CPos.New(39,16), CPos.New(38,16), CPos.New(37,16), CPos.New(36,16), CPos.New(35,16) } DelxCellTriggerActivator = { CPos.New(42,20), CPos.New(41,20), CPos.New(40,20), CPos.New(39,20), CPos.New(38,20) } DelyCellTriggerActivator = { CPos.New(31,28), CPos.New(30,28), CPos.New(31,27), CPos.New(30,27), CPos.New(31,26), CPos.New(30,26), CPos.New(31,25), CPos.New(30,25), CPos.New(31,24), CPos.New(30,24) } DelzCellTriggerActivator = { CPos.New(18,20), CPos.New(17,20), CPos.New(16,20), CPos.New(15,20), CPos.New(14,20), CPos.New(13,20), CPos.New(12,20), CPos.New(11,20), CPos.New(25,19), CPos.New(24,19), CPos.New(23,19), CPos.New(22,19), CPos.New(21,19), CPos.New(20,19), CPos.New(19,19), CPos.New(18,19), CPos.New(17,19), CPos.New(16,19), CPos.New(15,19), CPos.New(14,19), CPos.New(13,19), CPos.New(12,19), CPos.New(11,19), CPos.New(25,18), CPos.New(24,18), CPos.New(23,18), CPos.New(22,18), CPos.New(21,18), CPos.New(20,18), CPos.New(19,18) } Atk3TriggerCounter = 2 Atk1TriggerFunctionTime = DateTime.Seconds(20) XxxxTriggerFunctionTime = DateTime.Seconds(50) YyyyTriggerFunctionTime = DateTime.Minutes(1) + DateTime.Seconds(40) ZzzzTriggerFunctionTime = DateTime.Minutes(2) + DateTime.Seconds(30) NodCiviliansActors = { NodCiv1, NodCiv2, NodCiv3, NodCiv4, NodCiv5, NodCiv6, NodCiv7, NodCiv8, NodCiv9 } Atk6TriggerFunction = function() Reinforcements.ReinforceWithTransport(GDI, 'apc', Atk6Units, Atk6WaypointsPart1, Atk6WaypointsPart2, function(transport, cargo) Utils.Do(cargo, function(actor) IdleHunt(actor) end) end, function(unit) IdleHunt(unit) end) end Atk5TriggerFunction = function () if not Atk5TriggerSwitch then Atk5TriggerSwitch = true Reinforcements.ReinforceWithTransport(GDI, 'apc', Atk5Units, Atk5Waypoints, nil, function(transport, cargo) transport.UnloadPassengers() Utils.Do(cargo, function(actor) IdleHunt(actor) end) end, function(unit) IdleHunt(unit) end) end end Atk1TriggerFunction = function() Reinforcements.Reinforce(GDI, Atk1Units, Spawnpoint, 15, function(actor) Atk1Movement(actor) end) end XxxxTriggerFunction = function() if not XxxxTriggerSwitch then Reinforcements.Reinforce(GDI, XxxxUnits, Spawnpoint, 15, function(actor) Atk2Movement(actor) end) end end YyyyTriggerFunction = function() if not YyyyTriggerSwitch then Reinforcements.Reinforce(GDI, YyyyUnits, Spawnpoint, 15, function(actor) Atk4Movement(actor) end) end end ZzzzTriggerFunction = function() if not ZzzzTriggerSwitch then Reinforcements.ReinforceWithTransport(GDI, 'apc', ZzzzUnits, Atk5Waypoints, nil, function(transport, cargo) transport.UnloadPassengers() Utils.Do(cargo, function(actor) IdleHunt(actor) end) end, function(unit) IdleHunt(unit) end) end end Atk3Movement = function(unit) Utils.Do(Atk3Waypoints, function(waypoint) unit.AttackMove(waypoint.Location) end) IdleHunt(unit) end Atk2Movement = function(unit) Utils.Do(Atk2Waypoints, function(waypoint) unit.AttackMove(waypoint.Location) end) IdleHunt(unit) end Atk1Movement = function(unit) Utils.Do(Atk1Waypoints, function(waypoint) unit.AttackMove(waypoint.Location) end) IdleHunt(unit) end GcivMovement = function(unit) Utils.Do(GcivWaypoints, function(waypoint) unit.AttackMove(waypoint.Location) end) end Atk4Movement = function(unit) Utils.Do(Atk4Waypoints, function(waypoint) unit.AttackMove(waypoint.Location) end) IdleHunt(unit) end InsertNodUnits = function() Media.PlaySpeechNotification(Nod, "Reinforce") Reinforcements.Reinforce(Nod, NodUnitsBuggy, { UnitsEntryBuggy.Location, UnitsRallyBuggy.Location }, 11) Reinforcements.Reinforce(Nod, NodUnitsBikes, { UnitsEntryBikes.Location, UnitsRallyBikes.Location }, 15) Reinforcements.Reinforce(Nod, NodUnitsGunner, { UnitsEntryGunner.Location, UnitsRallyGunner.Location }, 15) Reinforcements.Reinforce(Nod, NodUnitsRocket, { UnitsEntryRocket.Location, UnitsRallyRocket.Location }, 15) end CreateCivilians = function(actor, discoverer) Utils.Do(NodCiviliansActors, function(actor) actor.Owner = Nod end) NodObjective2 = Nod.AddPrimaryObjective("Protect the civilians that support Nod.") Trigger.OnAllKilled(NodCiviliansActors, function() Nod.MarkFailedObjective(NodObjective2) end) Utils.Do(GcivActors, function(actor) if not actor.IsDead then actor.AttackMove(waypoint7.Location) actor.AttackMove(waypoint8.Location) IdleHunt(actor) end end) end WorldLoaded = function() NodSupporter = Player.GetPlayer("NodSupporter") Nod = Player.GetPlayer("Nod") GDI = Player.GetPlayer("GDI") Trigger.OnObjectiveAdded(Nod, function(p, id) Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective") end) Trigger.OnObjectiveCompleted(Nod, function(p, id) Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed") end) Trigger.OnObjectiveFailed(Nod, function(p, id) Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed") end) Trigger.OnPlayerWon(Nod, function() Media.PlaySpeechNotification(Nod, "Win") end) Trigger.OnPlayerLost(Nod, function() Media.PlaySpeechNotification(Nod, "Lose") end) Trigger.OnAnyKilled(Atk6ActorTriggerActivator, Atk6TriggerFunction) OnAnyDamaged(Atk5ActorTriggerActivator, Atk5TriggerFunction) Trigger.OnEnteredFootprint(Atk3CellTriggerActivator, function(a, id) if a.Owner == Nod then for type, count in pairs({ ['e1'] = 3, ['e2'] = 2, ['mtnk'] = 1 }) do local myActors = Utils.Take(count, GDI.GetActorsByType(type)) Utils.Do(myActors, function(actor) Atk3Movement(actor) end) end Atk3TriggerCounter = Atk3TriggerCounter - 1 if Atk3TriggerCounter < 0 then Trigger.RemoveFootprintTrigger(id) end end end) Trigger.OnEnteredFootprint(Atk2CellTriggerActivator, function(a, id) if a.Owner == Nod then MyActors = Utils.Take(1, GDI.GetActorsByType('jeep')) Utils.Do(MyActors, function(actor) Atk2Movement(actor) end) Trigger.RemoveFootprintTrigger(id) end end) Trigger.OnEnteredFootprint(GcivCellTriggerActivator, function(a, id) if a.Owner == Nod then Utils.Do(GcivActors, function(actor) GcivMovement(actor) end) Trigger.RemoveFootprintTrigger(id) end end) Trigger.AfterDelay(Atk1TriggerFunctionTime, Atk1TriggerFunction) Trigger.OnEnteredFootprint(Atk4CellTriggerActivator, function(a, id) if a.Owner == Nod then for type, count in pairs({ ['e1'] = 2,['e2'] = 1 }) do local myActors = Utils.Take(count, GDI.GetActorsByType(type)) Utils.Do(myActors, function(actor) Atk4Movement(actor) end) end Trigger.RemoveFootprintTrigger(id) end end) Trigger.AfterDelay(XxxxTriggerFunctionTime, XxxxTriggerFunction) Trigger.AfterDelay(YyyyTriggerFunctionTime, YyyyTriggerFunction) Trigger.AfterDelay(ZzzzTriggerFunctionTime, ZzzzTriggerFunction) Trigger.OnEnteredFootprint(DelxCellTriggerActivator, function(a, id) if a.Owner == Nod then XxxxTriggerSwitch = true Trigger.RemoveFootprintTrigger(id) end end) Trigger.OnEnteredFootprint(DelyCellTriggerActivator, function(a, id) if a.Owner == Nod then YyyyTriggerSwitch = true Trigger.RemoveFootprintTrigger(id) end end) Trigger.OnEnteredFootprint(DelzCellTriggerActivator, function(a, id) if a.Owner == Nod then ZzzzTriggerSwitch = true Trigger.RemoveFootprintTrigger(id) end end) Trigger.OnPlayerDiscovered(NodSupporter, CreateCivilians) Trigger.OnAllKilled(WinActorTriggerActivator, function() Nod.MarkCompletedObjective(NodObjective1) if NodObjective2 then Nod.MarkCompletedObjective(NodObjective2) end end) GDIObjective = GDI.AddPrimaryObjective("Eliminate all Nod forces in the area.") NodObjective1 = Nod.AddPrimaryObjective("Kill all civilian GDI supporters.") InsertNodUnits() Camera.Position = waypoint6.CenterPosition end Tick = function() if Nod.HasNoRequiredUnits() then if DateTime.GameTime > 2 then GDI.MarkCompletedObjective(GDIObjective) end end end OnAnyDamaged = function(actors, func) Utils.Do(actors, function(actor) Trigger.OnDamaged(actor, func) end) end IdleHunt = function(unit) if not unit.IsDead then Trigger.OnIdle(unit, unit.Hunt) end end
gpl-3.0
jshackley/darkstar
scripts/zones/Cloister_of_Tremors/bcnms/trial_by_earth.lua
19
1779
----------------------------------- -- Area: Cloister of Tremors -- BCNM: Trial by Earth -- @pos -539 1 -493 209 ----------------------------------- package.loaded["scripts/zones/Cloister_of_Tremors/TextIDs"] = nil; ------------------------------------- require("scripts/globals/keyitems"); require("scripts/globals/quests"); require("scripts/zones/Cloister_of_Tremors/TextIDs"); ----------------------------------- -- After registering the BCNM via bcnmRegister(bcnmid) function onBcnmRegister(player,instance) end; -- Physically entering the BCNM via bcnmEnter(bcnmid) function onBcnmEnter(player,instance) end; -- Leaving the BCNM by every mean possible, given by the LeaveCode -- 1=Select Exit on circle -- 2=Winning the BC -- 3=Disconnected or warped out -- 4=Losing the BC -- via bcnmLeave(1) or bcnmLeave(2). LeaveCodes 3 and 4 are called -- from the core when a player disconnects or the time limit is up, etc function onBcnmLeave(player,instance,leavecode) -- print("leave code "..leavecode); if (leavecode == 2) then -- play end CS. Need time and battle id for record keeping + storage if (player:hasCompleteQuest(BASTOK,TRIAL_BY_EARTH)) then player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,0,1); else player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,0,0); end elseif (leavecode == 4) then player:startEvent(0x7d02); end end; function onEventUpdate(player,csid,option) -- print("bc update csid "..csid.." and option "..option); end; function onEventFinish(player,csid,option) -- print("bc finish csid "..csid.." and option "..option); if (csid == 0x7d01) then player:delKeyItem(TUNING_FORK_OF_EARTH); player:addKeyItem(WHISPER_OF_TREMORS); player:messageSpecial(KEYITEM_OBTAINED,WHISPER_OF_TREMORS); end end;
gpl-3.0
jshackley/darkstar
scripts/zones/Norg/npcs/Achika.lua
19
1252
----------------------------------- -- Area: Norg -- NPC: Achika -- Type: Tenshodo Merchant -- @pos 1.300 0.000 19.259 252 ----------------------------------- package.loaded["scripts/zones/Norg/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/shop"); require("scripts/globals/keyitems"); require("scripts/zones/Norg/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:hasKeyItem(TENSHODO_MEMBERS_CARD)) then if (player:sendGuild(60421,9,23,7)) then player:showText(npc, ACHIKA_SHOP_DIALOG); end else -- player:startEvent(0x0096); 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
jshackley/darkstar
scripts/zones/Bastok_Mines/npcs/Virnage.lua
17
2326
----------------------------------- -- Area: Bastok Mines -- NPC: Virnage -- Starts Quest: Altana's Sorrow -- @zone 234 -- @pos 0 0 51 ----------------------------------- package.loaded["scripts/zones/Bastok_Mines/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/shop"); require("scripts/globals/quests"); require("scripts/zones/Bastok_Mines/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) AltanaSorrow = player:getQuestStatus(BASTOK,ALTANA_S_SORROW); if (AltanaSorrow == QUEST_AVAILABLE and player:getFameLevel(BASTOK) >= 4 and player:getMainLvl() >= 10) then player:startEvent(0x008d); -- Start quest "Altana's Sorrow" elseif (AltanaSorrow == QUEST_ACCEPTED) then if (player:hasKeyItem(BUCKET_OF_DIVINE_PAINT) == true) then player:startEvent(0x008f); -- CS with Bucket of Divine Paint KI elseif (player:hasKeyItem(LETTER_FROM_VIRNAGE) == true) then --player:showText(npc,VIRNAGE_DIALOG_2); player:startEvent(0x0090); -- During quest (after KI) else -- player:showText(npc,VIRNAGE_DIALOG_1); player:startEvent(0x008e); -- During quest "Altana's Sorrow" (before KI) end elseif (AltanaSorrow == QUEST_COMPLETED) then player:startEvent(0x0091); -- New standard dialog else player:startEvent(0x008c); -- 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 == 0x008d and option == 0) then player:addQuest(BASTOK,ALTANA_S_SORROW); elseif (csid == 0x008f) then player:delKeyItem(BUCKET_OF_DIVINE_PAINT); player:addKeyItem(LETTER_FROM_VIRNAGE); player:messageSpecial(KEYITEM_OBTAINED,LETTER_FROM_VIRNAGE); end end;
gpl-3.0
Mythikos/Flood-2.0
flood/gamemode/client/cl_hud.lua
1
9184
surface.CreateFont( "Flood_HUD_Small", { font = "Tehoma", size = 14, weight = 500, antialias = true }) surface.CreateFont( "Flood_HUD", { font = "Tehoma", size = 16, weight = 500, antialias = true }) surface.CreateFont( "Flood_HUD_Large", { font = "Tehoma", size = 30, weight = 500, antialias = true }) surface.CreateFont( "Flood_HUD_B", { font = "Tehoma", size = 18, weight = 600, antialias = true }) -- Hud Stuff local color_grey = Color(120, 120, 120, 100) local color_black = Color(0, 0, 0, 200) local active_color = Color(24, 24, 24, 255) local outline_color = Color(0, 0, 0, 255) local x = ScrW() local y = ScrH() -- Timer Stuff local GameState = 0 local BuildTimer = -1 local FloodTimer = -1 local FightTimer = -1 local ResetTimer = -1 local xPos = x * 0.0025 local yPos = y * 0.005 -- Hud Positioning local Spacer = y * 0.006 local xSize = x * 0.2 local ySize = y * 0.04 local bWidth = Spacer + xSize + Spacer local bHeight = Spacer + ySize + Spacer net.Receive("RoundState", function(len) GameState = net.ReadFloat() BuildTimer = net.ReadFloat() FloodTimer = net.ReadFloat() FightTimer = net.ReadFloat() ResetTimer = net.ReadFloat() end) function GM:HUDPaint() if BuildTimer and FloodTimer and FightTimer and ResetTimer then if GameState == 0 then draw.RoundedBoxEx(6, xPos, y * 0.005, x * 0.175, x * 0.018, active_color, true, true, false, false) draw.SimpleText("Waiting for players.", "Flood_HUD", x * 0.01, y * 0.01, color_white, 0, 0) draw.SimpleText("Build a boat.", "Flood_HUD", x * 0.01, y * 0.044, color_grey, 0, 0) draw.SimpleText("Get on your boat!", "Flood_HUD", x * 0.01, y * 0.078, color_grey, 0, 0) draw.SimpleText("Destroy enemy boats!", "Flood_HUD", x * 0.01, y * 0.115, color_grey, 0, 0) draw.SimpleText("Restarting the round.", "Flood_HUD", x * 0.01, y * 0.151, color_grey, 0, 0) else draw.RoundedBoxEx(6, xPos, y * 0.005, x * 0.175, x * 0.018, color_grey, true, true, false, false) end if GameState == 1 then draw.RoundedBox(0, xPos, yPos + (Spacer * 6), x * 0.175, x * 0.018, active_color) draw.SimpleText(BuildTimer, "Flood_HUD", x * 0.15, y * 0.044, color_white, 0, 0) draw.SimpleText("Waiting for players.", "Flood_HUD", x * 0.01, y * 0.01, color_grey, 0, 0) draw.SimpleText("Build a boat.", "Flood_HUD", x * 0.01, y * 0.044, color_white, 0, 0) draw.SimpleText("Get on your boat!", "Flood_HUD", x * 0.01, y * 0.078, color_grey, 0, 0) draw.SimpleText("Destroy enemy boats!", "Flood_HUD", x * 0.01, y * 0.115, color_grey, 0, 0) draw.SimpleText("Restarting the round.", "Flood_HUD", x * 0.01, y * 0.151, color_grey, 0, 0) else draw.RoundedBox(0, xPos, yPos + (Spacer * 6), x * 0.175, x * 0.018, color_grey) draw.SimpleText(BuildTimer, "Flood_HUD", x * 0.15, y * 0.044, color_grey, 0, 0) end if GameState == 2 then draw.RoundedBox(0, xPos, yPos + (Spacer * 12), x * 0.175, x * 0.018, active_color) draw.SimpleText(FloodTimer, "Flood_HUD", x * 0.15, y * 0.078, color_white, 0, 0) draw.SimpleText("Waiting for players.", "Flood_HUD", x * 0.01, y * 0.01, color_grey, 0, 0) draw.SimpleText("Build a boat.", "Flood_HUD", x * 0.01, y * 0.044, color_grey, 0, 0) draw.SimpleText("Get on your boat!", "Flood_HUD", x * 0.01, y * 0.078, color_white, 0, 0) draw.SimpleText("Destroy enemy boats!", "Flood_HUD", x * 0.01, y * 0.115, color_grey, 0, 0) draw.SimpleText("Restarting the round.", "Flood_HUD", x * 0.01, y * 0.151, color_grey, 0, 0) else draw.RoundedBox(0, xPos, yPos + (Spacer * 12), x * 0.175, x * 0.018, color_grey) draw.SimpleText(FloodTimer, "Flood_HUD", x * 0.15, y * 0.078, color_grey, 0, 0) end if GameState == 3 then draw.RoundedBox(0, xPos, yPos + (Spacer * 18), x * 0.175, x * 0.018, active_color) draw.SimpleText(FightTimer, "Flood_HUD", x * 0.15, y * 0.115, color_white, 0, 0) draw.SimpleText("Waiting for players.", "Flood_HUD", x * 0.01, y * 0.01, color_grey, 0, 0) draw.SimpleText("Build a boat.", "Flood_HUD", x * 0.01, y * 0.044, color_grey, 0, 0) draw.SimpleText("Get on your boat!", "Flood_HUD", x * 0.01, y * 0.078, color_grey, 0, 0) draw.SimpleText("Destroy enemy boats!", "Flood_HUD", x * 0.01, y * 0.115, color_white, 0, 0) draw.SimpleText("Restarting the round.", "Flood_HUD", x * 0.01, y * 0.151, color_grey, 0, 0) else draw.RoundedBox(0, xPos, yPos + (Spacer * 18), x * 0.175, x * 0.018, color_grey) draw.SimpleText(FightTimer, "Flood_HUD", x * 0.15, y * 0.115, color_grey, 0, 0) end if GameState == 4 then draw.RoundedBoxEx(6, xPos, yPos + (Spacer * 24), x * 0.175, x * 0.018, active_color, false, false, true, true) draw.SimpleText(ResetTimer, "Flood_HUD", x * 0.15, y * 0.151, color_white, 0, 0) draw.SimpleText("Waiting for players.", "Flood_HUD", x * 0.01, y * 0.01, color_grey, 0, 0) draw.SimpleText("Build a boat.", "Flood_HUD", x * 0.01, y * 0.044, color_grey, 0, 0) draw.SimpleText("Get on your boat!", "Flood_HUD", x * 0.01, y * 0.078, color_grey, 0, 0) draw.SimpleText("Destroy enemy boats!", "Flood_HUD", x * 0.01, y * 0.115, color_grey, 0, 0) draw.SimpleText("Restarting the round.", "Flood_HUD", x * 0.01, y * 0.151, color_white, 0, 0) else draw.RoundedBoxEx(6,xPos, yPos + (Spacer * 24), x * 0.175, x * 0.018, color_grey, false, false, true, true) draw.SimpleText(ResetTimer, "Flood_HUD", x * 0.15, y * 0.151, color_grey, 0, 0) end end -- Display Prop's Health local tr = util.TraceLine(util.GetPlayerTrace(LocalPlayer())) if tr.Entity:IsValid() and not tr.Entity:IsPlayer() then if tr.Entity:GetNWInt("CurrentPropHealth") == "" or tr.Entity:GetNWInt("CurrentPropHealth") == nil or tr.Entity:GetNWInt("CurrentPropHealth") == NULL then draw.SimpleText("Fetching Health", "Flood_HUD_Small", x * 0.5, y * 0.5 - 25, color_white, 1, 1) else draw.SimpleText("Health: " .. tr.Entity:GetNWInt("CurrentPropHealth"), "Flood_HUD_Small", x * 0.5, y * 0.5 - 25, color_white, 1, 1) end end -- Display Player's Health and Name if tr.Entity:IsValid() and tr.Entity:IsPlayer() then draw.SimpleText("Name: " .. tr.Entity:GetName(), "Flood_HUD_Small", x * 0.5, y * 0.5 - 75, color_white, 1, 1) draw.SimpleText("Health: " .. tr.Entity:Health(), "Flood_HUD_Small", x * 0.5, y * 0.5 - 60, color_white, 1, 1) end -- Bottom left HUD Stuff if LocalPlayer():Alive() and IsValid(LocalPlayer()) then draw.RoundedBox(6, 4, y - ySize - Spacer - (bHeight * 2), bWidth, bHeight * 2 + ySize, Color(24, 24, 24, 255)) -- Health local pHealth = LocalPlayer():Health() local pHealthClamp = math.Clamp(pHealth / 100, 0, 1) local pHealthWidth = (xSize - Spacer) * pHealthClamp draw.RoundedBoxEx(6, Spacer * 2, y - (Spacer * 4) - (ySize * 3), Spacer + pHealthWidth, ySize, Color(128, 28, 28, 255), true, true, false, false) draw.SimpleText(math.Max(pHealth, 0).." HP","Flood_HUD_B", xSize * 0.5 + (Spacer * 2), y - (ySize * 2.5) - (Spacer * 4), color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) -- Ammo if IsValid(LocalPlayer():GetActiveWeapon()) then if LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType()) > 0 or LocalPlayer():GetActiveWeapon():Clip1() > 0 then local wBulletCount = (LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType()) + LocalPlayer():GetActiveWeapon():Clip1()) + 1 local wBulletClamp = math.Clamp(wBulletCount / 100, 0, 1) local wBulletWidth = (xSize - bWidth) * wBulletClamp draw.RoundedBox(0, Spacer * 2, y - (ySize * 2) - (Spacer * 3), bWidth + wBulletWidth, ySize, Color(30, 105, 105, 255)) draw.SimpleText(wBulletCount.." Bullets", "Flood_HUD_B", xSize * 0.5 + (Spacer * 2), y - ySize - (ySize * 0.5) - (Spacer * 3), color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) else draw.RoundedBox(0, Spacer * 2, y - (ySize * 2) - (Spacer * 3), xSize, ySize, Color(30, 105, 105, 255)) draw.SimpleText("Doesn't Use Ammo", "Flood_HUD_B", xSize * 0.5 + (Spacer * 2), y - ySize - (ySize * 0.5) - (Spacer * 3), color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) end else draw.RoundedBox(0, Spacer * 2, y - (ySize * 2) - (Spacer * 3), xSize, ySize, Color(30, 105, 105, 255)) draw.SimpleText("No Ammo", "Flood_HUD_B", xSize * 0.5 + (Spacer * 2), y - ySize - (ySize * 0.5) - (Spacer * 3), color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) end -- Cash local pCash = LocalPlayer():GetNWInt("flood_cash") or 0 local pCashClamp = math.Clamp(pCash / 5000, 0, xSize) draw.RoundedBoxEx(6, Spacer * 2, y - ySize - (Spacer * 2), xSize, ySize, Color(63, 140, 64, 255), false, false, true, true) draw.SimpleText("$"..pCash, "Flood_HUD_B", (xSize * 0.5) + (Spacer * 2), y - (ySize * 0.5) - (Spacer * 2), WHITE, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) end end function hidehud(name) for k, v in pairs{"CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo"} do if name == v then return false end end end hook.Add("HUDShouldDraw", "hidehud", hidehud)
mit
jshackley/darkstar
scripts/zones/Aht_Urhgan_Whitegate/npcs/Rujen-Gorgen.lua
34
1037
----------------------------------- -- Area: Aht Urhgan Whitegate -- NPC: Rujen-Gorgen -- Standard Info NPC ----------------------------------- package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x029B); 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
jshackley/darkstar
scripts/globals/items/gurnard.lua
18
1256
----------------------------------------- -- ID: 5132 -- Item: Gurnard -- Food Effect: 5Min, Mithra only ----------------------------------------- -- Dexterity 2 -- Mind -4 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) result = 0 if (target:getRace() ~= 7) then result = 247; end if (target:getMod(MOD_EAT_RAW_FISH) == 1) then result = 0; end if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,300,5132); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_DEX, 2); target:addMod(MOD_MND, -4); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_DEX, 2); target:delMod(MOD_MND, -4); end;
gpl-3.0
Ombridride/minetest-minetestforfun-server
mods/unified_inventory/bags.lua
6
11622
-- Bags for Minetest -- Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com> -- License: GPLv3 local S = unified_inventory.gettext local F = unified_inventory.fgettext unified_inventory.register_page("bags", { get_formspec = function(player) local player_name = player:get_player_name() local formspec = "background[0.06,0.99;7.92,7.52;ui_bags_main_form.png]" formspec = formspec.."label[0,0;"..F("Bags").."]" formspec = formspec.."button[0,2;2,0.5;bag1;"..F("Bag 1").."]" .. "button[0,3;2,0.5;unequip_bag1;Unequip]" formspec = formspec.."button[2,2;2,0.5;bag2;"..F("Bag 2").."]" .. "button[2,3;2,0.5;unequip_bag2;Unequip]" formspec = formspec.."button[4,2;2,0.5;bag3;"..F("Bag 3").."]" .. "button[4,3;2,0.5;unequip_bag3;Unequip]" formspec = formspec.."button[6,2;2,0.5;bag4;"..F("Bag 4").."]" .. "button[6,3;2,0.5;unequip_bag4;Unequip]" formspec = formspec.."listcolors[#00000000;#00000000]" formspec = formspec.."list[detached:"..minetest.formspec_escape(player_name).."_bags;bag1;0.5,1;1,1;]" formspec = formspec.."list[detached:"..minetest.formspec_escape(player_name).."_bags;bag2;2.5,1;1,1;]" formspec = formspec.."list[detached:"..minetest.formspec_escape(player_name).."_bags;bag3;4.5,1;1,1;]" formspec = formspec.."list[detached:"..minetest.formspec_escape(player_name).."_bags;bag4;6.5,1;1,1;]" return {formspec=formspec} end, }) unified_inventory.register_button("bags", { type = "image", image = "ui_bags_icon.png", tooltip = S("Bags"), hide_lite=true, show_with = false, --Modif MFF (Crabman 30/06/2015) }) unified_inventory.register_page("bag1", { get_formspec = function(player) local stack = player:get_inventory():get_stack("bag1", 1) local image = stack:get_definition().inventory_image local formspec = "image[7,0;1,1;"..image.."]" formspec = formspec.."label[0,0;"..F("Bag 1").."]" formspec = formspec.."listcolors[#00000000;#00000000]" formspec = formspec.."list[current_player;bag1contents;0,1;8,3;]" formspec = formspec.."listring[current_name;bag1contents]" formspec = formspec.."listring[current_player;main]" local slots = stack:get_definition().groups.bagslots if slots == 8 then formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_sm_form.png]" elseif slots == 16 then formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_med_form.png]" elseif slots == 24 then formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_lg_form.png]" end return {formspec=formspec} end, }) unified_inventory.register_page("bag2", { get_formspec = function(player) local stack = player:get_inventory():get_stack("bag2", 1) local image = stack:get_definition().inventory_image local formspec = "image[7,0;1,1;"..image.."]" formspec = formspec.."label[0,0;"..F("Bag 2").."]" formspec = formspec.."listcolors[#00000000;#00000000]" formspec = formspec.."list[current_player;bag2contents;0,1;8,3;]" formspec = formspec.."listring[current_name;bag2contents]" formspec = formspec.."listring[current_player;main]" local slots = stack:get_definition().groups.bagslots if slots == 8 then formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_sm_form.png]" elseif slots == 16 then formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_med_form.png]" elseif slots == 24 then formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_lg_form.png]" end return {formspec=formspec} end, }) unified_inventory.register_page("bag3", { get_formspec = function(player) local stack = player:get_inventory():get_stack("bag3", 1) local image = stack:get_definition().inventory_image local formspec = "image[7,0;1,1;"..image.."]" formspec = formspec.."label[0,0;"..F("Bag 3").."]" formspec = formspec.."listcolors[#00000000;#00000000]" formspec = formspec.."list[current_player;bag3contents;0,1;8,3;]" formspec = formspec.."listring[current_name;bag3contents]" formspec = formspec.."listring[current_player;main]" local slots = stack:get_definition().groups.bagslots if slots == 8 then formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_sm_form.png]" elseif slots == 16 then formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_med_form.png]" elseif slots == 24 then formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_lg_form.png]" end return {formspec=formspec} end, }) unified_inventory.register_page("bag4", { get_formspec = function(player) local stack = player:get_inventory():get_stack("bag4", 1) local image = stack:get_definition().inventory_image local formspec = "image[7,0;1,1;"..image.."]" formspec = formspec.."label[0,0;"..F("Bag 4").."]" formspec = formspec.."listcolors[#00000000;#00000000]" formspec = formspec.."list[current_player;bag4contents;0,1;8,3;]" formspec = formspec.."listring[current_name;bag4contents]" formspec = formspec.."listring[current_player;main]" local slots = stack:get_definition().groups.bagslots if slots == 8 then formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_sm_form.png]" elseif slots == 16 then formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_med_form.png]" elseif slots == 24 then formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_lg_form.png]" end return {formspec=formspec} end, }) minetest.register_on_player_receive_fields(function(player, formname, fields) if formname ~= "" then return end for i = 1, 4 do if fields["bag"..i] then local stack = player:get_inventory():get_stack("bag"..i, 1) if not stack:get_definition().groups.bagslots then return end unified_inventory.set_inventory_formspec(player, "bag"..i) return elseif fields["unequip_bag" .. i] then local stack = unified_inventory.extract_bag(player, i) if not stack then return elseif stack == "overflow" then minetest.chat_send_player(player:get_player_name(), "You bag is too heavy to be unequipped... Remove some items and retry") return elseif not player:get_inventory():room_for_item("main", stack) then local pos = player:getpos() pos.y = pos.y + 2 minetest.add_item(pos, stack) return end player:get_inventory():add_item("main", stack) end end end) minetest.register_on_joinplayer(function(player) local player_inv = player:get_inventory() local bags_inv = minetest.create_detached_inventory(player:get_player_name().."_bags",{ on_put = function(inv, listname, index, stack, player) local pinv = player:get_inventory() pinv:set_stack(listname, index, stack) pinv:set_size(listname.."contents", stack:get_definition().groups.bagslots) -- Retrieve the serialized inventory if any if stack:get_metadata() ~= "" then for i, item in pairs(minetest.deserialize(stack:get_metadata())) do pinv:set_stack(listname .. "contents", i, ItemStack(item)) end end end, allow_take = function() return 0 end, allow_put = function(inv, listname, index, stack, player) if stack:get_definition().groups.bagslots then return 1 else return 0 end end, allow_move = function(inv, from_list, from_index, to_list, to_index, count, player) return 0 end, }) for i=1,4 do local bag = "bag"..i player_inv:set_size(bag, 1) bags_inv:set_size(bag, 1) bags_inv:set_stack(bag, 1, player_inv:get_stack(bag, 1)) end end) -- register bag tools minetest.register_tool("unified_inventory:bag_small", { description = S("Small Bag"), inventory_image = "bags_small.png", groups = {bagslots=8}, }) minetest.register_tool("unified_inventory:bag_medium", { description = S("Medium Bag"), inventory_image = "bags_medium.png", groups = {bagslots=16}, }) minetest.register_tool("unified_inventory:bag_large", { description = S("Large Bag"), inventory_image = "bags_large.png", groups = {bagslots=24}, }) local colours = {"orange", "blue", "green", "violet"} for _, colour in pairs(colours) do minetest.register_tool("unified_inventory:bag_small_" .. colour, { description = S("Small Bag"), inventory_image = "bags_small_" .. colour .. ".png", groups = {bagslots=8}, }) minetest.register_tool("unified_inventory:bag_medium_" .. colour, { description = S("Medium Bag"), inventory_image = "bags_medium_" .. colour .. ".png", groups = {bagslots=16}, }) minetest.register_tool("unified_inventory:bag_large_" .. colour, { description = S("Large Bag"), inventory_image = "bags_large_" .. colour .. ".png", groups = {bagslots=24}, }) -- register bag crafts minetest.register_craft({ output = "unified_inventory:bag_small_" .. colour, recipe = { {"dye:"..colour, "unified_inventory:bag_small"}, }, }) minetest.register_craft({ output = "unified_inventory:bag_medium_" .. colour, recipe = { {"", "", ""}, {"farming:cotton", "unified_inventory:bag_small_" .. colour, "farming:cotton"}, {"farming:cotton", "unified_inventory:bag_small_" .. colour, "farming:cotton"}, }, }) minetest.register_craft({ output = "unified_inventory:bag_large_" .. colour, recipe = { {"", "", ""}, {"farming:cotton", "unified_inventory:bag_medium_" .. colour, "farming:cotton"}, {"farming:cotton", "unified_inventory:bag_medium_" .. colour, "farming:cotton"}, }, }) end --minetest.register_alias("unified_inventory:bag_small", "unified_inventory:bad_small_red") --minetest.register_alias("unified_inventory:bag_medium", "unified_inventory:bad_medium_red") --minetest.register_alias("unified_inventory:bag_large", "unified_inventory:bad_large_red") -- register bag crafts minetest.register_craft({ output = "unified_inventory:bag_small", recipe = { {"", "farming:cotton", ""}, {"group:wool", "group:wool", "group:wool"}, {"group:wool", "group:wool", "group:wool"}, }, }) minetest.register_craft({ output = "unified_inventory:bag_medium", recipe = { {"", "", ""}, {"farming:cotton", "unified_inventory:bag_small", "farming:cotton"}, {"farming:cotton", "unified_inventory:bag_small", "farming:cotton"}, }, }) minetest.register_craft({ output = "unified_inventory:bag_large", recipe = { {"", "", ""}, {"farming:cotton", "unified_inventory:bag_medium", "farming:cotton"}, {"farming:cotton", "unified_inventory:bag_medium", "farming:cotton"}, }, }) function unified_inventory.extract_bag(player, id) if not player then minetest.log("error", "[u_inv] Invalid player for bag extraction : nil") return end if tonumber(id) == nil or id > 4 or id < 0 then minetest.log("error", "Invalid id: " .. (id or 'nil')) return end local stack = player:get_inventory():get_stack("bag"..id, 1) if not stack:get_definition().groups.bagslots then return end local pinv = player:get_inventory() local inv = pinv:get_list("bag" .. id .. "contents") local list = {} for i, item in pairs(inv) do list[i] = item:to_table() end if minetest.serialize(list):len() >= 4096 then minetest.log("warning", "[U_Inv] Preventing metadata overflow with bag metadata") return "overflow" end pinv:remove_item("bag" .. id, stack) local dinv = minetest.get_inventory({type = "detached", name = minetest.formspec_escape(player:get_player_name()) .. "_bags"}) if dinv then dinv:set_stack("bag" .. id, 1, nil) end pinv:set_list("bag" .. id .. "contents", {}) stack:set_metadata(minetest.serialize(list)) return stack end
unlicense
luastoned/turbo
turbo/iosimple.lua
8
8013
--- Turbo.lua IO Stream module. -- Very High-level wrappers for asynchronous socket communication. -- -- Copyright 2015 John Abrahamsen -- -- 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. -- -- -- A interface for turbo.iostream without the callback spaghetti, but still -- the async backend (the yield is done internally): -- turbo.ioloop.instance():add_callback(function() -- local stream = turbo.iosimple.dial("tcp://turbolua.org:80") -- stream:write("GET / HTTP/1.0\r\n\r\n") -- -- local data = stream:read_until_close() -- print(data) -- -- turbo.ioloop.instance():close() -- end):start() -- -- local log = require "turbo.log" local ioloop = require "turbo.ioloop" local coctx = require "turbo.coctx" local socket = require "turbo.socket_ffi" local sockutils = require "turbo.sockutil" local util = require "turbo.util" local iostream = require "turbo.iostream" local crypto = require "turbo.crypto" local iosimple = {} -- iosimple namespace --- Connect to a host using a simple URI pattern. -- @param address (String) E.g tcp://turbolua.org:8887 -- @param io (IOLoop object) IOLoop class instance to use for event -- processing. If none is set then the global instance is used, see the -- ioloop.instance() function. -- @return (IOSimple class instance) or raise error. function iosimple.dial(address, ssl, io) assert(type(address) == "string", "No address in call to dial.") local protocol, host, port = address:match("^(%a+)://(.+):(%d+)") port = tonumber(port) assert( protocol and host, "Invalid address. Use e.g \"tcp://turbolua.org:8080\".") io = io or ioloop.instance() local sock_t local address_family if protocol == "tcp" then sock_t = socket.SOCK_STREAM address_family = socket.AF_INET elseif protocol == "udp" then sock_t = socket.SOCK_DGRAM address_family = socket.AF_INET elseif protocol == "unix" then sock_t = socket.SOCK_STREAM address_family = socket.AF_UNIX else error("Unknown schema: " .. protocol) end local err, ssl_context if ssl then if ssl == true then ssl = {verify=true} end err, res = crypto.ssl_create_client_context( ssl.cert_file, ssl.key_file, ssl.ca_cert_file, ssl.verify) if err ~= 0 then error(res) end ssl_context = res end local sock, msg = socket.new_nonblock_socket( address_family, sock_t, 0) if sock == -1 then error("Could not create socket.") end local ctx = coctx.CoroutineContext(io) local stream if ssl and ssl_context then stream = iostream.SSLIOStream(sock, {_ssl_ctx=ssl_context, _type=1}) stream:connect(host, port, address_family, ssl.verify or false, function() ctx:set_arguments({true}) ctx:finalize_context() end, function(err) ctx:set_arguments({false, sockerr, strerr}) ctx:finalize_context() end ) else stream = iostream.IOStream(sock) stream:connect(host, port, address_family, function() ctx:set_arguments({true}) ctx:finalize_context() end, function(err) ctx:set_arguments({false, sockerr, strerr}) ctx:finalize_context() end ) end local rc, sockerr, strerr = coroutine.yield(ctx) if rc ~= true then error(string.format("Could not connect to %s, %s", address, strerr)) end return iosimple.IOSimple(stream, io) end iosimple.IOSimple = class("IOSimple") --- Wrap a IOStream class instance with a simpler IO. -- @param stream IOStream class instance, already connected. If not consider -- using iosimple.dial. function iosimple.IOSimple:initialize(stream) self.stream = stream self.io = self.stream.io_loop self.stream:set_close_callback(self._wake_yield_close, self) end --- Close this stream and clean up. function iosimple.IOSimple:close() self.stream:close() end --- Returns the IOStream instance backed by the current IOSimple instance. -- @return (IOStream class instance) function iosimple.IOSimple:get_iostream() return self.stream end --- Write the given data to the stream. Return when data has been written. -- @param data (String) Data to write to stream. function iosimple.IOSimple:write(data) assert(not self.coctx, "IOSimple is already working.") self.coctx = coctx.CoroutineContext(self.io) self.stream:write(data, self._wake_yield, self) local res, err = coroutine.yield(self.coctx) if not res and err then error(err) end return res end --- Read until delimiter. -- Delimiter is plain text, and does not support Lua patterns. -- See read_until_pattern for Lua patterns. -- read_until should be used instead of read_until_pattern wherever possible -- because of the overhead of doing pattern matching. -- @param delimiter (String) Delimiter sequence, text or binary. -- @return (String) Data recieved until delimiter. function iosimple.IOSimple:read_until(delimiter) assert(not self.coctx, "IOSimple is already working.") self.coctx = coctx.CoroutineContext(self.io) self.stream:read_until(delimiter, self._wake_yield, self) local res, err = coroutine.yield(self.coctx) if not res and err then error(err) end return res end --- Read given amount of bytes from connection. -- @param bytes (Number) The amount of bytes to read. -- @return (String) Data recieved. function iosimple.IOSimple:read_bytes(bytes) assert(not self.coctx, "IOSimple is already working.") self.coctx = coctx.CoroutineContext(self.io) self.stream:read_bytes(bytes, self._wake_yield, self) local res, err = coroutine.yield(self.coctx) if not res and err then error(err) end return res end --- Read until pattern is matched, then returns recieved data. -- If you only are doing plain text matching then using read_until -- is recommended for less overhead. -- @param pattern (String) The pattern to match. -- @return (String) Data recieved. function iosimple.IOSimple:read_until_pattern(pattern) assert(not self.coctx, "IOSimple is already working.") self.coctx = coctx.CoroutineContext(self.io) self.stream:read_until_pattern(pattern, self._wake_yield, self) local res, err = coroutine.yield(self.coctx) if not res and err then error(err) end return res end --- Reads all data from the socket until it is closed. -- @return (String) Data recieved. function iosimple.IOSimple:read_until_close() assert(not self.coctx, "IOSimple is already working.") self.coctx = coctx.CoroutineContext(self.io) self.stream:read_until_close(self._wake_yield, self) local res, err = coroutine.yield(self.coctx) if not res and err then error(err) end return res end function iosimple.IOSimple:_wake_yield_close(...) if self.coctx then self.coctx:set_arguments({nil, "disconnected"}) self.coctx:finalize_context() self.coctx = nil end end function iosimple.IOSimple:_wake_yield(...) local ctx = self.coctx self.coctx = nil ctx:set_arguments({...}) ctx:finalize_context() end return iosimple
apache-2.0
Ombridride/minetest-minetestforfun-server
mods/moreblocks/stairsplus/registrations.lua
8
1292
--[[ More Blocks: registrations Copyright (c) 2011-2015 Calinou and contributors. Licensed under the zlib license. See LICENSE.md for more information. --]] local default_nodes = { -- Default stairs/slabs/panels/microblocks: "stone", "cobble", "mossycobble", "brick", "sandstone", "steelblock", "goldblock", "copperblock", "bronzeblock", "diamondblock", "desert_stone", "desert_cobble", "meselamp", "glass", "tree", "wood", "jungletree", "junglewood", "pine_tree", "pine_wood", "cherry_tree", "cherry_plank", "acacia_tree", "acacia_wood", "obsidian", "obsidian_glass", "stonebrick", "desert_stonebrick", "sandstonebrick", "obsidianbrick", } for _, name in pairs(default_nodes) do local nodename = "default:" .. name local ndef = minetest.registered_nodes[nodename] if ndef then local drop if type(ndef.drop) == "string" then drop = ndef.drop:split(" ")[1]:sub(9) end local tiles = ndef.tiles if #ndef.tiles > 1 and ndef.drawtype:find("glass") then tiles = { ndef.tiles[1] } end stairsplus:register_all("moreblocks", name, nodename, { description = ndef.description, drop = drop, groups = ndef.groups, sounds = ndef.sounds, tiles = tiles, sunlight_propagates = true, light_source = ndef.light_source }) end end
unlicense
jshackley/darkstar
scripts/zones/Gusgen_Mines/npcs/_5gb.lua
34
1345
----------------------------------- -- Area: Gusgen Mines -- NPC: _5gb (Lever B) -- @pos 19.999 -40.561 -54.198 196 ----------------------------------- package.loaded["scripts/zones/Gusgen_Mines/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Gusgen_Mines/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) --local nID = npc:getID(); --printf("id: %u", nID); local Lever = npc:getID(); npc:openDoor(2); -- Lever animation if (GetNPCByID(Lever-6):getAnimation() == 9) then GetNPCByID(Lever-7):setAnimation(9);--close door C GetNPCByID(Lever-6):setAnimation(8);--open door B GetNPCByID(Lever-5):setAnimation(9);--close door A 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
opentibia/server
data/scripts/otstd/commands.lua
3
1400
otstd.Commands = {} Command = {} Command_meta = { __index = Command } function Command:new(name) local command = {} setmetatable(command, Command_meta) command.name = name return command end function Command:register() if self.Listeners ~= nil then stopListener(self.Listeners) end if self.words == nil then error("Can not register command without words!") end if self.groups == nil then self.groups = {} end if self.handler == nil then error("Can not register command '" .. self.words .. " without handler!") end local function registerHandler(words) local function internalHandler(event) local speaker = event.creature event.player = speaker if typeof(speaker, "Player") then if (type(self.groups) == "string" and self.groups == "All") or table.find(self.groups, speaker:getAccessGroup()) then event.cmd = words event.param = event.text:sub(words:len()+1) or "" self.handler(event) event:skip() end else error("A non-player creature attempted to use a command.") end end table.append(self.Listeners, registerOnSay("beginning", true, words, internalHandler)) end self.Listeners = {} if type(self.words) == "table" then for k, words in ipairs(self.words) do registerHandler(words) end else registerHandler(self.words) end otstd.Commands[self.name] = self end require_directory("otstd/commands")
gpl-2.0
jshackley/darkstar
scripts/zones/Port_San_dOria/npcs/Altiret.lua
36
2942
----------------------------------- -- Area: Port San d'Oria -- NPC: Altiret -- NPC for Quest "The Pickpocket" ----------------------------------- package.loaded["scripts/zones/Port_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/titles"); require("scripts/globals/settings"); require("scripts/globals/quests"); require("scripts/zones/Port_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- "Flyers for Regine" conditional script FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE); -- "The Pickpocket" Quest status thePickpocket = player:getQuestStatus(SANDORIA, THE_PICKPOCKET); -- "The Pickpocket" Quest, trading for light axe if (thePickpocket == 1) then count = trade:getItemCount(); freeSlot = player:getFreeSlotsCount(); giltGlasses = trade:hasItemQty(579, 1); if (count == 1 and freeSlot > 0 and giltGlasses == true) then player:tradeComplete(); player:addFame(SANDORIA,SAN_FAME*30); player:addTitle(PICKPOCKET_PINCHER); player:completeQuest(SANDORIA,THE_PICKPOCKET); player:startEvent(0x0226); elseif (giltGlasses == false) then player:startEvent(0x0227); else player:messageSpecial(6402, 579); -- CANNOT_OBTAIN_ITEM end; -- "Flyers for Regine" elseif (FlyerForRegine == 1) then count = trade:getItemCount(); MagicFlyer = trade:hasItemQty(532,1); if (MagicFlyer == true and count == 1) then player:messageSpecial(FLYER_REFUSED); elseif (MagicFlyer == false) then player:startEvent(0x0227); end; else player:startEvent(0x0227); end; end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) -- Vars for the Quest "The Pickpocket" thePickpocket = player:getQuestStatus(SANDORIA, THE_PICKPOCKET); openingCS = player:getVar("thePickpocket"); -- "The Pickpocket" Quest dialog if (thePickpocket == 0 and openingCS == 1) then player:startEvent(0x0223); player:addQuest(SANDORIA,THE_PICKPOCKET); elseif (thePickpocket == 1) then player:startEvent(0x0223); elseif (thePickpocket == 2) then player:startEvent(0x0244); else player:startEvent(0x022f); end; end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); -- "The Pickpocket" reward with light axe, done with quest if (csid == 0x0226) then player:addItem(16667); player:messageSpecial(6403, 16667); end; end;
gpl-3.0
LiberatorUSA/GUCEF
plugins/CORE/dstorepluginPARSIFALXML/premake5.lua
1
1961
-------------------------------------------------------------------- -- This file was automatically generated by ProjectGenerator -- which is tooling part the build system designed for GUCEF -- (Galaxy Unlimited Framework) -- For the latest info, see http://www.VanvelzenSoftware.com/ -- -- The contents of this file are placed in the public domain. Feel -- free to make use of it in any way you like. -------------------------------------------------------------------- -- -- Configuration for module: dstorepluginPARSIFALXML project( "dstorepluginPARSIFALXML" ) configuration( {} ) location( os.getenv( "PM5OUTPUTDIR" ) ) configuration( {} ) targetdir( os.getenv( "PM5TARGETDIR" ) ) configuration( {} ) language( "C" ) configuration( {} ) kind( "SharedLib" ) configuration( {} ) links( { "gucefCORE", "gucefMT", "libparsifal" } ) links( { "libparsifal" } ) configuration( {} ) defines( { "DSTOREPLUGINPARSIFALXML_BUILD_MODULE" } ) configuration( {} ) vpaths { ["Headers"] = { "**.h", "**.hpp", "**.hxx" } } files( { "include/DLLMainDSTOREpluginPARSIFALXML.h" } ) configuration( {} ) vpaths { ["Source"] = { "**.c", "**.cpp", "**.cs", "**.asm" } } files( { "src/DLLMainDSTOREpluginPARSIFALXML.c" } ) configuration( {} ) includedirs( { "../../../common/include", "../../../dependencies/libparsifal/include", "../../../dependencies/libparsifal/include/libparsifal", "../../../platform/gucefCORE/include", "../../../platform/gucefMT/include", "include" } ) configuration( { "ANDROID" } ) includedirs( { "../../../platform/gucefCORE/include/android" } ) configuration( { "LINUX32" } ) includedirs( { "../../../platform/gucefCORE/include/linux" } ) configuration( { "LINUX64" } ) includedirs( { "../../../platform/gucefCORE/include/linux" } ) configuration( { "WIN32" } ) includedirs( { "../../../platform/gucefCORE/include/mswin" } ) configuration( { "WIN64" } ) includedirs( { "../../../platform/gucefCORE/include/mswin" } )
apache-2.0
MeGaTG/amirdb
lang/persian_lang.lua
1
27958
-------------------------------------------------- -- ____ ____ _____ -- -- | \| _ )_ _|___ ____ __ __ -- -- | |_ ) _ \ | |/ ·__| _ \_| \/ | -- -- |____/|____/ |_|\____/\_____|_/\/\_| -- -- -- -------------------------------------------------- -- -- -- Developers: @Josepdal & @MaSkAoS -- -- Support: @Skneos, @iicc1 & @serx666 -- -- -- -- Translated by: @NimaGame -- -- Translated by: @Iamjavid -- -- -- -------------------------------------------------- local LANG = 'fa' local function run(msg, matches) if permissions(msg.from.id, msg.to.id, "lang_install") then ------------------------- -- Translation version -- ------------------------- set_text(LANG, 'version', '0.3') set_text(LANG, 'versionExtended', 'نسخه ترجمه : نسخه 0.3') set_text(LANG, 'langname', 'فارسی') ------------- -- Plugins -- ------------- -- global plugins -- set_text(LANG, 'require_sudo', 'این پلاگین نیاز به دسترسی سودو دارد.') set_text(LANG, 'require_admin', 'این پلاگین نیاز به دسترسی ادمین و یا بالا تر دارد.') set_text(LANG, 'require_mod', 'این پلاگین نیاز به دسترسی مدیر و یا بالا تر دارد.') set_text(LANG, 'require_owner', 'این پلاگین نیاز به دسترسی صاحب چت و یا بالا تر دارد.') set_text(LANG, 'require_down100', 'لطفا یک مقدار بین 1 تا 99 وارد نمایید.') set_text(LANG, 'onlychannel', 'شما فقط در یک سوپر گروه میتوانید از این دستور استفاده نمایید.') set_text(LANG, 'rankisup', 'مقام فعلی کاربر از مقامی که میخواهید برای وی تنظیم کنید بالاتر است.') -- know.lua -- set_text(LANG, 'require_know', 'باید یک دانستنی معتبر وارد نمایید.') set_text(LANG, 'require_joke', 'باید یک جک معتبر وارد نمایید.') set_text(LANG, 'require_noemjoke', 'هیچ جکی در لیست جک های این چت وجود ندارد.') set_text(LANG, 'require_noemknow', 'هیچ دانستنیی در لیست دانستنی های این چت وجود ندارد.') set_text(LANG, 'require_gnoemjoke', 'هیچ جکی در لیست جک های ربات وجود ندارد.') set_text(LANG, 'require_gnoemknow', 'هیچ دانستنیی در لیست دانستنی های ربات وجود ندارد.') set_text(LANG, 'require_grjoke', 'جک مورد نظر از قبل در لیست جک های ربات موجود است.') set_text(LANG, 'require_grknow', 'دانستنی مورد نظر از قبل در لیست دانستنی های ربات موجود است.') set_text(LANG, 'require_rjoke', 'جک مورد نظر از قبل در لیست جک های چت موجود است.') set_text(LANG, 'require_rknow', 'دانستنی مورد نظر از قبل در لیست دانستنی های چت موجود است.') set_text(LANG, 'gknowadded', 'دانستنی مورد نظر به لیست دانستنی های ربات افزوده شد.') set_text(LANG, 'knowadded', 'دانستنی مورد نظر به لیست دانستنی های چت افزوده شد.') set_text(LANG, 'gjockadded', 'جک مورد نظر به لیست جک های ربات افزوده شد.') set_text(LANG, 'jockadded', 'جک مورد نظر به لیست جک های چت افزوده شد.') set_text(LANG, 'gknowremoved', 'دانستنی مورد نظر از لیست دانستنی های ربات حذف شد.') set_text(LANG, 'knowremoved', 'دانستنی مورد نظر از لیست دانستنی های چت حذف شد.') set_text(LANG, 'gjockremoved', 'جک مورد نظر از لیست جک های ربات حذف شد.') set_text(LANG, 'jockremoved', 'جک مورد نظر از لیست جک های چت حذف شد.') set_text(LANG, 'ngknowremoved', 'دانستنی مورد نظر در لیست دانستنی های ربات وجود ندارد.') set_text(LANG, 'nknowremoved', 'دانستنی مورد نظر در لیست دانستنی های چت وجود ندارد.') set_text(LANG, 'ngjockremoved', 'جک مورد نظر در لیست جک های ربات وجود ندارد.') set_text(LANG, 'njockremoved', 'جک مورد نظر در لیست جک های چت وجود ندارد.') -- Spam.lua -- set_text(LANG, 'reportUser', 'کاربر') set_text(LANG, 'reportReason', 'دلیل ریپورت') set_text(LANG, 'reportGroup', 'گروه') set_text(LANG, 'reportMessage', 'پیام') set_text(LANG, 'allowedSpamT', 'این گروه در مقابل اسپمینگ محافظت نمیشود.') set_text(LANG, 'allowedSpamL', 'این سوپر گروه در مقابل اسپمینگ محافظت نمیشود.') set_text(LANG, 'notAllowedSpamT', 'اسپمینگ در این گروه ممنوع میباشد.') set_text(LANG, 'notAllowedSpamL', 'اسپمینگ در این سوپر گروه ممنوع میباشد.') -- inchat.lua -- set_text(LANG, 'gadding', 'این گروه به لیست چت های من افزوده شد\n لطفا من را مدیر گروه نمایید تا انجام وظیفه نمایم در غیر ایصورت امکانات من کمتر از معمول خواهد بود') set_text(LANG, 'sadding', 'این سوپرگروه به لیست چت های من افزوده شد\n لطفا من را مدیر سوپرگروه نمایید تا انجام وظیفه نمایم در غیر ایصورت امکانات من کمتر از معمول خواهد بود') set_text(LANG, 'ngadding', 'این گروه از قبل در لیست چت های من موجود بود') set_text(LANG, 'nsadding', 'این سوپرگروه از قبل در لیست چت های من موجود بود') set_text(LANG, 'chatrems', 'چت مورد نظر از ليست چت هاي من پاک شد.') set_text(LANG, 'nchatrems', 'چت مورد نظر در ليست چت هاي من موجود نيست.') set_text(LANG, 'chatrem', 'با دستور ادمين چت شما نظر از ليست چت هاي من پاک شد.') set_text(LANG, 'gnadding', 'شما ادمین نیستید و نمی توانید به رایگان از امکانات ربات استفاده نمایید تکرار این کار محرومیت شما را درپی خواهد داشت') -- bot.lua -- set_text(LANG, 'botOn', 'ربات روشن شد') set_text(LANG, 'botOff', 'ربات خاموش شد') -- sticker -- set_text(LANG, 'u_image', 'این هم تصویر شما و تصویر با فرمت ویژه (png) برای ساخت پکیج استیکر؛ لذت ببرید برای ساخت پک به @Stickers مراجعه کنید') set_text(LANG, 'u_sticker', 'این هم استیکر شما و تصویر با فرمت ویژه (png) برای ساخت پکیج استیکر؛ لذت ببرید برای ساخت پک به @Stickers مراجعه کنید') -- settings.lua -- set_text(LANG, 'user', 'کاربر') set_text(LANG, 'isFlooding', 'درحال اسپم کردن است.') set_text(LANG, 'noStickersT', 'استفاده از استیکر در این گروه ممنوع میباشد.') set_text(LANG, 'noStickersL', 'استفاده از استیکر در این سوپر گروه ممنوع میباشد.') set_text(LANG, 'stickersT', 'استفاده از استیکر در این گروه آزاد است.') set_text(LANG, 'stickersL', 'استفاده از استیکر در این سوپر گروه آزاد است.') set_text(LANG, 'LinksT', 'استفاده از لینک در این گروه ممنوع میباشد.') set_text(LANG, 'LinksL', 'استفاده از لینک در این سوپر گروه ممنوع میباشد.') set_text(LANG, 'noLinksT', 'استفاده از لینک در این گروه آزاد است.') set_text(LANG, 'noLinksL', 'استفاده از لینک در این سوپر گروه آزاد است.') set_text(LANG, 'noGiftT', 'استفاده از عکس متحرک در این گروه ممنوع میباشد.') set_text(LANG, 'noGiftL', 'استفاده از عکس متحرک در این سوپر گروه ممنوع میباشد.') set_text(LANG, 'GiftT','استفاده از عکس متحرک در این گروه آزاد است.') set_text(LANG, 'GiftL', 'استفاده از عکس متحرک در این سوپر گروه آزاد است.') set_text(LANG, 'photosT', 'ارسال عکس در این گروه آزاد میباشد.') set_text(LANG, 'photosL', 'ارسال عکس در این سوپر گروه آزاد میباشد.') set_text(LANG, 'noPhotos،', 'استفاده از عکس در این گروه ممنوع میباشد.') set_text(LANG, 'noPhotosL', 'استفاده از عکس در این سوپر گروه ممنوع میباشد.') set_text(LANG, 'botsT', 'ربات در این گروه آزاد میباشد.') set_text(LANG, 'botsL', 'ربات در این سوپر گروه آزاد میباشد.') set_text(LANG, 'noBotsT', 'ربات در این گروه ممنوع میباشد.') set_text(LANG, 'noBotsL', 'ربات در این سوپر گروه ممنوع میباشد.') set_text(LANG, 'noArabicT', 'در این گروه شما نمیتوانید با زبان هایی مانند عربی و... صحبت کنید.') set_text(LANG, 'noArabicL', 'در این سوپر گروه شما نمیتوانید با زبان هایی مانند عربی و... صحبت کنید.') set_text(LANG, 'ArabicT', 'استفاده از زبان هایی مانند عربی و... در این گروه آزاد است.') set_text(LANG, 'ArabicL', 'استفاده از زبان هایی مانند عربی و... در این سوپر گروه آزاد است.') set_text(LANG, 'audiosT', 'ارسال فایل صوتی به این گروه آزاد است.') set_text(LANG, 'audiosL', 'ارسال فایل صوتی به این سوپر گروه آزاد است.') set_text(LANG, 'noAudiosT', 'ارسال فایل صوتی در این گروه ممنوع میباشد.') set_text(LANG, 'noAudiosL', 'ارسال فایل صوتی در این سوپر گروه ممنوع میباشد.') set_text(LANG, 'kickmeT', 'استفاده از دستور kickme در این گروه آزاد است.') set_text(LANG, 'kickmeL', 'استفاده از دستور kickme در این سوپر گروه آزاد است.') set_text(LANG, 'noKickmeT', 'شما نمیتوانید از این دستور در این گروه استفاده کنید.') set_text(LANG, 'noKickmeL', 'شما نمیتوانید از این دستور در این سوپر گروه استفاده کنید.') set_text(LANG, 'floodT', 'اسپمینگ در این گروه محافظت نمیشود.') set_text(LANG, 'floodL', 'اسپمینگ در این سوپر گروه محافظت نمیشود.') set_text(LANG, 'noFloodT', 'شما اجازه اسپم در این گروه را ندارید.') set_text(LANG, 'noFloodL', 'شما اجازه اسپم در این سوپر گروه را ندارید.') set_text(LANG, 'floodTime', 'زمان برسی فلودینگ در این چت تنظیم شد به هر : ') set_text(LANG, 'floodMax', 'حداکثر حساسیت سیستم آنتی فلود تنظیم شد به : ') set_text(LANG, 'gSettings', 'تنظیمات گروه') set_text(LANG, 'sSettings', 'تنظیمات سوپرگروه') set_text(LANG, 'allowed', 'امکان پذیر') set_text(LANG, 'noAllowed', 'ممنوع') set_text(LANG, 'noSet', 'تنظیم نشده است') set_text(LANG, 'flood', 'اسپم') set_text(LANG, 'badwords', 'استفاده از کلمات فیلتر') set_text(LANG, 'porns', 'استفاده از تصاویر مستهجن') set_text(LANG, 'spam', 'تبلیغات') set_text(LANG, 'arabic', 'استفاده از حروف زبان عربی و فارسی') set_text(LANG, 'bots', 'آوردن ربات به چت') set_text(LANG, 'stickers', 'ارسال استیکر') set_text(LANG, 'gifs', 'ارسال عکس متحرک') set_text(LANG, 'photos', 'ارسال عکس') set_text(LANG, 'audios', 'ارسال فایل صوتی') set_text(LANG, 'contacts', 'به اشتراک گذاشتن شماره') set_text(LANG, 'gName', 'تغییر نام گروه') set_text(LANG, 'glockmember', 'افزودن عضو جدید') set_text(LANG, 'language', 'زبان') set_text(LANG, 'mFlood', 'حداکثر حساسیت فلود') set_text(LANG, 'tFlood', 'زمان برسی فلودینگ') set_text(LANG, 'setphoto', 'تنظیم عکس گروه') set_text(LANG, 'photoSaved', 'عکس با موفقیت ذخیره شد.') set_text(LANG, 'photoFailed', 'عملیات ناموفق بود، دوباره سعی کنید!') set_text(LANG, 'setPhotoAborted', 'متوقف کردن عملیات تنظیم عکس...') set_text(LANG, 'sendPhoto', 'لطفا عکسی را ارسال کنید.') set_text(LANG, 'chatSetphoto', 'میتوانید عکس گروه را تغییر دهید.') set_text(LANG, 'channelSetphoto', 'میتوانید عکس سوپر گروه را تغییر دهید.') set_text(LANG, 'notChatSetphoto', 'دیگر نمی توان عکس گروه را تغییر داد.') set_text(LANG, 'notChannelSetphoto', 'دیگر نمی توان عکس سوپر گروه را تغییر داد.') set_text(LANG, 'setPhotoError', 'لطفا در تنظیمات این امکان را فعال کنید؛ تابتوانید عکس گروه/سوپرگروه را تغییر دهید.') set_text(LANG, 'linkSaved', 'لینک جدید با موفقیت ذخیره شد') set_text(LANG, 'groupLink', 'لینک گروه :') set_text(LANG, 'sGroupLink', 'لینک سوپرگروه :') set_text(LANG, 'noLinkSet', 'هیچ لینکی تنظیم نشده است. لطفا با دستور #newlink لینک جدیدی بسازید.') set_text(LANG, 'chatRename', 'میتوانید اسم گروه را تغییر دهید') set_text(LANG, 'channelRename', 'میتوانید اسم سوپر گروه را تغییر دهید') set_text(LANG, 'notChatRename', 'دیگر نمی توان نام گروه را تغییر داد.') set_text(LANG, 'notChannelRename', 'دیگر نمی توان نام سوپر گروه را تغییر داد.') set_text(LANG, 'lockMembersT', 'تعداد اعضا در این چت قفل شده است.') set_text(LANG, 'lockMembersL', 'تعداد اعضا در این سوپر گروه قفل شده است.') set_text(LANG, 'notLockMembersT', 'قفل تعداد اعضا در این چت باز شد.') set_text(LANG, 'notLockMembersL', 'قفل تعداد اعضا در این سوپر گروه باز شد.') set_text(LANG, 'langUpdated', 'زبان شما به فارسی تغییر کرد.') set_text(LANG, 'chatUpgrade', 'این گروه با موفقیت به سوپر گروه ارتقا یافت.') set_text(LANG, 'notInChann', 'شما نمیتوانید آن را در یک سوپر گروه انجام دهید') set_text(LANG, 'desChanged', 'شرح سوپر گروه با موفقیت تغییر یافت.') set_text(LANG, 'desOnlyChannels', 'تغییر شرح تنها در سوپر گروه ممکن است.') set_text(LANG, 'muteAll', 'توانایی صحبت از همه گرفته شد.') set_text(LANG, 'unmuteAll', 'توانایی صحبت به همه بازپس داده شد.') set_text(LANG, 'muteAllX:1', 'شما نمی توانید به مدت') set_text(LANG, 'muteAllX:2', 'ثانیه در این سوپر گروه چت کنید..') set_text(LANG, 'createGroup:1', 'گروه') set_text(LANG, 'createGroup:2', 'ساخته شد.') set_text(LANG, 'newGroupWelcome', 'به گروه جدیدتان خوش امدید!') -- export_gban.lua -- set_text(LANG, 'accountsGban', 'اکانت مورد نظر به صورت جهانی مسدود شد') -- giverank.lua -- set_text(LANG, 'alreadyAdmin', 'این شخص درحال حاضر ادمین است.') set_text(LANG, 'alreadyMod', 'این شخص درحال حاضر مدیر است.') set_text(LANG, 'newAdmin', 'ادمین جدید') set_text(LANG, 'newMod', 'مدیر جدید') set_text(LANG, 'nowUser', 'از حالا یک کاربر معمولی است.') set_text(LANG, 'modList', 'لیست مدیران') set_text(LANG, 'chatow', 'صاحب چت') set_text(LANG, 'memberList', 'لیست اعضا') set_text(LANG, 'adminList', 'لیست ادمین') set_text(LANG, 'modEmpty', 'این چت هیچ مدیری ندارد.') set_text(LANG, 'adminEmpty', 'درحال حاضر هیچ کسی ادمین نیست.') -- chatlist.lua -- set_text(LANG, 'chatList', 'لیست گروه ها و سوپر گروه ها') set_text(LANG, 'joinchatHelp', 'برای ورود به یکی از گروه ها یا سوپر گروه ها از join id#استفاده کنید.') set_text(LANG, 'chatEmpty', 'درحال حاضر هیچ گروه/سوپر گروهی موجود نیست.') -- join.lua set_text(LANG, 'chatExist', 'شما با موفقیت به گروه/سوپرگروه مورد نظر اضافه شدید.') set_text(LANG, 'notchatExist', 'هیچ گروه/سوپرگروهی با این اطلاعات پیدا نشد.') set_text(LANG, 'notaddExist', 'مشکلی برای ورود به گروه/سوپرگروه مورد نظر به وجود آمد.') -- id.lua -- set_text(LANG, 'user', 'آیدی کاربر') set_text(LANG, 'uuser', 'آیدی شما') set_text(LANG, 'supergroupName', 'نام سوپرگروه') set_text(LANG, 'chatName', 'نام گروه') set_text(LANG, 'supergroup', 'آیدی سوپرگروه') set_text(LANG, 'chat', 'آیدی گروه') set_text(LANG, 'usernotfound', 'این نام کاربری وجود ندارد.') set_text(LANG, 'userfirstname', 'نام') set_text(LANG, 'userlastname', 'نام خانوادگی') set_text(LANG, 'userusername', 'نام کاربری') set_text(LANG, 'userphone', 'شماره تلفن') set_text(LANG, 'useroprator', 'اپراتور موبایل') set_text(LANG, 'userrank', 'مقام') set_text(LANG, 'usermsgs', 'تعداد کل پیام های کاربر با این ربات') set_text(LANG, 'userchatmsgs', 'تعداد پیام های کاربر در این چت از لحظه عضویت ربات') set_text(LANG, 'ownerName', 'نام صاحب چت') set_text(LANG, 'ownerId', 'آیدی صاحب چت') set_text(LANG, 'ownerUsername', 'نام کاربری صاحب چت') set_text(LANG, 'memberCount', 'تعداد اعضای چت') set_text(LANG, 'modCount', 'تعداد مدیران چت') set_text(LANG, 'chatCount', 'تعداد کل پیام های فرستاده شده در چت از لحظه ورود ربات') -- moderation.lua -- set_text(LANG, 'userUnmuted:1', 'کاربر') set_text(LANG, 'userUnmuted:2', 'توانایی چت کردن را دوباره بدست آورد.') set_text(LANG, 'userMuted:1', 'کاربر') set_text(LANG, 'userMuted:2', 'توانایی چت کردن را از دست داد.') set_text(LANG, 'kickUser:1', 'کاربر') set_text(LANG, 'kickUser:2', 'اخراج شد.') set_text(LANG, 'banUser:1', 'کاربر') set_text(LANG, 'banUser:2', 'مسدود شد.') set_text(LANG, 'unbanUser:1', 'کاربر') set_text(LANG, 'unbanUser:2', 'از حالت مسدود خارج شد.') set_text(LANG, 'gbanUser:1', 'کاربر') set_text(LANG, 'gbanUser:2', 'به صورت جهانی مسدود شد.') set_text(LANG, 'ungbanUser:1', 'کاربر') set_text(LANG, 'ungbanUser:2', 'از حالت مسدود جهانی خارج شد.') set_text(LANG, 'addUser:1', 'کاربر') set_text(LANG, 'addUser:2', 'به گروه اضافه شد.') set_text(LANG, 'addUser:3', 'به سوپر گروه اضافه شد') set_text(LANG, 'kickmeBye', 'خداحافظ') -- plugins.lua -- set_text(LANG, 'plugins', 'پلاگین ها') set_text(LANG, 'installedPlugins', 'پلاگین های نصب شده.') set_text(LANG, 'pEnabled', 'فعال.') set_text(LANG, 'pDisabled', 'غیرفعال.') set_text(LANG, 'isEnabled:1', 'پلاگین') set_text(LANG, 'isEnabled:2', 'فعال است.') set_text(LANG, 'notExist:1', 'پلاگین') set_text(LANG, 'notExist:2', 'وجود ندارد.') set_text(LANG, 'notEnabled:1', 'پلاگین') set_text(LANG, 'notEnabled:2', 'فعال نیست.') set_text(LANG, 'pNotExists', 'این پلاگین وجود ندارد.') set_text(LANG, 'pDisChat:1', 'پلاگین') set_text(LANG, 'pDisChat:2', 'در این گروه غیرفعال است.') set_text(LANG, 'anyDisPlugin', 'هیچ پلاگینی غیرفعال نیست.') set_text(LANG, 'anyDisPluginChat', 'هیچ پلاگینی در این گروه فعال نیست') set_text(LANG, 'notDisabled', 'این پلاگین غیرفعال نیست.') set_text(LANG, 'enabledAgain:1', 'پلاگین') set_text(LANG, 'enabledAgain:2', 'دوباره فعال شد.') -- commands.lua -- set_text(LANG, 'commandsT', 'دستورات') set_text(LANG, 'errorNoPlug', 'این پلاگین وجود ندارد و یا فعال نیست.') -- rules.lua -- set_text(LANG, 'setRules', 'قوانین گروه/سوپر گروه بروز شد.') set_text(LANG, 'remRules', 'قوانین گروه/سوپر گروه حذف شد.') set_text(LANG, 'wmsg', 'متن خوش آمد گویی گروه/سوپر گروه بروز شد.') set_text(LANG, 'rwmsg', 'متن خوش آمد گویی گروه/سوپر گروه حذف شد.') set_text(LANG, 'wmsgh', 'شما میتوانید از TNAME , TUSERNAME , TGPNAME به ترتیب برای نشان دادن نام کاربر ، نام کاربری کاربر و نام چت استفاده نمایید.') ------------ -- Usages -- ------------ set_text(LANG, 'thelp', '💢راهنمای ربات ضد اسپم و فان تیاگو♨️\n🔹🔸🔹🔸🔹🔸🔹🔸🔹🔸🔹🔸\n\n🔺#help⚠️:راهنمایی کلی ربات\n\n🔺#cmds🆑:دستورات عضو عادی\n\n🔺#sudocmds🔱🆑:دستورات سودو\n\n🔺#admincmds⚜🆑:دستورات ادمین\n\n🔺#modcmds✴️🆑:دستورات مدیران گروه\n\n🔺#funcmds😜🆑:دستورات فان\n\n🔹🔸🔹🔸🔹🔸🔹🔸🔹🔸🔹🔸\nℹ️ شما میتوانید از علامت های ! و / و # در ابتدای دستورات استفاده نمایید') set_text(LANG, 'tfuncmds','🆑دستورات فان#⃣\n🔹🔸🔹🔸🔹🔸🔹🔸🔹🔸🔹🔸\n\n🔺#remind <0h0m> <text>📢:یاداوری به شما بعد زمان مشخصی\n🔘مثال:\n#remind 2h34m تست\nℹ️یاد اوری بعد دوساعت و 34 دقیقه (با حد اکثر خطای 5 دقیقه ای)\n\n🔺#c <text>💬:برای چت کردن با ربات\n\n🔺#weather <city>⛅️: نشان دادن اب و هوای شهر مورد نظر \n\n🔺#calc <mathtext>📟:محاسبه عملیات ریاضی\n\n🔺#praytime <city>🕌: نشان دادن اوقات شرعی شهر مورد نظر\n\n🔺#wiki<lang:en,es,...،def=fa><word>📑: گرفتن اطلاعات از ویکی پدیا\n\n🔺#google <word>🔎: جستجور در گوگل\n\n🔺#insta <username>📸: گرفتن اطلاعات از اینستاگرام\n\n🔺#clash<m,empty> <clantag>🔰: گرفتن اعضای کلن/گرفتن اطلاعات کلن\n\n🔺#tosticker🔳: تبدیل عکس به استیکر\n\n🔺#tophoto🔄: تبدیل استیکر به عکس\n\n🔺#joke😂: فرستادن جک تصادفی\n\n🔺#knowℹ: فرستادن دانستنی تصادفی\n\n🔹🔸🔹🔸🔹🔸🔹🔸🔹🔸\nℹ️ شما میتوانید از علامت های ! و / و # در ابتدای دستورات استفاده نمایید') set_text(LANG, 'tadmincmds', '🆑دستورات ادمین#⃣\n🔹🔸🔹🔸🔹🔸🔹🔸🔹🔸🔹🔸\n\n🔺#rank owner(reply,id,username)🌟:تنظیم صاحب چت فعلی\n\n🔺#rank mod(reply,id,username)⭐️:برای تنظیم مدیر چت فعلی\n\n🔺#rank member(reply,id,username)💫:گرفتن مقام\n\n🔺#gban(reply,id,username)📛:محروم کردن کاربر از ربات به صورت جهانی\n\n🔺#ungban(reply,id,username)♨️: رفع محرومیت جهانی کاربر\n\n🔺#gbans🃏:لیست افراد محروم جهانی\n\n🔺#addchat✅:افزودن چت فعلی به چت های مدیریت شده ربات\n\n🔺#remchat ❌: حذف چت فعلی از چت های مدیریت شده ربات\n‼️:توجه شود که اگر در سوپرگروهی که ربات سازنده ان است استفاده شود ربات از سوپرگروه خارج نمی شود و صرفا در آن چت غیر فعال میشود.\n\n🔺#creategroup <name>🆕:ساخت گروه با نام دلخواه شما\n\n🔹🔸🔹🔸🔹🔸🔹🔸🔹🔸\nℹ️ شما میتوانید از علامت های ! و / و # در ابتدای دستورات استفاده نمایید ') set_text(LANG, 'tcmds', '🆑دستورات عضو عادی#⃣\n🔹🔸🔹🔸🔹🔸🔹🔸🔹🔸🔹🔸\n\n🔺#sudos🔱: لیست سودوهای ربات\n\n🔺#admins⚜: لیست ادمین های روبات\n\n🔺#mods✴: لیست مدیران چت\n\n🔺#members👥: لیست اعضای چت\n\n🔺#id (reply/username)🆔: گرفتن آیدی\n\n🔺#info (reply/username)ℹ: گرفتن اطلاعات\n\n🔺#kickme🏮: اخراج موقت شما\n\n🔺#version❓: نسخه ربات\n\n🔺#rules🔣: قوانین گروه\n\n🔹🔸🔹🔸🔹🔸🔹🔸🔹🔸\nℹ️ شما میتوانید از علامت های ! و / و # در ابتدای دستورات استفاده نمایید\n\n@offlineteam') if matches[1] == 'install' then return 'ℹ️ فارسی شد.' elseif matches[1] == 'update' then return 'ℹ️ فارسی شد.' end else return "🚫 برای شما مجاز نیست." end end return { patterns = { '#(install) (persian_lang)$', '#(update) (persian_lang)$' }, run = run }
gpl-2.0
jshackley/darkstar
scripts/zones/Port_Windurst/npcs/Ada.lua
38
1030
----------------------------------- -- Area: Port Windurst -- NPC: Ada -- Type: Standard NPC -- @zone: 240 -- @pos -79.803 -6.75 168.652 -- -- Auto-Script: Requires Verification (Verfied by Brawndo) ----------------------------------- package.loaded["scripts/zones/Port_Windurst/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x002c); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
gpl-3.0
jshackley/darkstar
scripts/globals/mobskills/Mangle.lua
4
1103
--------------------------------------------- -- Mangle -- Family: Qutrub -- Description: Deals damage in a threefold attack to targets in a fan-shaped area of effect. -- Type: Physical -- Utsusemi/Blink absorb: 3 shadows -- Range: Front cone -- Notes: Used only when wielding their initial sword, or the dagger on their backs. --------------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/monstertpmoves"); --------------------------------------------- function onMobSkillCheck(target,mob,skill) if (mob:AnimationSub() == 0 or mob:AnimationSub() == 2) then return 0; else return 1; end end; function onMobWeaponSkill(target, mob, skill) local numhits = 3; local accmod = 1; local dmgmod = .8; local info = MobPhysicalMove(mob,target,skill,numhits,accmod,dmgmod,TP_NO_EFFECT); local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_PHYSICAL,MOBPARAM_SLASH,info.hitslanded); target:delHP(dmg); return dmg; end;
gpl-3.0
jshackley/darkstar
scripts/zones/Temenos/mobs/Enhanced_Slime.lua
1
1050
----------------------------------- -- Area: Temenos W T -- NPC: Enhanced_Slime ----------------------------------- package.loaded["scripts/zones/Temenos/TextIDs"] = nil; ----------------------------------- require("scripts/globals/limbus"); require("scripts/zones/Temenos/TextIDs"); ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) end; ----------------------------------- -- onMobEngaged ----------------------------------- function onMobEngaged(mob,target) end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob,killer,ally) local cofferID=Randomcoffer(5,GetInstanceRegion(1298)); local mobX = mob:getXPos(); local mobY = mob:getYPos(); local mobZ = mob:getZPos(); GetNPCByID(16929239):setStatus(STATUS_NORMAL); if (cofferID~=0) then GetNPCByID(16928768+cofferID):setPos(mobX,mobY,mobZ); GetNPCByID(16928768+cofferID):setStatus(STATUS_NORMAL); end end;
gpl-3.0
jshackley/darkstar
scripts/zones/Carpenters_Landing/npcs/Guilloud.lua
19
1380
----------------------------------- -- Area: Carpenters' Landing -- NPC: Guilloud -- Type: Standard NPC -- @pos -123.770 -6.654 -469.062 2 ----------------------------------- package.loaded["scripts/zones/Carpenters_Landing/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:getCurrentMission(COP) == THE_ROAD_FORKS and player:getVar("EMERALD_WATERS_Status") == 4) then SpawnMob(16785709,180):updateClaim(player); elseif (player:getCurrentMission(COP) == THE_ROAD_FORKS and player:getVar("EMERALD_WATERS_Status") == 5) then player:startEvent(0x0000); else player:startEvent(0x0001); 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 == 0x0000) then player:setVar("EMERALD_WATERS_Status",6); end end;
gpl-3.0
jshackley/darkstar
scripts/zones/Alzadaal_Undersea_Ruins/Zone.lua
21
6100
----------------------------------- -- -- Zone: Alzadaal_Undersea_Ruins (72) -- ----------------------------------- package.loaded["scripts/zones/Alzadaal_Undersea_Ruins/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/zones/Alzadaal_Undersea_Ruins/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) zone:registerRegion(1, -329, -2, 483,-323, 0, 489); -- map 1 SE porter zone:registerRegion(2, -477, -2, 631,-471, 0, 636); -- map 1 NW porter zone:registerRegion(3, 110, -2,-556, 116, 0,-551); -- map 2 west porter (white) zone:registerRegion(4, 30, -2, 750, 36, 0, 757); -- map 3 west porter (blue) zone:registerRegion(5, 83, -2, 750, 90, 0, 757); -- map 3 east porter (white) zone:registerRegion(6, -329, -2, 150,-323, 0, 156); -- map 4 porter (white) zone:registerRegion(7, -208, -2,-556,-202, 0,-551); -- map 5 porter (white) zone:registerRegion(8, 323, -2, 591, 329, 0, 598); -- map 6 east porter (white) zone:registerRegion(9, 270, -2, 591, 276, 0, 598); -- map 6 west porter (blue) zone:registerRegion(10, 442, -2,-557, 450, 0,-550); -- map 7 porter (white) zone:registerRegion(11, -63,-10, 56, -57,-8, 62); -- map 8 NW/Arrapago porter zone:registerRegion(12, 17, -6, 56, 23,-4, 62); -- map 8 NE/Silver Sea/Khim porter zone:registerRegion(13, -63,-10, -23, -57,-8, -16); -- map 8 SW/Zhayolm/bird camp porter zone:registerRegion(14, 17, -6, -23, 23,-4, -16); -- map 8 SE/Bhaflau Porter zone:registerRegion(15,-556, -2, -77,-550, 0, -71); -- map 9 east porter (white) zone:registerRegion(16,-609, -2, -77,-603, 0, -71); -- map 9 west porter (blue) zone:registerRegion(17, 643, -2,-289, 649, 0,-283); -- map 10 east porter (blue) zone:registerRegion(18, 590, -2,-289, 597, 0,-283); -- map 10 west porter (white) zone:registerRegion(19, 603, -2, 522, 610, 0, 529); -- map 11 east porter (blue) zone:registerRegion(20, 550, -2, 522, 557, 0, 529); -- map 11 west porter (white) zone:registerRegion(21,-556, -2,-489,-550, 0,-483); -- map 12 east porter (white) zone:registerRegion(22,-610, -2,-489,-603, 0,-483); -- map 12 west porter (blue) zone:registerRegion(23,382, -1,-582,399, 1,-572); --mission 9 TOAU end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) local cs = -1; if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then player:setPos(222.798, -0.5, 19.872, 0); end return cs; end; ----------------------------------- -- afterZoneIn ----------------------------------- function afterZoneIn(player) player:entityVisualPacket("1pa1"); player:entityVisualPacket("1pb1"); player:entityVisualPacket("2pb1"); end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) switch (region:GetRegionID()): caseof { [1] = function (x) player:startEvent(0x00CC); end, [2] = function (x) player:startEvent(0x00CD); end, [3] = function (x) player:startEvent(0x00C9); end, [4] = function (x) player:startEvent(0x00CB); end, [5] = function (x) player:startEvent(0x00CA); end, [6] = function (x) player:startEvent(0x00CE); end, [7] = function (x) player:startEvent(0x00D3); end, [8] = function (x) player:startEvent(0x00C8); end, [9] = function (x) player:startEvent(0x00C9); end, [10] = function (x) player:startEvent(0x00D5); end, [11] = function (x) player:startEvent(0x00DA); end, [12] = function (x) player:startEvent(0x00DD); end, [13] = function (x) player:startEvent(0x00DB); end, [14] = function (x) player:startEvent(0x00DC); end, [15] = function (x) player:startEvent(0x00CF); end, [16] = function (x) player:startEvent(0x00D0); end, [17] = function (x) player:startEvent(0x00D6); end, [18] = function (x) player:startEvent(0x00CF); end, [19] = function (x) player:startEvent(0x00CA); end, [20] = function (x) player:startEvent(0x00CF); end, [21] = function (x) player:startEvent(0x00CF); end, [22] = function (x) player:startEvent(0x00D2); end, [23] = function (x) if (player:getCurrentMission(TOAU) == UNDERSEA_SCOUTING and player:getVar("TOAUM9") ==0) then player:startEvent(0x0001); end end, } end; ----------------------------------- -- onRegionLeave ----------------------------------- function onRegionLeave(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) printf("CSID: %u",csid); printf("RESULT: %u",option); if (csid == 0x0001 and option == 10) then player:updateEvent(1,0,0,0,0,0,0); elseif (csid == 0x0001 and option == 2) then player:updateEvent(3,0,0,0,0,0,0); elseif (csid == 0x0001 and option == 3) then player:updateEvent(7,0,0,0,0,0,0); end end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) printf("CSID: %u",csid); printf("RESULT: %u",option); if (csid ==0x0001) then player:addKeyItem(ASTRAL_COMPASS); player:messageSpecial(KEYITEM_OBTAINED,ASTRAL_COMPASS); player:setVar("TOAUM9",0); player:completeMission(TOAU,UNDERSEA_SCOUTING); player:addMission(TOAU,ASTRAL_WAVES); end end;
gpl-3.0
jshackley/darkstar
scripts/zones/Aht_Urhgan_Whitegate/npcs/Dkhaaya.lua
17
2387
----------------------------------- -- Area: Aht Urhgan Whitegate -- NPC: Dkhaaya -- Type: Standard NPC -- @pos -73.212 -1 -5.842 50 ----------------------------------- package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil; ----------------------------------- require("scripts/globals/keyitems"); require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs"); require("scripts/globals/quests"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local olduumQuest = player:getQuestStatus(AHT_URHGAN, OLDUUM); local ringCheck = player:hasItem(2217); if (olduumQuest == QUEST_AVAILABLE) then player:startEvent(0x004); elseif (player:hasKeyItem(ELECTROLOCOMOTIVE) or player:hasKeyItem(ELECTROPOT) or player:hasKeyItem(ELECTROCELL) and ringCheck == false) then if (olduumQuest == QUEST_ACCEPTED) then player:startEvent(0x006); else player:startEvent(0x008); end elseif (olduumQuest ~= QUEST_AVAILABLE and ringCheck == false) then player:startEvent(0x005); else player:startEvent(0x007); 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 == 0x004) then player:addKeyItem(DKHAAYAS_RESEARCH_JOURNAL); player:messageSpecial(KEYITEM_OBTAINED, DKHAAYAS_RESEARCH_JOURNAL); player:addQuest(AHT_URHGAN, OLDUUM); elseif (csid == 0x006 or csid == 0x008) then if (player:getFreeSlotsCount() >= 1) then player:addItem(2217); player:messageSpecial(ITEM_OBTAINED, 2217); player:delKeyItem(DKHAAYAS_RESEARCH_JOURNAL); player:delKeyItem(ELECTROLOCOMOTIVE); player:delKeyItem(ELECTROPOT); player:delKeyItem(ELECTROCELL); if (csid == 0x006) then player:completeQuest(AHT_URHGAN, OLDUUM); end else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED, 2217); end end end;
gpl-3.0
elbamos/nn
CMulTable.lua
22
1350
local CMulTable, parent = torch.class('nn.CMulTable', 'nn.Module') function CMulTable:__init() parent.__init(self) self.gradInput = {} end function CMulTable:updateOutput(input) self.output:resizeAs(input[1]):copy(input[1]) for i=2,#input do self.output:cmul(input[i]) end return self.output end function CMulTable:updateGradInput_efficient(input, gradOutput) self.tout = self.tout or input[1].new() self.tout:resizeAs(self.output) for i=1,#input do self.gradInput[i] = self.gradInput[i] or input[1].new() self.gradInput[i]:resizeAs(input[i]):copy(gradOutput) self.tout:copy(self.output):cdiv(input[i]) self.gradInput[i]:cmul(self.tout) end for i=#input+1, #self.gradInput do self.gradInput[i] = nil end return self.gradInput end function CMulTable:updateGradInput(input, gradOutput) for i=1,#input do self.gradInput[i] = self.gradInput[i] or input[1].new() self.gradInput[i]:resizeAs(input[i]):copy(gradOutput) for j=1,#input do if i~=j then self.gradInput[i]:cmul(input[j]) end end end for i=#input+1, #self.gradInput do self.gradInput[i] = nil end return self.gradInput end function CMulTable:clearState() if self.tout then self.tout:set() end return parent.clearState(self) end
bsd-3-clause
jshackley/darkstar
scripts/globals/mobskills/Nocturnal_Combustion.lua
4
1120
--------------------------------------------- -- Nocturnal Combustion -- -- Description: Self-destructs, releasing dark energy at nearby targets. -- Type: Magical -- Utsusemi/Blink absorb: Ignores shadows -- Range: 20' radial -- Notes: Damage is based on remaining HP and time of day (more damaging near midnight). The djinn will not use this until it has been affected by the current day's element. --------------------------------------------- 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 dmgmod = 1; local BOMB_TOSS_HPP = skill:getHPP() / 100; local info = MobMagicalMove(mob,target,skill,mob:getWeaponDmg()*20*BOMB_TOSS_HPP,ELE_DARK,dmgmod,TP_MAB_BONUS,1); local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_MAGICAL,MOBPARAM_DARK,MOBPARAM_IGNORE_SHADOWS); mob:setHP(0); target:delHP(dmg); return dmg; end;
gpl-3.0
10sa/Advanced-Nutscript
nutscript/plugins/improveddoors/cl_plugin.lua
1
6047
local PLUGIN = PLUGIN; function PLUGIN:DrawDoor(entity, eyePos) local posData = self:GetDoorDrawPosition(entity); if (self:IsDoor(entity) and !posData.hitWorld) then if (entity:GetNetVar("hidden")) then return; end; local alpha = self:GetAlphaFromDistance(256, eyePos, entity:GetPos()) if(alpha <= 0 or entity:IsEffectActive(EF_NODRAW)) then return end; local owner = entity:GetNetVar("owner"); local title = entity:GetNetVar("title", PLUGIN:GetPluginLanguage("doors_can_buy")); local desc = PLUGIN:GetPluginLanguage("doors_buy_desc"); local lastY = -30; local panelAlpha = math.min(alpha + 10, 200); local textAlpha = math.min(alpha + 50, 255); local doorDesc = entity:GetNetVar("desc"); if (doorDesc) then desc = doorDesc; else if (entity:GetNetVar("unownable")) then title = entity:GetNetVar("title") or PLUGIN:GetPluginLanguage("doors_cant_buy"); desc = entity:GetNetVar("desc") or PLUGIN:GetPluginLanguage("doors_cant_buy"); end end; local titleWidth, titleHeight = AdvNut.util.GetTextSize("AdvNut_3D2DTitleFont", title or ""); local descWidth, descHeight = AdvNut.util.GetTextSize("AdvNut_3D2DDescFont", desc or ""); local largeWidth = titleWidth; if (descWidth > largeWidth) then largeWidth = descWidth; end; local scale = math.abs((posData.width * 0.75) / largeWidth); local titleScale = math.min(scale, 0.05); local descScale = math.min(scale, 0.03); local longHeight = (titleHeight + descHeight + 10) * 1.5 cam.Start3D2D(posData.forwardPos, posData.forwardAngle, titleScale) AdvNut.util.DrawCenterGradient(-(largeWidth / 2) - 128, lastY - longHeight * 0.25, largeWidth + 256, longHeight, Color(100, 100, 100, panelAlpha)); nut.util.DrawText(0, lastY, title, Color(120, 120, 120, textAlpha), "AdvNut_3D2DTitleFont"); nut.util.DrawText(0, lastY + descHeight + 8, desc, Color(120, 120, 120, textAlpha), "AdvNut_3D2DDescFont"); cam.End3D2D(); cam.Start3D2D(posData.backPos, posData.backAngle, titleScale) AdvNut.util.DrawCenterGradient(-(largeWidth / 2) - 128, lastY - longHeight * 0.25, largeWidth + 256, longHeight, Color(100, 100, 100, panelAlpha)); nut.util.DrawText(0, lastY, title, Color(120, 120, 120, textAlpha), "AdvNut_3D2DTitleFont"); nut.util.DrawText(0, lastY + descHeight + 8, desc, Color(120, 120, 120, textAlpha), "AdvNut_3D2DDescFont"); cam.End3D2D(); end end function PLUGIN:GetDoorDrawPosition(door, reversed) local traceData = {}; local obbCenter = door:OBBCenter(); local obbMaxs = door:OBBMaxs(); local obbMins = door:OBBMins(); traceData.endpos = door:LocalToWorld(obbCenter); traceData.filter = ents.FindInSphere(traceData.endpos, 20); for k, v in pairs(traceData.filter) do if (v == door) then traceData.filter[k] = nil; end; end; local length = 0; local width = 0; local size = obbMins - obbMaxs; size.x = math.abs(size.x); size.y = math.abs(size.y); size.z = math.abs(size.z); if (size.z < size.x and size.z < size.y) then length = size.z; width = size.y; if (reverse) then traceData.start = traceData.endpos - (door:GetUp() * length); else traceData.start = traceData.endpos + (door:GetUp() * length); end; elseif (size.x < size.y) then length = size.x; width = size.y; if (reverse) then traceData.start = traceData.endpos - (door:GetForward() * length); else traceData.start = traceData.endpos + (door:GetForward() * length); end; elseif (size.y < size.x) then length = size.y; width = size.x; if (reverse) then traceData.start = traceData.endpos - (door:GetRight() * length); else traceData.start = traceData.endpos + (door:GetRight() * length); end; end; local trace = util.TraceLine(traceData); local forwardAngle = trace.HitNormal:Angle(); if (trace.HitWorld and !reversed) then return self:GetDoorDrawPosition(door, true); end; forwardAngle:RotateAroundAxis(forwardAngle:Forward(), 90); forwardAngle:RotateAroundAxis(forwardAngle:Right(), 90); local forwardPos = trace.HitPos - (((traceData.endpos - trace.HitPos):Length() * 2) + 2) * trace.HitNormal; local backAngle = trace.HitNormal:Angle(); local backPos = trace.HitPos + (trace.HitNormal * 2); backAngle:RotateAroundAxis(backAngle:Forward(), 90); backAngle:RotateAroundAxis(backAngle:Right(), -90); return { backPos = backPos, backAngle = backAngle, forwardPos = forwardPos, hitWorld = trace.HitWorld, forwardAngle = forwardAngle, width = math.abs(width) }; end; function PLUGIN:PostDrawTranslucentRenderables(drawingDepth, drawingSkybox) local eyeAngles = EyeAngles(); local eyePos = EyePos(); cam.Start3D(eyePos, eyeAngles); local entities = ents.FindInSphere(eyePos, 256); for k, v in pairs(entities) do if (IsValid(v) and self:IsDoor(v)) then self:DrawDoor(v, eyePos); end; end; cam.End3D(); end; function PLUGIN:GetAlphaFromDistance(maximum, start, finish) if (type(start) == "Player") then start = start:GetShootPos(); elseif (type(start) == "Entity") then start = start:GetPos(); end; if (type(finish) == "Player") then finish = finish:GetShootPos(); elseif (type(finish) == "Entity") then finish = finish:GetPos(); end; return math.Clamp(255 - ((255 / maximum) * (start:Distance(finish))), 0, 255); end; function PLUGIN:PlayerBindPress(bind, pressed) if (bind == "gm_showteam") then local client = LocalPlayer(); local entity = AdvNut.util.GetPlayerTraceEntity(client); if (IsValid(entity) and PLUGIN:IsDoor(entity)) then if (!PLUGIN:IsDoorOwned(entity)) then client:ConCommand("nut doorbuy"); elseif (PLUGIN:GetDoorOwner(entity) == client) then client:ConCommand("nut doorsell"); end end end; end AdvNut.hook.Add("PlayerBindPress", "DoorBindPress", PLUGIN.PlayerBindPress); function PLUGIN:PlayerCanOpenQuickRecognitionMenu() local entity = AdvNut.util.GetPlayerTraceEntity(LocalPlayer()); if (IsValid(entity) and PLUGIN:IsDoor(entity)) then return false; else return true; end; end;
mit
kidaa/turbo
turbo/structs/buffer.lua
12
8668
-- Turbo.lua Low-level buffer implementation -- -- Copyright 2013 John Abrahamsen -- -- 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 "turbo.cdef" require 'turbo.3rdparty.middleclass' local ffi = require "ffi" ffi.cdef([[ struct tbuffer{ char *data; size_t mem; size_t sz; size_t sz_hint; }; ]]) --- Low-level Buffer class. -- Using C buffers. This class supports storing above the LuaJIT memory limit. -- It is still garbage collected. local Buffer = class('Buffer') local function _tbuffer_free(ptr) ptr = ffi.cast("struct tbuffer *", ptr) ffi.C.free(ptr.data) ffi.C.free(ptr) end --- Create a new buffer. -- @param size_hint The buffer is preallocated with this amount of storage. -- @return Buffer instance. function Buffer:initialize(size_hint) size_hint = size_hint or 1024 local ptr = ffi.C.malloc(ffi.sizeof("struct tbuffer")) if ptr == nil then error("No memory.") end self.tbuffer = ffi.cast("struct tbuffer *", ptr) ffi.gc(self.tbuffer, _tbuffer_free) ptr = ffi.C.malloc(size_hint) if ptr == nil then error("No memory.") end self.tbuffer.mem = size_hint self.tbuffer.sz = 0 self.tbuffer.data = ptr self.tbuffer.sz_hint = size_hint end --- Append data to buffer. -- @param data The data to append in char * form. -- @param len The length of the data in bytes. function Buffer:append_right(data, len) if self.tbuffer.mem - self.tbuffer.sz >= len then ffi.copy(self.tbuffer.data + self.tbuffer.sz, data, len) self.tbuffer.sz = self.tbuffer.sz + len else -- Realloc and double required memory size. local new_sz = self.tbuffer.sz + len local new_mem = new_sz * 2 local ptr = ffi.C.realloc(self.tbuffer.data, new_mem) if ptr == nil then error("No memory.") end self.tbuffer.data = ptr ffi.copy(self.tbuffer.data + self.tbuffer.sz, data, len) self.tbuffer.mem = new_mem self.tbuffer.sz = new_sz end return self end function Buffer:append_char_right(char) if self.tbuffer.mem - self.tbuffer.sz >= 1 then self.tbuffer.data[self.tbuffer.sz] = char self.tbuffer.sz = self.tbuffer.sz + 1 else -- Realloc and double required memory size. local new_sz = self.tbuffer.sz + 1 local new_mem = new_sz * 2 local ptr = ffi.C.realloc(self.tbuffer.data, new_mem) if ptr == nil then error("No memory.") end self.tbuffer.data = ptr self.tbuffer.data[self.tbuffer.sz] = char self.tbuffer.mem = new_mem self.tbuffer.sz = new_sz end return self end --- Append Lua string to right side of buffer. -- @param str Lua string function Buffer:append_luastr_right(str) if not str then error("Appending a nil value, not possible.") end self:append_right(str, str:len()) return self end --- Prepend data to buffer. -- @param data The data to prepend in char * form. -- @param len The length of the data in bytes. function Buffer:append_left(data, len) if self.tbuffer.mem - self.tbuffer.sz >= len then -- Do not use ffi.copy, but memmove as the memory are overlapping. if self.tbuffer.sz ~= 0 then ffi.C.memmove( self.tbuffer.data + len, self.tbuffer.data, self.tbuffer.sz) end ffi.copy(self.tbuffer.data, data, len) self.tbuffer.sz = self.tbuffer.sz + len else -- Realloc and double required memory size. local new_sz = self.tbuffer.sz + len local new_mem = new_sz * 2 local ptr = ffi.C.realloc(self.tbuffer.data, new_mem) if ptr == nil then error("No memory.") end self.tbuffer.data = ptr if self.tbuffer.sz ~= 0 then ffi.C.memmove(self.tbuffer.data + len, self.tbuffer.data, self.tbuffer.sz) end ffi.copy(self.tbuffer.data, data, len) self.tbuffer.mem = new_mem self.tbuffer.sz = new_sz end return self end --- Prepend Lua string to the buffer -- @param str Lua string function Buffer:append_luastr_left(str) if not str then error("Appending a nil value, not possible.") end return self:append_left(str, str:len()) end --- Pop bytes from left side of buffer. If sz exceeds size of buffer then a -- error is raised. Note: does not release memory allocated. function Buffer:pop_left(sz) if self.tbuffer.sz < sz then error("Trying to pop_left side greater than total size of buffer") else local move = self.tbuffer.sz - sz ffi.C.memmove(self.tbuffer.data, self.tbuffer.data + sz, move) self.tbuffer.sz = move end return self end --- Pop bytes from right side of the buffer. If sz exceeds size of buffer then -- a error is raised. Note: does not release memory allocated. function Buffer:pop_right(sz) if self.tbuffer.sz < sz then error("Trying to pop_right side greater than total size of buffer") else self.tbuffer.sz = self.tbuffer.sz - sz end return self end --- Create a "deep" copy of the buffer. function Buffer:copy() local new = Buffer(self.tbuffer.sz) new:append_right(self:get()) return new end --- Shrink buffer memory usage to its minimum. function Buffer:shrink() if self.tbuffer.sz_hint > self.tbuffer.sz or self.tbuffer.sz == self.tbuffer.mem then -- Current size is smaller than size hint or current size equals memory -- allocated. Bail. return self end local ptr = ffi.C.realloc(self.tbuffer.data, self.tbuffer.sz) if ptr == nil then error("No memory.") end self.tbuffer.data = ptr return self end --- Clear buffer. Note: does not release memory allocated. -- @param wipe Zero fill allocated memory range. function Buffer:clear(wipe) if wipe then ffi.fill(self.tbuffer.data, self.tbuffer.mem, 0) end self.tbuffer.sz = 0 return self end --- Get current size of the buffer. -- @return size of buffer in bytes. function Buffer:len() return self.tbuffer.sz end --- Get the total number of bytes currently allocated to this instance. -- @return number of bytes allocated. function Buffer:mem() return self.tbuffer.mem end --- Get internal buffer pointer. Must be treated as a const value. -- @return char * to data. -- @return current size of buffer, in bytes. function Buffer:get() return self.tbuffer.data, self.tbuffer.sz end --- Convert to Lua type string using the tostring() builtin or implicit -- conversions. function Buffer:__tostring() return ffi.string(self.tbuffer.data, self.tbuffer.sz) end --- Compare two buffers by using the == operator. function Buffer:__eq(cmp) if instanceOf(Buffer, cmp) == true then if cmp.tbuffer.sz == self.tbuffer.sz then if ffi.C.memcmp(cmp.tbuffer.data, self.tbuffer.data, self.tbuffer.sz) == 0 then return true end end else error("Trying to compare Buffer with " .. type(cmp)) end return false end --- Concat by using the .. operator, Lua type strings can be concated also. -- Please note that this involves deep copying and is slower than manually -- building a buffer with append_right(). function Buffer:__concat(src) if type(self) == "string" then if instanceOf(Buffer, src) then return self .. tostring(src) end elseif instanceOf(Buffer, self) == true then if instanceOf(Buffer, src) == true then local new = Buffer(src.tbuffer.sz + self.tbuffer.sz) new:append_right(self:get()) new:append_right(src:get()) return new elseif type(src) == "string" then local strlen = src:len() local new = Buffer(strlen + self.tbuffer.sz) new:append_right(self:get()) new:append_right(src, strlen) return new end end error("Trying to concat Buffer with " .. type(cmp)) end return Buffer
apache-2.0
jshackley/darkstar
scripts/globals/status.lua
3
77278
------------------------------------ -- -- STATUSES AND MODS -- -- Contains variable-ized definitions of things like core enums for use in lua scripts. ------------------------------------ ------------------------------------ -- Job IDs ------------------------------------ JOB_NON = 0 JOB_WAR = 1 JOB_MNK = 2 JOB_WHM = 3 JOB_BLM = 4 JOB_RDM = 5 JOB_THF = 6 JOB_PLD = 7 JOB_DRK = 8 JOB_BST = 9 JOB_BRD = 10 JOB_RNG = 11 JOB_SAM = 12 JOB_NIN = 13 JOB_DRG = 14 JOB_SMN = 15 JOB_BLU = 16 JOB_COR = 17 JOB_PUP = 18 JOB_DNC = 19 JOB_SCH = 20 JOB_GEO = 21 JOB_RUN = 22 MAX_JOB_TYPE = 23 ------------------------------------ -- STATUSES ------------------------------------ STATUS_NORMAL = 0; STATUS_UPDATE = 1; STATUS_DISAPPEAR = 2; STATUS_3 = 3; STATUS_4 = 4; STATUS_CUTSCENE_ONLY = 6; STATUS_18 = 18; STATUS_SHUTDOWN = 20; ------------------------------------ -- These codes represent the subeffects for -- additional effects animations from battleentity.h ------------------------------------ -- ATTACKS SUBEFFECT_FIRE_DAMAGE = 1; -- 110000 3 SUBEFFECT_ICE_DAMAGE = 2; -- 1-01000 5 SUBEFFECT_WIND_DAMAGE = 3; -- 111000 7 SUBEFFECT_EARTH_DAMAGE = 4; -- 1-00100 9 SUBEFFECT_LIGHTNING_DAMAGE = 5; -- 110100 11 SUBEFFECT_WATER_DAMAGE = 6; -- 1-01100 13 SUBEFFECT_LIGHT_DAMAGE = 7; -- 111100 15 SUBEFFECT_DARKNESS_DAMAGE = 8; -- 1-00010 17 SUBEFFECT_SLEEP = 9; -- 110010 19 SUBEFFECT_POISON = 10; -- 1-01010 21 SUBEFFECT_PARALYSIS = 11; SUBEFFECT_BLIND = 12; -- 1-00110 25 SUBEFFECT_SILENCE = 13; SUBEFFECT_PETRIFY = 14; SUBEFFECT_PLAGUE = 15; SUBEFFECT_STUN = 16; SUBEFFECT_CURSE = 17; SUBEFFECT_DEFENSE_DOWN = 18; -- 1-01001 37 SUBEFFECT_EVASION_DOWN = 18; -- ID needs verification SUBEFFECT_ATTACK_DOWN = 18; -- ID needs verification SUBEFFECT_DEATH = 19; SUBEFFECT_SHIELD = 20; SUBEFFECT_HP_DRAIN = 21; -- 1-10101 43 SUBEFFECT_MP_DRAIN = 22; -- This is correct animation SUBEFFECT_TP_DRAIN = 22; -- Verified this should look exactly like Aspir Samba. SUBEFFECT_HASTE = 23; -- Below are almost certain to be wrong: -- Someone needs to go on retail and verify the SubEffect IDs SUBEFFECT_AMNESIA = 11; -- SUBEFFECT_DISPEL = 13; -- Correct ID possibly 20 ? -- SPIKES SUBEFFECT_BLAZE_SPIKES = 1; -- 01-1000 6 SUBEFFECT_ICE_SPIKES = 2; -- 01-0100 10 SUBEFFECT_DREAD_SPIKES = 3; -- 01-1100 14 SUBEFFECT_CURSE_SPIKES = 4; -- 01-0010 18 SUBEFFECT_SHOCK_SPIKES = 5; -- 01-1010 22 SUBEFFECT_REPRISAL = 6; -- 01-0110 26 SUBEFFECT_WIND_SPIKES = 7; SUBEFFECT_STONE_SPIKES = 8; SUBEFFECT_DELUGE_SPIKES = 9; SUBEFFECT_DEATH_SPIKES = 10; -- yes really: http://www.ffxiah.com/item/26944/ SUBEFFECT_COUNTER = 63; -- SKILLCHAINS SUBEFFECT_NONE = 0; SUBEFFECT_LIGHT = 1; SUBEFFECT_DARKNESS = 2; SUBEFFECT_GRAVITATION = 3; SUBEFFECT_FRAGMENTATION = 4; SUBEFFECT_DISTORTION = 5; SUBEFFECT_FUSION = 6; SUBEFFECT_COMPRESSION = 7; SUBEFFECT_LIQUEFACATION = 8; SUBEFFECT_INDURATION = 9; SUBEFFECT_REVERBERATION = 10; SUBEFFECT_TRANSFIXION = 11; SUBEFFECT_SCISSION = 12; SUBEFFECT_DETONATION = 13; SUBEFFECT_IMPACTION = 14; ------------------------------------ -- These codes represent the actual status effects. -- They are simply for convenience. ------------------------------------ EFFECT_KO = 0 EFFECT_WEAKNESS = 1 EFFECT_SLEEP_I = 2 EFFECT_POISON = 3 EFFECT_PARALYSIS = 4 EFFECT_BLINDNESS = 5 EFFECT_SILENCE = 6 EFFECT_PETRIFICATION = 7 EFFECT_DISEASE = 8 EFFECT_CURSE_I = 9 EFFECT_STUN = 10 EFFECT_BIND = 11 EFFECT_WEIGHT = 12 EFFECT_SLOW = 13 EFFECT_CHARM_I = 14 EFFECT_DOOM = 15 EFFECT_AMNESIA = 16 EFFECT_CHARM_II = 17 EFFECT_GRADUAL_PETRIFICATION = 18 EFFECT_SLEEP_II = 19 EFFECT_CURSE_II = 20 EFFECT_ADDLE = 21 EFFECT_INTIMIDATE = 22 EFFECT_KAUSTRA = 23 EFFECT_TERROR = 28 EFFECT_MUTE = 29 EFFECT_BANE = 30 EFFECT_PLAGUE = 31 EFFECT_FLEE = 32 EFFECT_HASTE = 33 EFFECT_BLAZE_SPIKES = 34 EFFECT_ICE_SPIKES = 35 EFFECT_BLINK = 36 EFFECT_STONESKIN = 37 EFFECT_SHOCK_SPIKES = 38 EFFECT_AQUAVEIL = 39 EFFECT_PROTECT = 40 EFFECT_SHELL = 41 EFFECT_REGEN = 42 EFFECT_REFRESH = 43 EFFECT_MIGHTY_STRIKES = 44 EFFECT_BOOST = 45 EFFECT_HUNDRED_FISTS = 46 EFFECT_MANAFONT = 47 EFFECT_CHAINSPELL = 48 EFFECT_PERFECT_DODGE = 49 EFFECT_INVINCIBLE = 50 EFFECT_BLOOD_WEAPON = 51 EFFECT_SOUL_VOICE = 52 EFFECT_EAGLE_EYE_SHOT = 53 EFFECT_MEIKYO_SHISUI = 54 EFFECT_ASTRAL_FLOW = 55 EFFECT_BERSERK = 56 EFFECT_DEFENDER = 57 EFFECT_AGGRESSOR = 58 EFFECT_FOCUS = 59 EFFECT_DODGE = 60 EFFECT_COUNTERSTANCE = 61 EFFECT_SENTINEL = 62 EFFECT_SOULEATER = 63 EFFECT_LAST_RESORT = 64 EFFECT_SNEAK_ATTACK = 65 EFFECT_COPY_IMAGE = 66 EFFECT_THIRD_EYE = 67 EFFECT_WARCRY = 68 EFFECT_INVISIBLE = 69 EFFECT_DEODORIZE = 70 EFFECT_SNEAK = 71 EFFECT_SHARPSHOT = 72 EFFECT_BARRAGE = 73 EFFECT_HOLY_CIRCLE = 74 EFFECT_ARCANE_CIRCLE = 75 EFFECT_HIDE = 76 EFFECT_CAMOUFLAGE = 77 EFFECT_DIVINE_SEAL = 78 EFFECT_ELEMENTAL_SEAL = 79 EFFECT_STR_BOOST = 80 EFFECT_DEX_BOOST = 81 EFFECT_VIT_BOOST = 82 EFFECT_AGI_BOOST = 83 EFFECT_INT_BOOST = 84 EFFECT_MND_BOOST = 85 EFFECT_CHR_BOOST = 86 EFFECT_TRICK_ATTACK = 87 EFFECT_MAX_HP_BOOST = 88 EFFECT_MAX_MP_BOOST = 89 EFFECT_ACCURACY_BOOST = 90 EFFECT_ATTACK_BOOST = 91 EFFECT_EVASION_BOOST = 92 EFFECT_DEFENSE_BOOST = 93 EFFECT_ENFIRE = 94 EFFECT_ENBLIZZARD = 95 EFFECT_ENAERO = 96 EFFECT_ENSTONE = 97 EFFECT_ENTHUNDER = 98 EFFECT_ENWATER = 99 EFFECT_BARFIRE = 100 EFFECT_BARBLIZZARD = 101 EFFECT_BARAERO = 102 EFFECT_BARSTONE = 103 EFFECT_BARTHUNDER = 104 EFFECT_BARWATER = 105 EFFECT_BARSLEEP = 106 EFFECT_BARPOISON = 107 EFFECT_BARPARALYZE = 108 EFFECT_BARBLIND = 109 EFFECT_BARSILENCE = 110 EFFECT_BARPETRIFY = 111 EFFECT_BARVIRUS = 112 EFFECT_RERAISE = 113 EFFECT_COVER = 114 EFFECT_UNLIMITED_SHOT = 115 EFFECT_PHALANX = 116 EFFECT_WARDING_CIRCLE = 117 EFFECT_ANCIENT_CIRCLE = 118 EFFECT_STR_BOOST_II = 119 EFFECT_DEX_BOOST_II = 120 EFFECT_VIT_BOOST_II = 121 EFFECT_AGI_BOOST_II = 122 EFFECT_INT_BOOST_II = 123 EFFECT_MND_BOOST_II = 124 EFFECT_CHR_BOOST_II = 125 EFFECT_SPIRIT_SURGE = 126 EFFECT_COSTUME = 127 EFFECT_BURN = 128 EFFECT_FROST = 129 EFFECT_CHOKE = 130 EFFECT_RASP = 131 EFFECT_SHOCK = 132 EFFECT_DROWN = 133 EFFECT_DIA = 134 EFFECT_BIO = 135 EFFECT_STR_DOWN = 136 EFFECT_DEX_DOWN = 137 EFFECT_VIT_DOWN = 138 EFFECT_AGI_DOWN = 139 EFFECT_INT_DOWN = 140 EFFECT_MND_DOWN = 141 EFFECT_CHR_DOWN = 142 EFFECT_LEVEL_RESTRICTION = 143 EFFECT_MAX_HP_DOWN = 144 EFFECT_MAX_MP_DOWN = 145 EFFECT_ACCURACY_DOWN = 146 EFFECT_ATTACK_DOWN = 147 EFFECT_EVASION_DOWN = 148 EFFECT_DEFENSE_DOWN = 149 EFFECT_PHYSICAL_SHIELD = 150 EFFECT_ARROW_SHIELD = 151 EFFECT_MAGIC_SHIELD = 152 EFFECT_DAMAGE_SPIKES = 153 EFFECT_SHINING_RUBY = 154 EFFECT_MEDICINE = 155 EFFECT_FLASH = 156 EFFECT_SJ_RESTRICTION = 157 EFFECT_PROVOKE = 158 EFFECT_PENALTY = 159 EFFECT_PREPARATIONS = 160 EFFECT_SPRINT = 161 EFFECT_ENCHANTMENT = 162 EFFECT_AZURE_LORE = 163 EFFECT_CHAIN_AFFINITY = 164 EFFECT_BURST_AFFINITY = 165 EFFECT_OVERDRIVE = 166 EFFECT_MAGIC_DEF_DOWN = 167 EFFECT_INHIBIT_TP = 168 EFFECT_POTENCY = 169 EFFECT_REGAIN = 170 EFFECT_PAX = 171 EFFECT_INTENSION = 172 EFFECT_DREAD_SPIKES = 173 EFFECT_MAGIC_ACC_DOWN = 174 EFFECT_MAGIC_ATK_DOWN = 175 EFFECT_QUICKENING = 176 EFFECT_ENCUMBRANCE_II = 177 EFFECT_FIRESTORM = 178 EFFECT_HAILSTORM = 179 EFFECT_WINDSTORM = 180 EFFECT_SANDSTORM = 181 EFFECT_THUNDERSTORM = 182 EFFECT_RAINSTORM = 183 EFFECT_AURORASTORM = 184 EFFECT_VOIDSTORM = 185 EFFECT_HELIX = 186 EFFECT_SUBLIMATION_ACTIVATED = 187 EFFECT_SUBLIMATION_COMPLETE = 188 EFFECT_MAX_TP_DOWN = 189 EFFECT_MAGIC_ATK_BOOST = 190 EFFECT_MAGIC_DEF_BOOST = 191 EFFECT_REQUIEM = 192 EFFECT_LULLABY = 193 EFFECT_ELEGY = 194 EFFECT_PAEON = 195 EFFECT_BALLAD = 196 EFFECT_MINNE = 197 EFFECT_MINUET = 198 EFFECT_MADRIGAL = 199 EFFECT_PRELUDE = 200 EFFECT_MAMBO = 201 EFFECT_AUBADE = 202 EFFECT_PASTORAL = 203 EFFECT_HUM = 204 EFFECT_FANTASIA = 205 EFFECT_OPERETTA = 206 EFFECT_CAPRICCIO = 207 EFFECT_SERENADE = 208 EFFECT_ROUND = 209 EFFECT_GAVOTTE = 210 EFFECT_FUGUE = 211 EFFECT_RHAPSODY = 212 EFFECT_ARIA = 213 EFFECT_MARCH = 214 EFFECT_ETUDE = 215 EFFECT_CAROL = 216 EFFECT_THRENODY = 217 EFFECT_HYMNUS = 218 EFFECT_MAZURKA = 219 EFFECT_SIRVENTE = 220 EFFECT_DIRGE = 221 EFFECT_SCHERZO = 222 EFFECT_NOCTURNE = 223 EFFECT_STORE_TP = 227 EFFECT_EMBRAVA = 228 EFFECT_MANAWELL = 229 EFFECT_SPONTANEITY = 230 EFFECT_MARCATO = 231 EFFECT_NA = 232 EFFECT_AUTO_REGEN = 233 EFFECT_AUTO_REFRESH = 234 EFFECT_FISHING_IMAGERY = 235 EFFECT_WOODWORKING_IMAGERY = 236 EFFECT_SMITHING_IMAGERY = 237 EFFECT_GOLDSMITHING_IMAGERY = 238 EFFECT_CLOTHCRAFT_IMAGERY = 239 EFFECT_LEATHERCRAFT_IMAGERY = 240 EFFECT_BONECRAFT_IMAGERY = 241 EFFECT_ALCHEMY_IMAGERY = 242 EFFECT_COOKING_IMAGERY = 243 EFFECT_IMAGERY_1 = 244 EFFECT_IMAGERY_2 = 245 EFFECT_IMAGERY_3 = 246 EFFECT_IMAGERY_4 = 247 EFFECT_IMAGERY_5 = 248 EFFECT_DEDICATION = 249 EFFECT_EF_BADGE = 250 EFFECT_FOOD = 251 EFFECT_CHOCOBO = 252 EFFECT_SIGNET = 253 EFFECT_BATTLEFIELD = 254 EFFECT_NONE = 255 EFFECT_SANCTION = 256 EFFECT_BESIEGED = 257 EFFECT_ILLUSION = 258 EFFECT_ENCUMBRANCE_I = 259 EFFECT_OBLIVISCENCE = 260 EFFECT_IMPAIRMENT = 261 EFFECT_OMERTA = 262 EFFECT_DEBILITATION = 263 EFFECT_PATHOS = 264 EFFECT_FLURRY = 265 EFFECT_CONCENTRATION = 266 EFFECT_ALLIED_TAGS = 267 EFFECT_SIGIL = 268 EFFECT_LEVEL_SYNC = 269 EFFECT_AFTERMATH_LV1 = 270 EFFECT_AFTERMATH_LV2 = 271 EFFECT_AFTERMATH_LV3 = 272 EFFECT_AFTERMATH = 273 EFFECT_ENLIGHT = 274 EFFECT_AUSPICE = 275 EFFECT_CONFRONTATION = 276 EFFECT_ENFIRE_II = 277 EFFECT_ENBLIZZARD_II = 278 EFFECT_ENAERO_II = 279 EFFECT_ENSTONE_II = 280 EFFECT_ENTHUNDER_II = 281 EFFECT_ENWATER_II = 282 EFFECT_PERFECT_DEFENSE = 283 EFFECT_EGG = 284 EFFECT_VISITANT = 285 EFFECT_BARAMNESIA = 286 EFFECT_ATMA = 287 EFFECT_ENDARK = 288 EFFECT_ENMITY_BOOST = 289 EFFECT_SUBTLE_BLOW_PLUS = 290 EFFECT_ENMITY_DOWN = 291 EFFECT_PENNANT = 292 EFFECT_NEGATE_PETRIFY = 293 EFFECT_NEGATE_TERROR = 294 EFFECT_NEGATE_AMNESIA = 295 EFFECT_NEGATE_DOOM = 296 EFFECT_NEGATE_POISON = 297 EFFECT_CRIT_HIT_EVASION_DOWN = 298 EFFECT_OVERLOAD = 299 EFFECT_FIRE_MANEUVER = 300 EFFECT_ICE_MANEUVER = 301 EFFECT_WIND_MANEUVER = 302 EFFECT_EARTH_MANEUVER = 303 EFFECT_THUNDER_MANEUVER = 304 EFFECT_WATER_MANEUVER = 305 EFFECT_LIGHT_MANEUVER = 306 EFFECT_DARK_MANEUVER = 307 EFFECT_DOUBLE_UP_CHANCE = 308 EFFECT_BUST = 309 EFFECT_FIGHTERS_ROLL = 310 EFFECT_MONKS_ROLL = 311 EFFECT_HEALERS_ROLL = 312 EFFECT_WIZARDS_ROLL = 313 EFFECT_WARLOCKS_ROLL = 314 EFFECT_ROGUES_ROLL = 315 EFFECT_GALLANTS_ROLL = 316 EFFECT_CHAOS_ROLL = 317 EFFECT_BEAST_ROLL = 318 EFFECT_CHORAL_ROLL = 319 EFFECT_HUNTERS_ROLL = 320 EFFECT_SAMURAI_ROLL = 321 EFFECT_NINJA_ROLL = 322 EFFECT_DRACHEN_ROLL = 323 EFFECT_EVOKERS_ROLL = 324 EFFECT_MAGUSS_ROLL = 325 EFFECT_CORSAIRS_ROLL = 326 EFFECT_PUPPET_ROLL = 327 EFFECT_DANCERS_ROLL = 328 EFFECT_SCHOLARS_ROLL = 329 EFFECT_BOLTERS_ROLL = 330 EFFECT_CASTERS_ROLL = 331 EFFECT_COURSERS_ROLL = 332 EFFECT_BLITZERS_ROLL = 333 EFFECT_TACTICIANS_ROLL = 334 EFFECT_ALLIES_ROLL = 335 EFFECT_MISERS_ROLL = 336 EFFECT_COMPANIONS_ROLL = 337 EFFECT_AVENGERS_ROLL = 338 -- EFFECT_NONE = 339 EFFECT_WARRIOR_S_CHARGE = 340 EFFECT_FORMLESS_STRIKES = 341 EFFECT_ASSASSIN_S_CHARGE = 342 EFFECT_FEINT = 343 EFFECT_FEALTY = 344 EFFECT_DARK_SEAL = 345 EFFECT_DIABOLIC_EYE = 346 EFFECT_NIGHTINGALE = 347 EFFECT_TROUBADOUR = 348 EFFECT_KILLER_INSTINCT = 349 EFFECT_STEALTH_SHOT = 350 EFFECT_FLASHY_SHOT = 351 EFFECT_SANGE = 352 EFFECT_HASSO = 353 EFFECT_SEIGAN = 354 EFFECT_CONVERGENCE = 355 EFFECT_DIFFUSION = 356 EFFECT_SNAKE_EYE = 357 EFFECT_LIGHT_ARTS = 358 EFFECT_DARK_ARTS = 359 EFFECT_PENURY = 360 EFFECT_PARSIMONY = 361 EFFECT_CELERITY = 362 EFFECT_ALACRITY = 363 EFFECT_RAPTURE = 364 EFFECT_EBULLIENCE = 365 EFFECT_ACCESSION = 366 EFFECT_MANIFESTATION = 367 EFFECT_DRAIN_SAMBA = 368 EFFECT_ASPIR_SAMBA = 369 EFFECT_HASTE_SAMBA = 370 EFFECT_VELOCITY_SHOT = 371 EFFECT_BUILDING_FLOURISH = 375 EFFECT_TRANCE = 376 EFFECT_TABULA_RASA = 377 EFFECT_DRAIN_DAZE = 378 EFFECT_ASPIR_DAZE = 379 EFFECT_HASTE_DAZE = 380 EFFECT_FINISHING_MOVE_1 = 381 EFFECT_FINISHING_MOVE_2 = 382 EFFECT_FINISHING_MOVE_3 = 383 EFFECT_FINISHING_MOVE_4 = 384 EFFECT_FINISHING_MOVE_5 = 385 EFFECT_LETHARGIC_DAZE_1 = 386 EFFECT_LETHARGIC_DAZE_2 = 387 EFFECT_LETHARGIC_DAZE_3 = 388 EFFECT_LETHARGIC_DAZE_4 = 389 EFFECT_LETHARGIC_DAZE_5 = 390 EFFECT_SLUGGISH_DAZE_1 = 391 EFFECT_SLUGGISH_DAZE_2 = 392 EFFECT_SLUGGISH_DAZE_3 = 393 EFFECT_SLUGGISH_DAZE_4 = 394 EFFECT_SLUGGISH_DAZE_5 = 395 EFFECT_WEAKENED_DAZE_1 = 396 EFFECT_WEAKENED_DAZE_2 = 397 EFFECT_WEAKENED_DAZE_3 = 398 EFFECT_WEAKENED_DAZE_4 = 399 EFFECT_WEAKENED_DAZE_5 = 400 EFFECT_ADDENDUM_WHITE = 401 EFFECT_ADDENDUM_BLACK = 402 EFFECT_REPRISAL = 403 EFFECT_MAGIC_EVASION_DOWN = 404 EFFECT_RETALIATION = 405 EFFECT_FOOTWORK = 406 EFFECT_KLIMAFORM = 407 EFFECT_SEKKANOKI = 408 EFFECT_PIANISSIMO = 409 EFFECT_SABER_DANCE = 410 EFFECT_FAN_DANCE = 411 EFFECT_ALTRUISM = 412 EFFECT_FOCALIZATION = 413 EFFECT_TRANQUILITY = 414 EFFECT_EQUANIMITY = 415 EFFECT_ENLIGHTENMENT = 416 EFFECT_AFFLATUS_SOLACE = 417 EFFECT_AFFLATUS_MISERY = 418 EFFECT_COMPOSURE = 419 EFFECT_YONIN = 420 EFFECT_INNIN = 421 EFFECT_CARBUNCLE_S_FAVOR = 422 EFFECT_IFRIT_S_FAVOR = 423 EFFECT_SHIVA_S_FAVOR = 424 EFFECT_GARUDA_S_FAVOR = 425 EFFECT_TITAN_S_FAVOR = 426 EFFECT_RAMUH_S_FAVOR = 427 EFFECT_LEVIATHAN_S_FAVOR = 428 EFFECT_FENRIR_S_FAVOR = 429 EFFECT_DIABOLOS_S_FAVOR = 430 EFFECT_AVATAR_S_FAVOR = 431 EFFECT_MULTI_STRIKES = 432 EFFECT_DOUBLE_SHOT = 433 EFFECT_TRANSCENDENCY = 434 EFFECT_RESTRAINT = 435 EFFECT_PERFECT_COUNTER = 436 EFFECT_MANA_WALL = 437 EFFECT_DIVINE_EMBLEM = 438 EFFECT_NETHER_VOID = 439 EFFECT_SENGIKORI = 440 EFFECT_FUTAE = 441 EFFECT_PRESTO = 442 EFFECT_CLIMACTIC_FLOURISH = 443 EFFECT_COPY_IMAGE_2 = 444 EFFECT_COPY_IMAGE_3 = 445 EFFECT_COPY_IMAGE_4 = 446 EFFECT_MULTI_SHOTS = 447 EFFECT_BEWILDERED_DAZE_1 = 448 EFFECT_BEWILDERED_DAZE_2 = 449 EFFECT_BEWILDERED_DAZE_3 = 450 EFFECT_BEWILDERED_DAZE_4 = 451 EFFECT_BEWILDERED_DAZE_5 = 452 EFFECT_DIVINE_CARESS_I = 453 EFFECT_SABOTEUR = 454 EFFECT_TENUTO = 455 EFFECT_SPUR = 456 EFFECT_EFFLUX = 457 EFFECT_EARTHEN_ARMOR = 458 EFFECT_DIVINE_CARESS_II = 459 EFFECT_BLOOD_RAGE = 460 EFFECT_IMPETUS = 461 EFFECT_CONSPIRATOR = 462 EFFECT_SEPULCHER = 463 EFFECT_ARCANE_CREST = 464 EFFECT_HAMANOHA = 465 EFFECT_DRAGON_BREAKER = 466 EFFECT_TRIPLE_SHOT = 467 EFFECT_STRIKING_FLOURISH = 468 EFFECT_PERPETUANCE = 469 EFFECT_IMMANENCE = 470 EFFECT_MIGAWARI = 471 EFFECT_TERNARY_FLOURISH = 472 -- DNC 93 EFFECT_MUDDLE = 473 -- MOB EFFECT EFFECT_PROWESS = 474 -- GROUNDS OF VALOR EFFECT_VOIDWATCHER = 475 -- VOIDWATCH EFFECT_ENSPHERE = 476 -- ATMACITE EFFECT_SACROSANCTITY = 477 -- WHM 95 EFFECT_PALISADE = 478 -- PLD 95 EFFECT_SCARLET_DELIRIUM = 479 -- DRK 95 EFFECT_SCARLET_DELIRIUM_1 = 480 -- DRK 95 -- EFFECT_NONE = 481 -- NONE EFFECT_DECOY_SHOT = 482 -- RNG 95 EFFECT_HAGAKURE = 483 -- SAM 95 EFFECT_ISSEKIGAN = 484 -- NIN 95 EFFECT_UNBRIDLED_LEARNING = 485 -- BLU 95 EFFECT_COUNTER_BOOST = 486 -- EFFECT_ENDRAIN = 487 -- FENRIR 96 EFFECT_ENASPIR = 488 -- FENRIR 96 EFFECT_AFTERGLOW = 489 -- WS AFTEREFFECT EFFECT_BRAZEN_STRENGTH = 490 -- EFFECT_INNER_STRENGTH = 491 EFFECT_ASYLUM = 492 EFFECT_SUBTLE_SORCERY = 493 EFFECT_STYMIE = 494 -- EFFECT_NONE = 495 EFFECT_INTERVENE = 496 EFFECT_SOUL_ENSLAVEMENT = 497 EFFECT_UNLEASH = 498 EFFECT_CLARION_CALL = 499 EFFECT_OVERKILL = 500 EFFECT_YAEGASUMI = 501 EFFECT_MIKAGE = 502 EFFECT_FLY_HIGH = 503 EFFECT_ASTRAL_CONDUIT = 504 EFFECT_UNBRIDLED_WISDOM = 505 -- EFFECT_NONE = 506 EFFECT_GRAND_PAS = 507 EFFECT_WIDENED_COMPASS = 508 EFFECT_ODYLLIC_SUBTERFUGE = 509 EFFECT_ERGON_MIGHT = 510 EFFECT_REIVE_MARK = 511 EFFECT_IONIS = 512 EFFECT_BOLSTER = 513 -- EFFECT_NONE = 514 EFFECT_LASTING_EMANATION = 515 EFFECT_ECLIPTIC_ATTRITION = 516 EFFECT_COLLIMATED_FERVOR = 517 EFFECT_DEMATERIALIZE = 518 EFFECT_THEURGIC_FOCUS = 519 -- EFFECT_NONE = 520 -- EFFECT_NONE = 521 EFFECT_ELEMENTAL_SFORZO = 522 EFFECT_IGNIS = 523 EFFECT_GELUS = 524 EFFECT_FLABRA = 525 EFFECT_TELLUS = 526 EFFECT_SULPOR = 527 EFFECT_UNDA = 528 EFFECT_LUX = 529 EFFECT_TENEBRAE = 530 EFFECT_VALLATION = 531 EFFECT_SWORDPLAY = 532 EFFECT_PFLUG = 533 EFFECT_EMBOLDEN = 534 EFFECT_VALIANCE = 535 EFFECT_GAMBIT = 536 EFFECT_LIEMENT = 537 EFFECT_ONE_FOR_ALL = 538 EFFECT_REGEN_II = 539 EFFECT_POISON_II = 540 EFFECT_REFRESH_II = 541 EFFECT_STR_BOOST_III = 542 EFFECT_DEX_BOOST_III = 543 EFFECT_VIT_BOOST_III = 544 EFFECT_AGI_BOOST_III = 545 EFFECT_INT_BOOST_III = 546 EFFECT_MND_BOOST_III = 547 EFFECT_CHR_BOOST_III = 548 EFFECT_ATTACK_BOOST_II = 549 EFFECT_DEFENSE_BOOST_II = 550 EFFECT_MAGIC_ATK_BOOST_II = 551 EFFECT_MAGIC_DEF_BOOST_II = 552 EFFECT_ACCURACY_BOOST_II = 553 EFFECT_EVASION_BOOST_II = 554 EFFECT_MAGIC_ACC_BOOST_II = 555 EFFECT_MAGIC_EVASION_BOOST_II = 556 EFFECT_ATTACK_DOWN_II = 557 EFFECT_DEFENSE_DOWN_II = 558 EFFECT_MAGIC_ATK_DOWN_II = 559 EFFECT_MAGIC_DEF_DOWN_II = 560 EFFECT_ACCURACY_DOWN_II = 561 EFFECT_EVASION_DOWN_II = 562 EFFECT_MAGIC_ACC_DOWN_II = 563 EFFECT_MAGIC_EVASION_DOWN_II = 564 EFFECT_SLOW_II = 565 EFFECT_PARALYSIS_II = 566 EFFECT_WEIGHT_II = 567 EFFECT_FOIL = 568 EFFECT_BLAZE_OF_GLORY = 569 EFFECT_BATTUTA = 570 EFFECT_RAYKE = 571 EFFECT_AVOIDANCE_DOWN = 572 EFFECT_DELUGE_SPIKES = 573 -- Exists in client, unused on retail? EFFECT_FAST_CAST = 574 EFFECT_GESTATION = 575 EFFECT_DOUBT = 576 -- Bully: Intimidation Enfeeble status EFFECT_CAIT_SITH_S_FAVOR = 577 EFFECT_FISHY_INTUITION = 578 EFFECT_COMMITMENT = 579 EFFECT_HASTE_II = 580 EFFECT_FLURRY_II = 581 EFFECT_APOGEE = 583 -- Effect icons in packet can go from 0-767, so no custom effects should go in that range. -- Purchased from Cruor Prospector EFFECT_ABYSSEA_STR = 768 EFFECT_ABYSSEA_DEX = 769 EFFECT_ABYSSEA_VIT = 770 EFFECT_ABYSSEA_AGI = 771 EFFECT_ABYSSEA_INT = 772 EFFECT_ABYSSEA_MND = 773 EFFECT_ABYSSEA_CHR = 774 EFFECT_ABYSSEA_HP = 775 EFFECT_ABYSSEA_MP = 776 -- *Prowess increases not currently retail accurate. -- GoV Prowess bonus effects, real effect at ID 474 EFFECT_PROWESS_CASKET_RATE = 777 -- (Unimplemented) EFFECT_PROWESS_SKILL_RATE = 778 -- (Unimplemented) EFFECT_PROWESS_CRYSTAL_YEILD = 779 -- (Unimplemented) EFFECT_PROWESS_TH = 780 -- +1 per tier EFFECT_PROWESS_ATTACK_SPEED = 781 -- *flat 4% for now EFFECT_PROWESS_HP_MP = 782 -- Base 3% and another 1% per tier. EFFECT_PROWESS_ACC_RACC = 783 -- *flat 4% for now EFFECT_PROWESS_ATT_RATT = 784 -- *flat 4% for now EFFECT_PROWESS_MACC_MATK = 785 -- *flat 4% for now EFFECT_PROWESS_CURE_POTENCY = 786 -- *flat 4% for now EFFECT_PROWESS_WS_DMG = 787 -- (Unimplemented) 2% per tier. EFFECT_PROWESS_KILLER = 788 -- *flat +4 for now -- End GoV Prowess fakery EFFECT_FIELD_SUPPORT_FOOD = 789 -- Used by Fov/GoV food buff. EFFECT_MARK_OF_SEED = 790 -- Tracks 30 min timer in ACP mission "Those Who Lurk in Shadows (II)" EFFECT_ALL_MISS = 791 EFFECT_SUPER_BUFF = 792 EFFECT_NINJUTSU_ELE_DEBUFF = 793 EFFECT_HEALING = 794 EFFECT_LEAVEGAME = 795 EFFECT_HASTE_SAMBA_HASTE = 796 EFFECT_TELEPORT = 797 EFFECT_CHAINBOUND = 798 EFFECT_SKILLCHAIN = 799 EFFECT_DYNAMIS = 800 EFFECT_MEDITATE = 801 -- Dummy effect for SAM Meditate JA -- EFFECT_PLACEHOLDER = 802 -- Description -- 802-1022 -- EFFECT_PLACEHOLDER = 1023 -- The client dat file seems to have only this many "slots", results of exceeding that are untested. ---------------------------------- -- SC masks ---------------------------------- EFFECT_SKILLCHAIN0 = 0x200 EFFECT_SKILLCHAIN1 = 0x400 EFFECT_SKILLCHAIN2 = 0x800 EFFECT_SKILLCHAIN3 = 0x1000 EFFECT_SKILLCHAIN4 = 0x2000 EFFECT_SKILLCHAIN5 = 0x4000 EFFECT_SKILLCHAINMASK = 0x7C00 ------------------------------------ -- Effect Flags ------------------------------------ EFFECTFLAG_NONE = 0x0000 EFFECTFLAG_DISPELABLE = 0x0001 EFFECTFLAG_ERASABLE = 0x0002 EFFECTFLAG_ATTACK = 0x0004 EFFECTFLAG_DAMAGE = 0x0010 EFFECTFLAG_DEATH = 0x0020 EFFECTFLAG_MAGIC_BEGIN = 0x0040 EFFECTFLAG_MAGIC_END = 0x0080 EFFECTFLAG_ON_ZONE = 0x0100 EFFECTFLAG_NO_LOSS_MESSAGE = 0x0200 EFFECTFLAG_INVISIBLE = 0x0400 EFFECTFLAG_DETECTABLE = 0x0800 EFFECTFLAG_NO_REST = 0x1000 EFFECTFLAG_PREVENT_ACTION = 0x2000 EFFECTFLAG_WALTZABLE = 0x4000 EFFECTFLAG_FOOD = 0x8000 EFFECTFLAG_SONG = 0x10000 EFFECTFLAG_ROLL = 0x20000 ------------------------------------ function removeSleepEffects(target) target:delStatusEffect(EFFECT_SLEEP_I); target:delStatusEffect(EFFECT_SLEEP_II); target:delStatusEffect(EFFECT_LULLABY); end; function hasSleepEffects(target) if (target:hasStatusEffect(EFFECT_SLEEP_I) or target:hasStatusEffect(EFFECT_SLEEP_II) or target:hasStatusEffect(EFFECT_LULLABY)) then return true; end return false; end; ------------------------------------ -- These codes are the gateway to directly interacting with the pXI core program with status effects. -- These are NOT the actual status effects such as weakness or silence, -- but rather arbitrary codes chosen to represent different modifiers to the effected characters and mobs. -- -- Even if the particular mod is not completely (or at all) implemented yet, you can still script the effects using these codes. -- -- Example: target:getMod(MOD_STR) will get the sum of STR bonuses/penalties from gear, food, STR Etude, Absorb-STR, and any other STR-related buff/debuff. -- Note that the above will ignore base statistics, and that getStat() should be used for stats, Attack, and Defense, while getACC(), getRACC(), and getEVA() also exist. ------------------------------------ MOD_NONE = 0 MOD_DEF = 1 MOD_HP = 2 MOD_HPP = 3 MOD_CONVMPTOHP = 4 MOD_MP = 5 MOD_MPP = 6 MOD_CONVHPTOMP = 7 MOD_STR = 8 MOD_DEX = 9 MOD_VIT = 10 MOD_AGI = 11 MOD_INT = 12 MOD_MND = 13 MOD_CHR = 14 MOD_FIREDEF = 15 MOD_ICEDEF = 16 MOD_WINDDEF = 17 MOD_EARTHDEF = 18 MOD_THUNDERDEF = 19 MOD_WATERDEF = 20 MOD_LIGHTDEF = 21 MOD_DARKDEF = 22 MOD_ATT = 23 MOD_RATT = 24 MOD_ACC = 25 MOD_RACC = 26 MOD_ENMITY = 27 MOD_ENMITY_LOSS_REDUCTION = 502 MOD_MATT = 28 MOD_MDEF = 29 MOD_MACC = 30 MOD_MEVA = 31 MOD_FIREATT = 32 MOD_ICEATT = 33 MOD_WINDATT = 34 MOD_EARTHATT = 35 MOD_THUNDERATT = 36 MOD_WATERATT = 37 MOD_LIGHTATT = 38 MOD_DARKATT = 39 MOD_FIREACC = 40 MOD_ICEACC = 41 MOD_WINDACC = 42 MOD_EARTHACC = 43 MOD_THUNDERACC = 44 MOD_WATERACC = 45 MOD_LIGHTACC = 46 MOD_DARKACC = 47 MOD_WSACC = 48 MOD_SLASHRES = 49 MOD_PIERCERES = 50 MOD_IMPACTRES = 51 MOD_HTHRES = 52 MOD_FIRERES = 54 MOD_ICERES = 55 MOD_WINDRES = 56 MOD_EARTHRES = 57 MOD_THUNDERRES = 58 MOD_WATERRES = 59 MOD_LIGHTRES = 60 MOD_DARKRES = 61 MOD_ATTP = 62 MOD_DEFP = 63 MOD_ACCP = 64 MOD_EVAP = 65 MOD_RATTP = 66 MOD_RACCP = 67 MOD_EVA = 68 MOD_RDEF = 69 MOD_REVA = 70 MOD_MPHEAL = 71 MOD_HPHEAL = 72 MOD_STORETP = 73 MOD_HTH = 80 MOD_DAGGER = 81 MOD_SWORD = 82 MOD_GSWORD = 83 MOD_AXE = 84 MOD_GAXE = 85 MOD_SCYTHE = 86 MOD_POLEARM = 87 MOD_KATANA = 88 MOD_GKATANA = 89 MOD_CLUB = 90 MOD_STAFF = 91 MOD_AUTO_MELEE_SKILL = 101 MOD_AUTO_RANGED_SKILL = 102 MOD_AUTO_MAGIC_SKILL = 103 MOD_ARCHERY = 104 MOD_MARKSMAN = 105 MOD_THROW = 106 MOD_GUARD = 107 MOD_EVASION = 108 MOD_SHIELD = 109 MOD_PARRY = 110 MOD_DIVINE = 111 MOD_HEALING = 112 MOD_ENHANCE = 113 MOD_ENFEEBLE = 114 MOD_ELEM = 115 MOD_DARK = 116 MOD_SUMMONING = 117 MOD_NINJUTSU = 118 MOD_SINGING = 119 MOD_STRING = 120 MOD_WIND = 121 MOD_BLUE = 122 MOD_FISH = 127 MOD_WOOD = 128 MOD_SMITH = 129 MOD_GOLDSMITH = 130 MOD_CLOTH = 131 MOD_LEATHER = 132 MOD_BONE = 133 MOD_ALCHEMY = 134 MOD_COOK = 135 MOD_SYNERGY = 136 MOD_RIDING = 137 MOD_ANTIHQ_WOOD = 144 MOD_ANTIHQ_SMITH = 145 MOD_ANTIHQ_GOLDSMITH = 146 MOD_ANTIHQ_CLOTH = 147 MOD_ANTIHQ_LEATHER = 148 MOD_ANTIHQ_BONE = 149 MOD_ANTIHQ_ALCHEMY = 150 MOD_ANTIHQ_COOK = 151 MOD_DMG = 160 MOD_DMGPHYS = 161 MOD_DMGBREATH = 162 MOD_DMGMAGIC = 163 MOD_DMGRANGE = 164 MOD_UDMGPHYS = 387 MOD_UDMGBREATH = 388 MOD_UDMGMAGIC = 389 MOD_UDMGRANGE = 390 MOD_CRITHITRATE = 165 MOD_CRIT_DMG_INCREASE = 421 MOD_ENEMYCRITRATE = 166 MOD_MAGIC_CRITHITRATE = 562 MOD_MAGIC_CRIT_DMG_INCREASE = 563 MOD_HASTE_MAGIC = 167 MOD_SPELLINTERRUPT = 168 MOD_MOVE = 169 MOD_FASTCAST = 170 MOD_UFASTCAST = 407 MOD_CURE_CAST_TIME = 519 MOD_DELAY = 171 MOD_RANGED_DELAY = 172 MOD_MARTIAL_ARTS = 173 MOD_SKILLCHAINBONUS = 174 MOD_SKILLCHAINDMG = 175 MOD_FOOD_HPP = 176 MOD_FOOD_HP_CAP = 177 MOD_FOOD_MPP = 178 MOD_FOOD_MP_CAP = 179 MOD_FOOD_ATTP = 180 MOD_FOOD_ATT_CAP = 181 MOD_FOOD_DEFP = 182 MOD_FOOD_DEF_CAP = 183 MOD_FOOD_ACCP = 184 MOD_FOOD_ACC_CAP = 185 MOD_FOOD_RATTP = 186 MOD_FOOD_RATT_CAP = 187 MOD_FOOD_RACCP = 188 MOD_FOOD_RACC_CAP = 189 MOD_VERMIN_KILLER = 224 MOD_BIRD_KILLER = 225 MOD_AMORPH_KILLER = 226 MOD_LIZARD_KILLER = 227 MOD_AQUAN_KILLER = 228 MOD_PLANTOID_KILLER = 229 MOD_BEAST_KILLER = 230 MOD_UNDEAD_KILLER = 231 MOD_ARCANA_KILLER = 232 MOD_DRAGON_KILLER = 233 MOD_DEMON_KILLER = 234 MOD_EMPTY_KILLER = 235 MOD_HUMANOID_KILLER = 236 MOD_LUMORIAN_KILLER = 237 MOD_LUMINION_KILLER = 238 MOD_SLEEPRES = 240 MOD_POISONRES = 241 MOD_PARALYZERES = 242 MOD_BLINDRES = 243 MOD_SILENCERES = 244 MOD_VIRUSRES = 245 MOD_PETRIFYRES = 246 MOD_BINDRES = 247 MOD_CURSERES = 248 MOD_GRAVITYRES = 249 MOD_SLOWRES = 250 MOD_STUNRES = 251 MOD_CHARMRES = 252 MOD_AMNESIARES = 253 MOD_LULLABYRES = 254 MOD_DEATHRES = 255 MOD_PARALYZE = 257 MOD_MIJIN_GAKURE = 258 MOD_DUAL_WIELD = 259 MOD_DOUBLE_ATTACK = 288 MOD_SUBTLE_BLOW = 289 MOD_COUNTER = 291 MOD_KICK_ATTACK = 292 MOD_AFFLATUS_SOLACE = 293 MOD_AFFLATUS_MISERY = 294 MOD_CLEAR_MIND = 295 MOD_CONSERVE_MP = 296 MOD_STEAL = 298 MOD_BLINK = 299 MOD_STONESKIN = 300 MOD_PHALANX = 301 MOD_TRIPLE_ATTACK = 302 MOD_TREASURE_HUNTER = 303 MOD_TAME = 304 MOD_RECYCLE = 305 MOD_ZANSHIN = 306 MOD_UTSUSEMI = 307 MOD_NINJA_TOOL = 308 MOD_BLUE_POINTS = 309 MOD_DMG_REFLECT = 316 MOD_ROLL_ROGUES = 317 MOD_ROLL_GALLANTS = 318 MOD_ROLL_CHAOS = 319 MOD_ROLL_BEAST = 320 MOD_ROLL_CHORAL = 321 MOD_ROLL_HUNTERS = 322 MOD_ROLL_SAMURAI = 323 MOD_ROLL_NINJA = 324 MOD_ROLL_DRACHEN = 325 MOD_ROLL_EVOKERS = 326 MOD_ROLL_MAGUS = 327 MOD_ROLL_CORSAIRS = 328 MOD_ROLL_PUPPET = 329 MOD_ROLL_DANCERS = 330 MOD_ROLL_SCHOLARS = 331 MOD_BUST = 332 MOD_FINISHING_MOVES = 333 MOD_SAMBA_DURATION = 490 -- Samba duration bonus MOD_WALTZ_POTENTCY = 491 -- Waltz Potentcy Bonus MOD_CHOCO_JIG_DURATION = 492 -- Chocobo Jig duration bonus MOD_VFLOURISH_MACC = 493 -- Violent Flourish accuracy bonus MOD_STEP_FINISH = 494 -- Bonus finishing moves from steps MOD_STEP_ACCURACY = 403 -- Accuracy bonus for steps MOD_SPECTRAL_JIG = 495 -- Spectral Jig duration modifier (percent increase) MOD_WALTZ_RECAST = 497 -- Waltz recast modifier (percent) MOD_SAMBA_PDURATION = 498 -- Samba percent duration bonus MOD_WIDESCAN = 340 MOD_BARRAGE_ACC = 420 -- MOD_ENSPELL = 341 MOD_SPIKES = 342 MOD_ENSPELL_DMG = 343 MOD_SPIKES_DMG = 344 MOD_TP_BONUS = 345 MOD_PERPETUATION_REDUCTION = 346 MOD_FIRE_AFFINITY_DMG = 347 MOD_EARTH_AFFINITY_DMG = 348 MOD_WATER_AFFINITY_DMG = 349 MOD_ICE_AFFINITY_DMG = 350 MOD_THUNDER_AFFINITY_DMG = 351 MOD_WIND_AFFINITY_DMG = 352 MOD_LIGHT_AFFINITY_DMG = 353 MOD_DARK_AFFINITY_DMG = 354 MOD_ALL_AFFINITY_DMG = 543 MOD_FIRE_AFFINITY_ACC = 544 MOD_EARTH_AFFINITY_ACC = 545 MOD_WATER_AFFINITY_ACC = 546 MOD_ICE_AFFINITY_ACC = 547 MOD_THUNDER_AFFINITY_ACC = 548 MOD_WIND_AFFINITY_ACC = 549 MOD_LIGHT_AFFINITY_ACC = 550 MOD_DARK_AFFINITY_ACC = 551 MOD_ALL_AFFINITY_ACC = 552 MOD_FIRE_AFFINITY_PERP = 553 MOD_EARTH_AFFINITY_PERP = 554 MOD_WATER_AFFINITY_PERP = 555 MOD_ICE_AFFINITY_PERP = 556 MOD_THUNDER_AFFINITY_PERP = 557 MOD_WIND_AFFINITY_PERP = 558 MOD_LIGHT_AFFINITY_PERP = 559 MOD_DARK_AFFINITY_PERP = 560 MOD_ALL_AFFINITY_PERP = 561 MOD_ADDS_WEAPONSKILL = 355 MOD_ADDS_WEAPONSKILL_DYN = 356 MOD_BP_DELAY = 357 MOD_STEALTH = 358 MOD_RAPID_SHOT = 359 MOD_CHARM_TIME = 360 MOD_JUMP_TP_BONUS = 361 MOD_JUMP_ATT_BONUS = 362 MOD_HIGH_JUMP_ENMITY_REDUCTION = 363 MOD_REWARD_HP_BONUS = 364 MOD_SNAP_SHOT = 365 MOD_MAIN_DMG_RATING = 366 MOD_SUB_DMG_RATING = 367 MOD_REGAIN = 368 MOD_REFRESH = 369 MOD_REGEN = 370 MOD_AVATAR_PERPETUATION = 371 MOD_WEATHER_REDUCTION = 372 MOD_DAY_REDUCTION = 373 MOD_CURE_POTENCY = 374 MOD_CURE_POTENCY_RCVD = 375 MOD_DELAYP = 380 MOD_RANGED_DELAYP = 381 MOD_EXP_BONUS = 382 MOD_HASTE_ABILITY = 383 MOD_HASTE_GEAR = 384 MOD_SHIELD_BASH = 385 MOD_KICK_DMG = 386 MOD_CHARM_CHANCE = 391 MOD_WEAPON_BASH = 392 MOD_BLACK_MAGIC_COST = 393 MOD_WHITE_MAGIC_COST = 394 MOD_BLACK_MAGIC_CAST = 395 MOD_WHITE_MAGIC_CAST = 396 MOD_BLACK_MAGIC_RECAST = 397 MOD_WHITE_MAGIC_RECAST = 398 MOD_ALACRITY_CELERITY_EFFECT = 399 MOD_LIGHT_ARTS_EFFECT = 334 MOD_DARK_ARTS_EFFECT = 335 MOD_LIGHT_ARTS_SKILL = 336 MOD_DARK_ARTS_SKILL = 337 MOD_REGEN_EFFECT = 338 MOD_REGEN_DURATION = 339 MOD_HELIX_EFFECT = 478 MOD_HELIX_DURATION = 477 MOD_STORMSURGE_EFFECT = 400 MOD_SUBLIMATION_BONUS = 401 MOD_GRIMOIRE_SPELLCASTING = 489 -- "Grimoire: Reduces spellcasting time" bonus MOD_WYVERN_BREATH = 402 MOD_REGEN_DOWN = 404 -- poison MOD_REFRESH_DOWN = 405 -- plague, reduce mp MOD_REGAIN_DOWN = 406 -- plague, reduce tp MOD_MAGIC_DAMAGE = 311 -- Magic damage added directly to the spell's base damage -- Gear set modifiers MOD_DA_DOUBLE_DAMAGE = 408 -- Double attack's double damage chance %. MOD_TA_TRIPLE_DAMAGE = 409 -- Triple attack's triple damage chance %. MOD_ZANSHIN_DOUBLE_DAMAGE = 410 -- Zanshin's double damage chance %. MOD_RAPID_SHOT_DOUBLE_DAMAGE = 479 -- Rapid shot's double damage chance %. MOD_ABSORB_DMG_CHANCE = 480 -- Chance to absorb damage % MOD_EXTRA_DUAL_WIELD_ATTACK = 481 -- Chance to land an extra attack when dual wielding MOD_EXTRA_KICK_ATTACK = 482 -- Occasionally allows a second Kick Attack during an attack round without the use of Footwork. MOD_SAMBA_DOUBLE_DAMAGE = 415 -- Double damage chance when samba is up. MOD_NULL_PHYSICAL_DAMAGE = 416 -- Chance to null physical damage. MOD_QUICK_DRAW_TRIPLE_DAMAGE = 417 -- Chance to do triple damage with quick draw. MOD_BAR_ELEMENT_NULL_CHANCE = 418 -- Bar Elemental spells will occasionally nullify damage of the same element. MOD_GRIMOIRE_INSTANT_CAST = 419 -- Spells that match your current Arts will occasionally cast instantly, without recast. MOD_DOUBLE_SHOT_RATE = 422 -- The rate that double shot can proc MOD_VELOCITY_SNAPSHOT_BONUS = 423 -- Increases Snapshot whilst Velocity Shot is up. MOD_VELOCITY_RATT_BONUS = 424 -- Increases Ranged Attack whilst Velocity Shot is up. MOD_SHADOW_BIND_EXT = 425 -- Extends the time of shadowbind MOD_ABSORB_PHYSDMG_TO_MP = 426 -- Absorbs a percentage of physical damage taken to MP. MOD_ENMITY_REDUCTION_PHYSICAL = 427 -- Reduces Enmity decrease when taking physical damage MOD_SHIELD_MASTERY_TP = 485 -- Shield mastery TP bonus when blocking with a shield MOD_PERFECT_COUNTER_ATT = 428 -- Raises weapon damage by 20 when countering while under the Perfect Counter effect. This also affects Weapon Rank (though not if fighting barehanded). MOD_FOOTWORK_ATT_BONUS = 429 -- Raises the attack bonus of Footwork. (Tantra Gaiters +2 raise 100/1024 to 152/1024) MOD_MINNE_EFFECT = 433 -- MOD_MINUET_EFFECT = 434 -- MOD_PAEON_EFFECT = 435 -- MOD_REQUIEM_EFFECT = 436 -- MOD_THRENODY_EFFECT = 437 -- MOD_MADRIGAL_EFFECT = 438 -- MOD_MAMBO_EFFECT = 439 -- MOD_LULLABY_EFFECT = 440 -- MOD_ETUDE_EFFECT = 441 -- MOD_BALLAD_EFFECT = 442 -- MOD_MARCH_EFFECT = 443 -- MOD_FINALE_EFFECT = 444 -- MOD_CAROL_EFFECT = 445 -- MOD_MAZURKA_EFFECT = 446 -- MOD_ELEGY_EFFECT = 447 -- MOD_PRELUDE_EFFECT = 448 -- MOD_HYMNUS_EFFECT = 449 -- MOD_VIRELAI_EFFECT = 450 -- MOD_SCHERZO_EFFECT = 451 -- MOD_ALL_SONGS_EFFECT = 452 -- MOD_MAXIMUM_SONGS_BONUS = 453 -- MOD_SONG_DURATION_BONUS = 454 -- MOD_QUICK_DRAW_DMG = 411 -- MOD_QUAD_ATTACK = 430 -- Quadruple attack chance. MOD_ADDITIONAL_EFFECT = 431 -- All additional effects MOD_ENSPELL_DMG_BONUS = 432 MOD_FIRE_ABSORB = 459 -- MOD_EARTH_ABSORB = 460 -- MOD_WATER_ABSORB = 461 -- MOD_WIND_ABSORB = 462 -- MOD_ICE_ABSORB = 463 -- MOD_LTNG_ABSORB = 464 -- MOD_LIGHT_ABSORB = 465 -- MOD_DARK_ABSORB = 466 -- MOD_FIRE_NULL = 467 -- MOD_EARTH_NULL = 468 -- MOD_WATER_NULL = 469 -- MOD_WIND_NULL = 470 -- MOD_ICE_NULL = 471 -- MOD_LTNG_NULL = 472 -- MOD_LIGHT_NULL = 473 -- MOD_DARK_NULL = 474 -- MOD_MAGIC_ABSORB = 475 -- MOD_MAGIC_NULL = 476 -- MOD_PHYS_ABSORB = 512 -- MOD_ABSORB_DMG_TO_MP = 516 -- Unlike PLD gear mod, works on all damage types (Ethereal Earring) MOD_WARCRY_DURATION = 483 -- Warcy duration bonus from gear MOD_AUSPICE_EFFECT = 484 -- Auspice Subtle Blow Bonus MOD_TACTICAL_PARRY = 486 -- Tactical Parry TP Bonus MOD_MAG_BURST_BONUS = 487 -- Magic Burst Bonus MOD_INHIBIT_TP = 488 -- Inhibits TP Gain (percent) MOD_GOV_CLEARS = 496 -- Tracks GoV page completion (for 4% bonus on rewards). -- Reraise (Auto Reraise, will be used by ATMA) MOD_RERAISE_I = 456 -- Reraise. MOD_RERAISE_II = 457 -- Reraise II. MOD_RERAISE_III = 458 -- Reraise III. MOD_ITEM_SPIKES_TYPE = 499 -- Type spikes an item has MOD_ITEM_SPIKES_DMG = 500 -- Damage of an items spikes MOD_ITEM_SPIKES_CHANCE = 501 -- Chance of an items spike proc MOD_FERAL_HOWL_DURATION = 503 -- +20% duration per merit when wearing augmented Monster Jackcoat +2 MOD_MANEUVER_BONUS = 504 -- Maneuver Stat Bonus MOD_OVERLOAD_THRESH = 505 -- Overload Threshold Bonus MOD_EXTRA_DMG_CHANCE = 506 -- Proc rate of MOD_OCC_DO_EXTRA_DMG. 111 would be 11.1% MOD_OCC_DO_EXTRA_DMG = 507 -- Multiplier for "Occasionally do x times normal damage". 250 would be 2.5 times damage. MOD_EAT_RAW_FISH = 412 -- MOD_EAT_RAW_MEAT = 413 -- MOD_ENHANCES_CURSNA = 310 -- Raises success rate of Cursna when removing effect (like Doom) that are not 100% chance to remove MOD_RETALIATION = 414 -- Increases damage of Retaliation hits MOD_AUGMENTS_THIRD_EYE = 508 -- Adds counter to 3rd eye anticipates & if using Seigan counter rate is increased by 15% MOD_CLAMMING_IMPROVED_RESULTS = 509 -- MOD_CLAMMING_REDUCED_INCIDENTS = 510 -- MOD_CHOCOBO_RIDING_TIME = 511 -- Increases chocobo riding time MOD_HARVESTING_RESULT = 513 -- Improves harvesting results MOD_LOGGING_RESULT = 514 -- Improves logging results MOD_MINNING_RESULT = 515 -- Improves mining results MOD_EGGHELM = 517 -- Egg Helm (Chocobo Digging) MOD_SHIELDBLOCKRATE = 518 -- Affects shield block rate, percent based MOD_SCAVENGE_EFFECT = 312 -- MOD_DIA_DOT = 313 -- Increases the DoT damage of Dia MOD_SHARPSHOT = 314 -- Sharpshot accuracy bonus MOD_ENH_DRAIN_ASPIR = 315 -- % damage boost to Drain and Aspir MOD_TRICK_ATK_AGI = 520 -- % AGI boost to Trick Attack (if gear mod, needs to be equipped on hit) MOD_NIN_NUKE_BONUS = 522 -- magic attack bonus for NIN nukes MOD_AMMO_SWING = 523 -- Extra swing rate w/ ammo (ie. Jailer weapons). Use gearsets, and does nothing for non-players. MOD_ROLL_RANGE = 528 -- Additional range for COR roll abilities. MOD_ENHANCES_REFRESH = 529 -- "Enhances Refresh" adds +1 per modifier to spell's tick result. MOD_NO_SPELL_MP_DEPLETION = 530 -- % to not deplete MP on spellcast. MOD_FORCE_FIRE_DWBONUS = 531 -- Set to 1 to force fire day/weather spell bonus/penalty. Do not have it total more than 1. MOD_FORCE_EARTH_DWBONUS = 532 -- Set to 1 to force earth day/weather spell bonus/penalty. Do not have it total more than 1. MOD_FORCE_WATER_DWBONUS = 533 -- Set to 1 to force water day/weather spell bonus/penalty. Do not have it total more than 1. MOD_FORCE_WIND_DWBONUS = 534 -- Set to 1 to force wind day/weather spell bonus/penalty. Do not have it total more than 1. MOD_FORCE_ICE_DWBONUS = 535 -- Set to 1 to force ice day/weather spell bonus/penalty. Do not have it total more than 1. MOD_FORCE_LIGHTNING_DWBONUS = 536 -- Set to 1 to force lightning day/weather spell bonus/penalty. Do not have it total more than 1. MOD_FORCE_LIGHT_DWBONUS = 537 -- Set to 1 to force light day/weather spell bonus/penalty. Do not have it total more than 1. MOD_FORCE_DARK_DWBONUS = 538 -- Set to 1 to force dark day/weather spell bonus/penalty. Do not have it total more than 1. MOD_STONESKIN_BONUS_HP = 539 -- Bonus "HP" granted to Stoneskin spell. MOD_ENHANCES_ELEMENTAL_SIPHON = 540 -- Bonus Base MP added to Elemental Siphon skill. MOD_BP_DELAY_II = 541 -- Blood Pact Delay Reduction II MOD_JOB_BONUS_CHANCE = 542 -- Chance to apply job bonus to COR roll without having the job in the party. -- Mythic Weapon Mods MOD_AUGMENTS_ABSORB = 521 -- Direct Absorb spell increase while Liberator is equipped (percentage based) MOD_AOE_NA = 524 -- Set to 1 to make -na spells/erase always AoE w/ Divine Veil MOD_AUGMENTS_CONVERT = 525 -- Convert HP to MP Ratio Multiplier. Value = MP multiplier rate. MOD_AUGMENTS_SA = 526 -- Adds Critical Attack Bonus to Sneak Attack, percentage based. MOD_AUGMENTS_TA = 527 -- Adds Critical Attack Bonus to Trick Attack, percentage based. MOD_JUG_LEVEL_RANGE = 564 -- Decreases the level range of spawned jug pets. Maxes out at 2. -- The entire mod list is in desperate need of kind of some organizing. -- The spares take care of finding the next ID to use so long as we don't forget to list IDs that have been freed up by refactoring. -- MOD_SPARE = 92, -- stuff -- MOD_SPARE = 93, -- stuff -- MOD_SPARE = 94, -- stuff -- MOD_SPARE = 95, -- stuff -- MOD_SPARE = 96, -- stuff -- MOD_SPARE = 97, -- stuff -- MOD_SPARE = 98, -- stuff -- MOD_SPARE = 99, -- stuff -- MOD_SPARE = 100, -- stuff -- MOD_SPARE = 565, -- stuff -- MOD_SPARE = 566, -- stuff ------------------------------------ -- Merit Definitions ------------------------------------ MCATEGORY_HP_MP = 0x0040 MCATEGORY_ATTRIBUTES = 0x0080 MCATEGORY_COMBAT = 0x00C0 MCATEGORY_MAGIC = 0x0100 MCATEGORY_OTHERS = 0x0140 MCATEGORY_WAR_1 = 0x0180 MCATEGORY_MNK_1 = 0x01C0 MCATEGORY_WHM_1 = 0x0200 MCATEGORY_BLM_1 = 0x0240 MCATEGORY_RDM_1 = 0x0280 MCATEGORY_THF_1 = 0x02C0 MCATEGORY_PLD_1 = 0x0300 MCATEGORY_DRK_1 = 0x0340 MCATEGORY_BST_1 = 0x0380 MCATEGORY_BRD_1 = 0x03C0 MCATEGORY_RNG_1 = 0x0400 MCATEGORY_SAM_1 = 0x0440 MCATEGORY_NIN_1 = 0x0480 MCATEGORY_DRG_1 = 0x04C0 MCATEGORY_SMN_1 = 0x0500 MCATEGORY_BLU_1 = 0x0540 MCATEGORY_COR_1 = 0x0580 MCATEGORY_PUP_1 = 0x05C0 MCATEGORY_DNC_1 = 0x0600 MCATEGORY_SCH_1 = 0x0640 MCATEGORY_WS = 0x0680 MCATEGORY_UNK_0 = 0x06C0 MCATEGORY_UNK_1 = 0x0700 MCATEGORY_UNK_2 = 0x0740 MCATEGORY_UNK_3 = 0x0780 MCATEGORY_UNK_4 = 0x07C0 MCATEGORY_WAR_2 = 0x0800 MCATEGORY_MNK_2 = 0x0840 MCATEGORY_WHM_2 = 0x0880 MCATEGORY_BLM_2 = 0x08C0 MCATEGORY_RDM_2 = 0x0900 MCATEGORY_THF_2 = 0x0940 MCATEGORY_PLD_2 = 0x0980 MCATEGORY_DRK_2 = 0x09C0 MCATEGORY_BST_2 = 0x0A00 MCATEGORY_BRD_2 = 0x0A40 MCATEGORY_RNG_2 = 0x0A80 MCATEGORY_SAM_2 = 0x0AC0 MCATEGORY_NIN_2 = 0x0B00 MCATEGORY_DRG_2 = 0x0B40 MCATEGORY_SMN_2 = 0x0B80 MCATEGORY_BLU_2 = 0x0BC0 MCATEGORY_COR_2 = 0x0C00 MCATEGORY_PUP_2 = 0x0C40 MCATEGORY_DNC_2 = 0x0C80 MCATEGORY_SCH_2 = 0x0CC0 MCATEGORY_START = 0x0040 MCATEGORY_COUNT = 0x0D00 --HP MERIT_MAX_HP = MCATEGORY_HP_MP + 0x00 MERIT_MAX_MP = MCATEGORY_HP_MP + 0x02 --ATTRIBUTES MERIT_STR = MCATEGORY_ATTRIBUTES + 0x00 MERIT_DEX = MCATEGORY_ATTRIBUTES + 0x02 MERIT_VIT = MCATEGORY_ATTRIBUTES + 0x04 MERIT_AGI = MCATEGORY_ATTRIBUTES + 0x08 MERIT_INT = MCATEGORY_ATTRIBUTES + 0x0A MERIT_MND = MCATEGORY_ATTRIBUTES + 0x0C MERIT_CHR = MCATEGORY_ATTRIBUTES + 0x0E --COMBAT SKILLS MERIT_H2H = MCATEGORY_COMBAT + 0x00 MERIT_DAGGER = MCATEGORY_COMBAT + 0x02 MERIT_SWORD = MCATEGORY_COMBAT + 0x04 MERIT_GSWORD = MCATEGORY_COMBAT + 0x06 MERIT_AXE = MCATEGORY_COMBAT + 0x08 MERIT_GAXE = MCATEGORY_COMBAT + 0x0A MERIT_SCYTHE = MCATEGORY_COMBAT + 0x0C MERIT_POLEARM = MCATEGORY_COMBAT + 0x0E MERIT_KATANA = MCATEGORY_COMBAT + 0x10 MERIT_GKATANA = MCATEGORY_COMBAT + 0x12 MERIT_CLUB = MCATEGORY_COMBAT + 0x14 MERIT_STAFF = MCATEGORY_COMBAT + 0x16 MERIT_ARCHERY = MCATEGORY_COMBAT + 0x18 MERIT_MARKSMANSHIP = MCATEGORY_COMBAT + 0x1A MERIT_THROWING = MCATEGORY_COMBAT + 0x1C MERIT_GUARDING = MCATEGORY_COMBAT + 0x1E MERIT_EVASION = MCATEGORY_COMBAT + 0x20 MERIT_SHIELD = MCATEGORY_COMBAT + 0x22 MERIT_PARRYING = MCATEGORY_COMBAT + 0x24 --MAGIC SKILLS MERIT_DIVINE = MCATEGORY_MAGIC + 0x00 MERIT_HEALING = MCATEGORY_MAGIC + 0x02 MERIT_ENHANCING = MCATEGORY_MAGIC + 0x04 MERIT_ENFEEBLING = MCATEGORY_MAGIC + 0x06 MERIT_ELEMENTAL = MCATEGORY_MAGIC + 0x08 MERIT_DARK = MCATEGORY_MAGIC + 0x0A MERIT_SUMMONING = MCATEGORY_MAGIC + 0x0C MERIT_NINJITSU = MCATEGORY_MAGIC + 0x0E MERIT_SINGING = MCATEGORY_MAGIC + 0x10 MERIT_STRING = MCATEGORY_MAGIC + 0x12 MERIT_WIND = MCATEGORY_MAGIC + 0x14 MERIT_BLUE = MCATEGORY_MAGIC + 0x16 --OTHERS MERIT_ENMITY_INCREASE = MCATEGORY_OTHERS + 0x00 MERIT_ENMITY_DECREASE = MCATEGORY_OTHERS + 0x02 MERIT_CRIT_HIT_RATE = MCATEGORY_OTHERS + 0x04 MERIT_ENEMY_CRIT_RATE = MCATEGORY_OTHERS + 0x06 MERIT_SPELL_INTERUPTION_RATE = MCATEGORY_OTHERS + 0x08 --WAR 1 MERIT_BERSERK_RECAST = MCATEGORY_WAR_1 + 0x00 MERIT_DEFENDER_RECAST = MCATEGORY_WAR_1 + 0x02 MERIT_WARCRY_RECAST = MCATEGORY_WAR_1 + 0x04 MERIT_AGGRESSOR_RECAST = MCATEGORY_WAR_1 + 0x06 MERIT_DOUBLE_ATTACK_RATE = MCATEGORY_WAR_1 + 0x08 --MNK 1 MERIT_FOCUS_RECAST = MCATEGORY_MNK_1 + 0x00 MERIT_DODGE_RECAST = MCATEGORY_MNK_1 + 0x02 MERIT_CHAKRA_RECAST = MCATEGORY_MNK_1 + 0x04 MERIT_COUNTER_RATE = MCATEGORY_MNK_1 + 0x06 MERIT_KICK_ATTACK_RATE = MCATEGORY_MNK_1 + 0x08 --WHM 1 MERIT_DIVINE_SEAL_RECAST = MCATEGORY_WHM_1 + 0x00 MERIT_CURE_CAST_TIME = MCATEGORY_WHM_1 + 0x02 MERIT_BAR_SPELL_EFFECT = MCATEGORY_WHM_1 + 0x04 MERIT_BANISH_EFFECT = MCATEGORY_WHM_1 + 0x06 MERIT_REGEN_EFFECT = MCATEGORY_WHM_1 + 0x08 --BLM 1 MERIT_ELEMENTAL_SEAL_RECAST = MCATEGORY_BLM_1 + 0x00 MERIT_FIRE_MAGIC_POTENCY = MCATEGORY_BLM_1 + 0x02 MERIT_ICE_MAGIC_POTENCY = MCATEGORY_BLM_1 + 0x04 MERIT_WIND_MAGIC_POTENCY = MCATEGORY_BLM_1 + 0x06 MERIT_EARTH_MAGIC_POTENCY = MCATEGORY_BLM_1 + 0x08 MERIT_LIGHTNING_MAGIC_POTENCY = MCATEGORY_BLM_1 + 0x0A MERIT_WATER_MAGIC_POTENCY = MCATEGORY_BLM_1 + 0x0C --RDM 1 MERIT_CONVERT_RECAST = MCATEGORY_RDM_1 + 0x00 MERIT_FIRE_MAGIC_ACCURACY = MCATEGORY_RDM_1 + 0x02 MERIT_ICE_MAGIC_ACCURACY = MCATEGORY_RDM_1 + 0x04 MERIT_WIND_MAGIC_ACCURACY = MCATEGORY_RDM_1 + 0x06 MERIT_EARTH_MAGIC_ACCURACY = MCATEGORY_RDM_1 + 0x08 MERIT_LIGHTNING_MAGIC_ACCURACY = MCATEGORY_RDM_1 + 0x0A MERIT_WATER_MAGIC_ACCURACY = MCATEGORY_RDM_1 + 0x0C --THF 1 MERIT_FLEE_RECAST = MCATEGORY_THF_1 + 0x00 MERIT_HIDE_RECAST = MCATEGORY_THF_1 + 0x02 MERIT_SNEAK_ATTACK_RECAST = MCATEGORY_THF_1 + 0x04 MERIT_TRICK_ATTACK_RECAST = MCATEGORY_THF_1 + 0x06 MERIT_TRIPLE_ATTACK_RATE = MCATEGORY_THF_1 + 0x08 --PLD 1 MERIT_SHIELD_BASH_RECAST = MCATEGORY_PLD_1 + 0x00 MERIT_HOLY_CIRCLE_RECAST = MCATEGORY_PLD_1 + 0x02 MERIT_SENTINEL_RECAST = MCATEGORY_PLD_1 + 0x04 MERIT_COVER_EFFECT_LENGTH = MCATEGORY_PLD_1 + 0x06 MERIT_RAMPART_RECAST = MCATEGORY_PLD_1 + 0x08 --DRK 1 MERIT_SOULEATER_RECAST = MCATEGORY_DRK_1 + 0x00 MERIT_ARCANE_CIRCLE_RECAST = MCATEGORY_DRK_1 + 0x02 MERIT_LAST_RESORT_RECAST = MCATEGORY_DRK_1 + 0x04 MERIT_LAST_RESORT_EFFECT = MCATEGORY_DRK_1 + 0x06 MERIT_WEAPON_BASH_EFFECT = MCATEGORY_DRK_1 + 0x08 --BST 1 MERIT_KILLER_EFFECTS = MCATEGORY_BST_1 + 0x00 MERIT_REWARD_RECAST = MCATEGORY_BST_1 + 0x02 MERIT_CALL_BEAST_RECAST = MCATEGORY_BST_1 + 0x04 MERIT_SIC_RECAST = MCATEGORY_BST_1 + 0x06 MERIT_TAME_RECAST = MCATEGORY_BST_1 + 0x08 --BRD 1 MERIT_LULLABY_RECAST = MCATEGORY_BRD_1 + 0x00 MERIT_FINALE_RECAST = MCATEGORY_BRD_1 + 0x02 MERIT_MINNE_EFFECT = MCATEGORY_BRD_1 + 0x04 MERIT_MINUET_EFFECT = MCATEGORY_BRD_1 + 0x06 MERIT_MADRIGAL_EFFECT = MCATEGORY_BRD_1 + 0x08 --RNG 1 MERIT_SCAVENGE_EFFECT = MCATEGORY_RNG_1 + 0x00 MERIT_CAMOUFLAGE_RECAST = MCATEGORY_RNG_1 + 0x02 MERIT_SHARPSHOT_RECAST = MCATEGORY_RNG_1 + 0x04 MERIT_UNLIMITED_SHOT_RECAST = MCATEGORY_RNG_1 + 0x06 MERIT_RAPID_SHOT_RATE = MCATEGORY_RNG_1 + 0x08 --SAM 1 MERIT_THIRD_EYE_RECAST = MCATEGORY_SAM_1 + 0x00 MERIT_WARDING_CIRCLE_RECAST = MCATEGORY_SAM_1 + 0x02 MERIT_STORE_TP_EFFECT = MCATEGORY_SAM_1 + 0x04 MERIT_MEDITATE_RECAST = MCATEGORY_SAM_1 + 0x06 MERIT_ZASHIN_ATTACK_RATE = MCATEGORY_SAM_1 + 0x08 --NIN 1 MERIT_SUBTLE_BLOW_EFFECT = MCATEGORY_NIN_1 + 0x00 MERIT_KATON_EFFECT = MCATEGORY_NIN_1 + 0x02 MERIT_HYOTON_EFFECT = MCATEGORY_NIN_1 + 0x04 MERIT_HUTON_EFFECT = MCATEGORY_NIN_1 + 0x06 MERIT_DOTON_EFFECT = MCATEGORY_NIN_1 + 0x08 MERIT_RAITON_EFFECT = MCATEGORY_NIN_1 + 0x0A MERIT_SUITON_EFFECT = MCATEGORY_NIN_1 + 0x0C --DRG 1 MERIT_ANCIENT_CIRCLE_RECAST = MCATEGORY_DRG_1 + 0x00 MERIT_JUMP_RECAST = MCATEGORY_DRG_1 + 0x02 MERIT_HIGH_JUMP_RECAST = MCATEGORY_DRG_1 + 0x04 MERIT_SUPER_JUMP_RECAST = MCATEGORY_DRG_1 + 0x05 MERIT_SPIRIT_LINK_RECAST = MCATEGORY_DRG_1 + 0x08 --SMN 1 MERIT_AVATAR_PHYSICAL_ACCURACY = MCATEGORY_SMN_1 + 0x00 MERIT_AVATAR_PHYSICAL_ATTACK = MCATEGORY_SMN_1 + 0x02 MERIT_AVATAR_MAGICAL_ACCURACY = MCATEGORY_SMN_1 + 0x04 MERIT_AVATAR_MAGICAL_ATTACK = MCATEGORY_SMN_1 + 0x06 MERIT_SUMMONING_MAGIC_CAST_TIME = MCATEGORY_SMN_1 + 0x08 --BLU 1 MERIT_CHAIN_AFFINITY_RECAST = MCATEGORY_BLU_1 + 0x00 MERIT_BURST_AFFINITY_RECAST = MCATEGORY_BLU_1 + 0x02 MERIT_MONSTER_CORRELATION = MCATEGORY_BLU_1 + 0x04 MERIT_PHYSICAL_POTENCY = MCATEGORY_BLU_1 + 0x06 MERIT_MAGICAL_ACCURACY = MCATEGORY_BLU_1 + 0x08 --COR 1 MERIT_PHANTOM_ROLL_RECAST = MCATEGORY_COR_1 + 0x00 MERIT_QUICK_DRAW_RECAST = MCATEGORY_COR_1 + 0x02 MERIT_QUICK_DRAW_ACCURACY = MCATEGORY_COR_1 + 0x04 MERIT_RANDOM_DEAL_RECAST = MCATEGORY_COR_1 + 0x06 MERIT_BUST_DURATION = MCATEGORY_COR_1 + 0x08 --PUP 1 MERIT_AUTOMATION_MELEE_SKILL = MCATEGORY_PUP_1 + 0x00 MERIT_AUTOMATION_RANGED_SKILL = MCATEGORY_PUP_1 + 0x02 MERIT_AUTOMATION_MAGIC_SKILL = MCATEGORY_PUP_1 + 0x04 MERIT_ACTIVATE_RECAST = MCATEGORY_PUP_1 + 0x06 MERIT_REPAIR_RECAST = MCATEGORY_PUP_1 + 0x08 --DNC 1 MERIT_STEP_ACCURACY = MCATEGORY_DNC_1 + 0x00 MERIT_HASTE_SAMBA_EFFECT = MCATEGORY_DNC_1 + 0x02 MERIT_REVERSE_FLOURISH_EFFECT = MCATEGORY_DNC_1 + 0x04 MERIT_BUILDING_FLOURISH_EFFECT = MCATEGORY_DNC_1 + 0x06 --SCH 1 MERIT_GRIMOIRE_RECAST = MCATEGORY_SCH_1 + 0x00 MERIT_MODUS_VERITAS_DURATION = MCATEGORY_SCH_1 + 0x02 MERIT_HELIX_MAGIC_ACC_ATT = MCATEGORY_SCH_1 + 0x04 MERIT_MAX_SUBLIMATION = MCATEGORY_SCH_1 + 0x06 --WEAPON SKILLS MERIT_SHIJIN_SPIRAL = MCATEGORY_WS + 0x00 MERIT_EXENTERATOR = MCATEGORY_WS + 0x02 MERIT_REQUIESCAT = MCATEGORY_WS + 0x04 MERIT_RESOLUTION = MCATEGORY_WS + 0x06 MERIT_RUINATOR = MCATEGORY_WS + 0x08 MERIT_UPHEAVAL = MCATEGORY_WS + 0x0A MERIT_ENTROPY = MCATEGORY_WS + 0x0C MERIT_STARDIVER = MCATEGORY_WS + 0x0E MERIT_BLADE_SHUN = MCATEGORY_WS + 0x10 MERIT_TACHI_SHOHA = MCATEGORY_WS + 0x12 MERIT_REALMRAZER = MCATEGORY_WS + 0x14 MERIT_SHATTERSOUL = MCATEGORY_WS + 0x16 MERIT_APEX_ARROW = MCATEGORY_WS + 0x18 MERIT_LAST_STAND = MCATEGORY_WS + 0x1A -- unknown --MERIT_UNKNOWN1 = MCATEGORY_UNK_0 + 0x00 --MERIT_UNKNOWN2 = MCATEGORY_UNK_1 + 0x00 --MERIT_UNKNOWN3 = MCATEGORY_UNK_2 + 0x00 --MERIT_UNKNOWN4 = MCATEGORY_UNK_3 + 0x00 --MERIT_UNKNOWN5 = MCATEGORY_UNK_4 + 0x00 --WAR 2 MERIT_WARRIORS_CHARGE = MCATEGORY_WAR_2 + 0x00 MERIT_TOMAHAWK = MCATEGORY_WAR_2 + 0x02 MERIT_SAVAGERY = MCATEGORY_WAR_2 + 0x04 MERIT_AGGRESSIVE_AIM = MCATEGORY_WAR_2 + 0x06 --MNK 2 MERIT_MANTRA = MCATEGORY_MNK_2 + 0x00 MERIT_FORMLESS_STRIKES = MCATEGORY_MNK_2 + 0x02 MERIT_INVIGORATE = MCATEGORY_MNK_2 + 0x04 MERIT_PENANCE = MCATEGORY_MNK_2 + 0x06 --WHM 2 MERIT_MARTYR = MCATEGORY_WHM_2 + 0x00 MERIT_DEVOTION = MCATEGORY_WHM_2 + 0x02 MERIT_PROTECTRA_V = MCATEGORY_WHM_2 + 0x04 MERIT_SHELLRA_V = MCATEGORY_WHM_2 + 0x06 --BLM 2 MERIT_FLARE_II = MCATEGORY_BLM_2 + 0x00 MERIT_FREEZE_II = MCATEGORY_BLM_2 + 0x02 MERIT_TORNADO_II = MCATEGORY_BLM_2 + 0x04 MERIT_QUAKE_II = MCATEGORY_BLM_2 + 0x06 MERIT_BURST_II = MCATEGORY_BLM_2 + 0x08 MERIT_FLOOD_II = MCATEGORY_BLM_2 + 0x0A --RDM 2 MERIT_DIA_III = MCATEGORY_RDM_2 + 0x00 MERIT_SLOW_II = MCATEGORY_RDM_2 + 0x02 MERIT_PARALYZE_II = MCATEGORY_RDM_2 + 0x04 MERIT_PHALANX_II = MCATEGORY_RDM_2 + 0x06 MERIT_BIO_III = MCATEGORY_RDM_2 + 0x08 MERIT_BLIND_II = MCATEGORY_RDM_2 + 0x0A --THF 2 MERIT_ASSASSINS_CHARGE = MCATEGORY_THF_2 + 0x00 MERIT_FEINT = MCATEGORY_THF_2 + 0x02 MERIT_AURA_STEAL = MCATEGORY_THF_2 + 0x04 MERIT_AMBUSH = MCATEGORY_THF_2 + 0x06 --PLD 2 MERIT_FEALTY = MCATEGORY_PLD_2 + 0x00 MERIT_CHIVALRY = MCATEGORY_PLD_2 + 0x02 MERIT_IRON_WILL = MCATEGORY_PLD_2 + 0x04 MERIT_GUARDIAN = MCATEGORY_PLD_2 + 0x06 --DRK 2 MERIT_DARK_SEAL = MCATEGORY_DRK_2 + 0x00 MERIT_DIABOLIC_EYE = MCATEGORY_DRK_2 + 0x02 MERIT_MUTED_SOUL = MCATEGORY_DRK_2 + 0x04 MERIT_DESPERATE_BLOWS = MCATEGORY_DRK_2 + 0x06 --BST 2 MERIT_FERAL_HOWL = MCATEGORY_BST_2 + 0x00 MERIT_KILLER_INSTINCT = MCATEGORY_BST_2 + 0x02 MERIT_BEAST_AFFINITY = MCATEGORY_BST_2 + 0x04 MERIT_BEAST_HEALER = MCATEGORY_BST_2 + 0x06 --BRD 2 MERIT_NIGHTINGALE = MCATEGORY_BRD_2 + 0x00 MERIT_TROUBADOUR = MCATEGORY_BRD_2 + 0x02 MERIT_FOE_SIRVENTE = MCATEGORY_BRD_2 + 0x04 MERIT_ADVENTURERS_DIRGE = MCATEGORY_BRD_2 + 0x06 --RNG 2 MERIT_STEALTH_SHOT = MCATEGORY_RNG_2 + 0x00 MERIT_FLASHY_SHOT = MCATEGORY_RNG_2 + 0x02 MERIT_SNAPSHOT = MCATEGORY_RNG_2 + 0x04 MERIT_RECYCLE = MCATEGORY_RNG_2 + 0x06 --SAM 2 MERIT_SHIKIKOYO = MCATEGORY_SAM_2 + 0x00 MERIT_BLADE_BASH = MCATEGORY_SAM_2 + 0x02 MERIT_IKISHOTEN = MCATEGORY_SAM_2 + 0x04 MERIT_OVERWHELM = MCATEGORY_SAM_2 + 0x06 --NIN 2 MERIT_SANGE = MCATEGORY_NIN_2 + 0x00 MERIT_NINJA_TOOL_EXPERTISE = MCATEGORY_NIN_2 + 0x02 MERIT_KATON_SAN = MCATEGORY_NIN_2 + 0x04 MERIT_HYOTON_SAN = MCATEGORY_NIN_2 + 0x06 MERIT_HUTON_SAN = MCATEGORY_NIN_2 + 0x08 MERIT_DOTON_SAN = MCATEGORY_NIN_2 + 0x0A MERIT_RAITON_SAN = MCATEGORY_NIN_2 + 0x0C MERIT_SUITON_SAN = MCATEGORY_NIN_2 + 0x0E --DRG 2 MERIT_DEEP_BREATHING = MCATEGORY_DRG_2 + 0x00 MERIT_ANGON = MCATEGORY_DRG_2 + 0x02 MERIT_EMPATHY = MCATEGORY_DRG_2 + 0x04 MERIT_STRAFE = MCATEGORY_DRG_2 + 0x06 --SMN 2 MERIT_METEOR_STRIKE = MCATEGORY_SMN_2 + 0x00 MERIT_HEAVENLY_STRIKE = MCATEGORY_SMN_2 + 0x02 MERIT_WIND_BLADE = MCATEGORY_SMN_2 + 0x04 MERIT_GEOCRUSH = MCATEGORY_SMN_2 + 0x06 MERIT_THUNDERSTORM = MCATEGORY_SMN_2 + 0x08 MERIT_GRANDFALL = MCATEGORY_SMN_2 + 0x0A --BLU 2 MERIT_CONVERGENCE = MCATEGORY_BLU_2 + 0x00 MERIT_DIFFUSION = MCATEGORY_BLU_2 + 0x02 MERIT_ENCHAINMENT = MCATEGORY_BLU_2 + 0x04 MERIT_ASSIMILATION = MCATEGORY_BLU_2 + 0x06 --COR 2 MERIT_SNAKE_EYE = MCATEGORY_COR_2 + 0x00 MERIT_FOLD = MCATEGORY_COR_2 + 0x02 MERIT_WINNING_STREAK = MCATEGORY_COR_2 + 0x04 MERIT_LOADED_DECK = MCATEGORY_COR_2 + 0x06 --PUP 2 MERIT_ROLE_REVERSAL = MCATEGORY_PUP_2 + 0x00 MERIT_VENTRILOQUY = MCATEGORY_PUP_2 + 0x02 MERIT_FINE_TUNING = MCATEGORY_PUP_2 + 0x04 MERIT_OPTIMIZATION = MCATEGORY_PUP_2 + 0x06 --DNC 2 MERIT_SABER_DANCE = MCATEGORY_DNC_2 + 0x00 MERIT_FAN_DANCE = MCATEGORY_DNC_2 + 0x02 MERIT_NO_FOOT_RISE = MCATEGORY_DNC_2 + 0x04 MERIT_CLOSED_POSITION = MCATEGORY_DNC_2 + 0x06 --SCH 2 MERIT_ALTRUISM = MCATEGORY_SCH_2 + 0x00 MERIT_FOCALIZATION = MCATEGORY_SCH_2 + 0x02 MERIT_TRANQUILITY = MCATEGORY_SCH_2 + 0x04 MERIT_EQUANIMITY = MCATEGORY_SCH_2 + 0x06 MERIT_ENLIGHTENMENT = MCATEGORY_SCH_2 + 0x08 MERIT_STORMSURGE = MCATEGORY_SCH_2 + 0x0A ------------------------------------ -- Slot Definitions ------------------------------------ SLOT_MAIN = 0 SLOT_SUB = 1 SLOT_RANGED = 2 SLOT_AMMO = 3 SLOT_HEAD = 4 SLOT_BODY = 5 SLOT_HANDS = 6 SLOT_LEGS = 7 SLOT_FEET = 8 SLOT_NECK = 9 SLOT_WAIST = 10 SLOT_EAR1 = 11 SLOT_EAR2 = 12 SLOT_RING1 = 13 SLOT_RING2 = 14 SLOT_BACK = 15 MAX_SLOTID = 15 ---------------------------------- -- Objtype Definitions ---------------------------------- TYPE_PC = 0x01 TYPE_NPC = 0x02 TYPE_MOB = 0x04 TYPE_PET = 0x08 TYPE_SHIP = 0x10 ---------------------------------- -- Allegiance Definitions ---------------------------------- ALLEGIANCE_MOB = 0 ALLEGIANCE_PLAYER = 1 ALLEGIANCE_SAN_DORIA = 2 ALLEGIANCE_BASTOK = 3 ALLEGIANCE_WINDURST = 4 ------------------------------------ -- Inventory enum ------------------------------------ LOC_INVENTORY = 0 LOC_MOGSAFE = 1 LOC_STORAGE = 2 LOC_TEMPITEMS = 3 LOC_MOGLOCKER = 4 LOC_MOGSATCHEL = 5 LOC_MOGSACK = 6 ------------------------------------ -- Message enum ------------------------------------ MSGBASIC_DEFEATS_TARG = 6 -- The <player> defeats <target>. MSGBASIC_ALREADY_CLAIMED = 12 -- Cannot attack. Your target is already claimed. MSGBASIC_IS_INTERRUPTED = 16 -- The <player>'s casting is interrupted. MSGBASIC_UNABLE_TO_CAST = 18 -- Unable to cast spells at this time. MSGBASIC_CANNOT_PERFORM = 71 -- The <player> cannot perform that action. MSGBASIC_CANNOT_PERFORM_TARG = 72 -- That action cannot be performed on <target>. MSGBASIC_UNABLE_TO_USE_JA = 87 -- Unable to use job ability. MSGBASIC_UNABLE_TO_USE_JA2 = 88 -- Unable to use job ability. MSGBASIC_IS_PARALYZED = 29 -- The <player> is paralyzed. MSGBASIC_SHADOW_ABSORB = 31 -- .. of <target>'s shadows absorb the damage and disappear. MSGBASIC_NOT_ENOUGH_MP = 34 -- The <player> does not have enough MP to cast (NULL). MSGBASIC_NO_NINJA_TOOLS = 35 -- The <player> lacks the ninja tools to cast (NULL). MSGBASIC_UNABLE_TO_CAST_SPELLS = 49 -- The <player> is unable to cast spells. MSGBASIC_WAIT_LONGER = 94 -- You must wait longer to perform that action. MSGBASIC_USES_JA = 100 -- The <player> uses .. MSGBASIC_USES_JA2 = 101 -- The <player> uses .. MSGBASIC_USES_RECOVERS_HP = 102 -- The <player> uses .. <target> recovers .. HP. MSGBASIC_USES_JA_TAKE_DAMAGE = 317 -- The <player> uses .. <target> takes .. points of damage. MSGBASIC_IS_INTIMIDATED = 106 -- The <player> is intimidated by <target>'s presence. MSGBASIC_CANNOT_ON_THAT_TARG = 155 -- You cannot perform that action on the specified target. MSGBASIC_CANNOT_ATTACK_TARGET = 446 -- You cannot attack that target MSGBASIC_NEEDS_2H_WEAPON = 307 -- That action requires a two-handed weapon. MSGBASIC_USES_BUT_MISSES = 324 -- The <player> uses .. but misses <target>. MSGBASIC_CANT_BE_USED_IN_AREA = 316 -- That action cannot be used in this area. MSGBASIC_REQUIRES_SHIELD = 199 -- That action requires a shield. MSGBASIC_REQUIRES_COMBAT = 525 -- .. can only be performed during battle. MSGBASIC_STATUS_PREVENTS = 569 -- Your current status prevents you from using that ability. -- Distance MSGBASIC_TARG_OUT_OF_RANGE = 4 -- <target> is out of range. MSGBASIC_UNABLE_TO_SEE_TARG = 5 -- Unable to see <target>. MSGBASIC_LOSE_SIGHT = 36 -- You lose sight of <target>. MSGBASIC_TOO_FAR_AWAY = 78 -- <target> is too far away. -- Weaponskills MSGBASIC_CANNOT_USE_WS = 190 -- The <player> cannot use that weapon ability. MSGBASIC_NOT_ENOUGH_TP = 192 -- The <player> does not have enough TP. -- Pets MSGBASIC_REQUIRES_A_PET = 215 -- That action requires a pet. MSGBASIC_THAT_SOMEONES_PET = 235 -- That is someone's pet. MSGBASIC_ALREADY_HAS_A_PET = 315 -- The <player> already has a pet. MSGBASIC_NO_EFFECT_ON_PET = 336 -- No effect on that pet. MSGBASIC_NO_JUG_PET_ITEM = 337 -- You do not have the necessary item equipped to call a beast. MSGBASIC_MUST_HAVE_FOOD = 347 -- You must have pet food equipped to use that command. MSGBASIC_PET_CANNOT_DO_ACTION = 574 -- <player>'s pet is currently unable to perform that action. MSGBASIC_PET_NOT_ENOUGH_TP = 575 -- <player>'s pet does not have enough TP to perform that action. -- Items MSGBASIC_CANNOT_USE_ITEM_ON = 92 -- Cannot use the <item> on <target>. MSGBASIC_ITEM_FAILS_TO_ACTIVATE = 62 -- The <item> fails to activate. MSGBASIC_FULL_INVENTORY = 356 -- Cannot execute command. Your inventory is full. -- Ranged MSGBASIC_NO_RANGED_WEAPON = 216 -- You do not have an appropriate ranged weapon equipped. MSGBASIC_CANNOT_SEE = 217 -- You cannot see <target>. MSGBASIC_MOVE_AND_INTERRUPT = 218 -- You move and interrupt your aim. -- Additional effects and spike effects MSGBASIC_ADD_EFFECT_STATUS = 160 -- Additional effect: <Status Effect>. MSGBASIC_ADD_EFFECT_HP_DRAIN = 161 -- Additional effect: <number> HP drained from <target>. MSGBASIC_ADD_EFFECT_MP_DRAIN = 162 -- Additional effect: <number> MP drained from <target>. MSGBASIC_ADD_EFFECT_DMG = 163 -- Additional effect: <number> points of damage. MSGBASIC_ADD_EFFECT_STATUS2 = 164 -- Additional effect: <Status Effect>. (Duplicate?) MSGBASIC_ADD_EFFECT_TP_DRAIN = 165 -- Additional effect: <number> TP drained from <target>. MSGBASIC_ADD_EFFECT_STATUS3 = 166 -- Additional effect: The <target> gains the effect of <Status Effect>. (Only difference from 160 and 164 is "The") MSGBASIC_ADD_EFFECT_HEAL = 167 -- Additional effect: The <target> recovers <number> HP. (used when target absorbs element) MSGBASIC_ADD_EFFECT_DISPEL = 168 -- Additional effect: <target>'s KO effect disappears! MSGBASIC_ADD_EFFECT_WARP = 169 -- Additional effect: Warp! (used by holloween staves) -- Charm MSGBASIC_CANNOT_CHARM = 210 -- The <player> cannot charm <target>! MSGBASIC_VERY_DIFFICULT_CHARM = 211 -- It would be very difficult for the <player> to charm <target>. MSGBASIC_DIFFICULT_TO_CHARM = 212 -- It would be difficult for the <player> to charm <target>. MSGBASIC_MIGHT_BE_ABLE_CHARM = 213 -- The <player> might be able to charm <target>. MSGBASIC_SHOULD_BE_ABLE_CHARM = 214 -- The <player> should be able to charm <target>. -- BLU MSGBASIC_LEARNS_SPELL = 419 -- <target> learns (NULL)! -- COR MSGBASIC_ROLL_MAIN = 420 -- The <player> uses .. The total comes to ..! <target> receives the effect of .. MSGBASIC_ROLL_SUB = 421 -- <target> receives the effect of .. MSGBASIC_ROLL_MAIN_FAIL = 422 -- The <player> uses .. The total comes to ..! No effect on <target>. MSGBASIC_ROLL_SUB_FAIL = 423 -- No effect on <target>. MSGBASIC_DOUBLEUP = 424 -- The <player> uses Double-Up. The total for . increases to ..! <target> receives the effect of .. MSGBASIC_DOUBLEUP_FAIL = 425 -- The <player> uses Double-Up. The total for . increases to ..! No effect on <target>. MSGBASIC_DOUBLEUP_BUST = 426 -- The <player> uses Double-Up. Bust! <target> loses the effect of .. MSGBASIC_DOUBLEUP_BUST_SUB = 427 -- <target> loses the effect of .. MSGBASIC_NO_ELIGIBLE_ROLL = 428 -- There are no rolls eligible for Double-Up. Unable to use ability. MSGBASIC_ROLL_ALREADY_ACTIVE = 429 -- The same roll is already active on the <player>. MSGBASIC_EFFECT_ALREADY_ACTIVE = 523 -- The same effect is already active on <player>. MSGBASIC_NO_FINISHINGMOVES = 524 -- You have not earned enough finishing moves to perform that action. ------------------------------------ -- Spell Groups ------------------------------------ SPELLGROUP_NONE = 0 SPELLGROUP_SONG = 1 SPELLGROUP_BLACK = 2 SPELLGROUP_BLUE = 3 SPELLGROUP_NINJUTSU = 4 SPELLGROUP_SUMMONING = 5 SPELLGROUP_WHITE = 6 ------------------------------------ -- MOBMODs ------------------------------------ MOBMOD_NONE = 0 MOBMOD_GIL_MIN = 1 MOBMOD_GIL_MAX = 2 MOBMOD_MP_BASE = 3 MOBMOD_SIGHT_RANGE = 4 MOBMOD_SOUND_RANGE = 5 MOBMOD_BUFF_CHANCE = 6 MOBMOD_GA_CHANCE = 7 MOBMOD_HEAL_CHANCE = 8 MOBMOD_HP_HEAL_CHANCE = 9 MOBMOD_SUBLINK = 10 MOBMOD_LINK_RADIUS = 11 MOBMOD_DRAW_IN = 12 MOBMOD_RAGE = 13 MOBMOD_SKILL_LIST = 14 MOBMOD_MUG_GIL = 15 MOBMOD_MAIN_2HOUR = 16 MOBMOD_NO_DESPAWN = 17 MOBMOD_VAR = 18 MOBMOD_SUB_2HOUR = 19 MOBMOD_TP_USE_CHANCE = 20 MOBMOD_PET_SPELL_LIST = 21 MOBMOD_NA_CHANCE = 22 MOBMOD_IMMUNITY = 23 MOBMOD_GRADUAL_RAGE = 24 MOBMOD_BUILD_RESIST = 25 MOBMOD_SUPERLINK = 26 MOBMOD_SPELL_LIST = 27 MOBMOD_EXP_BONUS = 28 MOBMOD_ASSIST = 29 MOBMOD_SPECIAL_SKILL = 30 MOBMOD_ROAM_DISTANCE = 31 MOBMOD_2HOUR_MULTI = 32 MOBMOD_SPECIAL_COOL = 33 MOBMOD_MAGIC_COOL = 34 MOBMOD_STANDBACK_COOL = 35 MOBMOD_ROAM_COOL = 36 MOBMOD_ALWAYS_AGGRO = 37 MOBMOD_NO_DROPS = 38 MOBMOD_SHARE_POS = 39 MOBMOD_TELEPORT_CD = 40 MOBMOD_TELEPORT_START = 41 MOBMOD_TELEPORT_END = 42 MOBMOD_TELEPORT_TYPE = 43 MOBMOD_DUAL_WIELD = 44 MOBMOD_ADD_EFFECT = 45 MOBMOD_AUTO_SPIKES = 46 MOBMOD_SPAWN_LEASH = 47 MOBMOD_SHARE_TARGET = 48 MOBMOD_SCRIPTED_2HOUR = 49 MOBMOD_2HOUR_PROC = 50 MOBMOD_ROAM_TURNS = 51 MOBMOD_ROAM_RATE = 52 MOBMOD_BEHAVIOR = 53 MOBMOD_GIL_BONUS = 54 MOBMOD_IDLE_DESPAWN = 55 MOBMOD_HP_STANDBACK = 56 ------------------------------------ -- Skills ------------------------------------ -- Combat Skills SKILL_NON = 0 SKILL_H2H = 1 SKILL_DAG = 2 SKILL_SWD = 3 SKILL_GSD = 4 SKILL_AXE = 5 SKILL_GAX = 6 SKILL_SYH = 7 SKILL_POL = 8 SKILL_KAT = 9 SKILL_GKT = 10 SKILL_CLB = 11 SKILL_STF = 12 -- 13~21 unused -- 22~24 pup's Automaton skills SKILL_ARC = 25 SKILL_MRK = 26 SKILL_THR = 27 -- Defensive Skills SKILL_GRD = 28 SKILL_EVA = 29 SKILL_SHL = 30 SKILL_PAR = 31 -- Magic Skills SKILL_DIV = 32 SKILL_HEA = 33 SKILL_ENH = 34 SKILL_ENF = 35 SKILL_ELE = 36 SKILL_DRK = 37 SKILL_SUM = 38 SKILL_NIN = 39 SKILL_SNG = 40 SKILL_STR = 41 SKILL_WND = 42 SKILL_BLU = 43 SKILL_GEO = 44 -- 45~47 unused -- Crafting Skills SKILL_FISHING = 48 SKILL_WOODWORKING = 49 SKILL_SMITHING = 50 SKILL_GOLDSMITHING = 51 SKILL_CLOTHCRAFT = 52 SKILL_LEATHERCRAFT = 53 SKILL_BONECRAFT = 54 SKILL_ALCHEMY = 55 SKILL_COOKING = 56 SKILL_SYNERGY = 57 -- Other Skills SKILL_RID = 58 SKILL_DIG = 59 -- 60~63 unused -- MAX_SKILLTYPE = 64 ------------------------------------ -- Recast IDs ------------------------------------ RECAST_ITEM = 0 RECAST_MAGIC = 1 RECAST_ABILITY = 2 ------------------------------------ -- ACTION IDs ------------------------------------ ACTION_NONE = 0; ACTION_ATTACK = 1; ACTION_RANGED_FINISH = 2; ACTION_WEAPONSKILL_FINISH = 3; ACTION_MAGIC_FINISH = 4; ACTION_ITEM_FINISH = 5; ACTION_JOBABILITY_FINISH = 6; ACTION_WEAPONSKILL_START = 7; ACTION_MAGIC_START = 8; ACTION_ITEM_START = 9; ACTION_JOBABILITY_START = 10; ACTION_MOBABILITY_FINISH = 11; ACTION_RANGED_START = 12; ACTION_RAISE_MENU_SELECTION = 13; ACTION_DANCE = 14; ACTION_UNKNOWN_15 = 15; ACTION_ROAMING = 16; ACTION_ENGAGE = 17; ACTION_DISENGAGE = 18; ACTION_CHANGE_TARGET = 19; ACTION_FALL = 20; ACTION_DROPITEMS = 21; ACTION_DEATH = 22; ACTION_FADE_OUT = 23; ACTION_DESPAWN = 24; ACTION_SPAWN = 25; ACTION_STUN = 26; ACTION_SLEEP = 27; ACTION_ITEM_USING = 28; ACTION_ITEM_INTERRUPT = 29; ACTION_MAGIC_CASTING = 30; ACTION_MAGIC_INTERRUPT = 31; ACTION_RANGED_INTERRUPT = 32; ACTION_MOBABILITY_START = 33; ACTION_MOBABILITY_USING = 34; ACTION_MOBABILITY_INTERRUPT = 35; ACTION_LEAVE = 36; ------------------------------------ -- ECOSYSTEM IDs ------------------------------------ SYSTEM_ERROR = 0; SYSTEM_AMORPH = 1; SYSTEM_AQUAN = 2; SYSTEM_ARCANA = 3; SYSTEM_ARCHAICMACHINE = 4; SYSTEM_AVATAR = 5; SYSTEM_BEAST = 6; SYSTEM_BEASTMEN = 7; SYSTEM_BIRD = 8; SYSTEM_DEMON = 9; SYSTEM_DRAGON = 10; SYSTEM_ELEMENTAL = 11; SYSTEM_EMPTY = 12; SYSTEM_HUMANOID = 13; SYSTEM_LIZARD = 14; SYSTEM_LUMORIAN = 15; SYSTEM_LUMINION = 16; SYSTEM_PLANTOID = 17; SYSTEM_UNCLASSIFIED = 18; SYSTEM_UNDEAD = 19; SYSTEM_VERMIN = 20; SYSTEM_VORAGEAN = 21; ------------------------------------ -- Spell AOE IDs ------------------------------------ SPELLAOE_NONE = 0; SPELLAOE_RADIAL = 1; SPELLAOE_CONAL = 2; SPELLAOE_RADIAL_MANI = 3; -- AOE when under SCH stratagem Manifestation SPELLAOE_RADIAL_ACCE = 4; -- AOE when under SCH stratagem Accession SPELLAOE_PIANISSIMO = 5; -- Single target when under BRD JA Pianissimo SPELLAOE_DIFFUSION = 6; -- AOE when under Diffusion ------------------------------------ -- Spell flag bits ------------------------------------ SPELLFLAG_NONE = 0; SPELLFLAG_HIT_ALL = 1; -- hit all targets in range regardless of party ------------------------------------ -- Behaviour bits ------------------------------------ BEHAVIOUR_NONE = 0x000; BEHAVIOUR_NO_DESPAWN = 0x001; -- mob does not despawn on death BEHAVIOUR_STANDBACK = 0x002; -- mob will standback forever BEHAVIOUR_RAISABLE = 0x004; -- mob can be raised via Raise spells BEHAVIOUR_AGGRO_AMBUSH = 0x200; -- mob aggroes by ambush BEHAVIOUR_NO_TURN = 0x400; -- mob does not turn to face target ------------------------------------ -- Elevator IDs ------------------------------------ ELEVATOR_KUFTAL_TUNNEL_DSPPRNG_RCK = 0; ELEVATOR_PORT_BASTOK_DRWBRDG = 2; ELEVATOR_DAVOI_LIFT = 3; ELEVATOR_PALBOROUGH_MINES_LIFT = 4;
gpl-3.0
jshackley/darkstar
scripts/zones/West_Sarutabaruta/npcs/Mahien-Uhien.lua
17
1770
----------------------------------- -- Area: West Sarutabaruta -- NPC: Mahien-Uhien -- Type: Outpost Vendor -- @pos -13 -12 311 115 ----------------------------------- package.loaded["scripts/zones/West_Sarutabaruta/TextIDs"] = nil; ----------------------------------- require("scripts/globals/shop"); require("scripts/globals/conquest"); require("scripts/zones/West_Sarutabaruta/TextIDs"); local region = SARUTABARUTA; local csid = 0x7ff4; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local owner = GetRegionOwner(region); local arg1 = getArg1(owner,player); if (owner == player:getNation()) then nation = 1; elseif (arg1 < 1792) then nation = 2; else nation = 0; end player:startEvent(csid,nation,OP_TeleFee(player,region),0,OP_TeleFee(player,region),player:getCP(),0,0,0); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("OPTION: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("OPTION: %u",option); if (option == 1) then ShowOPVendorShop(player); elseif (option == 2) then if (player:delGil(OP_TeleFee(player,region))) then toHomeNation(player); end elseif (option == 6) then player:delCP(OP_TeleFee(player,region)); toHomeNation(player); end end;
gpl-3.0
10sa/Advanced-Nutscript
nutscript/gamemode/derma/cl_charmenu.lua
1
13965
local PANEL = {} local gradient = surface.GetTextureID("gui/gradient_up") local gradient2 = surface.GetTextureID("gui/gradient_down") local gradient3 = surface.GetTextureID("gui/gradient") local gradient4 = surface.GetTextureID("vgui/gradient-r") local blur = Material("pp/blurscreen") local function DrawBlur(panel, amount) local x, y = panel:LocalToScreen(0, 0) local scrW, scrH = ScrW(), ScrH() surface.SetDrawColor(255, 255, 255, 125) surface.SetMaterial(blur) for i = 1, 3 do blur:SetFloat("$blur", (i / 3) * (amount or 6)) blur:Recompute() render.UpdateScreenEffectTexture() surface.DrawTexturedRect(x * -1, y * -1, scrW, scrH) end end function PANEL:Init() timer.Remove("nut_FadeMenuMusic") self:SetSize(ScrW(), ScrH()) self:MakePopup() self:ParentToHUD() local color = nut.config.mainColor local r, g, b = color.r, color.g, color.b self.side = self:Add("DPanel") self.side:SetPos(0, 0) self.side:SetSize(ScrW(), ScrH()) self.side.Paint = function(this, w, h) DrawBlur(self.side, 8) surface.SetDrawColor(0, 0, 0, 100) surface.DrawRect(0, 0, w, h) end self.title = self.side:Add("DLabel") self.title:Dock(TOP) self.title:SetFont("nut_TitleFont") self.title:SetTall(100) self.title:SetTextColor(Color(240, 240, 240)) self.title:SetContentAlignment(5) self.title:DockMargin(24, ScrH()*0.15, 24, 0) self.title:SetText(SCHEMA.name); self.subTitle = self.side:Add("DLabel") self.subTitle:Dock(TOP) self.subTitle:SetText(SCHEMA.desc); self.subTitle:SetContentAlignment(5) self.subTitle:SetTall(ScrH()*0.09) self.subTitle:DockMargin(0, self.subTitle:GetTall()*-0.2, 0, 0) self.subTitle:SetFont("nut_SubTitleFont") self.leftButtons = self.side:Add("AdvNut_ScrollPanel") self.leftButtons:Dock(LEFT) self.leftButtons:SetWide(self.side:GetWide()*0.25) self.leftButtons:DockMargin(20, 50, 0, 0) self.leftButtons:DockPadding(0, 0, 0, 80) self.rightButtons = self.side:Add("AdvNut_ScrollPanel"); self.rightButtons:Dock(RIGHT); self.rightButtons:SetWide(self.side:GetWide()*0.25); self.rightButtons:DockMargin(0, 50, 20, 0); self.rightButtons:DockPadding(0, 0, 0, 80); nut.OldRenderScreenspaceEffects = nut.RenderScreenspaceEffects timer.Simple(0.1, function() GAMEMODE.RenderScreenspaceEffects = function() if (IsValid(self)) then self:RenderScreenspaceEffects() else GAMEMODE.RenderScreenspaceEffects = nut.OldRenderScreenspaceEffects end end end) local first = true self.leftButtonCount = 0; self.rightButtonCount = 0; local function AddButton(text, callback, dockPointer, noLang) if (self.choosing) then return end local button; local count; if(dockPointer == nil or dockPointer == LEFT) then button = self.leftButtons:Add("DLabel"); self.leftButtonCount = self.leftButtonCount + 1; count = self.leftButtonCount; elseif (dockPointer == RIGHT) then button = self.rightButtons:Add("DLabel"); self.rightButtonCount = self.rightButtonCount + 1; count = self.rightButtonCount; else ErrorNoHalt("Wrong Dock Pointer!"); end; button:SetText(noLang and text:upper() or nut.lang.Get(text:lower()):upper()); button:SetPos(ScrH()*0.1, ScrW()*0.3 - count * 50) button:SetWide(self:GetParent():GetWide()); button:SetFont("nut_MediumFont") button:SetContentAlignment(4) button:SetTextColor(color_white) button:SetTextInset(28, 0) button:SetTall(64) button:SetMouseInputEnabled(true) function button:OnCursorEntered() surface.PlaySound("ui/buttonrollover.wav") self:SetTextColor(Color(255, 230, 0, 255)) end function button:OnCursorExited() self:SetTextColor(color_white) self.alpha = 15 end button:SetExpensiveShadow(1, Color(0, 0, 0, 220)) if (first) then button:DockMargin(0, 20, 0, 0) first = false end if (callback) then button.DoClick = callback end end local function CreateMainButtons() self.leftButtonCount = 0; self.rightButtonCount = 0; if (IsValid(self.content)) then self.content:Remove() end self:RemoveButtons() local factions = {} for k, v in pairs(nut.faction.buffer) do if (nut.faction.CanBe(LocalPlayer(), v.index)) then factions[#factions + 1] = v end end local charIsValid = LocalPlayer().character != nil AddButton(charIsValid and "return" or "leave", function() if (charIsValid) then self:Remove() else LocalPlayer():ConCommand("disconnect") end end) if (nut.config.website and nut.config.website:find("http")) then AddButton("website", function() gui.OpenURL(nut.config.website) end) end if (#factions > 0 and (LocalPlayer().character and table.Count(LocalPlayer().characters) or 0) < nut.config.maxChars) then AddButton("create", function() local stageCounter = 1; self.leftButtonCount = 0; self.rightButtonCount = 0; self.Stages = { vgui.Create("AdvNut_charCreateFactionSelect", self), vgui.Create("AdvNut_charCreateWriteInfo", self), vgui.Create("AdvNut_charCreateAttributeSet", self), vgui.Create("AdvNut_charCreateWait", self) } self.Stages[stageCounter]:NextCallback(factions); self.leftButtons:Clear(); self.rightButtons:Clear(); self.title:SetText(""); self.subTitle:SetText(""); self.Stages[1]:Next(); AddButton("return", function() self.Stages[stageCounter]:Prev(); if(stageCounter <= 1) then CreateMainButtons(); else self.Stages[stageCounter - 1]:Next(self.Stages[stageCounter]); stageCounter = stageCounter - 1; end; end) AddButton("next", function() if(self.Stages[stageCounter]:ValidCheck() != false) then if(stageCounter < (table.Count(self.Stages) - 1)) then stageCounter = stageCounter + 1; self.Stages[stageCounter]:Next(self.Stages[stageCounter - 1]); self.Stages[stageCounter]:NextCallback(self.Stages[stageCounter - 1]:GetData()); else self.Stages[stageCounter]:Prev(); self.Stages[stageCounter + 1]:Next(); self.leftButtons:Clear(); self.rightButtons:Clear(); local characterInfo = {}; local infoTable = { "name", "gender", "desc", "model", "attribs", "factionID" }; for k, v in pairs(self.Stages) do local data = v:GetData(); if (data != nil) then for k2, v2 in pairs(infoTable) do if(data[v2] != nil) then characterInfo[v2] = data[v2]; end; end; end; end; self.isCreafting = true; self.creatingCallback = function() timer.Remove("timer.charCreate_Timeout"); self.Stages[#self.Stages]:Prev(); CreateMainButtons(); end; PrintTable(characterInfo); netstream.Start("nut_CharCreate", characterInfo); timer.Create("timer.charCreate_Timeout", 10, 0, function() self.Stages[stageCounter + 1]:TimeoutCallBack(); end); end; end; end, RIGHT) end) end local charAmount = 0; if(LocalPlayer().characters != nil) then charAmount = table.Count(LocalPlayer().characters); for k, v in pairs(LocalPlayer().characters) do if (v.banned) then charAmount = charAmount - 1; end end end if (nut.lastCharIndex) then charAmount = charAmount - 1; end; if (charAmount > 0) then AddButton("load", function() local charSelectCounter = 1; self.leftButtonCount = 0; self.rightButtonCount = 0; self.title:SetText("") self.subTitle:SetText("") self.leftButtons:Clear() self.rightButtons:Clear() self.charStage = {}; for k, v in SortedPairsByMemberValue(LocalPlayer().characters, "id") do if (k != "__SortedIndex" and !v.banned and v.id != nut.lastCharIndex) then local charSelect = vgui.Create("AdvNut_CharacterSelect", self); local insertIndex = #self.charStage + 1; charSelect:SetCharacter(k, function() if (charSelectCounter <= charAmount) then if(self.charStage[insertIndex - 1] == nil) then CreateMainButtons(); else self.charStage[insertIndex - 1]:Next(charSelect); charSelectCounter = charSelectCounter - 1; end else CreateMainButtons(); topButtons:Remove(); end; self.charStage[insertIndex] = nil; charSelect:Remove(); end); table.insert(self.charStage, charSelect); end end self.charStage[1]:Next(); AddButton("return", function() self.charStage[charSelectCounter]:Prev(); if (charSelectCounter <= 1) then CreateMainButtons(); else charSelectCounter = charSelectCounter - 1; self.charStage[charSelectCounter]:Next(self.charStage[charSelectCounter + 1]); if (charSelectCounter < charAmount) then self.rightButtons:Clear(); self.rightButtonCount = 0; AddButton("next", function() charSelectCounter = charSelectCounter + 1; self.charStage[charSelectCounter]:Next(self.charStage[charSelectCounter - 1]); if (!(charSelectCounter < charAmount)) then self.rightButtonCount = 0; self.rightButtons:Clear(); end; end, RIGHT); else self.rightButtonCount = 0; self.rightButtons:Clear(); end; end; end); if (charSelectCounter < charAmount) then AddButton("next", function() charSelectCounter = charSelectCounter + 1; self.charStage[charSelectCounter]:Next(self.charStage[charSelectCounter - 1]); if (!(charSelectCounter < charAmount)) then self.rightButtonCount = 0; self.rightButtons:Clear(); end; end, RIGHT); end end); end if(nut.config.prefixTitle) then self.title:SetText(nut.lang.Get("charMenuTitle")); self.subTitle:SetText(nut.lang.Get("charMenuDesc")); else self.title:SetText(SCHEMA.name); self.subTitle:SetText(SCHEMA.desc); end; end timer.Simple(0, CreateMainButtons) if (nut.config.menuMusic) then if (nut.menuMusic) then nut.menuMusic:Stop() nut.menuMusic = nil end local lower = string.lower(nut.config.menuMusic) if (string.Left(lower, 4) == "http") then local function createMusic() if (!IsValid(nut.gui.charMenu)) then return end local nextAttempt = 0 sound.PlayURL(nut.config.menuMusic, "noplay", function(music) if (music) then nut.menuMusic = music nut.menuMusic:Play() timer.Simple(0.5, function() if (!nut.menuMusic) then return end nut.menuMusic:SetVolume(nut.config.menuMusicVol / 100) end) elseif (nextAttempt < CurTime()) then nextAttempt = CurTime() + 1 createMusic() end end) end createMusic() else nut.menuMusic = CreateSound(LocalPlayer(), nut.config.menuMusic) nut.menuMusic:Play() nut.menuMusic:ChangeVolume(nut.config.menuMusicVol / 100, 0) end end nut.loaded = true end local colorData = {} colorData["$pp_colour_addr"] = 0 colorData["$pp_colour_addg"] = 0 colorData["$pp_colour_addb"] = 0 colorData["$pp_colour_brightness"] = -0.05 colorData["$pp_colour_contrast"] = 1 colorData["$pp_colour_colour"] = 0 colorData["$pp_colour_mulr"] = 0 colorData["$pp_colour_mulg"] = 0 colorData["$pp_colour_mulb"] = 0 function PANEL:RenderScreenspaceEffects() local x, y = self.side:LocalToScreen(0, 0) local w, h = self.side:GetWide(), ScrH() render.SetStencilEnable(true) render.SetStencilCompareFunction(STENCILCOMPARISONFUNCTION_EQUAL) render.SetStencilReferenceValue(1) render.ClearStencilBufferRectangle(x, y, x + w, h, 1) render.SetStencilEnable(1) DrawColorModify(colorData) render.SetStencilEnable(false) end function PANEL:FadeOutMusic() if (!nut.menuMusic) then return end if (nut.menuMusic.SetVolume) then local start = CurTime() local finish = CurTime() + nut.config.menuMusicFade if (timer.Exists("nut_FadeMenuMusic")) then timer.Remove("nut_FadeMenuMusic") if (nut.menuMusic) then nut.menuMusic:Stop() nut.menuMusic = nil end end timer.Create("nut_FadeMenuMusic", 0, 0, function() local fraction = (1 - math.TimeFraction(start, finish, CurTime())) * nut.config.menuMusicVol if (nut.menuMusic) then nut.menuMusic:SetVolume(fraction / 100) if (fraction <= 0) then nut.menuMusic:SetVolume(0) nut.menuMusic:Stop() nut.menuMusic = nil end end end) else nut.menuMusic:FadeOut(nut.config.menuMusicFade) nut.menuMusic = nil end end function PANEL:OnRemove() self:FadeOutMusic() end function PANEL:RemoveButtons() self.leftButtons:Clear(); self.rightButtons:Clear(); self.leftButtonCount = 0; self.rightButtonCount = 0; end; vgui.Register("nut_CharMenu", PANEL, "EditablePanel") if (IsValid(nut.gui.charMenu)) then nut.gui.charMenu:Remove() nut.gui.charMenu = vgui.Create("nut_CharMenu") end netstream.Hook("nut_CharMenu", function(forced) if (type(forced) == "table") then if (forced[2] == true) then LocalPlayer().character = nil if (forced[3]) then for k, v in pairs(LocalPlayer().characters) do if (v.id == forced[3]) then LocalPlayer().characters[k] = nil end end end end forced = forced[1] end if (IsValid(nut.gui.charMenu)) then nut.gui.charMenu:FadeOutMusic() if (IsValid(nut.gui.charMenu.model)) then nut.gui.charMenu.model:Remove() end nut.gui.charMenu:Remove() if (!forced) then return end end if (forced) then nut.loaded = nil end nut.gui.charMenu = vgui.Create("nut_CharMenu") end) netstream.Hook("nut_CharCreateAuthed", function() if (IsValid(nut.gui.charMenu)) then nut.gui.charMenu.creating = false nut.gui.charMenu.creatingCallback() nut.gui.charMenu.creatingCallback = nil end end)
mit
DipColor/mehrabon3
bot/bot.lua
1
6659
package.path = package.path .. ';.luarocks/share/lua/5.2/?.lua' ..';.luarocks/share/lua/5.2/?/init.lua' package.cpath = package.cpath .. ';.luarocks/lib/lua/5.2/?.so' require("./bot/utils") local f = assert(io.popen('/usr/bin/git describe --tags', 'r')) VERSION = assert(f:read('*a')) f:close() -- This function is called when tg receive a msg function on_msg_receive (msg) if not started then return end local receiver = get_receiver(msg) -- vardump(msg) msg = pre_process_service_msg(msg) if msg_valid(msg) then msg = pre_process_msg(msg) if msg then match_plugins(msg) mark_read(receiver, ok_cb, false) end end end function ok_cb(extra, success, result) end function on_binlog_replay_end() started = true postpone (cron_plugins, false, 60*5.0) -- See plugins/isup.lua as an example for cron _config = load_config() -- load plugins plugins = {} load_plugins() end function msg_valid(msg) -- Don't process outgoing messages if msg.out then print('\27[36mNot valid: msg from us\27[39m') return false end -- Before bot was started if msg.date < now then print('\27[36mNot valid: old msg\27[39m') return false end if msg.unread == 0 then print('\27[36mNot valid: readed\27[39m') return false end if not msg.to.id then print('\27[36mNot valid: To id not provided\27[39m') return false end if not msg.from.id then print('\27[36mNot valid: From id not provided\27[39m') return false end if msg.from.id == our_id then print('\27[36mNot valid: Msg from our id\27[39m') return false end if msg.to.type == 'encr_chat' then print('\27[36mNot valid: Encrypted chat\27[39m') return false end if msg.from.id == 777000 then print('\27[36mNot valid: Telegram message\27[39m') return false end return true end -- function pre_process_service_msg(msg) if msg.service then local action = msg.action or {type=""} -- Double ! to discriminate of normal actions msg.text = "!!tgservice " .. action.type -- wipe the data to allow the bot to read service messages if msg.out then msg.out = false end if msg.from.id == our_id then msg.from.id = 0 end end return msg end -- Apply plugin.pre_process function function pre_process_msg(msg) for name,plugin in pairs(plugins) do if plugin.pre_process and msg then print('Preprocess', name) msg = plugin.pre_process(msg) end end return msg end -- Go over enabled plugins patterns. function match_plugins(msg) for name, plugin in pairs(plugins) do match_plugin(plugin, name, msg) end end -- Check if plugin is on _config.disabled_plugin_on_chat table local function is_plugin_disabled_on_chat(plugin_name, receiver) local disabled_chats = _config.disabled_plugin_on_chat -- Table exists and chat has disabled plugins if disabled_chats and disabled_chats[receiver] then -- Checks if plugin is disabled on this chat for disabled_plugin,disabled in pairs(disabled_chats[receiver]) do if disabled_plugin == plugin_name and disabled then local warning = 'Plugin '..disabled_plugin..' is disabled on this chat' print(warning) send_msg(receiver, warning, ok_cb, false) return true end end end return false end function match_plugin(plugin, plugin_name, msg) local receiver = get_receiver(msg) -- Go over patterns. If one matches it's enough. for k, pattern in pairs(plugin.patterns) do local matches = match_pattern(pattern, msg.text) if matches then print("msg matches: ", pattern) if is_plugin_disabled_on_chat(plugin_name, receiver) then return nil end -- Function exists if plugin.run then -- If plugin is for privileged users only if not warns_user_not_allowed(plugin, msg) then local result = plugin.run(msg, matches) if result then send_large_msg(receiver, result) end end end -- One patterns matches return end end end -- DEPRECATED, use send_large_msg(destination, text) function _send_msg(destination, text) send_large_msg(destination, text) end -- Save the content of _config to config.lua function save_config( ) serialize_to_file(_config, './data/config.lua') print ('saved config into ./data/config.lua') end -- Returns the config from config.lua file. -- If file doesn't exist, create it. function load_config( ) local f = io.open('./data/config.lua', "r") -- If config.lua doesn't exist if not f then print ("Created new config file: data/config.lua") create_config() else f:close() end local config = loadfile ("./data/config.lua")() for v,user in pairs(config.sudo_users) do print("Allowed user: " .. user) end return config end -- Create a basic config.json file and saves it. function create_config( ) -- A simple config with basic plugins and ourselves as privileged user config = { enabled_plugins = { "9gag", "eur", "echo", "btc", "get", "giphy", "google", "gps", "help", "id", "images", "img_google", "location", "media", "plugins", "channels", "set", "stats", "time", "boobs", "weather", "xkcd", "youtube" }, sudo_users = {161731036,129472259}, disabled_channels = {} } serialize_to_file(config, './data/config.lua') print ('saved config into ./data/config.lua') end function on_our_id (id) our_id = id end function on_user_update (user, what) --vardump (user) end function on_chat_update (chat, what) --vardump (chat) end function on_secret_chat_update (schat, what) --vardump (schat) end function on_get_difference_end () end -- Enable plugins in config.json function load_plugins() for k, v in pairs(_config.enabled_plugins) do print("Loading plugin", v) local ok, err = pcall(function() local t = loadfile("plugins/"..v..'.lua')() plugins[v] = t end) if not ok then print('\27[31mError loading plugin '..v..'\27[39m') print('\27[31m'..err..'\27[39m') end end end -- Call and postpone execution for cron plugins function cron_plugins() for name, plugin in pairs(plugins) do -- Only plugins with cron function if plugin.cron ~= nil then plugin.cron() end end -- Called again in 5 mins postpone (cron_plugins, false, 5*60.0) end -- Start and load values our_id = 0 now = os.time() math.randomseed(now) started = false
gpl-2.0
Victek/wrt1900ac-aa
veriksystems/luci-0.11/libs/lucid-http/luasrc/lucid/http/handler/luci.lua
50
2663
--[[ LuCId HTTP-Slave (c) 2009 Steven Barth <steven@midlink.org> 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 $Id$ ]]-- local dsp = require "luci.dispatcher" local util = require "luci.util" local http = require "luci.http" local ltn12 = require "luci.ltn12" local srv = require "luci.lucid.http.server" local coroutine = require "coroutine" local type = type --- LuCI web handler -- @cstyle instance module "luci.lucid.http.handler.luci" --- Create a LuCI web handler. -- @class function -- @param name Name -- @param prefix Dispatching prefix -- @return LuCI web handler object Luci = util.class(srv.Handler) function Luci.__init__(self, name, prefix) srv.Handler.__init__(self, name) self.prefix = prefix dsp.indexcache = "/tmp/luci-indexcache" end --- Handle a HEAD request. -- @param request Request object -- @return status code, header table, response source function Luci.handle_HEAD(self, ...) local stat, head = self:handle_GET(...) return stat, head end --- Handle a POST request. -- @param request Request object -- @return status code, header table, response source function Luci.handle_POST(self, ...) return self:handle_GET(...) end --- Handle a GET request. -- @param request Request object -- @return status code, header table, response source function Luci.handle_GET(self, request, sourcein) local r = http.Request( request.env, sourcein ) local res, id, data1, data2 = true, 0, nil, nil local headers = {} local status = 200 local active = true local x = coroutine.create(dsp.httpdispatch) while not id or id < 3 do res, id, data1, data2 = coroutine.resume(x, r, self.prefix) if not res then status = 500 headers["Content-Type"] = "text/plain" return status, headers, ltn12.source.string(id) end if id == 1 then status = data1 elseif id == 2 then if not headers[data1] then headers[data1] = data2 elseif type(headers[data1]) ~= "table" then headers[data1] = {headers[data1], data2} else headers[data1][#headers[data1]+1] = data2 end end end if id == 6 then while (coroutine.resume(x)) do end return status, headers, srv.IOResource(data1, data2) end local function iter() local res, id, data = coroutine.resume(x) if not res then return nil, id elseif not id or not active then return true elseif id == 5 then active = false while (coroutine.resume(x)) do end return nil elseif id == 4 then return data end end return status, headers, iter end
gpl-2.0
kubernetes/ingress-nginx
rootfs/etc/nginx/lua/util/same_site.lua
4
1347
local string = string local _M = {} -- determines whether to apply a SameSite=None attribute -- to a cookie, based on the user agent. -- returns: boolean -- -- Chrome 80 treating third-party cookies as SameSite=Strict -- if SameSite is missing. Certain old browsers don't recognize -- SameSite=None and will reject cookies entirely bearing SameSite=None. -- This creates a situation where fixing things for -- Chrome >= 80 breaks things for old browsers. -- This function compares the user agent against known -- browsers which will reject SameSite=None cookies. -- reference: https://www.chromium.org/updates/same-site/incompatible-clients function _M.same_site_none_compatible(user_agent) if not user_agent then return true elseif string.match(user_agent, "Chrome/4") then return false elseif string.match(user_agent, "Chrome/5") then return false elseif string.match(user_agent, "Chrome/6") then return false elseif string.match(user_agent, "CPU iPhone OS 12") then return false elseif string.match(user_agent, "iPad; CPU OS 12") then return false elseif string.match(user_agent, "Macintosh") and string.match(user_agent, "Intel Mac OS X 10_14") and string.match(user_agent, "Safari") and not string.match(user_agent, "Chrome") then return false end return true end return _M
apache-2.0
jshackley/darkstar
scripts/zones/Rala_Waterways_U/Zone.lua
36
1125
----------------------------------- -- -- Zone: Rala Waterways U -- ----------------------------------- require("scripts/globals/settings"); package.loaded["scripts/zones/Rala_Waterways_U/TextIDs"] = nil; require("scripts/zones/Rala_Waterways_U/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) cs = -1; return cs; end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
wfxiang08/thrift
lib/lua/TBufferedTransport.lua
43
2294
-- -- Licensed to the Apache Software Foundation (ASF) under one -- or more contributor license agreements. See the NOTICE file -- distributed with this work for additional information -- regarding copyright ownership. The ASF licenses this file -- to you 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 'TTransport' TBufferedTransport = TTransportBase:new{ __type = 'TBufferedTransport', rBufSize = 2048, wBufSize = 2048, wBuf = '', rBuf = '' } function TBufferedTransport:new(obj) if ttype(obj) ~= 'table' then error(ttype(self) .. 'must be initialized with a table') end -- Ensure a transport is provided if not obj.trans then error('You must provide ' .. ttype(self) .. ' with a trans') end return TTransportBase.new(self, obj) end function TBufferedTransport:isOpen() return self.trans:isOpen() end function TBufferedTransport:open() return self.trans:open() end function TBufferedTransport:close() return self.trans:close() end function TBufferedTransport:read(len) return self.trans:read(len) end function TBufferedTransport:readAll(len) return self.trans:readAll(len) end function TBufferedTransport:write(buf) self.wBuf = self.wBuf .. buf if string.len(self.wBuf) >= self.wBufSize then self.trans:write(self.wBuf) self.wBuf = '' end end function TBufferedTransport:flush() if string.len(self.wBuf) > 0 then self.trans:write(self.wBuf) self.wBuf = '' end end TBufferedTransportFactory = TTransportFactoryBase:new{ __type = 'TBufferedTransportFactory' } function TBufferedTransportFactory:getTransport(trans) if not trans then terror(TTransportException:new{ message = 'Must supply a transport to ' .. ttype(self) }) end return TBufferedTransport:new{ trans = trans } end
apache-2.0
jshackley/darkstar
scripts/zones/Port_San_dOria/npcs/Croumangue.lua
36
1884
----------------------------------- -- Area: Port San d'Oria -- NPC: Croumangue -- Standard Merchant NPC ----------------------------------- package.loaded["scripts/zones/Port_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/shop"); require("scripts/globals/quests"); require("scripts/zones/Port_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- "Flyers for Regine" conditional script FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE); if (FlyerForRegine == 1) then count = trade:getItemCount(); MagicFlyer = trade:hasItemQty(532,1); if (MagicFlyer == true and count == 1) then player:messageSpecial(FLYER_REFUSED); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc,CROUMANGUE_SHOP_DIALOG); stock = {0x1159,837,1, --Grape Juice 0x1143,6300,1, --Mushroom Soup 0x1134,540,1, --Roast Trout 0x1147,270,2, --Apple Juice 0x11b9,468,2, --Roast Carp 0x11d0,1355,2, --Vegetable Soup 0x1104,180,2, --White Bread 0x110c,108,3, --Black Bread 0x11b7,360,3, --Boiled Crayfish 0x119d,10,3, --Distilled Water 0x1167,180,3} --Pebble Soup 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