repo_name stringlengths 6 69 | path stringlengths 6 178 | copies stringclasses 278
values | size stringlengths 4 7 | content stringlengths 671 917k | license stringclasses 15
values |
|---|---|---|---|---|---|
ricker75/Global-Server | data/actions/scripts/gnomebase/crystalWarzone1.lua | 2 | 2068 | --- [[ Warzone 1 feito por Yuri Lagrotta ]] ---
local posdotp = {x= 33104, y=31908, z=10} -- Posicao que o tp vai ser criado (Eh o tp que leva pra sala do Deathstriker)
local salaDeathstriker = {x=33101, y=31956, z=10} -- Posicao da sala do Deathstriker (Pos pra onde o player vai qd entrar no tp)
local posDeathstriker = {x=33108, y=31968, z=10} -- Posicao onde o Deathstriker vai nascer.
function removerTp(tp)
local t = getTileItemById(posdotp, 1387)
if t then
doRemoveItem(t.uid, 1)
doSendMagicEffect(posdotp, CONST_ME_POFF)
end
end
function TirarCristal()
local cristal = getTileItemById(posdotp, 17999) -- Id do cristal azul que some para dar lugar ao tp
if cristal then
doRemoveItem(cristal.uid, 1)
end
return true
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
if(getGlobalStorageValue(96973) < 1) then
setGlobalStorageValue(96973, 1)
for i = 1, 6 do
for k = 1, 10 do
creatures = {
"humongous fungus",
"hideous fungus"
}
pos = {x = math.random(33091, 33101), y = math.random(31899, 31916), z = 10}
addEvent(doSummonCreature, i * 20 * 1000, creatures[math.random(1, 2)], pos)
addEvent(doSendMagicEffect, i * 20 * 1000, pos, CONST_ME_TELEPORT)
end
addEvent(doCreatureSay, i * 20 * 1000, cid, "The crystals are charging.", TALKTYPE_ORANGE_1, false, cid, toPosition)
end
doCreatureSay(cid, "The crystals are damaging!", TALKTYPE_ORANGE_1, false, cid, toPosition)
addEvent(doSummonCreature, 62000+6*20*1000, "Deathstrike", posDeathstriker)
addEvent(doSendMagicEffect, 6*20*1000, posDeathstriker, CONST_ME_TELEPORT)
addEvent(TirarCristal, 6*20*1000)
addEvent(doCreateTeleport, 100+6*20*1000, 1387, salaDeathstriker, posdotp)
addEvent(removerTp, 60000+6*20*1000)
addEvent(doCreateItem, 61000+6*20*1000, 17999, posdotp)
addEvent(setGlobalStorageValue, 6*20*1000 + 30*60*1000, 96973, 0)
else
doPlayerSendCancel(cid, "Wait 30 minutes to start again.")
end
return true
end | gpl-2.0 |
ibm2431/darkstar | scripts/globals/items/aspir_knife.lua | 12 | 1125 | -----------------------------------------
-- ID: 16509
-- Item: Aspir Knife
-- Additional effect: MP Drain
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/magic")
require("scripts/globals/msg")
-----------------------------------
function onAdditionalEffect(player,target,damage)
local chance = 10
if (math.random(0,99) >= chance or target:isUndead()) then
return 0,0,0
else
local drain = math.random(1,3)
local params = {}
params.bonusmab = 0
params.includemab = false
-- drain = addBonusesAbility(player, dsp.magic.ele.DARK, target, drain, params)
drain = drain * applyResistanceAddEffect(player,target,dsp.magic.ele.DARK,0)
drain = adjustForTarget(target,drain,dsp.magic.ele.DARK)
drain = finalMagicNonSpellAdjustments(player,target,dsp.magic.ele.DARK,drain)
if (drain > target:getMP()) then
drain = target:getMP()
end
target:addMP(-drain)
return dsp.subEffect.MP_DRAIN, dsp.msg.basic.ADD_EFFECT_MP_DRAIN, player:addMP(drain)
end
end | gpl-3.0 |
ibm2431/darkstar | scripts/zones/Riverne-Site_B01/bcnms/storms_of_fate.lua | 9 | 2004 | -----------------------------------
-- Area: Riverne Site #B01
-- Name: Storms of Fate
-- !pos 299 -123 345 146
-----------------------------------
local ID = require("scripts/zones/Riverne-Site_B01/IDs")
require("scripts/globals/battlefield")
require("scripts/globals/keyitems")
require("scripts/globals/settings")
require("scripts/globals/quests")
require("scripts/globals/status")
require("scripts/globals/titles")
-----------------------------------
function onBattlefieldTick(battlefield, tick)
dsp.battlefield.onBattlefieldTick(battlefield, tick)
end
function onBattlefieldRegister(player, battlefield)
end
function onBattlefieldEnter(player, battlefield)
player:delStatusEffect(dsp.effect.LEVEL_RESTRICTION) -- can't be capped at 50 for this fight !
end
function onBattlefieldLeave(player, battlefield, leavecode)
if leavecode == dsp.battlefield.leaveCode.WON then
local name, clearTime, partySize = battlefield:getRecord()
local arg8 = (player:getQuestStatus(JEUNO, dsp.quest.id.jeuno.STORMS_OF_FATE) == QUEST_COMPLETED) and 1 or 0
player:startEvent(32001, battlefield:getArea(), clearTime, partySize, battlefield:getTimeInside(), 1, battlefield:getLocalVar("[cs]bit"), arg8)
elseif leavecode == dsp.battlefield.leaveCode.LOST then
player:startEvent(32002)
end
end
function onEventUpdate(player, csid, option)
end
function onEventFinish(player, csid, option)
if csid == 32001 then
if player:getQuestStatus(JEUNO, dsp.quest.id.jeuno.STORMS_OF_FATE) == QUEST_ACCEPTED and player:getCharVar('StormsOfFate') == 2 then
player:addKeyItem(dsp.ki.WHISPER_OF_THE_WYRMKING)
player:messageSpecial(ID.text.KEYITEM_OBTAINED, dsp.ki.WHISPER_OF_THE_WYRMKING)
player:setCharVar('StormsOfFate', 3)
player:addTitle(dsp.title.CONQUEROR_OF_FATE)
end
if ENABLE_COP_ZONE_CAP == 1 then
player:addStatusEffect(dsp.effect.LEVEL_RESTRICTION, 50, 0, 0)
end
end
end
| gpl-3.0 |
LegionXI/darkstar | scripts/zones/Giddeus/npcs/HomePoint#1.lua | 27 | 1248 | -----------------------------------
-- Area: Giddeus
-- NPC: HomePoint#1
-- @pos -132 -3 -303 145
-----------------------------------
package.loaded["scripts/zones/Giddeus/TextIDs"] = nil;
require("scripts/globals/settings");
require("scripts/zones/Giddeus/TextIDs");
require("scripts/globals/homepoint");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
homepointMenu( player, 0x21fc, 54);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x21fc) then
if (option == 1) then
player:setHomePoint();
player:messageSpecial(HOMEPOINT_SET);
else
hpTeleport( player, option);
end
end
end;
| gpl-3.0 |
greasydeal/darkstar | scripts/zones/Castle_Zvahl_Keep/npcs/_4i5.lua | 23 | 1492 | -----------------------------------
-- Area: Castle Zvahl Keep
-- NPC: Ore door
-- Involved In Quest: Recollections
-- @pos -14 0 69 162
-----------------------------------
package.loaded["scripts/zones/Castle_Zvahl_Keep/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/keyitems");
require("scripts/zones/Castle_Zvahl_Keep/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if(player:getQuestStatus(WINDURST,RECOLLECTIONS) == QUEST_ACCEPTED and player:getVar("recollectionsQuest") == 2) then
if(trade:hasItemQty(1106,1) and trade:getItemCount() == 1) then
player:startEvent(0x0008,1106);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x0009);
return 1;
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if(csid == 0x0008) then
player:tradeComplete();
player:setVar("recollectionsQuest",3);
player:addKeyItem(FOE_FINDER_MK_I);
player:messageSpecial(KEYITEM_OBTAINED,FOE_FINDER_MK_I);
end
end; | gpl-3.0 |
aginor/wesnoth | data/ai/micro_ais/cas/ca_goto.lua | 26 | 9404 | local H = wesnoth.require "lua/helper.lua"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local BC = wesnoth.require "ai/lua/battle_calcs.lua"
local LS = wesnoth.require "lua/location_set.lua"
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"
local MAISD = wesnoth.require "ai/micro_ais/micro_ai_self_data.lua"
local function custom_cost(x, y, unit, enemy_map, enemy_attack_map, multiplier)
local terrain = wesnoth.get_terrain(x, y)
local move_cost = wesnoth.unit_movement_cost(unit, terrain)
move_cost = move_cost + (enemy_map:get(x,y) or 0)
move_cost = move_cost + (enemy_attack_map.units:get(x,y) or 0) * multiplier
return move_cost
end
local ca_goto = {}
function ca_goto:evaluation(ai, cfg, self)
-- If cfg.release_all_units_at_goal is set, check whether the goal has
-- already been reached, in which case we do not do anything
if MAISD.get_mai_self_data(self.data, cfg.ai_id, "release_all") then
return 0
end
-- For convenience, we check for locations here, and just pass that to the exec function
-- This is mostly to make the unique_goals option easier
local width, height = wesnoth.get_map_size()
local all_locs = wesnoth.get_locations {
x = '1-' .. width,
y = '1-' .. height,
{ "and", cfg.filter_location }
}
if (#all_locs == 0) then return 0 end
-- If 'unique_goals' is set, check whether there are locations left to go to.
-- This does not have to be a persistent variable
local locs = {}
if cfg.unique_goals then
-- First, some cleanup of previous turn data
local str = 'goal_taken_' .. (wesnoth.current.turn - 1)
local old_goals = MAISD.get_mai_self_data(self.data, cfg.ai_id)
for goal,_ in pairs(old_goals) do
if string.find(goal, str) then
old_goals[goal] = nil -- This also removes it from self.data
end
end
-- Now on to the current turn
for _,loc in ipairs(all_locs) do
local str = 'goal_taken_' .. wesnoth.current.turn .. '_' .. loc[1] .. '_' .. loc[2]
if (not MAISD.get_mai_self_data(self.data, cfg.ai_id, str)) then
table.insert(locs, loc)
end
end
else
locs = all_locs
end
if (not locs[1]) then return 0 end
local all_units = AH.get_units_with_moves {
side = wesnoth.current.side,
{ "and", cfg.filter }
}
local units = {}
if cfg.release_unit_at_goal then
for _,unit in ipairs(all_units) do
if (not MAIUV.get_mai_unit_variables(unit, cfg.ai_id, "release")) then
table.insert(units, unit)
end
end
else
units = all_units
end
if (not units[1]) then return 0 end
-- Now store units and locs in self.data, so that we don't need to duplicate this in the exec function
self.data.GO_units, self.data.GO_locs = units, locs
return cfg.ca_score
end
function ca_goto:execution(ai, cfg, self)
local units, locs = self.data.GO_units, self.data.GO_locs
local enemy_map, enemy_attack_map
if cfg.avoid_enemies then
if (type(cfg.avoid_enemies) ~= 'number') then
H.wml_error("Goto AI avoid_enemies= requires a number as argument")
elseif (cfg.avoid_enemies <= 0) then
H.wml_error("Goto AI avoid_enemies= argument must be >0")
end
local enemies = wesnoth.get_units { { "filter_side", { { "enemy_of", { side = wesnoth.current.side } } } } }
enemy_map = LS.create()
for _,enemy in ipairs(enemies) do
enemy_map:insert(enemy.x, enemy.y, (enemy_map:get(enemy.x, enemy.y) or 0) + 1000)
for xa,ya in H.adjacent_tiles(enemy.x, enemy.y) do
enemy_map:insert(xa, ya, (enemy_map:get(xa, ya) or 0) + 10)
end
end
enemy_attack_map = BC.get_attack_map(enemies)
end
local max_rating, closest_hex, best_path, best_unit = -9e99
for _,unit in ipairs(units) do
for _,loc in ipairs(locs) do
-- If cfg.use_straight_line is set, we simply find the closest
-- hex to the goal that the unit can get to
if cfg.use_straight_line then
local hex, _, rating = AH.find_best_move(unit, function(x, y)
local r = - H.distance_between(x, y, loc[1], loc[2])
-- Also add distance from unit as very small rating component
-- This is mostly here to keep unit in place when no better hexes are available
r = r - H.distance_between(x, y, unit.x, unit.y) / 1000.
return r
end, { no_random = true })
if (rating > max_rating) then
max_rating = rating
closest_hex, best_unit = hex, unit
end
else -- Otherwise find the best path to take
local path, cost
if cfg.avoid_enemies then
path, cost = wesnoth.find_path(unit, loc[1], loc[2],
function(x, y, current_cost)
return custom_cost(x, y, unit, enemy_map, enemy_attack_map, cfg.avoid_enemies)
end
)
else
local enemy_at_goal
if cfg.ignore_enemy_at_goal then
enemy_at_goal = wesnoth.get_unit(loc[1], loc[2])
if enemy_at_goal and wesnoth.is_enemy(wesnoth.current.side, enemy_at_goal.side) then
wesnoth.extract_unit(enemy_at_goal)
else
enemy_at_goal = nil
end
end
path, cost = wesnoth.find_path(unit, loc[1], loc[2], { ignore_units = cfg.ignore_units })
if enemy_at_goal then
wesnoth.put_unit(enemy_at_goal)
--- Give massive penalty for this goal hex
cost = cost + 100
end
end
-- Make all hexes within the unit's current MP equaivalent
if (cost <= unit.moves) then cost = 0 end
local rating = - cost
-- Add a small penalty for hexes occupied by an allied unit
local unit_in_way = wesnoth.get_unit(loc[1], loc[2])
if unit_in_way and (unit_in_way ~= unit) then
rating = rating - 0.01
end
if (rating > max_rating) then
max_rating = rating
closest_hex, best_unit, best_path = loc, unit, path
end
end
end
end
-- If 'unique_goals' is set, mark this location as being taken
if cfg.unique_goals then
local str = 'goal_taken_' .. wesnoth.current.turn .. '_' .. closest_hex[1] .. '_' .. closest_hex[2]
local tmp_table = {}
tmp_table[str] = true
MAISD.insert_mai_self_data(self.data, cfg.ai_id, tmp_table)
end
-- If any of the non-standard path finding options were used,
-- we need to pick the farthest reachable hex along that path
-- For simplicity, we do it for all types of pathfinding here,
-- rather than using ai_helper.next_hop for standard pathfinding
-- Also, straight-line does not produce a path, so we do that first
if not best_path then
best_path = wesnoth.find_path(best_unit, closest_hex[1], closest_hex[2])
end
-- Now go through the hexes along that path, use normal path finding
closest_hex = best_path[1]
for i = 2,#best_path do
local sub_path, sub_cost = wesnoth.find_path(best_unit, best_path[i][1], best_path[i][2], cfg)
if sub_cost <= best_unit.moves then
local unit_in_way = wesnoth.get_unit(best_path[i][1], best_path[i][2])
if not unit_in_way then
closest_hex = best_path[i]
end
else
break
end
end
if closest_hex then
AH.checked_move_full(ai, best_unit, closest_hex[1], closest_hex[2])
else
AH.checked_stopunit_moves(ai, best_unit)
end
if (not best_unit) or (not best_unit.valid) then return end
-- If release_unit_at_goal= or release_all_units_at_goal= key is set:
-- Check if the unit made it to one of the goal hexes
-- This needs to be done for the original goal hexes, not by checking the SLF again,
-- as that might have changed based on the new situation on the map
if cfg.release_unit_at_goal or cfg.release_all_units_at_goal then
local is_unit_at_goal = false
for _,loc in ipairs(locs) do
if (best_unit.x == loc[1]) and (best_unit.y == loc[2]) then
is_unit_at_goal = true
break
end
end
if is_unit_at_goal then
if cfg.release_unit_at_goal then
MAIUV.set_mai_unit_variables(best_unit, cfg.ai_id, { release = true })
end
if cfg.release_all_units_at_goal then
MAISD.insert_mai_self_data(self.data, cfg.ai_id, { release_all = true })
end
end
end
self.data.GO_units, self.data.GO_locs = nil, nil
end
return ca_goto
| gpl-2.0 |
evrooije/beerarchy | mods/00_bt_hud/hudbars/init.lua | 2 | 18899 | local S
if (minetest.get_modpath("intllib")) then
S = intllib.Getter()
else
S = function ( s ) return s end
end
hb = {}
hb.hudtables = {}
-- number of registered HUD bars
hb.hudbars_count = 0
-- table which records which HUD bar slots have been โregisteredโ so far; used for automatic positioning
hb.registered_slots = {}
hb.settings = {}
function hb.load_setting(sname, stype, defaultval, valid_values)
local sval
if stype == "string" then
sval = minetest.setting_get(sname)
elseif stype == "bool" then
sval = minetest.setting_getbool(sname)
elseif stype == "number" then
sval = tonumber(minetest.setting_get(sname))
end
if sval ~= nil then
if valid_values ~= nil then
local valid = false
for i=1,#valid_values do
if sval == valid_values[i] then
valid = true
end
end
if not valid then
minetest.log("error", "[hudbars] Invalid value for "..sname.."! Using default value ("..tostring(defaultval)..").")
return defaultval
else
return sval
end
else
return sval
end
else
return defaultval
end
end
-- (hardcoded) default settings
hb.settings.max_bar_length = 160
hb.settings.statbar_length = 20
-- statbar positions
hb.settings.pos_left = {}
hb.settings.pos_right = {}
hb.settings.start_offset_left = {}
hb.settings.start_offset_right= {}
hb.settings.pos_left.x = hb.load_setting("hudbars_pos_left_x", "number", 0.5)
hb.settings.pos_left.y = hb.load_setting("hudbars_pos_left_y", "number", 1)
hb.settings.pos_right.x = hb.load_setting("hudbars_pos_right_x", "number", 0.5)
hb.settings.pos_right.y = hb.load_setting("hudbars_pos_right_y", "number", 1)
hb.settings.bar_type = hb.load_setting("hudbars_bar_type", "string", "progress_bar", {"progress_bar", "statbar_classic", "statbar_modern"})
if hb.settings.bar_type == "progress_bar" then
hb.settings.start_offset_left.x = hb.load_setting("hudbars_start_offset_left_x", "number", -175)
hb.settings.start_offset_left.y = hb.load_setting("hudbars_start_offset_left_y", "number", -86)
hb.settings.start_offset_right.x = hb.load_setting("hudbars_start_offset_right_x", "number", 15)
hb.settings.start_offset_right.y = hb.load_setting("hudbars_start_offset_right_y", "number", -86)
else
hb.settings.start_offset_left.x = hb.load_setting("hudbars_start_statbar_offset_left_x", "number", -265)
hb.settings.start_offset_left.y = hb.load_setting("hudbars_start_statbar_offset_left_y", "number", -90)
hb.settings.start_offset_right.x = hb.load_setting("hudbars_start_statbar_offset_right_x", "number", 25)
hb.settings.start_offset_right.y = hb.load_setting("hudbars_start_statbar_offset_right_y", "number", -90)
end
hb.settings.vmargin = hb.load_setting("hudbars_vmargin", "number", 24)
hb.settings.tick = hb.load_setting("hudbars_tick", "number", 0.1)
-- experimental setting: Changing this setting is not officially supported, do NOT rely on it!
hb.settings.forceload_default_hudbars = hb.load_setting("hudbars_forceload_default_hudbars", "bool", true)
-- Misc. settings
hb.settings.alignment_pattern = hb.load_setting("hudbars_alignment_pattern", "string", "zigzag", {"zigzag", "stack_up", "stack_down"})
hb.settings.autohide_breath = hb.load_setting("hudbars_autohide_breath", "bool", true)
local sorting = minetest.setting_get("hudbars_sorting")
if sorting ~= nil then
hb.settings.sorting = {}
hb.settings.sorting_reverse = {}
for k,v in string.gmatch(sorting, "(%w+)=(%w+)") do
hb.settings.sorting[k] = tonumber(v)
hb.settings.sorting_reverse[tonumber(v)] = k
end
else
hb.settings.sorting = { ["health"] = 0, ["breath"] = 1 }
hb.settings.sorting_reverse = { [0] = "health", [1] = "breath" }
end
local function player_exists(player)
return player ~= nil and player:is_player()
end
-- Table which contains all players with active default HUD bars (only for internal use)
hb.players = {}
function hb.value_to_barlength(value, max)
if max == 0 then
return 0
else
if hb.settings.bar_type == "progress_bar" then
local x
if value < 0 then x=-0.5 else x = 0.5 end
local ret = math.modf((value/max) * hb.settings.max_bar_length + x)
return ret
else
local x
if value < 0 then x=-0.5 else x = 0.5 end
local ret = math.modf((value/max) * hb.settings.statbar_length + x)
return ret
end
end
end
function hb.get_hudtable(identifier)
return hb.hudtables[identifier]
end
function hb.get_hudbar_position_index(identifier)
if hb.settings.sorting[identifier] ~= nil then
return hb.settings.sorting[identifier]
else
local i = 0
while true do
if hb.registered_slots[i] ~= true and hb.settings.sorting_reverse[i] == nil then
return i
end
i = i + 1
end
end
end
function hb.register_hudbar(identifier, text_color, label, textures, default_start_value, default_start_max, default_start_hidden, format_string)
minetest.log("action", "hb.register_hudbar: "..tostring(identifier))
local hudtable = {}
local pos, offset
local index = math.floor(hb.get_hudbar_position_index(identifier))
hb.registered_slots[index] = true
if hb.settings.alignment_pattern == "stack_up" then
pos = hb.settings.pos_left
offset = {
x = hb.settings.start_offset_left.x,
y = hb.settings.start_offset_left.y - hb.settings.vmargin * index
}
elseif hb.settings.alignment_pattern == "stack_down" then
pos = hb.settings.pos_left
offset = {
x = hb.settings.start_offset_left.x,
y = hb.settings.start_offset_left.y + hb.settings.vmargin * index
}
else
if index % 2 == 0 then
pos = hb.settings.pos_left
offset = {
x = hb.settings.start_offset_left.x,
y = hb.settings.start_offset_left.y - hb.settings.vmargin * (index/2)
}
else
pos = hb.settings.pos_right
offset = {
x = hb.settings.start_offset_right.x,
y = hb.settings.start_offset_right.y - hb.settings.vmargin * ((index-1)/2)
}
end
end
if format_string == nil then
format_string = S("%s: %d/%d")
end
hudtable.add_all = function(player, hudtable, start_value, start_max, start_hidden)
if start_value == nil then start_value = hudtable.default_start_value end
if start_max == nil then start_max = hudtable.default_start_max end
if start_hidden == nil then start_hidden = hudtable.default_start_hidden end
local ids = {}
local state = {}
local name = player:get_player_name()
local bgscale, iconscale, text, barnumber, bgiconnumber
if start_max == 0 or start_hidden then
bgscale = { x=0, y=0 }
else
bgscale = { x=1, y=1 }
end
if start_hidden then
iconscale = { x=0, y=0 }
barnumber = 0
bgiconnumber = 0
text = ""
else
iconscale = { x=1, y=1 }
barnumber = hb.value_to_barlength(start_value, start_max)
bgiconnumber = hb.settings.statbar_length
text = string.format(format_string, label, start_value, start_max)
end
if hb.settings.bar_type == "progress_bar" then
ids.bg = player:hud_add({
hud_elem_type = "image",
position = pos,
scale = bgscale,
text = "hudbars_bar_background.png",
alignment = {x=1,y=1},
offset = { x = offset.x - 1, y = offset.y - 1 },
})
if textures.icon ~= nil then
ids.icon = player:hud_add({
hud_elem_type = "image",
position = pos,
scale = iconscale,
text = textures.icon,
alignment = {x=-1,y=1},
offset = { x = offset.x - 3, y = offset.y },
})
end
elseif hb.settings.bar_type == "statbar_modern" then
if textures.bgicon ~= nil then
ids.bg = player:hud_add({
hud_elem_type = "statbar",
position = pos,
text = textures.bgicon,
number = bgiconnumber,
alignment = {x=-1,y=-1},
offset = { x = offset.x, y = offset.y },
direction = 0,
size = {x=24, y=24},
})
end
end
local bar_image, bar_size
if hb.settings.bar_type == "progress_bar" then
bar_image = textures.bar
bar_size = nil
elseif hb.settings.bar_type == "statbar_classic" or hb.settings.bar_type == "statbar_modern" then
bar_image = textures.icon
bar_size = {x=24, y=24}
end
ids.bar = player:hud_add({
hud_elem_type = "statbar",
position = pos,
text = bar_image,
number = barnumber,
alignment = {x=-1,y=-1},
offset = offset,
direction = 0,
size = bar_size,
})
if hb.settings.bar_type == "progress_bar" then
ids.text = player:hud_add({
hud_elem_type = "text",
position = pos,
text = text,
alignment = {x=1,y=1},
number = text_color,
direction = 0,
offset = { x = offset.x + 2, y = offset.y - 1},
})
end
-- Do not forget to update hb.get_hudbar_state if you add new fields to the state table
state.hidden = start_hidden
state.value = start_value
state.max = start_max
state.text = text
state.barlength = hb.value_to_barlength(start_value, start_max)
local main_error_text =
"[hudbars] Bad initial values of HUD bar identifier โ"..tostring(identifier).."โ for player "..name..". "
if start_max < start_value then
minetest.log("error", main_error_text.."start_max ("..start_max..") is smaller than start_value ("..start_value..")!")
end
if start_max < 0 then
minetest.log("error", main_error_text.."start_max ("..start_max..") is smaller than 0!")
end
if start_value < 0 then
minetest.log("error", main_error_text.."start_value ("..start_value..") is smaller than 0!")
end
hb.hudtables[identifier].hudids[name] = ids
hb.hudtables[identifier].hudstate[name] = state
end
hudtable.identifier = identifier
hudtable.format_string = format_string
hudtable.label = label
hudtable.hudids = {}
hudtable.hudstate = {}
hudtable.default_start_hidden = default_start_hidden
hudtable.default_start_value = default_start_value
hudtable.default_start_max = default_start_max
hb.hudbars_count= hb.hudbars_count + 1
hb.hudtables[identifier] = hudtable
end
function hb.init_hudbar(player, identifier, start_value, start_max, start_hidden)
if not player_exists(player) then return false end
local hudtable = hb.get_hudtable(identifier)
hb.hudtables[identifier].add_all(player, hudtable, start_value, start_max, start_hidden)
return true
end
function hb.change_hudbar(player, identifier, new_value, new_max_value, new_icon, new_bgicon, new_bar, new_label, new_text_color)
if new_value == nil and new_max_value == nil and new_icon == nil and new_bgicon == nil and new_bar == nil and new_label == nil and new_text_color == nil then
return true
end
if not player_exists(player) then
return false
end
local name = player:get_player_name()
local hudtable = hb.get_hudtable(identifier)
local value_changed, max_changed = false, false
if new_value ~= nil then
if new_value ~= hudtable.hudstate[name].value then
hudtable.hudstate[name].value = new_value
value_changed = true
end
else
new_value = hudtable.hudstate[name].value
end
if new_max_value ~= nil then
if new_max_value ~= hudtable.hudstate[name].max then
hudtable.hudstate[name].max = new_max_value
max_changed = true
end
else
new_max_value = hudtable.hudstate[name].max
end
if hb.settings.bar_type == "progress_bar" then
if new_icon ~= nil and hudtable.hudids[name].icon ~= nil then
player:hud_change(hudtable.hudids[name].icon, "text", new_icon)
end
if new_bgicon ~= nil and hudtable.hudids[name].bgicon ~= nil then
player:hud_change(hudtable.hudids[name].bgicon, "text", new_bgicon)
end
if new_bar ~= nil then
player:hud_change(hudtable.hudids[name].bar , "text", new_bar)
end
if new_label ~= nil then
hudtable.label = new_label
local new_text = string.format(hudtable.format_string, new_label, hudtable.hudstate[name].value, hudtable.hudstate[name].max)
player:hud_change(hudtable.hudids[name].text, "text", new_text)
end
if new_text_color ~= nil then
player:hud_change(hudtable.hudids[name].text, "number", new_text_color)
end
else
if new_icon ~= nil and hudtable.hudids[name].bar ~= nil then
player:hud_change(hudtable.hudids[name].bar, "text", new_icon)
end
if new_bgicon ~= nil and hudtable.hudids[name].bg ~= nil then
player:hud_change(hudtable.hudids[name].bg, "text", new_bgicon)
end
end
local main_error_text =
"[hudbars] Bad call to hb.change_hudbar, identifier: โ"..tostring(identifier).."โ, player name: โ"..name.."โ. "
if new_max_value < new_value then
minetest.log("error", main_error_text.."new_max_value ("..new_max_value..") is smaller than new_value ("..new_value..")!")
end
if new_max_value < 0 then
minetest.log("error", main_error_text.."new_max_value ("..new_max_value..") is smaller than 0!")
end
if new_value < 0 then
minetest.log("error", main_error_text.."new_value ("..new_value..") is smaller than 0!")
end
if hudtable.hudstate[name].hidden == false then
if max_changed and hb.settings.bar_type == "progress_bar" then
if hudtable.hudstate[name].max == 0 then
player:hud_change(hudtable.hudids[name].bg, "scale", {x=0,y=0})
else
player:hud_change(hudtable.hudids[name].bg, "scale", {x=1,y=1})
end
end
if value_changed or max_changed then
local new_barlength = hb.value_to_barlength(new_value, new_max_value)
if new_barlength ~= hudtable.hudstate[name].barlength then
player:hud_change(hudtable.hudids[name].bar, "number", hb.value_to_barlength(new_value, new_max_value))
hudtable.hudstate[name].barlength = new_barlength
end
if hb.settings.bar_type == "progress_bar" then
local new_text = string.format(hudtable.format_string, hudtable.label, new_value, new_max_value)
if new_text ~= hudtable.hudstate[name].text then
player:hud_change(hudtable.hudids[name].text, "text", new_text)
hudtable.hudstate[name].text = new_text
end
end
end
end
return true
end
function hb.hide_hudbar(player, identifier)
if not player_exists(player) then return false end
local name = player:get_player_name()
local hudtable = hb.get_hudtable(identifier)
if hudtable == nil then return false end
if(hudtable.hudstate[name].hidden == false) then
if hb.settings.bar_type == "progress_bar" then
if hudtable.hudids[name].icon ~= nil then
player:hud_change(hudtable.hudids[name].icon, "scale", {x=0,y=0})
end
player:hud_change(hudtable.hudids[name].bg, "scale", {x=0,y=0})
player:hud_change(hudtable.hudids[name].text, "text", "")
elseif hb.settings.bar_type == "statbar_modern" then
player:hud_change(hudtable.hudids[name].bg, "number", 0)
end
player:hud_change(hudtable.hudids[name].bar, "number", 0)
hudtable.hudstate[name].hidden = true
end
return true
end
function hb.unhide_hudbar(player, identifier)
if not player_exists(player) then return false end
local name = player:get_player_name()
local hudtable = hb.get_hudtable(identifier)
if hudtable == nil then return false end
if(hudtable.hudstate[name].hidden) then
local value = hudtable.hudstate[name].value
local max = hudtable.hudstate[name].max
if hb.settings.bar_type == "progress_bar" then
if hudtable.hudids[name].icon ~= nil then
player:hud_change(hudtable.hudids[name].icon, "scale", {x=1,y=1})
end
if hudtable.hudstate[name].max ~= 0 then
player:hud_change(hudtable.hudids[name].bg, "scale", {x=1,y=1})
end
player:hud_change(hudtable.hudids[name].text, "text", tostring(string.format(hudtable.format_string, hudtable.label, value, max)))
elseif hb.settings.bar_type == "statbar_modern" then
player:hud_change(hudtable.hudids[name].bg, "number", hb.settings.statbar_length)
end
player:hud_change(hudtable.hudids[name].bar, "number", hb.value_to_barlength(value, max))
hudtable.hudstate[name].hidden = false
end
return true
end
function hb.get_hudbar_state(player, identifier)
if not player_exists(player) then return nil end
local ref = hb.get_hudtable(identifier).hudstate[player:get_player_name()]
-- Do not forget to update this chunk of code in case the state changes
local copy = {
hidden = ref.hidden,
value = ref.value,
max = ref.max,
text = ref.text,
barlength = ref.barlength,
}
return copy
end
--register built-in HUD bars
if minetest.setting_getbool("enable_damage") or hb.settings.forceload_default_hudbars then
hb.register_hudbar("health", 0xFFFFFF, S("Health"), { bar = "hudbars_bar_health.png", icon = "hudbars_icon_health.png", bgicon = "hudbars_bgicon_health.png" }, 20, 20, false)
hb.register_hudbar("breath", 0xFFFFFF, S("Breath"), { bar = "hudbars_bar_breath.png", icon = "hudbars_icon_breath.png", bgicon = "hudbars_bgicon_breath.png" }, 10, 10, true)
end
local function hide_builtin(player)
local flags = player:hud_get_flags()
flags.healthbar = false
flags.breathbar = false
player:hud_set_flags(flags)
end
local function custom_hud(player)
if minetest.setting_getbool("enable_damage") or hb.settings.forceload_default_hudbars then
local hide
if minetest.setting_getbool("enable_damage") then
hide = false
else
hide = true
end
hb.init_hudbar(player, "health", player:get_hp(), nil, hide)
local breath = player:get_breath()
local hide_breath
if breath == 11 and hb.settings.autohide_breath == true then hide_breath = true else hide_breath = false end
hb.init_hudbar(player, "breath", math.min(breath, 10), nil, hide_breath or hide)
end
end
local function update_health(player)
hb.change_hudbar(player, "health", player:get_hp())
end
-- update built-in HUD bars
local function update_hud(player)
if not player_exists(player) then return end
if minetest.setting_getbool("enable_damage") then
if hb.settings.forceload_default_hudbars then
hb.unhide_hudbar(player, "health")
end
--air
local breath = player:get_breath()
if breath == 11 and hb.settings.autohide_breath == true then
hb.hide_hudbar(player, "breath")
else
hb.unhide_hudbar(player, "breath")
hb.change_hudbar(player, "breath", math.min(breath, 10))
end
--health
update_health(player)
elseif hb.settings.forceload_default_hudbars then
hb.hide_hudbar(player, "health")
hb.hide_hudbar(player, "breath")
end
end
minetest.register_on_player_hpchange(function(player)
if hb.players[player:get_player_name()] ~= nil then
update_health(player)
end
end)
minetest.register_on_respawnplayer(function(player)
update_health(player)
hb.hide_hudbar(player, "breath")
end)
minetest.register_on_joinplayer(function(player)
hide_builtin(player)
custom_hud(player)
hb.players[player:get_player_name()] = player
end)
minetest.register_on_leaveplayer(function(player)
hb.players[player:get_player_name()] = nil
end)
local main_timer = 0
local timer = 0
minetest.register_globalstep(function(dtime)
main_timer = main_timer + dtime
timer = timer + dtime
if main_timer > hb.settings.tick or timer > 4 then
if main_timer > hb.settings.tick then main_timer = 0 end
-- only proceed if damage is enabled
if minetest.setting_getbool("enable_damage") or hb.settings.forceload_default_hudbars then
for _, player in pairs(hb.players) do
-- update all hud elements
update_hud(player)
end
end
end
if timer > 4 then timer = 0 end
end)
| lgpl-2.1 |
ibm2431/darkstar | scripts/zones/Uleguerand_Range/npcs/qm3.lua | 9 | 3229 | -----------------------------------
-- Area: Uleguerand_Range
-- NPC: ??? (Trade Moblin Hotrok for Map of Uleguerand Range)
-- !pos -299 -62 -18
-- Involved in Quests: Over The Hills And Far Away
-----------------------------------
local ID = require("scripts/zones/Uleguerand_Range/IDs")
require("scripts/globals/npc_util")
require("scripts/globals/titles")
-----------------------------------
function onTrade(player,npc,trade)
local overTheHillsAndFarAway = player:getQuestStatus(SANDORIA, dsp.quest.id.sandoria.OVER_THE_HILLS_AND_FAR_AWAY)
local louverancesPath = player:getCharVar("COP_Louverance_s_Path")
-- Taking a logical guess what criteria displays what message.
if overTheHillsAndFarAway == QUEST_ACCEPTED and npcUtil.tradeHas(trade, 1729) then -- 1729 = Moblin Hotrok
if louverancesPath >= 10 then
if player:hasTitle(dsp.title.COMPANION_OF_LOUVERANCE) or player:hasTitle(dsp.title.TRUE_COMPANION_OF_LOUVERANCE) then
player:startEvent(10, 0, 1729, dsp.ki.MAP_OF_THE_ULEGUERAND_RANGE, 0, 0, 1, 0)
-- ^ 1 = Remembers you and girl from Tavnazia and asks to TRADE dagger for map
else
player:startEvent(10, 0, 1729, dsp.ki.MAP_OF_THE_ULEGUERAND_RANGE, 1, 0, 1, 0)
-- ^ 1 ^ 1 = Remembers you and girl from Tavnazia and asks for the dagger
end
else
if player:hasTitle(dsp.title.COMPANION_OF_LOUVERANCE) or player:hasTitle(dsp.title.TRUE_COMPANION_OF_LOUVERANCE) then
player:startEvent(10, 0, 1729, dsp.ki.MAP_OF_THE_ULEGUERAND_RANGE, 0, 1, 0, 0)
-- ^ 1 = Doesn't recognize you and asks to TRADE dagger for map
-- or
-- ^ 1 = Doesn't recognize you and asks to TRADE dagger for map
else
player:startEvent(10, 0, 1729, dsp.ki.MAP_OF_THE_ULEGUERAND_RANGE, 1, 0, 0, 0)
-- ^ 1 = Doesn't recognize you and asks for the dagger
end
end
end
end
function onTrigger(player,npc)
local overTheHillsAndFarAway = player:getQuestStatus(SANDORIA, dsp.quest.id.sandoria.OVER_THE_HILLS_AND_FAR_AWAY)
if overTheHillsAndFarAway == QUEST_COMPLETED then
player:messageSpecial(ID.text.NOTHING_OUT_OF_ORDINARY)
elseif overTheHillsAndFarAway == QUEST_ACCEPTED then
player:messageSpecial(ID.text.SOMETHING_GLITTERING)
player:messageSpecial(ID.text.WHAT_LIES_BENEATH, 0, 1729)
else
player:messageSpecial(ID.text.SOMETHING_GLITTERING_BUT)
end
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
if csid == 10 and npcUtil.completeQuest(player, SANDORIA, dsp.quest.id.sandoria.OVER_THE_HILLS_AND_FAR_AWAY, {gil = 2000, xp = 2000, ki = dsp.ki.MAP_OF_THE_ULEGUERAND_RANGE}) then
player:confirmTrade()
end
end
| gpl-3.0 |
nicholas-leonard/rnn | SeqReverseSequence.lua | 6 | 3161 | ------------------------------------------------------------------------
--[[ SeqReverseSequence ]] --
-- Reverses a sequence on a given dimension.
-- Example: Given a tensor of torch.Tensor({{1,2,3,4,5}, {6,7,8,9,10}})
-- nn.SeqReverseSequence(1):forward(tensor) would give: torch.Tensor({{6,7,8,9,10},{1,2,3,4,5}})
------------------------------------------------------------------------
local SeqReverseSequence, parent = torch.class("nn.SeqReverseSequence", "nn.Module")
function SeqReverseSequence:__init(dim)
parent.__init(self)
self.output = torch.Tensor()
self.gradInput = torch.Tensor()
assert(dim, "Must specify dimension to reverse sequence over")
assert(dim <= 3, "Dimension has to be no greater than 3 (Only supports up to a 3D Tensor).")
self.dim = dim
end
function SeqReverseSequence:reverseOutput(input)
self.output:resizeAs(input)
self.outputIndices = self.outputIndices or ((torch.type(input) == 'torch.CudaTensor') and torch.CudaTensor() or (torch.type(input) == 'torch.ClTensor') and torch.ClTensor() or torch.LongTensor())
self.outputIndices:resize(input:size())
local T = input:size(1)
for x = 1, T do
self.outputIndices:narrow(1, x, 1):fill(T - x + 1)
end
self.output:gather(input, 1, self.outputIndices)
end
function SeqReverseSequence:updateOutput(input)
if (self.dim == 1) then
self:reverseOutput(input)
end
if (self.dim == 2) then
input = input:transpose(1, 2)
self:reverseOutput(input)
self.output = self.output:transpose(1, 2)
end
if (self.dim == 3) then
input = input:transpose(1, 3)
self:reverseOutput(input)
self.output = self.output:transpose(1, 3)
end
return self.output
end
function SeqReverseSequence:reverseGradOutput(gradOutput)
self.gradInput:resizeAs(gradOutput)
self.gradIndices = self.gradIndices or ((torch.type(gradOutput) == 'torch.CudaTensor') and torch.CudaTensor() or (torch.type(gradOutput) == 'torch.ClTensor') and torch.ClTensor() or torch.LongTensor())
self.gradIndices:resize(gradOutput:size())
local T = gradOutput:size(1)
for x = 1, T do
self.gradIndices:narrow(1, x, 1):fill(T - x + 1)
end
self.gradInput:gather(gradOutput, 1, self.gradIndices)
end
function SeqReverseSequence:updateGradInput(inputTable, gradOutput)
if (self.dim == 1) then
self:reverseGradOutput(gradOutput)
end
if (self.dim == 2) then
gradOutput = gradOutput:transpose(1, 2)
self:reverseGradOutput(gradOutput)
self.gradInput = self.gradInput:transpose(1, 2)
end
if (self.dim == 3) then
gradOutput = gradOutput:transpose(1, 3)
self:reverseGradOutput(gradOutput)
self.gradInput = self.gradInput:transpose(1, 3)
end
return self.gradInput
end
function SeqReverseSequence:type(type, typecache)
if type then
self.outputIndices = nil
self.gradIndices = nil
end
return parent.type(self, type, typecache)
end
function SeqReverseSequence:clearState()
self.output:set()
self.gradInput:set()
self.outputIndices = nil
self.gradIndices = nil
end
| bsd-3-clause |
greasydeal/darkstar | scripts/zones/Yhoator_Jungle/npcs/Etaj-Pohtaj_WW.lua | 30 | 3054 | -----------------------------------
-- Area: Yhoator Jungle
-- NPC: Etaj-Pohtaj, W.W.
-- Outpost Conquest Guards
-- @pos 200.254 -1 -80.324 124
-----------------------------------
package.loaded["scripts/zones/Yhoator_Jungle/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/conquest");
require("scripts/zones/Yhoator_Jungle/TextIDs");
local guardnation = WINDURST; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno
local guardtype = 3; -- 1: city, 2: foreign, 3: outpost, 4: border
local region = ELSHIMOUPLANDS;
local csid = 0x7ff7;
-----------------------------------
-- 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 |
greasydeal/darkstar | scripts/zones/Lower_Jeuno/npcs/HomePoint#2.lua | 12 | 1239 | -----------------------------------
-- Area: Lower Jeuno
-- NPC: HomePoint#2
-- @pos 18 -1 54 245
-----------------------------------
package.loaded["scripts/zones/Lower_Jeuno/TextIDs"] = nil;
require("scripts/globals/settings");
require("scripts/zones/Lower_Jeuno/TextIDs");
require("scripts/globals/homepoint");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
homepointMenu( player, 0x21fd, 36);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if(csid == 0x21fd) then
if (option == 1) then
player:setHomePoint();
player:messageSpecial(HOMEPOINT_SET);
else
hpTeleport( player, option);
end
end
end; | gpl-3.0 |
LegionXI/darkstar | scripts/zones/Cloister_of_Storms/bcnms/trial_by_lightning.lua | 30 | 2230 | -----------------------------------
-- Area: Cloister of Storms
-- BCNM: Trial by Lightning
-----------------------------------
package.loaded["scripts/zones/Cloister_of_Storms/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/keyitems");
require("scripts/globals/missions");
require("scripts/zones/Cloister_of_Storms/TextIDs");
-----------------------------------
-- 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);
trialLightning = player:getQuestStatus(OTHER_AREAS,TRIAL_BY_LIGHTNING)
if (leavecode == 2) then -- play end CS. Need time and battle id for record keeping + storage
if (trialLightning == QUEST_COMPLETED) 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_LIGHTNING);
player:addKeyItem(WHISPER_OF_STORMS);
player:messageSpecial(KEYITEM_OBTAINED,WHISPER_OF_STORMS);
end
end;
| gpl-3.0 |
LegionXI/darkstar | scripts/zones/Port_Windurst/npcs/Kususu.lua | 17 | 1729 | -----------------------------------
-- Area: Port Windurst
-- NPC: Kususu
-- Standard Merchant NPC
-- Confirmed shop stock, August 2013
-----------------------------------
require("scripts/globals/shop");
package.loaded["scripts/zones/Port_Windurst/TextIDs"] = nil;
require("scripts/zones/Port_Windurst/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,KUSUSU_SHOP_DIALOG);
stock = {
0x1221, 1165,1, --Diaga
0x1236, 7025,1, --Stoneskin
0x1238, 837,1, --Slow
0x1202, 585,2, --Cure II
0x121c, 140,2, --Banish
0x1226, 1165,2, --Banishga
0x1235, 2097,2, --Blink
0x1201, 61,3, --Cure
0x1207, 1363,3, --Curaga
0x120e, 180,3, --Poisona
0x120f, 324,3, --Paralyna
0x1210, 990,3, --Blindna
0x1217, 82,3, --Dia
0x122b, 219,3, --Protect
0x1230, 1584,3, --Shell
0x1237, 360,3 --Aquaveil
}
showNationShop(player, NATION_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 |
LegionXI/darkstar | scripts/zones/Meriphataud_Mountains/npcs/Muzeze.lua | 14 | 1049 | -----------------------------------
-- Area: Meriphataud Mountains
-- NPC: Muzeze
-- Type: Armor Storer
-- @pos -6.782 -18.428 208.185 119
-----------------------------------
package.loaded["scripts/zones/Meriphataud_Mountains/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Meriphataud_Mountains/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x002c);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
herrbrave/RTS_Engine | RTS/RTS/Games/Delza/Delza.lua | 1 | 1675 | registrar = {
ASSET = 0,
DRAWABLE = 0,
ENTITY = 0,
FACTORY = 0,
PHYSICS = 0,
ANIMATION = 0,
INPUT = 1,
SCRIPT = 0,
ASSET = 0,
CAMERA = 1,
MOUSE_MOVE = 0,
UI = 0,
WORLD = 0,
}
function setup()
print("setup Delza Game", tostring(entityId))
sceneX = 0
sceneY = 0
end
-- Standard Mouse/Key events
function onMouseUp(x, y, button)
end
function onMouseDown(x, y, button)
end
function onKeyDown(keyId, ctrl, shft)
if keyId == SDLK_RIGHT then
sceneX = sceneX + 1
moveCamera()
elseif keyId == SDLK_DOWN then
sceneY = sceneY + 1
moveCamera()
elseif keyId == SDLK_LEFT then
sceneX = sceneX - 1
moveCamera()
elseif keyId == SDLK_UP then
sceneY = sceneY - 1
moveCamera()
end
end
function onKeyUp(keyId, ctrl, shft)
end
-- Entity Mouse Events
function onMouseEnterEntity()
end
function onMouseExitEntity()
end
function onClickEntity(button)
end
function onDragEntity(button)
end
-- Mouse Move Events --
function onMouseMove(x, y, button)
end
-- Collition Callback --
function onCollision(id)
end
function update(delta)
end
function onBroadcast(message, value)
if message == "OFF_SCREEN" then
if value == "RIGHT" then
sceneX = sceneX + 1
moveCamera()
elseif value == "LEFT" then
sceneX = sceneX - 1
moveCamera()
elseif value == "UP" then
sceneY = sceneY - 1
moveCamera()
elseif value == "DOWN" then
sceneY = sceneY + 1
moveCamera()
end
end
end
function onMessage(message, value)
return false
end
function onPhysics(delta)
end
function moveCamera()
x = (sceneX * 16 * 64) + (32 * 16)
y = (sceneY * 16 * 48) + (24 * 16)
print(tostring(x), tostring(y))
setCameraPosition(x, y)
end | mit |
LegionXI/darkstar | scripts/globals/spells/bluemagic/grand_slam.lua | 33 | 1713 | -----------------------------------------
-- Spell: Grand Slam
-- Delivers an area attack. Damage varies with TP
-- Spell cost: 24 MP
-- Monster Type: Beastmen
-- Spell Type: Physical (Blunt)
-- Blue Magic Points: 2
-- Stat Bonus: INT+1
-- Level: 30
-- Casting Time: 1 seconds
-- Recast Time: 14.25 seconds
-- Skillchain Element(s): Ice (can open Impaction, Compression, or Fragmentation; can close Induration)
-- Combos: Defense Bonus
-----------------------------------------
require("scripts/globals/magic");
require("scripts/globals/status");
require("scripts/globals/bluemagic");
-----------------------------------------
-- OnMagicCastingCheck
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onSpellCast(caster,target,spell)
local params = {};
-- This data should match information on http://wiki.ffxiclopedia.org/wiki/Calculating_Blue_Magic_Damage
params.tpmod = TPMOD_ATTACK;
params.dmgtype = DMGTYPE_BLUNT;
params.scattr = SC_INDURATION;
params.numhits = 1;
params.multiplier = 1.0;
params.tp150 = 1.0;
params.tp300 = 1.0;
params.azuretp = 1.0;
params.duppercap = 133;
params.str_wsc = 0.0;
params.dex_wsc = 0.0;
params.vit_wsc = 0.3;
params.agi_wsc = 0.0;
params.int_wsc = 0.1;
params.mnd_wsc = 0.1;
params.chr_wsc = 0.1;
damage = BluePhysicalSpell(caster, target, spell, params);
damage = BlueFinalAdjustments(caster, target, spell, damage, params);
return damage;
end; | gpl-3.0 |
lbthomsen/openwrt-luci | applications/luci-app-radicale2/luasrc/model/cbi/radicale2/logging.lua | 10 | 1503 | -- Licensed to the public under the Apache License 2.0.
local m = Map("radicale2", translate("Radicale 2.x"),
translate("A lightweight CalDAV/CardDAV server"))
local s = m:section(NamedSection, "logging", "section", translate("Logging"))
s.addremove = true
s.anonymous = false
local logging_file = nil
logging_file = s:option(FileUpload, "config", translate("Logging File"), translate("Log configuration file (no file means default procd which ends up in syslog"))
logging_file.rmempty = true
logging_file.default = ""
o = s:option(Button, "remove_conf", translate("Remove configuration for logging"),
translate("This permanently deletes configuration for logging"))
o.inputstyle = "remove"
function o.write(self, section)
if logging_file:cfgvalue(section) and fs.access(logging_file:cfgvalue(section)) then fs.unlink(loggin_file:cfgvalue(section)) end
self.map:del(section, "config")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "radicale2", "logging"))
end
o = s:option(Flag, "debug", translate("Debug"), translate("Send debug information to logs"))
o.rmempty = true
o.default = o.disabled
o = s:option(Flag, "full_environment", translate("Dump Environment"), translate("Include full environment in logs"))
o.rmempty = true
o.default = o.disabled
o = s:option(Flag, "mask_passwords", translate("Mask Passwords"), translate("Redact passwords in logs"))
o.rmempty = true
o.default = o.enabled
-- TODO: Allow configuration logging file from this page
return m
| apache-2.0 |
gOOvER/Factionizer | Libs/LibStub/tests/test2.lua | 100 | 1112 | debugstack = debug.traceback
strmatch = string.match
loadfile("../LibStub.lua")()
for major, library in LibStub:IterateLibraries() do
-- check that MyLib doesn't exist yet, by iterating through all the libraries
assert(major ~= "MyLib")
end
assert(not LibStub:GetLibrary("MyLib", true)) -- check that MyLib doesn't exist yet by direct checking
assert(not pcall(LibStub.GetLibrary, LibStub, "MyLib")) -- don't silently fail, thus it should raise an error.
local lib = LibStub:NewLibrary("MyLib", 1) -- create the lib
assert(lib) -- check it exists
assert(rawequal(LibStub:GetLibrary("MyLib"), lib)) -- verify that :GetLibrary("MyLib") properly equals the lib reference
assert(LibStub:NewLibrary("MyLib", 2)) -- create a new version
local count=0
for major, library in LibStub:IterateLibraries() do
-- check that MyLib exists somewhere in the libraries, by iterating through all the libraries
if major == "MyLib" then -- we found it!
count = count +1
assert(rawequal(library, lib)) -- verify that the references are equal
end
end
assert(count == 1) -- verify that we actually found it, and only once
| gpl-3.0 |
greasydeal/darkstar | scripts/globals/effects/fan_dance.lua | 17 | 1199 | -----------------------------------
--
-- EFFECT_FAN_DANCE
--
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
local fanDanceMerits = target:getMerit(MERIT_FAN_DANCE);
if(fanDanceMerits >5) then
target:addMod(MOD_WALTZ_RECAST, (fanDanceMerits-5));
end
target:delStatusEffect(EFFECT_HASTE_SAMBA);
target:delStatusEffect(EFFECT_ASPIR_SAMBA);
target:delStatusEffect(EFFECT_DRAIN_SAMBA);
target:delStatusEffect(EFFECT_SABER_DANCE);
target:addMod(MOD_ENMITY, 15);
end;
-----------------------------------
-- onEffectTick Action
-----------------------------------
function onEffectTick(target,effect)
end;
-----------------------------------
-- onEffectLose Action
-----------------------------------
function onEffectLose(target,effect)
local fanDanceMerits = target:getMerit(MERIT_FAN_DANCE);
if(fanDanceMerits >5) then
target:delMod(MOD_WALTZ_RECAST, (fanDanceMerits-5));
end
target:delMod(MOD_ENMITY, 15);
end; | gpl-3.0 |
naclander/tome | game/modules/tome/data/zones/town-iron-council/traps.lua | 3 | 2573 | -- ToME - Tales of Maj'Eyal
-- Copyright (C) 2009 - 2014 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
load("/data/general/traps/store.lua")
newEntity{ base = "BASE_STORE", define_as = "HEAVY_ARMOR_STORE",
name="Armoury",
display='2', color=colors.UMBER,
resolvers.store("HEAVY_ARMOR", "iron-throne", "store/shop_door.png", "store/shop_sign_armory.png"),
}
newEntity{ base = "BASE_STORE", define_as = "LIGHT_ARMOR_STORE",
name="Tanner",
display='2', color=colors.UMBER,
resolvers.store("LIGHT_ARMOR", "iron-throne", "store/shop_door.png", "store/shop_sign_tanner.png"),
}
newEntity{ base = "BASE_STORE", define_as = "CLOTH_ARMOR_STORE",
name="Tailor",
display='2', color=colors.UMBER,
resolvers.store("CLOTH_ARMOR", "iron-throne", "store/shop_door.png", "store/shop_sign_tailor.png"),
}
newEntity{ base = "BASE_STORE", define_as = "SWORD_WEAPON_STORE",
name="Sword smith",
display='3', color=colors.UMBER,
resolvers.store("SWORD_WEAPON", "iron-throne", "store/shop_door.png", "store/shop_sign_swordsmith.png"),
}
newEntity{ base = "BASE_STORE", define_as = "AXE_WEAPON_STORE",
name="Axe smith",
display='3', color=colors.UMBER,
resolvers.store("AXE_WEAPON", "iron-throne", "store/shop_door.png", "store/shop_sign_axesmith.png"),
}
newEntity{ base = "BASE_STORE", define_as = "MACE_WEAPON_STORE",
name="Mace smith",
display='3', color=colors.UMBER,
resolvers.store("MAUL_WEAPON", "iron-throne", "store/shop_door.png", "store/shop_sign_macesmith.png"),
}
newEntity{ base = "BASE_STORE", define_as = "RUNIC_STORE",
name="Runemaster",
display='5', color=colors.RED,
resolvers.store("SCROLL", "iron-throne", "store/shop_door.png", "store/shop_sign_alchemist.png"),
}
newEntity{ base = "BASE_STORE", define_as = "GEM_STORE",
name="Jewelry",
display='9', color=colors.LIGHT_RED,
resolvers.store("GEMSTORE", "iron-throne", "store/shop_door.png", "store/shop_sign_jewelry.png"),
}
| gpl-3.0 |
greasydeal/darkstar | scripts/globals/spells/sword_madrigal.lua | 13 | 1535 | -----------------------------------------
-- Spell: Sword Madrigal
-- Gives party members accuracy
-----------------------------------------
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 > 85) then
power = power + math.floor((sLvl+iLvl-85) / 18);
end
if(power >= 15) then
power = 15;
end
local iBoost = caster:getMod(MOD_MADRIGAL_EFFECT) + caster:getMod(MOD_ALL_SONGS_EFFECT);
if (iBoost > 0) then
power = power + 1 + (iBoost-1)*3;
end
power = power + caster:getMerit(MERIT_MADRIGAL_EFFECT);
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_MADRIGAL,power,0,duration,caster:getID(), 0, 1)) then
spell:setMsg(75);
end
return EFFECT_MADRIGAL;
end; | gpl-3.0 |
LegionXI/darkstar | scripts/globals/items/forest_carp.lua | 12 | 1340 | -----------------------------------------
-- ID: 4289
-- Item: forest_carp
-- Food Effect: 30Min, Mithra only
-----------------------------------------
-- Dexterity 2
-- Mind -4
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:getRace() ~= 7) then
result = 247;
end
if (target:getMod(MOD_EAT_RAW_FISH) == 1) then
result = 0;
end
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,1800,4289);
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 |
naclander/tome | game/thirdparty/jit/bcsave.lua | 20 | 18123 | ----------------------------------------------------------------------------
-- LuaJIT module to save/list bytecode.
--
-- Copyright (C) 2005-2013 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
--
-- This module saves or lists the bytecode for an input file.
-- It's run by the -b command line option.
--
------------------------------------------------------------------------------
local jit = require("jit")
assert(jit.version_num == 20002, "LuaJIT core/library version mismatch")
local bit = require("bit")
-- Symbol name prefix for LuaJIT bytecode.
local LJBC_PREFIX = "luaJIT_BC_"
------------------------------------------------------------------------------
local function usage()
io.stderr:write[[
Save LuaJIT bytecode: luajit -b[options] input output
-l Only list bytecode.
-s Strip debug info (default).
-g Keep debug info.
-n name Set module name (default: auto-detect from input name).
-t type Set output file type (default: auto-detect from output name).
-a arch Override architecture for object files (default: native).
-o os Override OS for object files (default: native).
-e chunk Use chunk string as input.
-- Stop handling options.
- Use stdin as input and/or stdout as output.
File types: c h obj o raw (default)
]]
os.exit(1)
end
local function check(ok, ...)
if ok then return ok, ... end
io.stderr:write("luajit: ", ...)
io.stderr:write("\n")
os.exit(1)
end
local function readfile(input)
if type(input) == "function" then return input end
if input == "-" then input = nil end
return check(loadfile(input))
end
local function savefile(name, mode)
if name == "-" then return io.stdout end
return check(io.open(name, mode))
end
------------------------------------------------------------------------------
local map_type = {
raw = "raw", c = "c", h = "h", o = "obj", obj = "obj",
}
local map_arch = {
x86 = true, x64 = true, arm = true, ppc = true, ppcspe = true,
mips = true, mipsel = true,
}
local map_os = {
linux = true, windows = true, osx = true, freebsd = true, netbsd = true,
openbsd = true, solaris = true,
}
local function checkarg(str, map, err)
str = string.lower(str)
local s = check(map[str], "unknown ", err)
return s == true and str or s
end
local function detecttype(str)
local ext = string.match(string.lower(str), "%.(%a+)$")
return map_type[ext] or "raw"
end
local function checkmodname(str)
check(string.match(str, "^[%w_.%-]+$"), "bad module name")
return string.gsub(str, "[%.%-]", "_")
end
local function detectmodname(str)
if type(str) == "string" then
local tail = string.match(str, "[^/\\]+$")
if tail then str = tail end
local head = string.match(str, "^(.*)%.[^.]*$")
if head then str = head end
str = string.match(str, "^[%w_.%-]+")
else
str = nil
end
check(str, "cannot derive module name, use -n name")
return string.gsub(str, "[%.%-]", "_")
end
------------------------------------------------------------------------------
local function bcsave_tail(fp, output, s)
local ok, err = fp:write(s)
if ok and output ~= "-" then ok, err = fp:close() end
check(ok, "cannot write ", output, ": ", err)
end
local function bcsave_raw(output, s)
local fp = savefile(output, "wb")
bcsave_tail(fp, output, s)
end
local function bcsave_c(ctx, output, s)
local fp = savefile(output, "w")
if ctx.type == "c" then
fp:write(string.format([[
#ifdef _cplusplus
extern "C"
#endif
#ifdef _WIN32
__declspec(dllexport)
#endif
const char %s%s[] = {
]], LJBC_PREFIX, ctx.modname))
else
fp:write(string.format([[
#define %s%s_SIZE %d
static const char %s%s[] = {
]], LJBC_PREFIX, ctx.modname, #s, LJBC_PREFIX, ctx.modname))
end
local t, n, m = {}, 0, 0
for i=1,#s do
local b = tostring(string.byte(s, i))
m = m + #b + 1
if m > 78 then
fp:write(table.concat(t, ",", 1, n), ",\n")
n, m = 0, #b + 1
end
n = n + 1
t[n] = b
end
bcsave_tail(fp, output, table.concat(t, ",", 1, n).."\n};\n")
end
local function bcsave_elfobj(ctx, output, s, ffi)
ffi.cdef[[
typedef struct {
uint8_t emagic[4], eclass, eendian, eversion, eosabi, eabiversion, epad[7];
uint16_t type, machine;
uint32_t version;
uint32_t entry, phofs, shofs;
uint32_t flags;
uint16_t ehsize, phentsize, phnum, shentsize, shnum, shstridx;
} ELF32header;
typedef struct {
uint8_t emagic[4], eclass, eendian, eversion, eosabi, eabiversion, epad[7];
uint16_t type, machine;
uint32_t version;
uint64_t entry, phofs, shofs;
uint32_t flags;
uint16_t ehsize, phentsize, phnum, shentsize, shnum, shstridx;
} ELF64header;
typedef struct {
uint32_t name, type, flags, addr, ofs, size, link, info, align, entsize;
} ELF32sectheader;
typedef struct {
uint32_t name, type;
uint64_t flags, addr, ofs, size;
uint32_t link, info;
uint64_t align, entsize;
} ELF64sectheader;
typedef struct {
uint32_t name, value, size;
uint8_t info, other;
uint16_t sectidx;
} ELF32symbol;
typedef struct {
uint32_t name;
uint8_t info, other;
uint16_t sectidx;
uint64_t value, size;
} ELF64symbol;
typedef struct {
ELF32header hdr;
ELF32sectheader sect[6];
ELF32symbol sym[2];
uint8_t space[4096];
} ELF32obj;
typedef struct {
ELF64header hdr;
ELF64sectheader sect[6];
ELF64symbol sym[2];
uint8_t space[4096];
} ELF64obj;
]]
local symname = LJBC_PREFIX..ctx.modname
local is64, isbe = false, false
if ctx.arch == "x64" then
is64 = true
elseif ctx.arch == "ppc" or ctx.arch == "ppcspe" or ctx.arch == "mips" then
isbe = true
end
-- Handle different host/target endianess.
local function f32(x) return x end
local f16, fofs = f32, f32
if ffi.abi("be") ~= isbe then
f32 = bit.bswap
function f16(x) return bit.rshift(bit.bswap(x), 16) end
if is64 then
local two32 = ffi.cast("int64_t", 2^32)
function fofs(x) return bit.bswap(x)*two32 end
else
fofs = f32
end
end
-- Create ELF object and fill in header.
local o = ffi.new(is64 and "ELF64obj" or "ELF32obj")
local hdr = o.hdr
if ctx.os == "bsd" or ctx.os == "other" then -- Determine native hdr.eosabi.
local bf = assert(io.open("/bin/ls", "rb"))
local bs = bf:read(9)
bf:close()
ffi.copy(o, bs, 9)
check(hdr.emagic[0] == 127, "no support for writing native object files")
else
hdr.emagic = "\127ELF"
hdr.eosabi = ({ freebsd=9, netbsd=2, openbsd=12, solaris=6 })[ctx.os] or 0
end
hdr.eclass = is64 and 2 or 1
hdr.eendian = isbe and 2 or 1
hdr.eversion = 1
hdr.type = f16(1)
hdr.machine = f16(({ x86=3, x64=62, arm=40, ppc=20, ppcspe=20, mips=8, mipsel=8 })[ctx.arch])
if ctx.arch == "mips" or ctx.arch == "mipsel" then
hdr.flags = 0x50001006
end
hdr.version = f32(1)
hdr.shofs = fofs(ffi.offsetof(o, "sect"))
hdr.ehsize = f16(ffi.sizeof(hdr))
hdr.shentsize = f16(ffi.sizeof(o.sect[0]))
hdr.shnum = f16(6)
hdr.shstridx = f16(2)
-- Fill in sections and symbols.
local sofs, ofs = ffi.offsetof(o, "space"), 1
for i,name in ipairs{
".symtab", ".shstrtab", ".strtab", ".rodata", ".note.GNU-stack",
} do
local sect = o.sect[i]
sect.align = fofs(1)
sect.name = f32(ofs)
ffi.copy(o.space+ofs, name)
ofs = ofs + #name+1
end
o.sect[1].type = f32(2) -- .symtab
o.sect[1].link = f32(3)
o.sect[1].info = f32(1)
o.sect[1].align = fofs(8)
o.sect[1].ofs = fofs(ffi.offsetof(o, "sym"))
o.sect[1].entsize = fofs(ffi.sizeof(o.sym[0]))
o.sect[1].size = fofs(ffi.sizeof(o.sym))
o.sym[1].name = f32(1)
o.sym[1].sectidx = f16(4)
o.sym[1].size = fofs(#s)
o.sym[1].info = 17
o.sect[2].type = f32(3) -- .shstrtab
o.sect[2].ofs = fofs(sofs)
o.sect[2].size = fofs(ofs)
o.sect[3].type = f32(3) -- .strtab
o.sect[3].ofs = fofs(sofs + ofs)
o.sect[3].size = fofs(#symname+1)
ffi.copy(o.space+ofs+1, symname)
ofs = ofs + #symname + 2
o.sect[4].type = f32(1) -- .rodata
o.sect[4].flags = fofs(2)
o.sect[4].ofs = fofs(sofs + ofs)
o.sect[4].size = fofs(#s)
o.sect[5].type = f32(1) -- .note.GNU-stack
o.sect[5].ofs = fofs(sofs + ofs + #s)
-- Write ELF object file.
local fp = savefile(output, "wb")
fp:write(ffi.string(o, ffi.sizeof(o)-4096+ofs))
bcsave_tail(fp, output, s)
end
local function bcsave_peobj(ctx, output, s, ffi)
ffi.cdef[[
typedef struct {
uint16_t arch, nsects;
uint32_t time, symtabofs, nsyms;
uint16_t opthdrsz, flags;
} PEheader;
typedef struct {
char name[8];
uint32_t vsize, vaddr, size, ofs, relocofs, lineofs;
uint16_t nreloc, nline;
uint32_t flags;
} PEsection;
typedef struct __attribute((packed)) {
union {
char name[8];
uint32_t nameref[2];
};
uint32_t value;
int16_t sect;
uint16_t type;
uint8_t scl, naux;
} PEsym;
typedef struct __attribute((packed)) {
uint32_t size;
uint16_t nreloc, nline;
uint32_t cksum;
uint16_t assoc;
uint8_t comdatsel, unused[3];
} PEsymaux;
typedef struct {
PEheader hdr;
PEsection sect[2];
// Must be an even number of symbol structs.
PEsym sym0;
PEsymaux sym0aux;
PEsym sym1;
PEsymaux sym1aux;
PEsym sym2;
PEsym sym3;
uint32_t strtabsize;
uint8_t space[4096];
} PEobj;
]]
local symname = LJBC_PREFIX..ctx.modname
local is64 = false
if ctx.arch == "x86" then
symname = "_"..symname
elseif ctx.arch == "x64" then
is64 = true
end
local symexport = " /EXPORT:"..symname..",DATA "
-- The file format is always little-endian. Swap if the host is big-endian.
local function f32(x) return x end
local f16 = f32
if ffi.abi("be") then
f32 = bit.bswap
function f16(x) return bit.rshift(bit.bswap(x), 16) end
end
-- Create PE object and fill in header.
local o = ffi.new("PEobj")
local hdr = o.hdr
hdr.arch = f16(({ x86=0x14c, x64=0x8664, arm=0x1c0, ppc=0x1f2, mips=0x366, mipsel=0x366 })[ctx.arch])
hdr.nsects = f16(2)
hdr.symtabofs = f32(ffi.offsetof(o, "sym0"))
hdr.nsyms = f32(6)
-- Fill in sections and symbols.
o.sect[0].name = ".drectve"
o.sect[0].size = f32(#symexport)
o.sect[0].flags = f32(0x00100a00)
o.sym0.sect = f16(1)
o.sym0.scl = 3
o.sym0.name = ".drectve"
o.sym0.naux = 1
o.sym0aux.size = f32(#symexport)
o.sect[1].name = ".rdata"
o.sect[1].size = f32(#s)
o.sect[1].flags = f32(0x40300040)
o.sym1.sect = f16(2)
o.sym1.scl = 3
o.sym1.name = ".rdata"
o.sym1.naux = 1
o.sym1aux.size = f32(#s)
o.sym2.sect = f16(2)
o.sym2.scl = 2
o.sym2.nameref[1] = f32(4)
o.sym3.sect = f16(-1)
o.sym3.scl = 2
o.sym3.value = f32(1)
o.sym3.name = "@feat.00" -- Mark as SafeSEH compliant.
ffi.copy(o.space, symname)
local ofs = #symname + 1
o.strtabsize = f32(ofs + 4)
o.sect[0].ofs = f32(ffi.offsetof(o, "space") + ofs)
ffi.copy(o.space + ofs, symexport)
ofs = ofs + #symexport
o.sect[1].ofs = f32(ffi.offsetof(o, "space") + ofs)
-- Write PE object file.
local fp = savefile(output, "wb")
fp:write(ffi.string(o, ffi.sizeof(o)-4096+ofs))
bcsave_tail(fp, output, s)
end
local function bcsave_machobj(ctx, output, s, ffi)
ffi.cdef[[
typedef struct
{
uint32_t magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds, flags;
} mach_header;
typedef struct
{
mach_header; uint32_t reserved;
} mach_header_64;
typedef struct {
uint32_t cmd, cmdsize;
char segname[16];
uint32_t vmaddr, vmsize, fileoff, filesize;
uint32_t maxprot, initprot, nsects, flags;
} mach_segment_command;
typedef struct {
uint32_t cmd, cmdsize;
char segname[16];
uint64_t vmaddr, vmsize, fileoff, filesize;
uint32_t maxprot, initprot, nsects, flags;
} mach_segment_command_64;
typedef struct {
char sectname[16], segname[16];
uint32_t addr, size;
uint32_t offset, align, reloff, nreloc, flags;
uint32_t reserved1, reserved2;
} mach_section;
typedef struct {
char sectname[16], segname[16];
uint64_t addr, size;
uint32_t offset, align, reloff, nreloc, flags;
uint32_t reserved1, reserved2, reserved3;
} mach_section_64;
typedef struct {
uint32_t cmd, cmdsize, symoff, nsyms, stroff, strsize;
} mach_symtab_command;
typedef struct {
int32_t strx;
uint8_t type, sect;
int16_t desc;
uint32_t value;
} mach_nlist;
typedef struct {
uint32_t strx;
uint8_t type, sect;
uint16_t desc;
uint64_t value;
} mach_nlist_64;
typedef struct
{
uint32_t magic, nfat_arch;
} mach_fat_header;
typedef struct
{
uint32_t cputype, cpusubtype, offset, size, align;
} mach_fat_arch;
typedef struct {
struct {
mach_header hdr;
mach_segment_command seg;
mach_section sec;
mach_symtab_command sym;
} arch[1];
mach_nlist sym_entry;
uint8_t space[4096];
} mach_obj;
typedef struct {
struct {
mach_header_64 hdr;
mach_segment_command_64 seg;
mach_section_64 sec;
mach_symtab_command sym;
} arch[1];
mach_nlist_64 sym_entry;
uint8_t space[4096];
} mach_obj_64;
typedef struct {
mach_fat_header fat;
mach_fat_arch fat_arch[4];
struct {
mach_header hdr;
mach_segment_command seg;
mach_section sec;
mach_symtab_command sym;
} arch[4];
mach_nlist sym_entry;
uint8_t space[4096];
} mach_fat_obj;
]]
local symname = '_'..LJBC_PREFIX..ctx.modname
local isfat, is64, align, mobj = false, false, 4, "mach_obj"
if ctx.arch == "x64" then
is64, align, mobj = true, 8, "mach_obj_64"
elseif ctx.arch == "arm" then
isfat, mobj = true, "mach_fat_obj"
else
check(ctx.arch == "x86", "unsupported architecture for OSX")
end
local function aligned(v, a) return bit.band(v+a-1, -a) end
local be32 = bit.bswap -- Mach-O FAT is BE, supported archs are LE.
-- Create Mach-O object and fill in header.
local o = ffi.new(mobj)
local mach_size = aligned(ffi.offsetof(o, "space")+#symname+2, align)
local cputype = ({ x86={7}, x64={0x01000007}, arm={7,12,12,12} })[ctx.arch]
local cpusubtype = ({ x86={3}, x64={3}, arm={3,6,9,11} })[ctx.arch]
if isfat then
o.fat.magic = be32(0xcafebabe)
o.fat.nfat_arch = be32(#cpusubtype)
end
-- Fill in sections and symbols.
for i=0,#cpusubtype-1 do
local ofs = 0
if isfat then
local a = o.fat_arch[i]
a.cputype = be32(cputype[i+1])
a.cpusubtype = be32(cpusubtype[i+1])
-- Subsequent slices overlap each other to share data.
ofs = ffi.offsetof(o, "arch") + i*ffi.sizeof(o.arch[0])
a.offset = be32(ofs)
a.size = be32(mach_size-ofs+#s)
end
local a = o.arch[i]
a.hdr.magic = is64 and 0xfeedfacf or 0xfeedface
a.hdr.cputype = cputype[i+1]
a.hdr.cpusubtype = cpusubtype[i+1]
a.hdr.filetype = 1
a.hdr.ncmds = 2
a.hdr.sizeofcmds = ffi.sizeof(a.seg)+ffi.sizeof(a.sec)+ffi.sizeof(a.sym)
a.seg.cmd = is64 and 0x19 or 0x1
a.seg.cmdsize = ffi.sizeof(a.seg)+ffi.sizeof(a.sec)
a.seg.vmsize = #s
a.seg.fileoff = mach_size-ofs
a.seg.filesize = #s
a.seg.maxprot = 1
a.seg.initprot = 1
a.seg.nsects = 1
ffi.copy(a.sec.sectname, "__data")
ffi.copy(a.sec.segname, "__DATA")
a.sec.size = #s
a.sec.offset = mach_size-ofs
a.sym.cmd = 2
a.sym.cmdsize = ffi.sizeof(a.sym)
a.sym.symoff = ffi.offsetof(o, "sym_entry")-ofs
a.sym.nsyms = 1
a.sym.stroff = ffi.offsetof(o, "sym_entry")+ffi.sizeof(o.sym_entry)-ofs
a.sym.strsize = aligned(#symname+2, align)
end
o.sym_entry.type = 0xf
o.sym_entry.sect = 1
o.sym_entry.strx = 1
ffi.copy(o.space+1, symname)
-- Write Macho-O object file.
local fp = savefile(output, "wb")
fp:write(ffi.string(o, mach_size))
bcsave_tail(fp, output, s)
end
local function bcsave_obj(ctx, output, s)
local ok, ffi = pcall(require, "ffi")
check(ok, "FFI library required to write this file type")
if ctx.os == "windows" then
return bcsave_peobj(ctx, output, s, ffi)
elseif ctx.os == "osx" then
return bcsave_machobj(ctx, output, s, ffi)
else
return bcsave_elfobj(ctx, output, s, ffi)
end
end
------------------------------------------------------------------------------
local function bclist(input, output)
local f = readfile(input)
require("jit.bc").dump(f, savefile(output, "w"), true)
end
local function bcsave(ctx, input, output)
local f = readfile(input)
local s = string.dump(f, ctx.strip)
local t = ctx.type
if not t then
t = detecttype(output)
ctx.type = t
end
if t == "raw" then
bcsave_raw(output, s)
else
if not ctx.modname then ctx.modname = detectmodname(input) end
if t == "obj" then
bcsave_obj(ctx, output, s)
else
bcsave_c(ctx, output, s)
end
end
end
local function docmd(...)
local arg = {...}
local n = 1
local list = false
local ctx = {
strip = true, arch = jit.arch, os = string.lower(jit.os),
type = false, modname = false,
}
while n <= #arg do
local a = arg[n]
if type(a) == "string" and string.sub(a, 1, 1) == "-" and a ~= "-" then
table.remove(arg, n)
if a == "--" then break end
for m=2,#a do
local opt = string.sub(a, m, m)
if opt == "l" then
list = true
elseif opt == "s" then
ctx.strip = true
elseif opt == "g" then
ctx.strip = false
else
if arg[n] == nil or m ~= #a then usage() end
if opt == "e" then
if n ~= 1 then usage() end
arg[1] = check(loadstring(arg[1]))
elseif opt == "n" then
ctx.modname = checkmodname(table.remove(arg, n))
elseif opt == "t" then
ctx.type = checkarg(table.remove(arg, n), map_type, "file type")
elseif opt == "a" then
ctx.arch = checkarg(table.remove(arg, n), map_arch, "architecture")
elseif opt == "o" then
ctx.os = checkarg(table.remove(arg, n), map_os, "OS name")
else
usage()
end
end
end
else
n = n + 1
end
end
if list then
if #arg == 0 or #arg > 2 then usage() end
bclist(arg[1], arg[2] or "-")
else
if #arg ~= 2 then usage() end
bcsave(ctx, arg[1], arg[2])
end
end
------------------------------------------------------------------------------
-- Public module functions.
module(...)
start = docmd -- Process -b command line option.
| gpl-3.0 |
evrooije/beerarchy | mods/00_bt_nodes/basic_machines/electronics_constructor.lua | 1 | 8598 | -- rnd 2016:
-- CONSTRUCTOR machine: used to make all other basic_machines
basic_machines.electronics_craft_recipes = {
["control_logic_unit"] = {
item = "basic_machines:control_logic_unit",
description = "Chip to control digtrons",
craft = { "default:diamond", "default:mese_crystal", "default:gold_ingot", "default:copper_ingot", "default:silver_sand"},
tex = "basic_machines_control_logic_unit"
},
["precision_component"] = {
item = "fun_tools:precision_component",
description = "Precision component",
craft = { "basic_machines:control_logic_unit", "default:steel_ingot", "default:diamond", "default:copper_ingot"},
tex = "fun_tools_component"
},
["internal_combustion_engine"] = {
item = "fun_tools:internal_combustion_engine",
description = "Internal Combustion Engine",
craft = { "basic_machines:control_logic_unit", "fun_tools:precision_component 4", "default:steelblock"},
tex = "fun_tools_engine"
},
["gps"] = {
item = "gps:gps",
description = "GPS",
craft = { "basic_machines:control_logic_unit 2", "default:steel_ingot 4", "default:stick"},
tex = "gps_item"
},
["flare_gun"] = {
item = "fun_tools:flare_gun",
description = "Flare gun",
craft = { "default:mese_crystal", "tnt:gunpowder", "default:steel_ingot 3", "default:stick"},
tex = "fun_tools_flare_gun"
},
["chainsaw"] = {
item = "fun_tools:chainsaw",
description = "Chainsaw",
craft = { "basic_machines:control_logic_unit", "fun_tools:precision_component 2", "fun_tools:internal_combustion_engine", "default:steel_ingot 3", "default:coalblock"},
tex = "fun_tools_chainsaw"
},
["jackhammer"] = {
item = "fun_tools:jackhammer",
description = "Jackhammer",
craft = { "basic_machines:control_logic_unit", "fun_tools:precision_component 2", "fun_tools:internal_combustion_engine", "default:diamond", "default:coalblock"},
tex = "fun_tools_jackhammer"
},
["elevator"] = {
item = "travelnet:elevator",
description = "Elevator",
craft = { "basic_machines:control_logic_unit 2", "fun_tools:precision_component 2", "fun_tools:internal_combustion_engine", "default:glass 2", "default:steel_ingot 6"},
tex = "travelnet_elevator_inv"
},
["travelnet"] = {
item = "travelnet:travelnet",
description = "Travelnet",
craft = { "basic_machines:control_logic_unit 4", "fun_tools:precision_component 2", "default:mese", "default:glass 6", "default:steel_ingot 2"},
tex = "travelnet_inv"
}
}
basic_machines.electronics_craft_recipe_order = { -- order in which nodes appear
"control_logic_unit",
"precision_component",
"internal_combustion_engine",
"gps",
"flare_gun",
"chainsaw",
"jackhammer",
"elevator",
"travelnet"
}
local constructor_process = function(pos, player)
local meta = minetest.get_meta(pos);
local craft = basic_machines.electronics_craft_recipes[meta:get_string("craft")];
if not craft then return end
local item = craft.item;
local craftlist = craft.craft;
local inv = meta:get_inventory();
for _,v in pairs(craftlist) do
if not inv:contains_item("main", ItemStack(v)) then
meta:set_string("infotext", "#CRAFTING: you need " .. v .. " to craft " .. craft.item)
return
end
end
for _,v in pairs(craftlist) do
inv:remove_item("main", ItemStack(v));
end
inv:add_item("main", ItemStack(item));
if player then
if player:get_player_name() == meta:get_string("owner") then
ranking.increase_rank(player, "intelligence", 2)
end
else
local owner = minetest.get_player_by_name(meta:get_string("owner"))
if owner then
ranking.increase_rank(player, "intelligence", 2)
end
end
end
local constructor_update_meta = function(pos)
local meta = minetest.get_meta(pos);
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
local craft = meta:get_string("craft");
local description = basic_machines.electronics_craft_recipes[craft];
local tex;
if description then
tex = description.tex;
local i = 0;
local itex;
local inv = meta:get_inventory(); -- set up craft list
for _,v in pairs(description.craft) do
i=i+1;
inv:set_stack("recipe", i, ItemStack(v))
end
for j = i+1,6 do
inv:set_stack("recipe", j, ItemStack(""))
end
description = description.description
else
description = ""
tex = ""
end
local textlist = " ";
local selected = meta:get_int("selected") or 1;
for _,v in ipairs(basic_machines.electronics_craft_recipe_order) do
textlist = textlist .. v .. ", ";
end
local form =
"size[8,10]"..
"textlist[0,0;3,1.5;craft;" .. textlist .. ";" .. selected .."]"..
"button[3.5,1;1.25,0.75;CRAFT;CRAFT]"..
"image[3.65,0;1,1;".. tex .. ".png]"..
"label[0,1.85;".. description .. "]"..
"list[context;recipe;5,0;3,2;]"..
"label[0,2.3;Put crafting materials here]"..
"list[context;main;0,2.7;8,3;]"..
--"list[context;dst;5,0;3,2;]"..
"label[0,5.5;player inventory]"..
"list[current_player;main;0,6;8,4;]"..
"listring[context;main]"..
"listring[current_player;main]";
meta:set_string("formspec", form);
end
minetest.register_node("basic_machines:electronics_constructor", {
description = "Electronics Constructor: used to make electronics and small electronic devices",
tiles = {"grinder.png","default_furnace_top.png", "electronics_constructor.png","electronics_constructor.png","electronics_constructor.png","electronics_constructor.png"},
groups = {cracky=3, mesecon_effector_on = 1},
sounds = default.node_sound_wood_defaults(),
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos);
meta:set_string("infotext", "Constructor: To operate it insert materials, select item to make and click craft button.")
meta:set_string("owner", placer:get_player_name());
meta:set_string("craft","keypad")
meta:set_int("selected",1);
local inv = meta:get_inventory();inv:set_size("main", 24);--inv:set_size("dst",6);
inv:set_size("recipe",8);
end,
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local meta = minetest.get_meta(pos);
local privs = minetest.get_player_privs(player:get_player_name());
if minetest.is_protected(pos, player:get_player_name()) and not privs.privs then return end -- only owner can interact with recycler
constructor_update_meta(pos);
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if listname == "recipe" then return 0 end
local meta = minetest.get_meta(pos);
local privs = minetest.get_player_privs(player:get_player_name());
if meta:get_string("owner")~=player:get_player_name() and not privs.privs then return 0 end
return stack:get_count();
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
if listname == "recipe" then return 0 end
local privs = minetest.get_player_privs(player:get_player_name());
if minetest.is_protected(pos, player:get_player_name()) and not privs.privs then return 0 end
return stack:get_count();
end,
on_metadata_inventory_put = function(pos, listname, index, stack, player)
if listname == "recipe" then return 0 end
local privs = minetest.get_player_privs(player:get_player_name());
if minetest.is_protected(pos, player:get_player_name()) and not privs.privs then return 0 end
return stack:get_count();
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
return 0;
end,
mesecons = {effector = {
action_on = function (pos, node,ttl)
if type(ttl)~="number" then ttl = 1 end
if ttl<0 then return end -- machines_TTL prevents infinite recursion
constructor_process(pos, nil);
end
}
},
on_receive_fields = function(pos, formname, fields, sender)
if minetest.is_protected(pos, sender:get_player_name()) then return end
local meta = minetest.get_meta(pos);
if fields.craft then
if string.sub(fields.craft,1,3)=="CHG" then
local sel = tonumber(string.sub(fields.craft,5)) or 1
meta:set_int("selected",sel);
local i = 0;
for _,v in ipairs(basic_machines.electronics_craft_recipe_order) do
i=i+1;
if i == sel then meta:set_string("craft",v); break; end
end
else
return
end
end
if fields.CRAFT then
constructor_process(pos, sender);
end
constructor_update_meta(pos);
end,
})
minetest.register_craft({
output = "basic_machines:electronics_constructor",
recipe = {
{"default:silver_sandstone_block","default:mese","default:silver_sandstone_block"},
{"default:mese","default:diamondblock","default:mese"},
{"default:silver_sandstone_block","default:mese","default:silver_sandstone_block"},
}
})
| lgpl-2.1 |
greasydeal/darkstar | scripts/globals/spells/jubaku_san.lua | 11 | 1693 | -----------------------------------------
-- Spell: Jubaku: San
-- Spell accuracy is most highly affected by Enfeebling Magic Skill, Magic Accuracy, and INT.
-- taken from paralyze
-----------------------------------------
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
local effect = EFFECT_PARALYSIS;
-- Base Stats
local dINT = (caster:getStat(MOD_INT) - target:getStat(MOD_INT));
--Duration Calculation
local duration = 420 * applyResistance(caster,spell,target,dINT,NINJUTSU_SKILL,0);
--Paralyze base power is 35 and is not affected by resistaces.
local power = 35;
--Calculates resist chanve from Reist Blind
if(math.random(0,100) >= target:getMod(MOD_PARALYZERES)) then
if(duration >= 210) then
-- Erases a weaker blind and applies the stronger one
local paralysis = target:getStatusEffect(effect);
if(paralysis ~= nil) then
if(paralysis:getPower() < power) then
target:delStatusEffect(effect);
target:addStatusEffect(effect,power,0,duration);
spell:setMsg(237);
else
spell:setMsg(75);
end
else
target:addStatusEffect(effect,power,0,duration);
spell:setMsg(237);
end
else
spell:setMsg(85);
end
else
spell:setMsg(284);
end
return effect;
end; | gpl-3.0 |
naclander/tome | src/luabitop/bittest.lua | 17 | 2353 | -- Test cases for bit operations library. Public domain.
local bit = require"bit"
local vb = {
0, 1, -1, 2, -2, 0x12345678, 0x87654321,
0x33333333, 0x77777777, 0x55aa55aa, 0xaa55aa55,
0x7fffffff, 0x80000000, 0xffffffff
}
local function cksum(name, s, r)
local z = 0
for i=1,#s do z = (z + string.byte(s, i)*i) % 2147483629 end
if z ~= r then
error("bit."..name.." test failed (got "..z..", expected "..r..")", 0)
end
end
local function check_unop(name, r)
local f = bit[name]
local s = ""
if pcall(f) or pcall(f, "z") or pcall(f, true) then
error("bit."..name.." fails to detect argument errors", 0)
end
for _,x in ipairs(vb) do s = s..","..tostring(f(x)) end
cksum(name, s, r)
end
local function check_binop(name, r)
local f = bit[name]
local s = ""
if pcall(f) or pcall(f, "z") or pcall(f, true) then
error("bit."..name.." fails to detect argument errors", 0)
end
for _,x in ipairs(vb) do
for _,y in ipairs(vb) do s = s..","..tostring(f(x, y)) end
end
cksum(name, s, r)
end
local function check_binop_range(name, r, yb, ye)
local f = bit[name]
local s = ""
if pcall(f) or pcall(f, "z") or pcall(f, true) or pcall(f, 1, true) then
error("bit."..name.." fails to detect argument errors", 0)
end
for _,x in ipairs(vb) do
for y=yb,ye do s = s..","..tostring(f(x, y)) end
end
cksum(name, s, r)
end
local function check_shift(name, r)
check_binop_range(name, r, 0, 31)
end
-- Minimal sanity checks.
assert(0x7fffffff == 2147483647, "broken hex literals")
assert(0xffffffff == -1 or 0xffffffff == 2^32-1, "broken hex literals")
assert(tostring(-1) == "-1", "broken tostring()")
assert(tostring(0xffffffff) == "-1" or tostring(0xffffffff) == "4294967295", "broken tostring()")
-- Basic argument processing.
assert(bit.tobit(1) == 1)
assert(bit.band(1) == 1)
assert(bit.bxor(1,2) == 3)
assert(bit.bor(1,2,4,8,16,32,64,128) == 255)
-- Apply operations to test vectors and compare checksums.
check_unop("tobit", 277312)
check_unop("bnot", 287870)
check_unop("bswap", 307611)
check_binop("band", 41206764)
check_binop("bor", 51253663)
check_binop("bxor", 79322427)
check_shift("lshift", 325260344)
check_shift("rshift", 139061800)
check_shift("arshift", 111364720)
check_shift("rol", 302401155)
check_shift("ror", 302316761)
check_binop_range("tohex", 47880306, -8, 8)
| gpl-3.0 |
LegionXI/darkstar | scripts/globals/items/saltena.lua | 12 | 1354 | -----------------------------------------
-- ID: 5885
-- Item: saltena
-- Food Effect: 30Min, All Races
-----------------------------------------
-- HP +6% (cap 100)
-- Increases rate of combat skill gains by 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,1800,5885);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_FOOD_HPP, 6);
target:addMod(MOD_FOOD_HP_CAP, 100);
target:addMod(MOD_COMBAT_SKILLUP_RATE, 20);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_FOOD_HPP, 6);
target:delMod(MOD_FOOD_HP_CAP, 100);
target:delMod(MOD_COMBAT_SKILLUP_RATE, 20);
end;
| gpl-3.0 |
greasydeal/darkstar | scripts/globals/mobskills/PW_Groundburst.lua | 25 | 1068 | ---------------------------------------------
-- Groundburst
--
-- Description: Expels a fireball on targets in an area of effect.
-- Type: Physical
-- Utsusemi/Blink absorb: Wipes shadows
-- Range: Unknown radial
-- Notes: Only used by notorious monsters, and from any Mamool Ja in besieged.
---------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------
function onMobSkillCheck(target,mob,skill)
local mobSkin = mob:getModelId();
if (mobSkin == 1863) then
return 0;
else
return 1;
end
end;
function onMobWeaponSkill(target, mob, skill)
local numhits = 1;
local accmod = 1;
local dmgmod = 3;
local info = MobPhysicalMove(mob,target,skill,numhits,accmod,dmgmod,TP_NO_EFFECT);
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_PHYSICAL,MOBPARAM_BLUNT,MOBPARAM_WIPE_SHADOWS);
target:delHP(dmg);
return dmg;
end; | gpl-3.0 |
greasydeal/darkstar | scripts/commands/checkvar.lua | 38 | 1130 | ---------------------------------------------------------------------------------------------------
-- func: @checkvar <varType> <varName>
-- desc: checks player or server variable and returns result value.
---------------------------------------------------------------------------------------------------
cmdprops =
{
permission = 1,
parameters = "ss"
};
function onTrigger(player, varType, varName)
if (varType == nil or varName == nil) then
player:PrintToPlayer("Incorrect command syntax or missing paramters.");
player:PrintToPlayer("@checkvar <player name or server> <variable name>");
return;
end
if (varType == "server") then
player:PrintToPlayer(string.format("Server Variable '%s' : %u ", varName, GetServerVariable(varName)));
else
local targ = GetPlayerByName(varType);
if (targ ~= nil) then
player:PrintToPlayer(string.format("Player '%s' variable '%s' : %u ", varType, varName, targ:getVar(varName)));
else
player:PrintToPlayer(string.format( "Player named '%s' not found!", varType));
end
end
end | gpl-3.0 |
naclander/tome | game/engines/default/engine/interface/PlayerRun.lua | 3 | 16700 | -- TE4 - T-Engine 4
-- Copyright (C) 2009 - 2014 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
require "engine.class"
local Dialog = require "engine.ui.Dialog"
--- Handles player running
-- This should work for running inside tunnel, alongside walls, in open spaces.<br/>
module(..., package.seeall, class.make)
local function checkDir(a, dir, dist)
dist = dist or 1
local x, y = a.x, a.y
for i = 1, dist do x, y = util.coordAddDir(x, y, dir) end
-- don't treat other actors as terrain or as something to notice (let the module handle this)
if game.level.map(x, y, game.level.map.ACTOR) and not game.level.map:checkEntity(x, y, game.level.map.TERRAIN, "block_move") then return false end
return (game.level.map:checkAllEntities(x, y, "block_move", a) or not game.level.map:isBound(x, y)) and true or false
end
--- Initializes running
-- We check the direction sides to know if we are in a tunnel, along a wall or in open space.
function _M:runInit(dir)
if checkDir(self, dir) then return end
self.running = {
dir = dir,
block_left = false,
block_right = false,
block_hard_left = false,
block_hard_right = false,
cnt = 1,
dialog = Dialog:simplePopup("Running...", "You are running, press Enter to stop.", function()
self:runStop()
end, false, true),
}
-- Check sides
local sides = util.dirSides(dir, self.x, self.y)
if sides then
if checkDir(self, sides.hard_left) then self.running.block_hard_left = true end
if checkDir(self, sides.hard_right) then self.running.block_hard_right = true end
if checkDir(self, sides.left) then
self.running.block_left = true
else
self.running.ignore_left = 2
end
if checkDir(self, sides.right) then
self.running.block_right = true
else
self.running.ignore_right = 2
end
end
self.running.dialog.__showup = nil
self.running.dialog.__hidden = true
self:runStep()
end
--- Initializes running to a specific position using the given path
-- This does not use the normal running algorithm
function _M:runFollow(path)
local found = false
local runpath = {}
-- Find ourself along the path
for i, c in ipairs(path) do
if found then runpath[#runpath+1] = c
elseif c.x == self.x and c.y == self.y then found = true end
end
if #runpath == 0 then
game.logPlayer(self, "You don't see how to get there...")
return
end
self.running = {
path = runpath,
cnt = 1,
dialog = Dialog:simplePopup("Running...", "You are running, press any key to stop.", function()
self:runStop()
end, false, true),
}
self.running.dialog.__showup = nil
self.running.dialog.__hidden = true
self:runStep()
end
--- Run a turn
-- For a turn based game you want in you player's act() something like that:<br/>
-- <pre>
-- if not self:runStep() then game.paused = true end
-- </pre><br/>
-- This will move the actor using the :move() method, this SHOULD have been redefined by the module
-- to use energy, otherwise running will be free.
-- @return true if we can continue to run, false otherwise
function _M:runStep()
if not self.running then return false end
local ret, msg = self:runCheck()
if not ret and (self.running.cnt > 1 or self.running.busy) then
self:runStop(msg)
return false
else
local oldx, oldy = self.x, self.y
if self.running.path then
if self.running.explore and self.checkAutoExplore and not self:checkAutoExplore() then
self:runStop()
elseif not self.running.path[self.running.cnt] then
self:runStop()
else
-- Allow auto-explore to perform actions other than movement, which should be performed
-- or setup in "checkAutoExplore". Hence, modules can make auto-explore borg-like if desired.
-- For example, non-move actions can be picking up an item, using a talent, resting, etc.
-- Some actions can require moving into a tile, such as opening a door or bump-attacking an enemy.
-- "self.running.cnt" is not incremented while "self.running.busy" exists.
if not self.running.busy or self.running.busy.do_move then
self:move(self.running.path[self.running.cnt].x, self.running.path[self.running.cnt].y)
end
self:runMoved()
-- Did not move ? no use in running unless we were busy
if self.running and not self.running.busy and self.x == oldx and self.y == oldy then
self:runStop("didn't move")
end
end
if not self.running then return false end
else
-- Try to move around known traps if possible
local dir_is_cardinal = self.running.dir == 2 or self.running.dir == 4 or self.running.dir == 6 or self.running.dir == 8
local sides = util.dirSides(self.running_dir, self.x, self.y)
local dx, dy = util.dirToCoord(self.running.dir, self.x, self.y)
local x, y = util.coordAddDir(self.x, self.y, self.running.dir)
local trap = game.level.map(x, y, game.level.map.TRAP)
if trap and trap:knownBy(self) then
-- Take a phantom step forward and check path; backup current data first
local running_bak = table.clone(self.running)
self.x, self.y = x, y
local ret2, msg2 = self:runCheck(true) -- don't remember other items or traps from phantom steps
local sides_bak = util.dirSides(running_bak.dir, self.x, self.y)
local sides_dir = util.dirSides(self.running.dir, self.x, self.y)
if self.running.dir == sides_bak.hard_left then
running_bak.dir = sides_bak.left
elseif self.running.dir == sides_bak.hard_right then
running_bak.dir = sides_bak.right
else
ret2 = false
end
if self.running.ignore_left then
running_bak.ignore_left = running_bak.ignore_left - 1
if running_bak.ignore_left <= 0 then running_bak.ignore_left = nil end
if checkDir(self, sides_dir.left) and (not checkDir(self, self.running.dir) or not dir_is_cardinal) then running_bak.block_left = true end
end
if self.running.ignore_right then
running_bak.ignore_right = running_bak.ignore_right - 1
if running_bak.ignore_right <= 0 then running_bak.ignore_right = nil end
if checkDir(self, sides_dir.right) and (not checkDir(self, self.running.dir) or not dir_is_cardinal) then running_bak.block_right = true end
end
if self.running.block_left then running_bak.ignore_left = nil end
if self.running.block_right then running_bak.ignore_right = nil end
-- Put data back
self.x, self.y = oldx, oldy
self.running = running_bak
-- Can't run around the trap
if not ret2 then
self:runStop("trap spotted")
return false
end
end
-- Move!
self:moveDir(self.running.dir)
self:runMoved()
-- Did not move ? no use in running
if self.x == oldx and self.y == oldy then self:runStop() end
if not self.running then return false end
local sides = util.dirSides(self.running.dir, self.x, self.y)
if self.running.block_left then self.running.ignore_left = nil end
if self.running.ignore_left then
self.running.ignore_left = self.running.ignore_left - 1
if self.running.ignore_left <= 0 then
self.running.ignore_left = nil
-- We do this check here because it is path/time dependent, not terrain configuration dependent
if dir_is_cardinal and checkDir(self, sides.left) and checkDir(self, self.running.dir, 2) then
self:runStop("terrain change on the left")
return false
end
end
if checkDir(self, sides.left) and (not checkDir(self, self.running.dir) or not dir_is_cardinal) then self.running.block_left = true end
end
if self.running.block_right then self.running.ignore_right = nil end
if self.running.ignore_right then
self.running.ignore_right = self.running.ignore_right - 1
if self.running.ignore_right <= 0 then
self.running.ignore_right = nil
-- We do this check here because it is path/time dependent, not terrain configuration dependent
if dir_is_cardinal and checkDir(self, sides.right) and checkDir(self, self.running.dir, 2) then
self:runStop("terrain change on the right")
return false
end
end
if checkDir(self, sides.right) and (not checkDir(self, self.running.dir) or not dir_is_cardinal) then self.running.block_right = true end
end
end
if not self.running then return false end
if not self.running.busy then
self.running.cnt = self.running.cnt + 1
elseif self.running.busy.no_energy then
return self:runStep()
end
return true
end
end
--- Can we continue running ?
-- Rewrite this method to hostiles, interesting terrain, whatever.
-- This method should be called by its submethod, it tries to detect changes in the terrain.<br/>
-- It will also try to follow tunnels when they simply change direction.
-- @return true if we can continue to run, false otherwise
function _M:runCheck()
if not self.running.path then
local dir_is_cardinal = self.running.dir == 2 or self.running.dir == 4 or self.running.dir == 6 or self.running.dir == 8
local blocked_ahead = checkDir(self, self.running.dir)
local sides = util.dirSides(self.running.dir, self.x, self.y)
local blocked_left = checkDir(self, sides.left)
local blocked_hard_left = checkDir(self, sides.hard_left)
local blocked_right = checkDir(self, sides.right)
local blocked_hard_right = checkDir(self, sides.hard_right)
-- Do we change run direction ? We can only choose to change for left or right, never backwards.
-- We must also be in a tunnel (both sides blocked)
if (self.running.block_left or self.running.ignore_left) and (self.running.block_right or self.running.ignore_right) then
if blocked_ahead then
if blocked_right and (blocked_hard_right or self.running.ignore_right) then
local back_left_x, back_left_y = util.coordAddDir(self.x, self.y, sides.hard_left)
local blocked_back_left = checkDir(self, util.dirSides(sides.hard_left, back_left_x, back_left_y).left)
-- Turn soft left
if not blocked_left and (blocked_hard_left or not dir_is_cardinal) then
if not dir_is_cardinal and not blocked_hard_left and not (checkDir(self, sides.left, 2) and blocked_back_left) then
return false, "terrain changed ahead"
end
self.running.dir = util.dirSides(self.running.dir, self.x, self.y).left
self.running.block_right = true
if blocked_hard_left then self.running.block_left = true end
return true
end
-- Turn hard left
if not blocked_hard_left and (not self.running.ignore_left or (self.running.block_hard_left and self.running.block_right)) then
if dir_is_cardinal and not blocked_left and not checkDir(self, sides.hard_left, 2) then
return false, "terrain change on the left"
end
if not dir_is_cardinal and not blocked_back_left then
return false, "terrain ahead blocks"
end
self.running.dir = sides.hard_left
if self.running.block_hard_left and self.running.ignore_left and self.running.ignore_left == 1 then
self.running.block_left = true
end
return true
end
end
if blocked_left and (blocked_hard_left or self.running.ignore_left) then
local back_right_x, back_right_y = util.coordAddDir(self.x, self.y, sides.hard_right)
local blocked_back_right = checkDir(self, util.dirSides(sides.hard_right, back_right_x, back_right_y).right)
-- Turn soft right
if not blocked_right and (blocked_hard_right or not dir_is_cardinal) then
if not dir_is_cardinal and not blocked_hard_right and not (checkDir(self, sides.right, 2) and blocked_back_right) then
return false, "terrain changed ahead"
end
self.running.dir = sides.right
self.running.block_left = true
if blocked_hard_right then self.running.block_right = true end
return true
end
-- Turn hard right
if not blocked_hard_right and (not self.running.ignore_right or (self.running.block_hard_right and self.running.block_left)) then
if dir_is_cardinal and not blocked_right and not checkDir(self, sides.hard_right, 2) then
return false, "terrain change on the right"
end
if not dir_is_cardinal and not blocked_back_right then
return false, "terrain ahead blocks"
end
self.running.dir = sides.hard_right
if self.running.block_hard_right and self.running.ignore_right and self.running.ignore_right == 1 then
self.running.block_right = true
end
return true
end
end
else
-- Favor cardinal directions if possible, otherwise we may miss something interesting
if not dir_is_cardinal then
-- Turn soft left
if blocked_right and blocked_hard_left and not blocked_left and (blocked_hard_right or self.running.ignore_right) and (not self.running.ignore_left or self.running.ignore_left ~= 2) then
if checkDir(self, sides.left, 2) then
self.running.dir = sides.left
self.running.block_left = true
self.running.block_right = true
return true
else
return false, "terrain changed ahead"
end
end
-- Turn soft right
if blocked_left and blocked_hard_right and not blocked_right and (blocked_hard_left or self.running.ignore_left) and (not self.running.ignore_right or self.running.ignore_right ~= 2) then
if checkDir(self, sides.right, 2) then
self.running.dir = sides.right
self.running.block_left = true
self.running.block_right = true
return true
else
return false, "terrain changed ahead"
end
end
end
if checkDir(self, self.running.dir, 2) then
if not dir_is_cardinal and ((self.running.block_left and not blocked_hard_left and not self.running.ignore_left) or (self.running.block_right and not blocked_hard_right and not self.running.ignore_right)) then
return false, "terrain changed ahead"
end
-- Continue forward so we may turn
if (blocked_left and not blocked_right) or (blocked_right and not blocked_left) then return true end
end
end
end
if not self.running.ignore_left and (self.running.block_left ~= blocked_left or self.running.block_left ~= blocked_hard_left) then
return false, "terrain change on left side"
end
if not self.running.ignore_right and (self.running.block_right ~= blocked_right or self.running.block_right ~= blocked_hard_right) then
return false, "terrain change on right side"
end
if blocked_ahead then
return false, "terrain ahead blocks"
end
end
return true
end
--- Stops running
function _M:runStop(msg)
if not self.running then return false end
game:unregisterDialog(self.running.dialog)
if not msg and self.running.explore and self.running.path and self.running.cnt == #self.running.path + 1 then
msg = "at " .. self.running.explore
end
if msg then
game.log("Ran for %d turns (stop reason: %s).", self.running.cnt, msg)
end
self:runStopped(self.running.cnt, msg)
self.running = nil
return true
end
--- Scan the run direction and sides with the given function
function _M:runScan(fct)
fct(self.x, self.y, "self")
if not self.running.path then
-- Ahead
local dx, dy = util.dirToCoord(self.running.dir, self.x, self.y)
local x, y = self.x + dx, self.y + dy
fct(x, y, "ahead")
local sides = util.dirSides(self.running.dir, self.x, self.y)
if sides then
-- Ahead left
local dx, dy = util.dirToCoord(sides.left, self.x, self.y)
local x, y = self.x + dx, self.y + dy
fct(x, y, "ahead left")
-- Ahead right
local dx, dy = util.dirToCoord(sides.right, self.x, self.y)
local x, y = self.x + dx, self.y + dy
fct(x, y, "ahead right")
-- Left
local dx, dy = util.dirToCoord(sides.hard_left, self.x, self.y)
local x, y = self.x + dx, self.y + dy
fct(x, y, "left")
-- Right
local dx, dy = util.dirToCoord(sides.hard_right, self.x, self.y)
local x, y = self.x + dx, self.y + dy
fct(x, y, "right")
end
elseif self.running.path[self.running.cnt] then
-- Ahead
local x, y = self.running.path[self.running.cnt].x, self.running.path[self.running.cnt].y
fct(x, y, "ahead")
end
end
--- Called after running a step
function _M:runMoved()
end
--- Called after stopping running
function _M:runStopped()
end
| gpl-3.0 |
LegionXI/darkstar | scripts/zones/Hall_of_Transference/npcs/_0e0.lua | 14 | 1356 | -----------------------------------
-- Area: Hall of Transference
-- NPC: Cermet Gate - Holla
-- @pos -219 -6 280 14
-----------------------------------
package.loaded["scripts/zones/Hall_of_Transference/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/missions");
require("scripts/zones/Hall_of_Transference/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getCurrentMission(COP) > BELOW_THE_ARKS) then
player:startEvent(0x0096);
else
player:messageSpecial(NO_RESPONSE_OFFSET+1); -- The door is firmly shut.
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0096 and option == 1) then
player:setPos(92.033, 0, 80.380, 255, 16); -- To Promyvion Holla {R}
end
end; | gpl-3.0 |
ibm2431/darkstar | scripts/globals/weaponskills/vorpal_thrust.lua | 10 | 1436 | -----------------------------------
-- Vorpal Thrust
-- Polearm weapon skill
-- Skill Level: 175
-- Delivers a single-hit attack. Chance of params.critical varies with TP.
-- Will stack with Sneak Attack.
-- Aligned with the Aqua Gorget & Light Gorget.
-- Aligned with the Aqua Belt & Light Belt.
-- Element: None
-- Modifiers: STR:50% AGI:50%
-- 100%TP 200%TP 300%TP
-- 1.00 1.00 1.00
-----------------------------------
require("scripts/globals/status")
require("scripts/globals/settings")
require("scripts/globals/weaponskills")
-----------------------------------
function onUseWeaponSkill(player, target, wsID, tp, primary, action, taChar)
local params = {}
params.numHits = 1
params.ftp100 = 1 params.ftp200 = 1 params.ftp300 = 1
params.str_wsc = 0.2 params.dex_wsc = 0.0 params.vit_wsc = 0.0 params.agi_wsc = 0.2 params.int_wsc = 0.0 params.mnd_wsc = 0.0 params.chr_wsc = 0.0
params.crit100 = 0.3 params.crit200 = 0.6 params.crit300 = 0.9
params.canCrit = true
params.acc100 = 0.0 params.acc200= 0.0 params.acc300= 0.0
params.atk100 = 1; params.atk200 = 1; params.atk300 = 1;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.str_wsc = 0.5 params.agi_wsc = 0.5
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, params, tp, action, primary, taChar)
return tpHits, extraHits, criticalHit, damage
end
| gpl-3.0 |
ibm2431/darkstar | scripts/globals/spells/bind.lua | 12 | 1261 | -----------------------------------------
-- Spell: Bind
-----------------------------------------
require("scripts/globals/magic")
require("scripts/globals/msg")
require("scripts/globals/status")
-----------------------------------------
function onMagicCastingCheck(caster, target, spell)
return 0
end
function onSpellCast(caster, target, spell)
-- Pull base stats.
local dINT = caster:getStat(dsp.mod.INT) - target:getStat(dsp.mod.INT)
-- Duration, including resistance. May need more research.
local duration = calculateDuration(60, spell:getSkillType(), spell:getSpellGroup(), caster, target)
-- Resist
local params = {}
params.diff = dINT
params.skillType = dsp.skill.ENFEEBLING_MAGIC
params.bonus = 0
params.effect = dsp.effect.BIND
local resist = applyResistanceEffect(caster, target, spell, params)
if resist >= 0.5 then --Do it!
--Try to erase a weaker bind.
if target:addStatusEffect(params.effect, target:speed(), 0 , duration * resist) then
spell:setMsg(dsp.msg.basic.MAGIC_ENFEEB_IS)
else
spell:setMsg(dsp.msg.basic.MAGIC_NO_EFFECT)
end
else
spell:setMsg(dsp.msg.basic.MAGIC_RESIST)
end
return params.effect
end
| gpl-3.0 |
atheurer/MoonGen | rfc2544/benchmarks/backtoback.lua | 9 | 13123 | package.path = package.path .. "rfc2544/?.lua"
local standalone = false
if master == nil then
standalone = true
master = "dummy"
end
local dpdk = require "dpdk"
local memory = require "memory"
local device = require "device"
local ts = require "timestamping"
local filter = require "filter"
local ffi = require "ffi"
local barrier = require "barrier"
local arp = require "proto.arp"
local timer = require "timer"
local namespaces = require "namespaces"
local utils = require "utils.utils"
local tikz = require "utils.tikz"
local UDP_PORT = 42
local benchmark = {}
benchmark.__index = benchmark
function benchmark.create()
local self = setmetatable({}, benchmark)
self.initialized = false
return self
end
setmetatable(benchmark, {__call = benchmark.create})
function benchmark:init(arg)
self.granularity = arg.granularity or 100
self.duration = arg.duration or 2
self.numIterations = arg.numIterations or 50
self.rxQueues = arg.rxQueues
self.txQueues = arg.txQueues
self.skipConf = arg.skipConf
self.dut = arg.dut
self.initialized = true
end
function benchmark:config()
self.undoStack = {}
utils.addInterfaceIP(self.dut.ifIn, "198.18.1.1", 24)
table.insert(self.undoStack, {foo = utils.delInterfaceIP, args = {self.dut.ifIn, "198.18.1.1", 24}})
utils.addInterfaceIP(self.dut.ifOut, "198.19.1.1", 24)
table.insert(self.undoStack, {foo = utils.delInterfaceIP, args = {self.dut.ifOut, "198.19.1.1", 24}})
end
function benchmark:undoConfig()
local len = #self.undoStack
for k, v in ipairs(self.undoStack) do
--work in stack order
local elem = self.undoStack[len - k + 1]
elem.foo(unpack(elem.args))
end
--clear stack
self.undoStack = {}
end
function benchmark:getCSVHeader()
local str = "frameSize,precision,linkspeed,duration"
for iteration=1, self.numIterations do
str = str .. ",burstsize iter" .. iteration
end
return str
end
function benchmark:resultToCSV(result)
str = result.frameSize .. "," .. self.granularity .. "," .. self.txQueues[1].dev:getLinkStatus().speed .. "," .. self.duration .. "s"
for iteration=1, self.numIterations do
str = str .. "," .. result[iteration]
end
return str
end
function benchmark:toTikz(filename, ...)
local values = {}
local numResults = select("#", ...)
for i=1, numResults do
local result = select(i, ...)
local avg = 0
local numVals = 0
for _, v in ipairs(result) do
avg = avg + v
numVals = numVals + 1
end
avg = avg / numVals
table.insert(values, {k = result.frameSize, v = avg})
end
table.sort(values, function(e1, e2) return e1.k < e2.k end)
local xtick = ""
local t64 = false
local last = -math.huge
for k, p in ipairs(values) do
if (p.k - last) >= 128 then
xtick = xtick .. p.k
if values[k + 1] then
xtick = xtick .. ","
end
last = p.k
end
end
local img = tikz.new(filename .. ".tikz", [[xlabel={packet size [byte]}, ylabel={burst size [packet]}, grid=both, ymin=0, xmin=0, xtick={]] .. xtick .. [[},scaled ticks=false, width=9cm, height=4cm, cycle list name=exotic]])
img:startPlot()
for _, p in ipairs(values) do
img:addPoint(p.k, p.v)
end
img:endPlot("average burst size")
img:startPlot()
for _, p in ipairs(values) do
local v = math.ceil((self.txQueues[1].dev:getLinkStatus().speed * 10^6 / ((p.k + 20) * 8)) * self.duration)
img:addPoint(p.k, v)
end
img:finalize("max burst size")
end
function benchmark:bench(frameSize)
if not self.initialized then
return print("benchmark not initialized");
elseif frameSize == nil then
return error("benchmark got invalid frameSize");
end
if not self.skipConf then
self:config()
end
local port = UDP_PORT
local bar = barrier.new(2)
local results = {frameSize = frameSize}
for iteration=1, self.numIterations do
printf("starting iteration %d for frame size %d", iteration, frameSize)
local loadSlave = dpdk.launchLua("backtobackLoadSlave", self.txQueues[1], frameSize, nil, bar, self.granularity, self.duration)
local counterSlave = dpdk.launchLua("backtobackCounterSlave", self.rxQueues[1], frameSize, bar, self.granularity, self.duration)
local longestS = loadSlave:wait()
local longestR = counterSlave:wait()
if longest ~= loadSlave:wait() then
printf("WARNING: loadSlave and counterSlave reported different burst sizes (sender=%d, receiver=%d)", longestS, longestR)
results[iteration] = -1
else
results[iteration] = longestS
printf("iteration %d: longest burst: %d", iteration, longestS)
end
end
if not self.skipConf then
self:undoConfig()
end
return results
end
local rsns = namespaces.get()
function sendBurst(numPkts, mem, queue, size, port, modFoo)
local sent = 0
local bufs = mem:bufArray(64)
local stop = numPkts - (numPkts % 64)
while dpdk.running() and sent < stop do
bufs:alloc(size)
for _, buf in ipairs(bufs) do
local pkt = buf:getUdpPacket()
pkt.udp:setDstPort(port)
end
bufs:offloadUdpChecksums()
sent = sent + queue:send(bufs)
end
if numPkts ~= stop then
bufs = mem:bufArray(numPkts % 64)
bufs:alloc(size)
for _, buf in ipairs(bufs) do
local pkt = buf:getUdpPacket()
pkt.udp:setDstPort(port)
end
bufs:offloadUdpChecksums()
sent = sent + queue:send(bufs)
end
return sent
end
function backtobackLoadSlave(queue, frameSize, modifier, bar, granularity, duration)
local ethDst = arp.blockingLookup("198.18.1.1", 10)
--TODO: error on timeout
-- gen payload template suggested by RFC2544
local udpPayloadLen = frameSize - 46
local udpPayload = ffi.new("uint8_t[?]", udpPayloadLen)
for i = 0, udpPayloadLen - 1 do
udpPayload[i] = bit.band(i, 0xf)
end
local mem = memory.createMemPool(function(buf)
local pkt = buf:getUdpPacket()
pkt:fill{
pktLength = frameSize - 4, -- self sets all length headers fields in all used protocols, -4 for FCS
ethSrc = queue, -- get the src mac from the device
ethDst = ethDst,
-- does not affect performance, as self fill is done before any packet is sent
ip4Src = "198.18.1.2",
ip4Dst = "198.19.1.2",
udpSrc = UDP_PORT,
-- udpSrc will be set later as it varies
}
-- fill udp payload with prepared udp payload
ffi.copy(pkt.payload, udpPayload, udpPayloadLen)
end)
--wait for counter slave
bar:wait()
--TODO: dirty workaround for resetting a barrier
dpdk.sleepMicros(100)
bar:reinit(2)
local linkSpeed = queue.dev:getLinkStatus().speed
local maxPkts = math.ceil((linkSpeed * 10^6 / ((frameSize + 20) * 8)) * duration) -- theoretical max packets send in about `duration` seconds with linkspeed
local count = maxPkts
local longest = 0
local binSearch = utils.binarySearch(0, maxPkts)
local first = true
while dpdk.running() do
local t = timer.new(0.5)
queue:setRate(10)
while t:running() do
sendBurst(64, mem, queue, frameSize - 4, UDP_PORT+1)
end
queue:setRate(linkSpeed)
local sent = sendBurst(count, mem, queue, frameSize - 4, UDP_PORT)
rsns.sent = sent
bar:wait()
--TODO: fix barrier reset
-- reinit interferes with wait
dpdk.sleepMicros(100)
bar:reinit(2)
-- do a binary search
-- throw away firt try
if first then
first = false
else
local top = sent == rsns.received
--get next rate
local nextCount, finished = binSearch:next(count, top, granularity)
-- update longest
longest = (top and count) or longest
if finished then
break
end
printf("loadSlave: sent %d and received %d => changing from %d to %d", sent, rsns.received, count, nextCount)
count = nextCount
end
dpdk.sleepMillis(2000)
end
return longest
end
function backtobackCounterSlave(queue, frameSize, bar, granularity, duration)
local bufs = memory.bufArray()
local maxPkts = math.ceil((queue.dev:getLinkStatus().speed * 10^6 / ((frameSize + 20) * 8)) * duration) -- theoretical max packets send in about `duration` seconds with linkspeed
local count = maxPkts
local longest = 0
local binSearch = utils.binarySearch(0, maxPkts)
local first = true
local t = timer:new(0.5)
while t:running() do
queue:tryRecv(bufs, 100)
bufs:freeAll()
end
-- wait for sender to be ready
bar:wait()
while dpdk.running() do
local timer = timer:new(duration + 2)
local counter = 0
while timer:running() do
rx = queue:tryRecv(bufs, 1000)
for i = 1, rx do
local buf = bufs[i]
local pkt = buf:getUdpPacket()
if pkt.udp:getDstPort() == UDP_PORT then
counter = counter + 1
end
end
bufs:freeAll()
if counter >= count then
break
end
end
rsns.received = counter
-- wait for sender -> both renewed value in rsns
bar:wait()
-- do a binary search
-- throw away firt try
if first then
first = false
else
local top = counter == rsns.sent
--get next rate
local nextCount, finished = binSearch:next(count, top, granularity)
-- update longest
longest = (top and count) or longest
if finished then
break
end
printf("counterSlave: sent %d and received %d => changing from %d to %d", rsns.sent, counter, count, nextCount)
count = nextCount
end
dpdk.sleepMillis(2000)
end
return longest
end
--for standalone benchmark
if standalone then
function master()
local args = utils.parseArguments(arg)
local txPort, rxPort = args.txport, args.rxport
if not txPort or not rxPort then
return print("usage: --txport <txport> --rxport <rxport> --duration <duration> --iterations <num iterations>")
end
local rxDev, txDev
if txPort == rxPort then
-- sending and receiving from the same port
txDev = device.config({port = txPort, rxQueues = 2, txQueues = 4})
rxDev = txDev
else
-- two different ports, different configuration
txDev = device.config({port = txPort, rxQueues = 2, txQueues = 4})
rxDev = device.config({port = rxPort, rxQueues = 2, txQueues = 3})
end
device.waitForLinks()
if txPort == rxPort then
dpdk.launchLua(arp.arpTask, {
{
txQueue = txDev:getTxQueue(0),
rxQueue = txDev:getRxQueue(1),
ips = {"198.18.1.2", "198.19.1.2"}
}
})
else
dpdk.launchLua(arp.arpTask, {
{
txQueue = txDev:getTxQueue(0),
rxQueue = txDev:getRxQueue(1),
ips = {"198.18.1.2"}
},
{
txQueue = rxDev:getTxQueue(0),
rxQueue = rxDev:getRxQueue(1),
ips = {"198.19.1.2", "198.18.1.1"}
}
})
end
local bench = benchmark()
bench:init({
txQueues = {txDev:getTxQueue(1)},
rxQueues = {rxDev:getRxQueue(0)},
granularity = 100,
duration = args.duration,
numIterations = args.iterations,
skipConf = true,
})
print(bench:getCSVHeader())
local results = {}
local FRAME_SIZES = {64, 128, 256, 512, 1024, 1280, 1518}
for _, frameSize in ipairs(FRAME_SIZES) do
local result = bench:bench(frameSize)
-- save and report results
table.insert(results, result)
print(bench:resultToCSV(result))
end
bench:toTikz("btb", unpack(results))
end
end
local mod = {}
mod.__index = mod
mod.benchmark = benchmark
return mod
| mit |
lache/RacingKingLee | crazyclient/frameworks/cocos2d-x/cocos/scripting/lua-bindings/auto/api/TransitionSlideInR.lua | 11 | 1045 |
--------------------------------
-- @module TransitionSlideInR
-- @extend TransitionSlideInL
-- @parent_module cc
--------------------------------
-- Creates a transition with duration and incoming scene.<br>
-- param t Duration time, in seconds.<br>
-- param scene A given scene.<br>
-- return A autoreleased TransitionSlideInR object.
-- @function [parent=#TransitionSlideInR] create
-- @param self
-- @param #float t
-- @param #cc.Scene scene
-- @return TransitionSlideInR#TransitionSlideInR ret (return value: cc.TransitionSlideInR)
--------------------------------
-- Returns the action that will be performed by the incoming and outgoing scene.
-- @function [parent=#TransitionSlideInR] action
-- @param self
-- @return ActionInterval#ActionInterval ret (return value: cc.ActionInterval)
--------------------------------
--
-- @function [parent=#TransitionSlideInR] TransitionSlideInR
-- @param self
-- @return TransitionSlideInR#TransitionSlideInR self (return value: cc.TransitionSlideInR)
return nil
| mit |
lache/RacingKingLee | crazyclient/frameworks/cocos2d-x/cocos/scripting/lua-bindings/auto/api/Event.lua | 3 | 1317 |
--------------------------------
-- @module Event
-- @extend Ref
-- @parent_module cc
--------------------------------
-- Checks whether the event has been stopped.<br>
-- return True if the event has been stopped.
-- @function [parent=#Event] isStopped
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- Gets the event type.<br>
-- return The event type.
-- @function [parent=#Event] getType
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- Gets current target of the event.<br>
-- return The target with which the event associates.<br>
-- note It onlys be available when the event listener is associated with node.<br>
-- It returns 0 when the listener is associated with fixed priority.
-- @function [parent=#Event] getCurrentTarget
-- @param self
-- @return Node#Node ret (return value: cc.Node)
--------------------------------
-- Stops propagation for current event.
-- @function [parent=#Event] stopPropagation
-- @param self
-- @return Event#Event self (return value: cc.Event)
--------------------------------
-- Constructor
-- @function [parent=#Event] Event
-- @param self
-- @param #int type
-- @return Event#Event self (return value: cc.Event)
return nil
| mit |
ibm2431/darkstar | scripts/zones/Crawlers_Nest_[S]/IDs.lua | 9 | 1081 | -----------------------------------
-- Area: Crawlers_Nest_[S]
-----------------------------------
require("scripts/globals/zone")
-----------------------------------
zones = zones or {}
zones[dsp.zone.CRAWLERS_NEST_S] =
{
text =
{
ITEM_CANNOT_BE_OBTAINED = 6904, -- You cannot obtain the <item>. Come back after sorting your inventory.
ITEM_OBTAINED = 6910, -- Obtained: <item>.
GIL_OBTAINED = 6911, -- Obtained <number> gil.
KEYITEM_OBTAINED = 6913, -- Obtained key item: <keyitem>.
ITEM_DELIVERY_DIALOG = 7677, -- Hello! Any packages to sendy-wend?
COMMON_SENSE_SURVIVAL = 8642, -- It appears that you have arrived at a new survival guide provided by the Servicemen's Mutual Aid Network. Common sense dictates that you should now be able to teleport here from similar tomes throughout the world.
},
mob =
{
MORILLE_MORTELLE_PH =
{
[17477636] = 17477640, -- 61 0 -4
},
},
npc =
{
},
}
return zones[dsp.zone.CRAWLERS_NEST_S] | gpl-3.0 |
LuaDist2/lzmq-timer | src/lua/lzmq/ffi/error.lua | 15 | 2429 | --
-- Author: Alexey Melnichuk <mimir@newmail.ru>
--
-- Copyright (C) 2013-2014 Alexey Melnichuk <mimir@newmail.ru>
--
-- Licensed according to the included 'LICENCE' document
--
-- This file is part of lua-lzqm library.
--
local ok, zmq = pcall(require, "lzmq")
if not ok then zmq = nil end
local errors
if zmq then
errors = {}
for n,e in pairs(zmq.errors) do
if type(n) == 'string' then
errors[n] = e
end
end
else -- WARNING this is not best way
local IS_WINDOWS =
(require "ffi".os:lower() == 'windows')
or package.config:sub(1,1) == '\\'
local ZMQ_HAUSNUMERO = 156384712
local zmq_errors = {
EFSM = ZMQ_HAUSNUMERO + 51;
ENOCOMPATPROTO = ZMQ_HAUSNUMERO + 52;
ETERM = ZMQ_HAUSNUMERO + 53;
EMTHREAD = ZMQ_HAUSNUMERO + 54;
}
errors = {
ENOMEM = 12;
EACCES = 13;
EFAULT = 14;
EINVAL = 22;
EAGAIN = 35;
EHOSTUNREACH = 65,
ENOTSOCK = 38;
ENETDOWN = 50;
EPROTONOSUPPORT = 43;
ENOBUFS = 55;
ENETUNREACH = 51;
ENOTSUP = 45;
ETIMEDOUT = 60;
EADDRNOTAVAIL = 49;
EADDRINUSE = 48;
ECONNABORTED = 53;
EAFNOSUPPORT = 47;
ECONNREFUSED = 61;
ENOTCONN = 57;
EINPROGRESS = 36;
ECONNRESET = 54;
EMSGSIZE = 40;
}
if IS_WINDOWS then
local winerr = {
EAGAIN = 11;
EHOSTUNREACH = 110;
ENOTSOCK = 128;
ENETDOWN = 116;
EPROTONOSUPPORT = 135;
ENOBUFS = 119;
ENETUNREACH = 118;
ENOTSUP = 129;
ETIMEDOUT = 138;
EADDRNOTAVAIL = 101;
EADDRINUSE = 100;
ECONNABORTED = 106;
EAFNOSUPPORT = 102;
ECONNREFUSED = 107;
ENOTCONN = 126;
EINPROGRESS = 112;
ECONNRESET = 108;
EMSGSIZE = 115;
}
for e, v in pairs(winerr) do errors[e]=v end
else
local ok, syscall = pcall(require, "syscall")
if not ok then syscall = nil end
if syscall and syscall.c and syscall.c.E then
local sys_errors = {}
local E = syscall.c.E
for e, v in pairs(errors) do
sys_errors[e] = E[(e:sub(2))] or v
end
errors = sys_errors
end
end
for e, v in pairs(zmq_errors) do errors[e]=v end
end
return errors
| mit |
naclander/tome | game/modules/tome/data/gfx/particles/teleport_water.lua | 3 | 1221 | -- ToME - Tales of Maj'Eyal
-- Copyright (C) 2009 - 2014 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
base_size = 32
return {
base = 1000,
angle = { 0, 360 }, anglev = { 2000, 5000 }, anglea = { 20, 60 },
life = { 20, 30 },
size = { 3, 7 }, sizev = {0, 0}, sizea = {0, 0},
r = {0, 0}, rv = {0, 0}, ra = {0, 0},
g = {10, 100}, gv = {0, 0}, ga = {0, 0},
b = {100, 255}, bv = {0, 10}, ba = {0, 0},
a = {25, 255}, av = {0, 0}, aa = {0, 0},
}, function(self)
self.nb = (self.nb or 0) + 1
if self.nb < 6 then
self.ps:emit(100)
end
end
| gpl-3.0 |
icyxp/kong | spec/03-plugins/20-hmac-auth/04-invalidations_spec.lua | 2 | 7695 | local helpers = require "spec.helpers"
local cjson = require "cjson"
local crypto = require "crypto"
describe("Plugin: hmac-auth (invalidations)", function()
local client_proxy, client_admin, consumer, credential
setup(function()
helpers.run_migrations()
local api = assert(helpers.dao.apis:insert {
name = "api-1",
hosts = { "hmacauth.com" },
upstream_url = helpers.mock_upstream_url,
})
assert(helpers.dao.plugins:insert {
name = "hmac-auth",
api_id = api.id,
config = {
clock_skew = 3000,
},
})
consumer = assert(helpers.dao.consumers:insert {
username = "consumer1",
custom_id = "1234",
})
credential = assert(helpers.dao["hmacauth_credentials"]:insert {
username = "bob",
secret = "secret",
consumer_id = consumer.id,
})
assert(helpers.start_kong({
nginx_conf = "spec/fixtures/custom_nginx.template",
}))
client_proxy = helpers.proxy_client()
client_admin = helpers.admin_client()
end)
teardown(function()
if client_proxy and client_admin then
client_proxy:close()
client_admin:close()
end
helpers.stop_kong(nil, true)
end)
local function hmac_sha1_binary(secret, data)
return crypto.hmac.digest("sha1", data, secret, true)
end
local function get_authorization(username)
local date = os.date("!%a, %d %b %Y %H:%M:%S GMT")
local encodedSignature = ngx.encode_base64(hmac_sha1_binary("secret", "date: " .. date))
return [["hmac username="]] .. username
.. [[",algorithm="hmac-sha1",headers="date",signature="]]
.. encodedSignature .. [["]], date
end
describe("HMAC Auth Credentials entity invalidation", function()
it("should invalidate when Hmac Auth Credential entity is deleted", function()
-- It should work
local authorization, date = get_authorization("bob")
local res = assert(client_proxy:send {
method = "GET",
path = "/requests",
body = {},
headers = {
["HOST"] = "hmacauth.com",
date = date,
authorization = authorization
}
})
assert.res_status(200, res)
-- Check that cache is populated
local cache_key = helpers.dao.hmacauth_credentials:cache_key("bob")
res = assert(client_admin:send {
method = "GET",
path = "/cache/" .. cache_key,
body = {},
})
assert.res_status(200, res)
-- Retrieve credential ID
res = assert(client_admin:send {
method = "GET",
path = "/consumers/consumer1/hmac-auth/",
body = {},
})
local body = assert.res_status(200, res)
local credential_id = cjson.decode(body).data[1].id
assert.equal(credential.id, credential_id)
-- Delete Hmac Auth credential (which triggers invalidation)
res = assert(client_admin:send {
method = "DELETE",
path = "/consumers/consumer1/hmac-auth/" .. credential_id,
body = {},
})
assert.res_status(204, res)
-- ensure cache is invalidated
helpers.wait_until(function()
local res = assert(client_admin:send {
method = "GET",
path = "/cache/" .. cache_key
})
res:read_body()
return res.status == 404
end)
-- It should not work
authorization, date = get_authorization("bob")
local res = assert(client_proxy:send {
method = "POST",
body = {},
headers = {
["HOST"] = "hmacauth.com",
date = date,
authorization = authorization
}
})
assert.res_status(403, res)
end)
it("should invalidate when Hmac Auth Credential entity is updated", function()
local res = assert(client_admin:send {
method = "POST",
path = "/consumers/consumer1/hmac-auth/",
body = {
username = "bob",
secret = "secret",
consumer_id = consumer.id,
},
headers = {
["Content-Type"] = "application/json",
}
})
local body = assert.res_status(201, res)
credential = cjson.decode(body)
-- It should work
local authorization, date = get_authorization("bob")
local res = assert(client_proxy:send {
method = "GET",
path = "/requests",
body = {},
headers = {
["HOST"] = "hmacauth.com",
date = date,
authorization = authorization
}
})
assert.res_status(200, res)
-- It should not work
local authorization, date = get_authorization("hello123")
res = assert(client_proxy:send {
method = "GET",
path = "/requests",
body = {},
headers = {
["HOST"] = "hmacauth.com",
date = date,
authorization = authorization
}
})
assert.res_status(403, res)
-- Update Hmac Auth credential (which triggers invalidation)
res = assert(client_admin:send {
method = "PATCH",
path = "/consumers/consumer1/hmac-auth/" .. credential.id,
body = {
username = "hello123"
},
headers = {
["Content-Type"] = "application/json"
}
})
assert.res_status(200, res)
-- ensure cache is invalidated
local cache_key = helpers.dao.hmacauth_credentials:cache_key("bob")
helpers.wait_until(function()
local res = assert(client_admin:send {
method = "GET",
path = "/cache/" .. cache_key
})
res:read_body()
return res.status == 404
end)
-- It should work
local authorization, date = get_authorization("hello123")
local res = assert(client_proxy:send {
method = "GET",
body = {},
headers = {
["HOST"] = "hmacauth.com",
date = date,
authorization = authorization
}
})
assert.res_status(200, res)
end)
end)
describe("Consumer entity invalidation", function()
it("should invalidate when Consumer entity is deleted", function()
-- It should work
local authorization, date = get_authorization("hello123")
local res = assert(client_proxy:send {
method = "GET",
path = "/requests",
body = {},
headers = {
["HOST"] = "hmacauth.com",
date = date,
authorization = authorization
}
})
assert.res_status(200, res)
-- Check that cache is populated
local cache_key = helpers.dao.hmacauth_credentials:cache_key("hello123")
res = assert(client_admin:send {
method = "GET",
path = "/cache/" .. cache_key,
body = {},
})
assert.res_status(200, res)
-- Delete Consumer (which triggers invalidation)
res = assert(client_admin:send {
method = "DELETE",
path = "/consumers/consumer1",
body = {},
})
assert.res_status(204, res)
-- ensure cache is invalidated
helpers.wait_until(function()
local res = assert(client_admin:send {
method = "GET",
path = "/cache/" .. cache_key
})
res:read_body()
return res.status == 404
end)
-- It should not work
local authorization, date = get_authorization("bob")
local res = assert(client_proxy:send {
method = "GET",
body = {},
headers = {
["HOST"] = "hmacauth.com",
date = date,
authorization = authorization
}
})
assert.res_status(403, res)
end)
end)
end)
| apache-2.0 |
LuaDist2/lzmq-timer | examples/perf/thread_thr.lua | 16 | 3469 | -- Copyright (c) 2011 Robert G. Jakabosky <bobby@sharedrealm.com>
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-- THE SOFTWARE.
if #arg < 1 then
print("usage: lua " .. arg[0] .. " [message-size] [message-count] [bind-to] [connect-to]")
end
local message_size = tonumber(arg[1] or 1)
local message_count = tonumber(arg[2] or 100000)
local bind_to = arg[3] or 'inproc://thread_lat_test'
local connect_to = arg[4] or 'inproc://thread_lat_test'
local zmq = require"lzmq"
local zthreads = require"lzmq.threads"
local assert = zmq.assert
local child_code = [[
local connect_to, message_size, message_count = ...
local zmq = require"lzmq"
local zthreads = require"lzmq.threads"
local assert = zmq.assert
local ctx = zthreads.get_parent_ctx()
local s = ctx:socket(zmq.PUB)
s:set_sndhwm(message_count+1)
s:connect(connect_to)
local data = ("0"):rep(message_size)
local msg_data = zmq.msg_init_data(data)
local msg = zmq.msg_init()
zmq.utils.sleep(2) -- wait subscriber
print("sending")
local timer = zmq.utils.stopwatch():start()
for i = 1, message_count + 1 do
assert(msg:copy(msg_data))
assert(s:send_msg(msg))
end
local elapsed = timer:stop()
s:close()
if elapsed == 0 then elapsed = 1 end
local throughput = message_count / (elapsed / 1000000)
local megabits = throughput * message_size * 8 / 1000000
print(string.format("Sender mean throughput: %i [msg/s]", throughput))
print(string.format("Sender mean throughput: %.3f [Mb/s]", megabits))
print("sending thread finished.")
]]
local ctx = zmq.init(1)
local s = ctx:socket(zmq.SUB)
s:set_subscribe("")
s:set_rcvhwm(message_count+1)
s:bind(bind_to)
print(string.format("message size: %i [B]", message_size))
print(string.format("message count: %i", message_count))
local child_thread = zthreads.runstring(ctx, child_code, connect_to, message_size, message_count)
child_thread:start()
local msg
msg = zmq.msg_init()
assert(s:recv_msg(msg))
local timer = zmq.utils.stopwatch():start()
for i = 1, message_count - 1 do
assert(s:recv_msg(msg))
assert(msg:size() == message_size, "Invalid message size")
end
local elapsed = timer:stop()
s:close()
child_thread:join()
ctx:term()
if elapsed == 0 then elapsed = 1 end
local throughput = message_count / (elapsed / 1000000)
local megabits = throughput * message_size * 8 / 1000000
print(string.format("mean throughput: %i [msg/s]", throughput))
print(string.format("mean throughput: %.3f [Mb/s]", megabits))
| mit |
ibm2431/darkstar | scripts/globals/items/dish_of_spaghetti_carbonara.lua | 11 | 1545 | -----------------------------------------
-- 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 % 17
-- Attack Cap 65
-- Store TP 6
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if target:hasStatusEffect(dsp.effect.FOOD) or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) then
result = dsp.msg.basic.IS_FULL
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,1800,5190)
end
function onEffectGain(target,effect)
target:addMod(dsp.mod.FOOD_HPP, 14)
target:addMod(dsp.mod.FOOD_HP_CAP, 175)
target:addMod(dsp.mod.MP, 10)
target:addMod(dsp.mod.STR, 4)
target:addMod(dsp.mod.VIT, 2)
target:addMod(dsp.mod.INT, -3)
target:addMod(dsp.mod.FOOD_ATTP, 17)
target:addMod(dsp.mod.FOOD_ATT_CAP, 65)
target:addMod(dsp.mod.STORETP, 6)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.FOOD_HPP, 14)
target:delMod(dsp.mod.FOOD_HP_CAP, 175)
target:delMod(dsp.mod.MP, 10)
target:delMod(dsp.mod.STR, 4)
target:delMod(dsp.mod.VIT, 2)
target:delMod(dsp.mod.INT, -3)
target:delMod(dsp.mod.FOOD_ATTP, 17)
target:delMod(dsp.mod.FOOD_ATT_CAP, 65)
target:delMod(dsp.mod.STORETP, 6)
end
| gpl-3.0 |
ibm2431/darkstar | scripts/zones/Sealions_Den/npcs/Airship_Door.lua | 8 | 1246 | -----------------------------------
-- Area: Sealion's Den
-- NPC: Airship_Door
-----------------------------------
local ID = require("scripts/zones/Sealions_Den/IDs")
-----------------------------------
function onTrade(player, npc, trade)
end
function onTrigger(player, npc)
local offset = npc:getID() - ID.npc.AIRSHIP_DOOR_OFFSET
player:startEvent(32003, offset + 1)
end
function onEventUpdate(player, csid, option)
local inst = player:getCharVar("bcnm_instanceid")
-- spawn omega for given instance
if csid == 1 and option == 0 then
local omegaId = ID.mob.ONE_TO_BE_FEARED_OFFSET + (7 * (inst - 1)) + 5
if omegaId and not GetMobByID(omegaId):isSpawned() then
SpawnMob(omegaId)
end
-- spawn ultima for given instance
elseif csid == 2 and option == 0 then
local ultimaId = ID.mob.ONE_TO_BE_FEARED_OFFSET + (7 * (inst - 1)) + 6
if ultimaId and not GetMobByID(ultimaId):isSpawned() then
SpawnMob(ultimaId)
end
end
end
function onEventFinish(player, csid, option)
if csid == 32003 and option >= 100 and option <= 102 then
local inst = option - 99
player:startEvent(player:getLocalVar("[OTBF]cs"), inst)
end
end
| gpl-3.0 |
LegionXI/darkstar | scripts/zones/Windurst_Woods/npcs/Kuzah_Hpirohpon.lua | 27 | 1199 | -----------------------------------
-- Area: Windurst Woods
-- NPC: Kuzah Hpirohpon
-- Guild Merchant NPC: Clothcrafting Guild
-- @pos -80.068 -3.25 -127.686 241
-----------------------------------
package.loaded["scripts/zones/Windurst_Woods/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/shop");
require("scripts/zones/Windurst_Woods/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:sendGuild(5152,6,21,0)) then
player:showText(npc,KUZAH_HPIROHPON_DIALOG);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
softer/prosody-modules | mod_openid/mod_openid.lua | 32 | 15176 | local usermanager = require "core.usermanager"
local httpserver = require "net.httpserver"
local jidutil = require "util.jid"
local hmac = require "hmac"
local base64 = require "util.encodings".base64
local humane = require "util.serialization".serialize
-- Configuration
local base = "openid"
local openidns = "http://specs.openid.net/auth/2.0" -- [#4.1.2]
local response_404 = { status = "404 Not Found", body = "<h1>Page Not Found</h1>Sorry, we couldn't find what you were looking for :(" };
local associations = {}
local function genkey(length)
-- FIXME not cryptographically secure
str = {}
for i = 1,length do
local rand = math.random(33, 126)
table.insert(str, string.char(rand))
end
return table.concat(str)
end
local function tokvstring(dict)
-- key-value encoding for a dictionary [#4.1.3]
local str = ""
for k,v in pairs(dict) do
str = str..k..":"..v.."\n"
end
return str
end
local function newassoc(key, shared)
-- TODO don't use genkey here
local handle = genkey(16)
associations[handle] = {}
associations[handle]["key"] = key
associations[handle]["shared"] = shared
associations[handle]["time"] = os.time()
return handle
end
local function split(str, sep)
local splits = {}
str:gsub("([^.."..sep.."]*)"..sep, function(c) table.insert(splits, c) end)
return splits
end
local function sign(response, key)
local fields = {}
for _,field in pairs(split(response["openid.signed"],",")) do
fields[field] = response["openid."..field]
end
-- [#10.1]
return base64.encode(hmac.sha256(key, tokvstring(fields)))
end
local function urlencode(s)
return (string.gsub(s, "%W",
function(str)
return string.format("%%%02X", string.byte(str))
end))
end
local function urldecode(s)
return(string.gsub(string.gsub(s, "+", " "), "%%(%x%x)",
function(str)
return string.char(tonumber(str,16))
end))
end
local function utctime()
local now = os.time()
local diff = os.difftime(now, os.time(os.date("!*t", now)))
return now-diff
end
local function nonce()
-- generate a response nonce [#10.1]
local random = ""
for i=0,10 do
random = random..string.char(math.random(33,126))
end
local timestamp = os.date("%Y-%m-%dT%H:%M:%SZ", utctime())
return timestamp..random
end
local function query_params(query)
if type(query) == "string" and #query > 0 then
if query:match("=") then
local params = {}
for k, v in query:gmatch("&?([^=%?]+)=([^&%?]+)&?") do
if k and v then
params[urldecode(k)] = urldecode(v)
end
end
return params
else
return urldecode(query)
end
end
end
local function split_host_port(combined)
local host = combined
local port = ""
local cpos = string.find(combined, ":")
if cpos ~= nil then
host = string.sub(combined, 0, cpos-1)
port = string.sub(combined, cpos+1)
end
return host, port
end
local function toquerystring(dict)
-- query string encoding for a dictionary [#4.1.3]
local str = ""
for k,v in pairs(dict) do
str = str..urlencode(k).."="..urlencode(v).."&"
end
return string.sub(str, 0, -1)
end
local function match_realm(url, realm)
-- FIXME do actual match [#9.2]
return true
end
local function handle_endpoint(method, body, request)
module:log("debug", "Request at OpenID provider endpoint")
local params = nil
if method == "GET" then
params = query_params(request.url.query)
elseif method == "POST" then
params = query_params(body)
else
-- TODO error
return response_404
end
module:log("debug", "Request Parameters:\n"..humane(params))
if params["openid.ns"] == openidns then
-- OpenID 2.0 request [#5.1.1]
if params["openid.mode"] == "associate" then
-- Associate mode [#8]
-- TODO implement association
-- Error response [#8.2.4]
local openidresponse = {
["ns"] = openidns,
["session_type"] = params["openid.session_type"],
["assoc_type"] = params["openid.assoc_type"],
["error"] = "Association not supported... yet",
["error_code"] = "unsupported-type",
}
local kvresponse = tokvstring(openidresponse)
module:log("debug", "OpenID Response:\n"..kvresponse)
return {
headers = {
["Content-Type"] = "text/plain"
},
body = kvresponse
}
elseif params["openid.mode"] == "checkid_setup" or params["openid.mode"] == "checkid_immediate" then
-- Requesting authentication [#9]
if not params["openid.realm"] then
-- set realm to default value of return_to [#9.1]
if params["openid.return_to"] then
params["openid.realm"] = params["openid.return_to"]
else
-- neither was sent, error [#9.1]
-- FIXME return proper error
return response_404
end
end
if params["openid.return_to"] then
-- Assure that the return_to url matches the realm [#9.2]
if not match_realm(params["openid.return_to"], params["openid.realm"]) then
-- FIXME return proper error
return response_404
end
-- Verify the return url [#9.2.1]
-- TODO implement return url verification
end
if params["openid.claimed_id"] and params["openid.identity"] then
-- asserting an identifier [#9.1]
if params["openid.identity"] == "http://specs.openid.net/auth/2.0/identifier_select" then
-- automatically select an identity [#9.1]
params["openid.identity"] = params["openid.claimed_id"]
end
if params["openid.mode"] == "checkid_setup" then
-- Check ID Setup mode
-- TODO implement: NEXT STEP
local head = "<title>Prosody OpenID : Login</title>"
local body = string.format([[
<p>Open ID Authentication<p>
<p>Identifier: <tt>%s</tt></p>
<p>Realm: <tt>%s</tt></p>
<p>Return: <tt>%s</tt></p>
<form method="POST" action="%s">
Jabber ID: <input type="text" name="jid"/><br/>
Password: <input type="password" name="password"/><br/>
<input type="hidden" name="openid.return_to" value="%s"/>
<input type="submit" value="Authenticate"/>
</form>
]], params["openid.claimed_id"], params["openid.realm"], params["openid.return_to"], base, params["openid.return_to"])
return string.format([[
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
%s
</head>
<body>
%s
</body>
</html>
]], head, body)
elseif params["openid.mode"] == "checkid_immediate" then
-- Check ID Immediate mode [#9.3]
-- TODO implement check id immediate
end
else
-- not asserting an identifier [#9.1]
-- used for extensions
-- TODO implement common extensions
end
elseif params["openid.mode"] == "check_authentication" then
module:log("debug", "OpenID Check Authentication Mode")
local assoc = associations[params["openid.assoc_handle"]]
module:log("debug", "Checking Association Handle: "..params["openid.assoc_handle"])
if assoc and not assoc["shared"] then
module:log("debug", "Found valid association")
local sig = sign(params, assoc["key"])
local is_valid = "false"
if sig == params["openid.sig"] then
is_valid = "true"
end
module:log("debug", "Signature is: "..is_valid)
openidresponse = {
ns = openidns,
is_valid = is_valid,
}
-- Delete this association
associations[params["openid.assoc_handle"]] = nil
return {
headers = {
["Content-Type"] = "text/plain"
},
body = tokvstring(openidresponse),
}
else
module:log("debug", "No valid association")
-- TODO return error
-- Invalidate the handle [#11.4.2.2]
end
else
-- Some other mode
-- TODO error
end
elseif params["password"] then
-- User is authenticating
local user, domain = jidutil.split(params["jid"])
module:log("debug", "Authenticating "..params["jid"].." ("..user..","..domain..") with password: "..params["password"])
local valid = usermanager.validate_credentials(domain, user, params["password"], "PLAIN")
if valid then
module:log("debug", "Authentication Succeeded: "..params["jid"])
if params["openid.return_to"] ~= "" then
-- TODO redirect the user to return_to with the openid response
-- included, need to handle the case if its a GET, that there are
-- existing query parameters on the return_to URL [#10.1]
local host, port = split_host_port(request.headers.host)
local endpointurl = ""
if port == '' then
endpointurl = string.format("http://%s/%s", host, base)
else
endpointurl = string.format("http://%s:%s/%s", host, port, base)
end
local nonce = nonce()
local key = genkey(32)
local assoc_handle = newassoc(key)
local openidresponse = {
["openid.ns"] = openidns,
["openid.mode"] = "id_res",
["openid.op_endpoint"] = endpointurl,
["openid.claimed_id"] = endpointurl.."/"..user,
["openid.identity"] = endpointurl.."/"..user,
["openid.return_to"] = params["openid.return_to"],
["openid.response_nonce"] = nonce,
["openid.assoc_handle"] = assoc_handle,
["openid.signed"] = "op_endpoint,identity,claimed_id,return_to,assoc_handle,response_nonce", -- FIXME
["openid.sig"] = nil,
}
openidresponse["openid.sig"] = sign(openidresponse, key)
queryresponse = toquerystring(openidresponse)
redirecturl = params["openid.return_to"]
-- add the parameters to the return_to
if redirecturl:match("?") then
redirecturl = redirecturl.."&"
else
redirecturl = redirecturl.."?"
end
redirecturl = redirecturl..queryresponse
module:log("debug", "Open ID Positive Assertion Response Table:\n"..humane(openidresponse))
module:log("debug", "Open ID Positive Assertion Response URL:\n"..queryresponse)
module:log("debug", "Redirecting User to:\n"..redirecturl)
return {
status = "303 See Other",
headers = {
Location = redirecturl,
},
body = "Redirecting to: "..redirecturl -- TODO Include a note with a hyperlink to redirect
}
else
-- TODO Do something useful is there is no return_to
end
else
module:log("debug", "Authentication Failed: "..params["jid"])
-- TODO let them try again
end
else
-- Not an Open ID request, do something useful
-- TODO
end
return response_404
end
local function handle_identifier(method, body, request, id)
module:log("debug", "Request at OpenID identifier")
local host, port = split_host_port(request.headers.host)
local user_name = ""
local user_domain = ""
local apos = string.find(id, "@")
if apos == nil then
user_name = id
user_domain = host
else
user_name = string.sub(id, 0, apos-1)
user_domain = string.sub(id, apos+1)
end
user, domain = jidutil.split(id)
local exists = usermanager.user_exists(user_name, user_domain)
if not exists then
return response_404
end
local endpointurl = ""
if port == '' then
endpointurl = string.format("http://%s/%s", host, base)
else
endpointurl = string.format("http://%s:%s/%s", host, port, base)
end
local head = string.format("<title>Prosody OpenID : %s@%s</title>", user_name, user_domain)
-- OpenID HTML discovery [#7.3]
head = head .. string.format('<link rel="openid2.provider" href="%s" />', endpointurl)
local content = 'request.url.path: ' .. request.url.path .. '<br/>'
content = content .. 'host+port: ' .. request.headers.host .. '<br/>'
content = content .. 'host: ' .. tostring(host) .. '<br/>'
content = content .. 'port: ' .. tostring(port) .. '<br/>'
content = content .. 'user_name: ' .. user_name .. '<br/>'
content = content .. 'user_domain: ' .. user_domain .. '<br/>'
content = content .. 'exists: ' .. tostring(exists) .. '<br/>'
local body = string.format('<p>%s</p>', content)
local data = string.format([[
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
%s
</head>
<body>
%s
</body>
</html>
]], head, body)
return data;
end
local function handle_request(method, body, request)
module:log("debug", "Received request")
-- Make sure the host is enabled
local host = split_host_port(request.headers.host)
if not hosts[host] then
return response_404
end
if request.url.path == "/"..base then
-- OpenID Provider Endpoint
return handle_endpoint(method, body, request)
else
local id = request.url.path:match("^/"..base.."/(.+)$")
if id then
-- OpenID Identifier
return handle_identifier(method, body, request, id)
else
return response_404
end
end
end
httpserver.new{ port = 5280, base = base, handler = handle_request, ssl = false}
| mit |
LegionXI/darkstar | scripts/globals/items/shrimp_cracker.lua | 12 | 1491 | -----------------------------------------
-- ID: 5635
-- Item: shrimp_cracker
-- Food Effect: 3Min, All Races
-----------------------------------------
-- Vitality 1
-- DEF +10
-- Amorph Killer 10
-- Resist Virus +10
-- HP Recovered While Healing 8
-----------------------------------------
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,180,5635);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_VIT, 1);
target:addMod(MOD_DEF, 10);
target:addMod(MOD_AMORPH_KILLER, 10);
target:addMod(MOD_VIRUSRES, 10);
target:addMod(MOD_HPHEAL, 8);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_VIT, 1);
target:delMod(MOD_DEF, 10);
target:delMod(MOD_AMORPH_KILLER, 10);
target:delMod(MOD_VIRUSRES, 10);
target:delMod(MOD_HPHEAL, 8);
end;
| gpl-3.0 |
greasydeal/darkstar | scripts/globals/items/army_biscuit.lua | 35 | 1254 | -----------------------------------------
-- ID: 5657
-- Item: army_biscuit
-- Food Effect: 5Min?, All Races
-----------------------------------------
-- HP Recovered While Healing 3
-- MP Recovered While Healing 3
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,300,5657);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HPHEAL, 3);
target:addMod(MOD_MPHEAL, 3);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HPHEAL, 3);
target:delMod(MOD_MPHEAL, 3);
end;
| gpl-3.0 |
bacsmar/Urho3D | bin/Data/LuaScripts/53_LANDiscovery.lua | 6 | 4321 | -- Chat example
-- This sample demonstrates:
-- - Starting up a network server or connecting to it
-- - Implementing simple chat functionality with network messages
require "LuaScripts/Utilities/Sample"
local startServer = nil;
local stopServer = nil;
local refreshServerList = nil;
local serverList = nil;
-- Local server port
local SERVER_PORT = 54654
function Start()
-- Execute the common startup for samples
SampleStart()
-- Enable OS cursor
input.mouseVisible = true
-- Create the user interface
CreateUI()
-- Set the mouse mode to use in the sample
SampleInitMouseMode(MM_FREE)
-- Subscribe to UI and network events
SubscribeToEvents()
end
function CreateUI()
SetLogoVisible(true) -- We need the full rendering window
local uiStyle = cache:GetResource("XMLFile", "UI/DefaultStyle.xml")
-- Set style to the UI root so that elements will inherit it
ui.root.defaultStyle = uiStyle
local marginTop = 20
CreateLabel("1. Start server", IntVector2(20, marginTop-20));
startServer = CreateButton("Start server", 160, IntVector2(20, marginTop));
stopServer = CreateButton("Stop server", 160, IntVector2(20, marginTop));
stopServer.visible = false;
marginTop = marginTop + 80;
CreateLabel("2. Discover LAN servers", IntVector2(20, marginTop-20));
refreshServerList = CreateButton("Search...", 160, IntVector2(20, marginTop));
marginTop = marginTop + 80;
CreateLabel("Local servers:", IntVector2(20, marginTop - 20));
serverList = CreateLabel("", IntVector2(20, marginTop));
end
function SubscribeToEvents()
SubscribeToEvent("NetworkHostDiscovered", "HandleNetworkHostDiscovered");
SubscribeToEvent(startServer, "Released", "HandleStartServer");
SubscribeToEvent(stopServer, "Released", "HandleStopServer");
SubscribeToEvent(refreshServerList, "Released", "HandleDoNetworkDiscovery");
end
function CreateButton(text, width, position)
local font = cache:GetResource("Font", "Fonts/Anonymous Pro.ttf")
local button = ui.root:CreateChild("Button")
button:SetStyleAuto()
button:SetFixedWidth(width)
button:SetFixedHeight(30)
button:SetPosition(position.x, position.y)
local buttonText = button:CreateChild("Text")
buttonText:SetFont(font, 12)
buttonText:SetAlignment(HA_CENTER, VA_CENTER)
buttonText.text = text
return button
end
function CreateLabel(text, position)
local font = cache:GetResource("Font", "Fonts/Anonymous Pro.ttf")
local label = ui.root:CreateChild("Text")
label:SetFont(font, 12)
label.color = Color(0.0, 1.0, 0.0)
label:SetPosition(position.x, position.y)
label.text = text
return label
end
function HandleNetworkHostDiscovered(eventType, eventData)
local text = serverList.text
local data = eventData["Beacon"]:GetVariantMap()
text = text .. "\n" .. data["Name"]:GetString() .. "(" .. data["Players"]:GetInt() .. ")" .. eventData["Address"]:GetString() .. ":" .. eventData["Port"]:GetInt()
serverList:SetText(text)
end
function HandleStartServer(eventType, eventData)
if network:StartServer(SERVER_PORT) == true
then
local data = VariantMap();
data["Name"] = "Test server";
data["Players"] = 100;
-- Set data which will be sent to all who requests LAN network discovery
network:SetDiscoveryBeacon(data);
startServer.visible = false;
stopServer.visible = true;
end
end
function HandleStopServer(eventType, eventData)
network:StopServer();
startServer.visible = true;
stopServer.visible = false;
end
function HandleDoNetworkDiscovery(eventType, eventData)
network:DiscoverHosts(SERVER_PORT)
serverList:SetText("")
end
-- Create XML patch instructions for screen joystick layout specific to this sample app
function GetScreenJoystickPatchString()
return
"<patch>" ..
" <add sel=\"/element/element[./attribute[@name='Name' and @value='Button2']]\">" ..
" <attribute name=\"Is Visible\" value=\"false\" />" ..
" </add>" ..
" <add sel=\"/element/element[./attribute[@name='Name' and @value='Hat0']]\">" ..
" <attribute name=\"Is Visible\" value=\"false\" />" ..
" </add>" ..
"</patch>"
end
| mit |
ibm2431/darkstar | scripts/globals/items/serving_of_cilbir.lua | 11 | 1294 | -----------------------------------------
-- ID: 5642
-- Item: serving_of_cilbir
-- Food Effect: 3Hrs, All Races
-----------------------------------------
-- HP % 5 (cap 150)
-- MP % 5 (cap 100)
-- HP recovered while healing 3
-- MP recovered while healing 3
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if target:hasStatusEffect(dsp.effect.FOOD) or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) then
result = dsp.msg.basic.IS_FULL
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,10800,5642)
end
function onEffectGain(target, effect)
target:addMod(dsp.mod.FOOD_HPP, 5)
target:addMod(dsp.mod.FOOD_HP_CAP, 150)
target:addMod(dsp.mod.FOOD_MPP, 5)
target:addMod(dsp.mod.FOOD_MP_CAP, 100)
target:addMod(dsp.mod.MPHEAL, 3)
target:addMod(dsp.mod.HPHEAL, 3)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.FOOD_HPP, 5)
target:delMod(dsp.mod.FOOD_HP_CAP, 150)
target:delMod(dsp.mod.FOOD_MPP, 5)
target:delMod(dsp.mod.FOOD_MP_CAP, 100)
target:delMod(dsp.mod.MPHEAL, 3)
target:delMod(dsp.mod.HPHEAL, 3)
end
| gpl-3.0 |
LegionXI/darkstar | scripts/zones/Balgas_Dais/mobs/Maat.lua | 14 | 1549 | -----------------------------------
-- Area: Balga Dais
-- MOB: Maat
-- Genkai 5 Fight
-----------------------------------
package.loaded["scripts/zones/Balgas_Dais/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Balgas_Dais/TextIDs");
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
end;
-----------------------------------
-- onMobEngaged Action
-----------------------------------
function onMobEngaged(mob,target)
-- target:showText(mob,YOU_DECIDED_TO_SHOW_UP);
printf("Maat Balga Dais works");
-- When he take damage: target:showText(mob,THAT_LL_HURT_IN_THE_MORNING);
-- He use dragon kick or tackle: target:showText(mob,TAKE_THAT_YOU_WHIPPERSNAPPER);
-- He use spining attack: target:showText(mob,TEACH_YOU_TO_RESPECT_ELDERS);
-- If you dying: target:showText(mob,LOOKS_LIKE_YOU_WERENT_READY);
end;
-----------------------------------
-- onMobFight Action
-----------------------------------
function onMobFight(mob, target)
local bf = mob:getBattlefield();
if (mob:getHPP() <20) then
bf:win();
return;
-- WHM's Maat additionally gives up if kept fighting for 5 min
elseif (target:getMainJob() == JOBS.WHM and mob:getBattleTime() > 300) then
bf:win();
return;
end
end;
-----------------------------------
-- onMobDeath Action
-----------------------------------
function onMobDeath(mob, player, isKiller)
player:showText(mob,YOUVE_COME_A_LONG_WAY);
end;
| gpl-3.0 |
xistoso/CppSharp | examples/SDL/premake4.lua | 8 | 1388 | project "SDL"
SetupExampleProject()
if config.ExampleTests then
project "SDL.Tests"
kind "ConsoleApp"
language "C#"
location "."
dependson "SDL"
files
{
libdir .. "/SDL/SDL.cs",
libdir .. "/SDL/SDL_assert.cs",
libdir .. "/SDL/SDL_audio.cs",
libdir .. "/SDL/SDL_blendmode.cs",
libdir .. "/SDL/SDL_clipboard.cs",
libdir .. "/SDL/SDL_cpuinfo.cs",
libdir .. "/SDL/SDL_error.cs",
libdir .. "/SDL/SDL_events.cs",
libdir .. "/SDL/SDL_gamecontroller.cs",
libdir .. "/SDL/SDL_gesture.cs",
libdir .. "/SDL/SDL_hints.cs",
libdir .. "/SDL/SDL_joystick.cs",
libdir .. "/SDL/SDL_keyboard.cs",
libdir .. "/SDL/SDL_keycode.cs",
libdir .. "/SDL/SDL_loadso.cs",
libdir .. "/SDL/SDL_log.cs",
libdir .. "/SDL/SDL_messagebox.cs",
libdir .. "/SDL/SDL_mouse.cs",
libdir .. "/SDL/SDL_pixels.cs",
libdir .. "/SDL/SDL_platform.cs",
libdir .. "/SDL/SDL_power.cs",
libdir .. "/SDL/SDL_rect.cs",
libdir .. "/SDL/SDL_render.cs",
libdir .. "/SDL/SDL_rwops.cs",
libdir .. "/SDL/SDL_scancode.cs",
libdir .. "/SDL/SDL_surface.cs",
libdir .. "/SDL/SDL_thread.cs",
libdir .. "/SDL/SDL_timer.cs",
libdir .. "/SDL/SDL_touch.cs",
libdir .. "/SDL/SDL_version.cs",
libdir .. "/SDL/SDL_video.cs",
"*.lua"
}
end | mit |
LegionXI/darkstar | scripts/zones/Port_Jeuno/npcs/Najib.lua | 30 | 1385 | -----------------------------------
-- Area: Port Jeuno
-- NPC: Najib
-- 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 >= 1 do
vHour = vHour - 6;
end
if ( vHour == -5) then vHour = 1;
elseif ( vHour == -4) then vHour = 2;
elseif ( 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( 0x272A, 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 |
ibm2431/darkstar | scripts/zones/Temenos/mobs/Proto-Ultima.lua | 9 | 1458 | -----------------------------------
-- Area: Temenos
-- Mob: Proto-Ultima
-----------------------------------
require("scripts/globals/titles");
require("scripts/globals/limbus");
-----------------------------------
function onMobSpawn(mob)
mob:SetMagicCastingEnabled(false);
end;
function onMobFight(mob,target)
local phase = mob:getLocalVar("battlePhase");
if (mob:actionQueueEmpty() == true) then
if (mob:getHPP() < (80 - (phase * 20))) then
mob:useMobAbility(1524); -- use Dissipation on phase change
phase = phase + 1;
if (phase == 2) then -- enable Holy II
mob:SetMagicCastingEnabled(true);
end
if (phase == 4) then -- add Regain in final phase
if (mob:hasStatusEffect(dsp.effect.REGAIN) == false) then
mob:addStatusEffect(dsp.effect.REGAIN,7,3,0);
mob:getStatusEffect(dsp.effect.REGAIN):setFlag(dsp.effectFlag.DEATH);
end
end
mob:setLocalVar("battlePhase", phase); -- incrementing the phase here instead of in the Dissipation skill because stunning it prevents use.
end
end
end;
function onMobDeath(mob, player, isKiller)
player:addTitle(dsp.title.TEMENOS_LIBERATOR);
GetNPCByID(16928768+79):setPos(-559,5,-357);
GetNPCByID(16928768+79):setStatus(dsp.status.NORMAL);
GetNPCByID(16928768+474):setStatus(dsp.status.NORMAL);
end;
| gpl-3.0 |
greasydeal/darkstar | scripts/zones/Port_San_dOria/TextIDs.lua | 4 | 4857 | -- Variable TextID Description text
-- General Texts
ITEM_CANNOT_BE_OBTAINED_1 = 6414; -- You cannot obtain the <<<Possible Special Code: 01>>><<<Possible Special Code: 05>>>#<<<BAD CHAR: 8280>>><<<BAD CHAR: 80>>><<<BAD CHAR: 80>>>.<<<Prompt>>>
ITEM_CANNOT_BE_OBTAINED_2 = 6415; -- You cannot obtain the <<<Possible Special Code: 01>>><<<Possible Special Code: 05>>>#<<<BAD CHAR: 8280>>><<<BAD CHAR: 80>>><<<BAD CHAR: 80>>>. Come back after sorting your inventory.
ITEM_CANNOT_BE_OBTAINED_3 = 6417; -- You cannot obtain the item. Come back after sorting your inventory.
FULL_INVENTORY_AFTER_TRADE = 6418; -- You cannot obtain the <<<Possible Special Code: 01>>><<<Possible Special Code: 05>>>#<<<BAD CHAR: 8280>>><<<BAD CHAR: 80>>><<<BAD CHAR: 80>>>. Try trading again after sorting your inventory.
ITEM_OBTAINED = 6419; -- Obtained: <<<Unknown Parameter (Type: 80) 1>>><<<Possible Special Code: 01>>><<<Possible Special Code: 05>>>#<<<BAD CHAR: 8280>>><<<BAD CHAR: 80>>><<<BAD CHAR: 80>>>.
GIL_OBTAINED = 6420; -- Obtained <<<Numeric Parameter 0>>> gil.
KEYITEM_OBTAINED = 6422; -- Obtained key item: <<<Unknown Parameter (Type: 80) 1>>><<<Possible Special Code: 01>>><<<Possible Special Code: 05>>>3<<<BAD CHAR: 8280>>><<<BAD CHAR: 80>>><<<BAD CHAR: 80>>>.
HOMEPOINT_SET = 24; -- Home point set!
FISHING_MESSAGE_OFFSET = 7203; -- You can't fish here.
ITEM_DELIVERY_DIALOG = 7918; -- Now delivering parcels to rooms everywhere!
-- Dialogs
FLYER_REFUSED = 7530; -- This person isn't interested.
FLYER_ALREADY = 7531; -- This person already has a flyer.
FLYER_ACCEPTED = 7532; -- Your flyer is accepted!
FLYERS_HANDED = 7533; -- You've handed outflyer(s).
PORTAURE_DIALOG = 7795; -- What's this? A magic shop? Hmm...I could use a new line of work, and magic just might be the ticket!
ANSWALD_DIALOG = 7815; -- A magic shop? Oh, it's right near here. I'll go check it out sometime.
PRIETTA_DIALOG = 7839; -- This is the first I've heard of a magic shop here in San d'Oria. Such arts have never been popular in the Kingdom.
AUVARE_DIALOG = 7846; -- What have I got here? Look, I can't read, but I takes what I gets, and you ain't getting it back!
MIENE_DIALOG = 7899; -- Oh, a magic shop... Here in San d'Oria? I'd take a look if I got more allowance.
ANSWALD_MESSAGE = 8392; -- Answald looks over curiously for a moment.
PRIETTA_MESSAGE = 8393; -- Prietta looks over curiously for a moment.
MIENE_MESSAGE = 8394; -- Miene looks over curiously for a moment.
PORTAURE_MESSAGE = 8395; -- Portaure looks over curiously for a moment.
AUVARE_MESSAGE = 8396; -- Auvare looks over curiously for a moment.
-- Shop Texts
ALBINIE_SHOP_DIALOG = 7859; -- Welcome to my simple shop.
COULLAVE_SHOP_DIALOG = 7905; -- Can I help you?
CROUMANGUE_SHOP_DIALOG = 7906; -- Can't fight on an empty stomach. How about some nourishment?
VENDAVOQ_OPEN_DIALOG = 7913; -- Vandoolin! Vendavoq vring voods vack vrom Vovalpolos! Vuy! Vuy!
VENDAVOQ_CLOSED_DIALOG = 7914; -- Vandoolin... Vendavoq's vream vo vell voods vrom vometown vf Vovalpolos...
FIVA_OPEN_DIALOG = 7907; -- I've got imports from Kolshushu!
MILVA_OPEN_DIALOG = 7908; -- How about some produce from Sarutabaruta?
FIVA_CLOSED_DIALOG = 7909; -- I'm trying to sell goods from Kolshushu. But I can't because we don't have enough influence there.
MILVA_CLOSED_DIALOG = 7910; -- I want to import produce from Sarutabaruta... But I can't do anything until we control that region!
NIMIA_CLOSED_DIALOG = 7911; -- I can't sell goods from the lowlands of Elshimo because it's under foreign control.
PATOLLE_CLOSED_DIALOG = 7912; -- I'm trying to find goods from Kuzotz. But how can I when it's under foreign control?
DEGUERENDARS_OPEN_DIALOG = 7915; -- Welcome! Have a look at these rare goods from Tavnazia!
DEGUERENDARS_CLOSED_DIALOG = 7916; -- With that other nation in control of the region, there is no way for me to import goods from Tavnazia...
DEGUERENDARS_COP_NOT_COMPLETED = 7917; -- Why must I wait for the Kingdom to issue a permit allowing me to set up shop? How am I to feed my children in the meantime!?
BONMAURIEUT_CLOSED_DIALOG = 8252; -- I would like to sell goods from the Elshimo Uplands, but I cannot, as it's under foreign control.
NIMIA_OPEN_DIALOG = 8253; -- Hello, friend! Can I interest you in specialty goods from the Elshimo Lowlands?
PATOLLE_OPEN_DIALOG = 8254; -- How about some specialty goods from Kuzotz?
BONMAURIEUT_OPEN_DIALOG = 8255; -- My shipment is in! Would you like to see what has just arrived from the Elshimo Uplands?
-- conquest Base
CONQUEST_BASE = 7044; -- Tallying conquest results...
| gpl-3.0 |
icyxp/kong | kong/plugins/response-transformer/header_transformer.lua | 5 | 2673 | local insert = table.insert
local type = type
local find = string.find
local lower = string.lower
local match = string.match
local _M = {}
local function iter(config_array)
return function(config_array, i, previous_header_name, previous_header_value)
i = i + 1
local header_to_test = config_array[i]
if header_to_test == nil then -- n + 1
return nil
end
local header_to_test_name, header_to_test_value = match(header_to_test, "^([^:]+):*(.-)$")
if header_to_test_value == "" then
header_to_test_value = nil
end
return i, header_to_test_name, header_to_test_value
end, config_array, 0
end
local function append_value(current_value, value)
local current_value_type = type(current_value)
if current_value_type == "string" then
return {current_value, value}
elseif current_value_type == "table" then
insert(current_value, value)
return current_value
else
return {value}
end
end
local function is_json_body(content_type)
return content_type and find(lower(content_type), "application/json", nil, true)
end
local function is_body_transform_set(conf)
return #conf.add.json > 0 or #conf.remove.json > 0 or #conf.replace.json > 0 or #conf.append.json > 0
end
-- export utility functions
_M.is_json_body = is_json_body
_M.is_body_transform_set = is_body_transform_set
---
-- # Example:
-- ngx.headers = header_filter.transform_headers(conf, ngx.headers)
-- We run transformations in following order: remove, replace, add, append.
-- @param[type=table] conf Plugin configuration.
-- @param[type=table] ngx_headers Table of headers, that should be `ngx.headers`
-- @return table A table containing the new headers.
function _M.transform_headers(conf, ngx_headers)
-- remove headers
for _, header_name, header_value in iter(conf.remove.headers) do
ngx_headers[header_name] = nil
end
-- replace headers
for _, header_name, header_value in iter(conf.replace.headers) do
if ngx_headers[header_name] ~= nil then
ngx_headers[header_name] = header_value
end
end
-- add headers
for _, header_name, header_value in iter(conf.add.headers) do
if ngx_headers[header_name] == nil then
ngx_headers[header_name] = header_value
end
end
-- append headers
for _, header_name, header_value in iter(conf.append.headers) do
ngx_headers[header_name] = append_value(ngx_headers[header_name], header_value)
end
-- Removing the content-length header because the body is going to change
if is_body_transform_set(conf) and is_json_body(ngx_headers["content-type"]) then
ngx_headers["content-length"] = nil
end
end
return _M
| apache-2.0 |
LegionXI/darkstar | scripts/zones/Bastok_Mines/npcs/Trail_Markings.lua | 7 | 2897 | -----------------------------------
-- Area: Bastok Mines
-- NPC: Trail Markings
-- Dynamis-Bastok Enter
-- @pos 99 1 -67 234
-----------------------------------
package.loaded["scripts/zones/Bastok_Mines/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/dynamis");
require("scripts/zones/Bastok_Mines/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getVar("Dynamis_Status") == 1) then
player:startEvent(0x00CB); -- cs with Cornelia
elseif (player:getVar("DynaBastok_Win") == 1) then
player:startEvent(0x00d7,HYDRA_CORPS_EYEGLASS); -- Win CS
elseif (player:hasKeyItem(VIAL_OF_SHROUDED_SAND)) then
local firstDyna = 0;
local realDay = os.time();
local dynaWaitxDay = player:getVar("dynaWaitxDay");
if (checkFirstDyna(player,2)) then -- First Dyna-Bastok => CS
firstDyna = 1;
end
if (player:getMainLvl() < DYNA_LEVEL_MIN) then
player:messageSpecial(PLAYERS_HAVE_NOT_REACHED_LEVEL,DYNA_LEVEL_MIN);
elseif ((dynaWaitxDay + (BETWEEN_2DYNA_WAIT_TIME * 24 * 60 * 60)) < realDay or player:getVar("DynamisID") == GetServerVariable("[DynaBastok]UniqueID")) then
player:startEvent(0x00c9,2,firstDyna,0,BETWEEN_2DYNA_WAIT_TIME,64,VIAL_OF_SHROUDED_SAND,4236,4237);
else
dayRemaining = math.floor(((dynaWaitxDay + (BETWEEN_2DYNA_WAIT_TIME * 24 * 60 * 60)) - realDay)/3456);
player:messageSpecial(YOU_CANNOT_ENTER_DYNAMIS,dayRemaining,2);
end
else
player:messageSpecial(UNUSUAL_ARRANGEMENT_PEBBLES);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("updateRESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("finishRESULT: %u",option);
if (csid == 0x00CB) then
player:addKeyItem(VIAL_OF_SHROUDED_SAND);
player:messageSpecial(KEYITEM_OBTAINED,VIAL_OF_SHROUDED_SAND);
player:setVar("Dynamis_Status",0);
elseif (csid == 0x00d7) then
player:setVar("DynaBastok_Win",0);
elseif (csid == 0x00c9 and option == 0) then
if (checkFirstDyna(player,2)) then
player:setVar("Dynamis_Status",player:getVar("Dynamis_Status") + 4);
end
player:setPos(116.482,0.994,-72.121,128,0xba);
end
end; | gpl-3.0 |
LegionXI/darkstar | scripts/zones/Lower_Jeuno/npcs/Naruru.lua | 24 | 3874 | -----------------------------------
-- Area: Lower Jeuno
-- NPC: Naruru
-- Starts and Finishes Quests: Cook's Pride
-- @pos -56 0.1 -138 245
-----------------------------------
package.loaded["scripts/zones/Lower_Jeuno/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/shop");
require("scripts/globals/quests");
require("scripts/zones/Lower_Jeuno/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local TheWonderMagicSet = player:getQuestStatus(JEUNO,THE_WONDER_MAGIC_SET);
local CooksPride = player:getQuestStatus(JEUNO,COOK_S_PRIDE);
local TheKindCardian = player:getQuestStatus(JEUNO,THE_KIND_CARDIAN);
local WildcatJeuno = player:getVar("WildcatJeuno");
if (player:getQuestStatus(JEUNO,LURE_OF_THE_WILDCAT_JEUNO) == QUEST_ACCEPTED and player:getMaskBit(WildcatJeuno,13) == false) then
player:startEvent(10053);
elseif (TheWonderMagicSet == QUEST_COMPLETED and CooksPride == QUEST_AVAILABLE) then
if (player:getVar("CooksPrideVar") == 0) then
player:startEvent(0x00BD); -- Start quest "Cook's pride" Long CS
else
player:startEvent(0x00BC); -- Start quest "Cook's pride" Short CS
end
elseif (CooksPride == QUEST_ACCEPTED and player:hasKeyItem(SUPER_SOUP_POT) == false) then
player:startEvent(0x00BA); -- During quest "Cook's pride"
elseif (player:hasKeyItem(SUPER_SOUP_POT) == true) then
player:startEvent(0x00BB); -- Finish quest "Cook's pride"
elseif (CooksPride == QUEST_COMPLETED and TheKindCardian == QUEST_AVAILABLE) then
if (player:getVar("theLostCardianVar") == 0) then
player:startEvent(0x001f); -- During quests "The lost cardian"
else
player:startEvent(0x0047); -- During quests "The lost cardian"
end
elseif (CooksPride == QUEST_COMPLETED and TheKindCardian ~= QUEST_COMPLETED) then
player:startEvent(0x0047); -- During quests "The kind cardien"
elseif (TheKindCardian == QUEST_COMPLETED) then
player:startEvent(0x0048); -- New standard dialog after the quest "The kind cardien"
else
player:startEvent(0x0062); -- 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 == 0x00BD or csid == 0x00BC) and option == 0) then
player:addQuest(JEUNO,COOK_S_PRIDE);
elseif (csid == 0x00BD and option == 1) then
player:setVar("CooksPrideVar",1);
elseif (csid == 0x00BB) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,13446);
else
player:addTitle(MERCY_ERRAND_RUNNER);
player:delKeyItem(SUPER_SOUP_POT);
player:setVar("CooksPrideVar",0);
player:addGil(GIL_RATE*3000);
player:messageSpecial(GIL_OBTAINED,GIL_RATE*3000);
player:addItem(13446);
player:messageSpecial(ITEM_OBTAINED,13446); -- Mythril Ring
player:addFame(JEUNO, 30);
player:completeQuest(JEUNO,COOK_S_PRIDE);
end
elseif (csid == 10053) then
player:setMaskBit(player:getVar("WildcatJeuno"),"WildcatJeuno",13,true);
end
end; | gpl-3.0 |
LegionXI/darkstar | scripts/zones/Windurst_Waters_[S]/npcs/Kristen.lua | 14 | 1054 | -----------------------------------
-- Area: Windurst Waters (S)
-- NPC: Kristen
-- Type: Standard NPC
-- @zone 94
-- @pos 2.195 -2 60.296
--
-- 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(0x0194);
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 |
icyxp/kong | kong/dao/errors.lua | 6 | 1712 | local printable_mt = require "kong.tools.printable"
local setmetatable = setmetatable
local getmetatable = getmetatable
local tostring = tostring
local type = type
local fmt = string.format
local error_mt = {}
function error_mt.__tostring(t)
if t.db_name then
return fmt("[%s error] %s", t.db_name, tostring(t.message))
end
return tostring(t.message)
end
function error_mt.__concat(a, b)
if getmetatable(a) == error_mt then
return tostring(a) .. b
else
return a .. tostring(b)
end
end
local ERRORS = {
unique = "unique",
foreign = "foreign",
schema = "schema",
db = "db"
}
local serializers = {
[ERRORS.unique] = function(tbl)
local ret = {}
for k, v in pairs(tbl) do
ret[k] = "already exists with value '" .. v .. "'"
end
return ret
end,
[ERRORS.foreign] = function(tbl)
local ret = {}
for k, v in pairs(tbl) do
ret[k] = "does not exist with value '" .. v .. "'"
end
return ret
end
}
local function build_error(err_type)
return function(err, db_name)
if err == nil then
return
elseif getmetatable(err) == error_mt then
return err
end
local err_obj = {
db_name = db_name,
[err_type] = true
}
if type(err) == "table" then
if serializers[err_type] ~= nil then
err_obj.tbl = serializers[err_type](err)
else
err_obj.tbl = err
end
end
if err_obj.tbl then
setmetatable(err_obj.tbl, printable_mt)
err_obj.message = tostring(err_obj.tbl)
else
err_obj.message = err
end
return setmetatable(err_obj, error_mt)
end
end
local _M = {}
for _, v in pairs(ERRORS) do
_M[v] = build_error(v)
end
return _M
| apache-2.0 |
ibm2431/darkstar | scripts/globals/items/pukatrice_egg_+1.lua | 11 | 1544 | -----------------------------------------
-- ID: 6275
-- Item: pukatrice_egg_+1
-- Food Effect: 60Min, All Races
-----------------------------------------
-- HP +20
-- MP +20
-- STR +3
-- Fire resistance +21
-- Attack +21% (cap 90)
-- Ranged Attack +21% (cap 90)
-- Subtle Blow +9
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if target:hasStatusEffect(dsp.effect.FOOD) or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) then
result = dsp.msg.basic.IS_FULL
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,3600,6275)
end
function onEffectGain(target,effect)
target:addMod(dsp.mod.HP, 20)
target:addMod(dsp.mod.MP, 20)
target:addMod(dsp.mod.STR, 3)
target:addMod(dsp.mod.FIRERES, 21)
target:addMod(dsp.mod.FOOD_ATTP, 21)
target:addMod(dsp.mod.FOOD_ATT_CAP, 90)
target:addMod(dsp.mod.FOOD_RATTP, 21)
target:addMod(dsp.mod.FOOD_RATT_CAP, 90)
target:addMod(dsp.mod.SUBTLE_BLOW, 9)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.HP, 20)
target:delMod(dsp.mod.MP, 20)
target:delMod(dsp.mod.STR, 3)
target:delMod(dsp.mod.FIRERES, 21)
target:delMod(dsp.mod.FOOD_ATTP, 21)
target:delMod(dsp.mod.FOOD_ATT_CAP, 90)
target:delMod(dsp.mod.FOOD_RATTP, 21)
target:delMod(dsp.mod.FOOD_RATT_CAP, 90)
target:delMod(dsp.mod.SUBTLE_BLOW, 9)
end
| gpl-3.0 |
TheCodingMonster/PeripheralsPlusPlus | lua/xp/enchanting.lua | 4 | 2209 | --[[
Created by Fxz_y
]]
p = peripheral.find("xp")
state = "on"
function printOut()
term.clear()
term.setCursorPos(1,1)
print("Levels: "..levels..".")
print("XP: "..xp..".")
if state == "on" then
print("Collecting XP: On.")
print("Press X to turn off XP collecting.")
elseif state == "off" then
print("Collecting XP: Off.")
print("Press X to turn on XP collecting.")
end
print("Press B to use bottles o' enchanting that are in the first slot.")
print("Press E to enchant an item in the first slot.")
print(" ")
print(" ")
print(" ")
print("Press R to refresh the page.")
end
function enchant()
term.clear()
term.setCursorPos(1,1)
print("What level do you want your enchant to be?")
level = read()
if tonumber(levels) >= tonumber(level) then
p.enchant(tonumber(level))
else
term.clear()
term.setCursorPos(1,1)
print("This turtle doesn't have enough levels to perform the enchant!")
print("You will be redirected in 5 seconds.")
sleep(5)
end
end
if p then
while true do
levels = p.getLevels()
xp = p.getXP()
printOut()
if state == "on"then
p.setAutoCollect(true)
continue = false
repeat
event, char = os.pullEvent()
printOut()
if event == "char" then
if char == "x" then
state = "off"
continue = true
elseif char == "b" then
p.add()
continue = true
elseif char == "e" then
enchant()
continue = true
elseif char == "r" then
continue = true
end
end
until continue
elseif state == "off" then
p.setAutoCollect(false)
continue = false
repeat
event, char = os.pullEvent()
printOut()
if event == "char" then
if char == "x" then
state = "on"
continue = true
elseif char == "b" then
p.add()
continue = true
elseif char == "e" then
enchant()
continue = true
elseif char == "r" then
continue = true
end
end
until continue
end
end
end
| gpl-2.0 |
LegionXI/darkstar | scripts/zones/Apollyon/mobs/Earth_Elemental.lua | 119 | 2740 | -----------------------------------
-- Area: Apollyon SW
-- NPC: elemental
-----------------------------------
package.loaded["scripts/zones/Apollyon/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/limbus");
require("scripts/zones/Apollyon/TextIDs");
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
end;
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
end;
-----------------------------------
-- onMobDespawn
-----------------------------------
function onMobDespawn(mob)
local mobID = mob:getID();
-- print(mobID);
local mobX = mob:getXPos();
local mobY = mob:getYPos();
local mobZ = mob:getZPos();
local elementalday = GetServerVariable("[SW_Apollyon]ElementalTrigger") - 1;
local correctelement=false;
switch (elementalday): caseof {
[0] = function (x)
if (mobID==16932913 or mobID==16932921 or mobID==16932929) then
correctelement=true;
end
end ,
[1] = function (x)
if (mobID==16932912 or mobID==16932920 or mobID==16932928 ) then
correctelement=true;
end
end ,
[2] = function (x)
if (mobID==16932916 or mobID==16932924 or mobID==16932932 ) then
correctelement=true;
end
end ,
[3] = function (x)
if (mobID==16932910 or mobID==16932918 or mobID==16932926 ) then
correctelement=true;
end
end ,
[4] = function (x)
if (mobID==16932914 or mobID==16932922 or mobID==16932930 ) then
correctelement=true;
end
end ,
[5] = function (x)
if (mobID==16932917 or mobID==16932925 or mobID==16932933 ) then
correctelement=true;
end
end ,
[6] = function (x)
if (mobID==16932931 or mobID==16932915 or mobID==16932923 ) then
correctelement=true;
end
end ,
[7] = function (x)
if (mobID==16932911 or mobID==16932919 or mobID==16932927 ) then
correctelement=true;
end
end ,
};
if (correctelement==true and IselementalDayAreDead()==true) then
GetNPCByID(16932864+313):setPos(mobX,mobY,mobZ);
GetNPCByID(16932864+313):setStatus(STATUS_NORMAL);
end
end; | gpl-3.0 |
ibm2431/darkstar | scripts/zones/Southern_San_dOria/npcs/Endracion.lua | 9 | 6588 | -----------------------------------
-- Area: Southern San d'Oria
-- NPC: Endracion
-- !pos -110 1 -34 230
-----------------------------------
local ID = require("scripts/zones/Southern_San_dOria/IDs");
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/missions");
-----------------------------------
function onTrade(player,npc,trade)
local CurrentMission = player:getCurrentMission(SANDORIA);
local OrcishScoutCompleted = player:hasCompletedMission(SANDORIA,dsp.mission.id.sandoria.SMASH_THE_ORCISH_SCOUTS);
local BatHuntCompleted = player:hasCompletedMission(SANDORIA,dsp.mission.id.sandoria.BAT_HUNT);
local TheCSpringCompleted = player:hasCompletedMission(SANDORIA,dsp.mission.id.sandoria.THE_CRYSTAL_SPRING);
local MissionStatus = player:getCharVar("MissionStatus");
local Count = trade:getItemCount();
if (CurrentMission ~= dsp.mission.id.sandoria.NONE) then
if (CurrentMission == dsp.mission.id.sandoria.SMASH_THE_ORCISH_SCOUTS and trade:hasItemQty(16656,1) and Count == 1 and OrcishScoutCompleted == false) then -- Trade Orcish Axe
player:startEvent(1020); -- Finish Mission "Smash the Orcish scouts" (First Time)
elseif (CurrentMission == dsp.mission.id.sandoria.SMASH_THE_ORCISH_SCOUTS and trade:hasItemQty(16656,1) and Count == 1) then -- Trade Orcish Axe
player:startEvent(1002); -- Finish Mission "Smash the Orcish scouts" (Repeat)
elseif (CurrentMission == dsp.mission.id.sandoria.BAT_HUNT and trade:hasItemQty(1112,1) and Count == 1 and BatHuntCompleted == false and MissionStatus == 2) then -- Trade Orcish Mail Scales
player:startEvent(1023); -- Finish Mission "Bat Hunt"
elseif (CurrentMission == dsp.mission.id.sandoria.BAT_HUNT and trade:hasItemQty(891,1) and Count == 1 and BatHuntCompleted == true) then -- Trade Bat Fang
player:startEvent(1003); -- Finish Mission "Bat Hunt" (repeat)
elseif (CurrentMission == dsp.mission.id.sandoria.THE_CRYSTAL_SPRING and trade:hasItemQty(4528,1) and Count == 1 and TheCSpringCompleted == false) then -- Trade Crystal Bass
player:startEvent(1030); -- Dialog During Mission "The Crystal Spring"
elseif (CurrentMission == dsp.mission.id.sandoria.THE_CRYSTAL_SPRING and trade:hasItemQty(4528,1) and Count == 1 and TheCSpringCompleted) then -- Trade Crystal Bass
player:startEvent(1013); -- Finish Mission "The Crystal Spring" (repeat)
else
player:startEvent(1008); -- Wrong Item
end
else
player:startEvent(1010); -- Mission not activated
end
end;
function onTrigger(player,npc)
local PresOfPapsqueCompleted = player:hasCompletedMission(SANDORIA,dsp.mission.id.sandoria.PRESTIGE_OF_THE_PAPSQUE);
if (player:getNation() ~= dsp.nation.SANDORIA) then
player:startEvent(1011); -- for Non-San d'Orians
else
local CurrentMission = player:getCurrentMission(SANDORIA);
local MissionStatus = player:getCharVar("MissionStatus");
local pRank = player:getRank();
local cs, p, offset = getMissionOffset(player,1,CurrentMission,MissionStatus);
if (CurrentMission <= dsp.mission.id.sandoria.THE_SHADOW_LORD and (cs ~= 0 or offset ~= 0 or (CurrentMission == dsp.mission.id.sandoria.SMASH_THE_ORCISH_SCOUTS and offset == 0))) then
if (cs == 0) then
player:showText(npc,ID.text.ORIGINAL_MISSION_OFFSET + offset); -- dialog after accepting mission
else
player:startEvent(cs,p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8]);
end
elseif (pRank == 1 and player:hasCompletedMission(SANDORIA,dsp.mission.id.sandoria.SMASH_THE_ORCISH_SCOUTS) == false) then
player:startEvent(1000); -- Start First Mission "Smash the Orcish scouts"
elseif (player:hasKeyItem(dsp.ki.ANCIENT_SANDORIAN_BOOK)) then
player:startEvent(1035);
elseif (CurrentMission == dsp.mission.id.sandoria.RANPERRE_S_FINAL_REST and player:getCharVar("MissionStatus",4) and tonumber(os.date("%j")) == player:getCharVar("Wait1DayForRanperre_date")) then
player:startEvent(1037);
elseif (CurrentMission == dsp.mission.id.sandoria.RANPERRE_S_FINAL_REST and player:getCharVar("MissionStatus") == 4 and tonumber(os.date("%j")) ~= player:getCharVar("Wait1DayForRanperre_date")) then -- Ready now.
player:startEvent(1039);
elseif (CurrentMission == dsp.mission.id.sandoria.RANPERRE_S_FINAL_REST and player:getCharVar("MissionStatus") == 6) then
player:startEvent(1039);
elseif (CurrentMission == dsp.mission.id.sandoria.RANPERRE_S_FINAL_REST and player:getCharVar("MissionStatus") == 9) then
player:startEvent(1033);
elseif (CurrentMission ~= dsp.mission.id.sandoria.THE_SECRET_WEAPON and pRank == 7 and PresOfPapsqueCompleted == true and getMissionRankPoints(player,19) == 1 and player:getCharVar("SecretWeaponStatus") == 0) then
player:startEvent(61);
elseif (CurrentMission == dsp.mission.id.sandoria.THE_SECRET_WEAPON and player:getCharVar("SecretWeaponStatus") == 3) then
player:startEvent(1043);
elseif ((CurrentMission ~= dsp.mission.id.sandoria.NONE) and not (player:getCharVar("MissionStatus") == 8)) then
player:startEvent(1001); -- Have mission already activated
else
local mission_mask, repeat_mask = getMissionMask(player);
player:startEvent(1009,mission_mask, 0, 0 ,0 ,0 ,repeat_mask); -- Mission List
end
end
end;
function onEventUpdate(player,csid,option)
-- printf("onUpdateCSID: %u",csid);
-- printf("onUpdateOPTION: %u",option);
end;
function onEventFinish(player,csid,option)
-- printf("onFinishCSID: %u",csid);
-- printf("onFinishOPTION: %u",option);
finishMissionTimeline(player,1,csid,option);
if (csid == 1035) then
player:setCharVar("MissionStatus",4);
player:delKeyItem(dsp.ki.ANCIENT_SANDORIAN_BOOK);
player:setCharVar("Wait1DayForRanperre_date", os.date("%j"));
elseif (csid == 1037) then
player:setCharVar("MissionStatus",6);
elseif (csid == 1039) then
player:setCharVar("MissionStatus",7);
player:setCharVar("Wait1DayForRanperre_date",0);
elseif (csid == 1033) then
finishMissionTimeline(player,2,csid,option);
elseif (csid == 61) then
player:setCharVar("SecretWeaponStatus",1);
elseif (csid == 1043) then
finishMissionTimeline(player,2,csid,option);
end
end;
| gpl-3.0 |
Igalia/snabbswitch | src/core/config.lua | 14 | 2514 | -- Use of this source code is governed by the Apache 2.0 license; see COPYING.
-- 'config' is a data structure that describes an app network.
module(..., package.seeall)
local lib = require("core.lib")
-- API: Create a new configuration.
-- Initially there are no apps or links.
function new ()
return {
apps = {}, -- list of {name, class, args}
links = {} -- table with keys like "a.out -> b.in"
}
end
-- API: Add an app to the configuration.
--
-- config.app(c, name, class, arg):
-- c is a config object.
-- name is the name of this app in the network (a string).
-- class is the Lua object with a class:new(arg) method to create the app.
-- arg is the app's configuration (to be passed to new()).
--
-- Example: config.app(c, "nic", Intel82599, {pciaddr = "0000:00:01.00"})
function app (config, name, class, arg)
assert(type(name) == "string", "name must be a string")
assert(type(class) == "table", "class must be a table")
if class.config then
local status, result = pcall(parse_app_arg, arg, class.config)
if status then arg = result
else error("failed to configure '"..name.."': "..result) end
end
config.apps[name] = { class = class, arg = arg}
end
-- API: Add a link to the configuration.
--
-- Example: config.link(c, "nic.tx -> vm.rx")
function link (config, spec)
config.links[canonical_link(spec)] = true
end
-- Given "a.out -> b.in" return "a", "out", "b", "in".
function parse_link (spec)
local fa, fl, ta, tl = spec:gmatch(link_syntax)()
if fa and fl and ta and tl then
return fa, fl, ta, tl
else
error("link parse error: " .. spec)
end
end
link_syntax = [[ *([%w_]+)%.([%w_]+) *-> *([%w_]+)%.([%w_]+) *]]
function format_link (fa, fl, ta, tl)
return ("%s.%s -> %s.%s"):format(fa, fl, ta, tl)
end
function canonical_link (spec)
return format_link(parse_link(spec))
end
-- Parse Lua object for the arg to an app based on config. Arg may be a table
-- or a string encoded Lua object.
function parse_app_arg (arg, config)
if type(arg) == 'string' then arg = lib.load_string(arg) end
return lib.parse(arg, config)
end
function graphviz (c)
local viz = 'digraph config {\n'
local function trim (name) return name:sub(0, 12) end
for linkspec,_ in pairs(c.links) do
local fa, fl, ta, tl = config.parse_link(linkspec)
viz = viz..' '..trim(fa).." -> "..trim(ta)..' [taillabel="'..fl..'" headlabel="'..tl..'"]\n'
end
viz = viz..'}\n'
return viz
end
| apache-2.0 |
Geigerkind/DPSMateTBC | DPSMate_Absorbs/DPSMate_Details_AbsorbsTotal.lua | 1 | 18571 | DPSMate.Modules.DetailsAbsorbsTotal = {}
local g, g2 = nil,nil
local curKey = 1
local db, cbt = {}, 0
local buttons = {}
local ColorTable={}
local _G = getglobal
local tinsert = table.insert
local tremove = table.remove
local strformat = string.format
local toggle = false
local totSumTable = {}
local totMax = 0
local totTime = 0
function DPSMate.Modules.DetailsAbsorbsTotal:UpdateDetails(obj, key)
curKey = key
db, cbt = DPSMate:GetMode(key)
buttons = {}
ColorTable={
{0.95,0.90,0.5},
{0.0,0.9,0.0},
{0.0,0.0,1.0},
{1.0,1.0,0.0},
{1.0,0.0,1.0},
{0.0,1.0,1.0},
{1.0,1.0,1.0},
{0.5,0.0,0.0},
{0.0,0.5,0.0},
{0.0,0.0,0.5},
{0.5,0.5,0.0},
{0.5,0.0,0.5},
{0.0,0.5,0.5},
{0.5,0.5,0.5},
{0.75,0.25,0.25},
{0.25,0.75,0.25},
{0.25,0.25,0.75},
{0.75,0.75,0.25},
{0.75,0.25,0.75},
{0.25,0.75,0.75},
{1.0,0.5,0.0},
{0.0,0.5,1.0},
{1.0,0.0,0.5},
{0.5,1.0,0.0},
{0.5,0.0,1.0},
{0.0,1.0,0.5},
{0.0,0.25,0.5},
{0.25,0,0.5},
{0.5,0.25,0.0},
{0.5,0.0,0.25},
{0.5,0.75,0.0},
{0.5,0.0,0.75},
{0.0,0.75,0.5},
{0.75,0.0,0.5},
}
if not g then
g=DPSMate.Options.graph:CreateGraphLine("ABSORBSTTLineGraph",DPSMate_Details_AbsorbsTotal_DiagramLine,"CENTER","CENTER",0,0,740,220)
g2=DPSMate.Options.graph:CreateStackedGraph("ABSORBSTTStackedGraph",DPSMate_Details_AbsorbsTotal_DiagramLine,"CENTER","CENTER",0,0,850,220)
g2:SetGridColor({0.5,0.5,0.5,0.5})
g2:SetAxisDrawing(true,true)
g2:SetAxisColor({1.0,1.0,1.0,1.0})
g2:SetAutoScale(true)
g2:SetYLabels(true, false)
g2:SetXLabels(true)
g2:Hide()
end
DPSMate_Details_AbsorbsTotal_PlayerList_CB:SetChecked(false)
DPSMate_Details_AbsorbsTotal_PlayerList_CB.act = false
DPSMate_Details_AbsorbsTotal_Title:SetText(DPSMate.L["absorbssum"])
self:LoadTable()
self:LoadLegendButtons()
if toggle then
self:UpdateStackedGraph()
else
self:UpdateLineGraph()
end
DPSMate_Details_AbsorbsTotal:Show()
DPSMate_Details_AbsorbsTotal:SetScale((DPSMateSettings["targetscale"] or 0.58)/UIParent:GetScale())
end
function DPSMate.Modules.DetailsAbsorbsTotal:UpdateLineGraph()
g:ResetData()
g:SetGridColor({0.5,0.5,0.5,0.5})
g:SetAxisDrawing(true,true)
g:SetAxisColor({1.0,1.0,1.0,1.0})
g:SetAutoScale(true)
g:SetYLabels(true, false)
g:SetXLabels(true)
g2:Hide()
DPSMate_Details_AbsorbsTotal_DiagramLine:SetWidth(770)
DPSMate_Details_AbsorbsTotal_DiagramLegend:Show()
g:Show()
toggle=false
self:AddTotalDataSeries()
local Max = totMax
for cat, val in pairs(buttons) do
g:AddDataSeries(val[3], {val[1], {}}, {})
local temp = DPSMate:GetMaxValue(val[3], 2)
if temp>Max then
Max = temp
end
end
g:SetGridSpacing(totTime/10,Max/7)
end
function DPSMate.Modules.DetailsAbsorbsTotal:UpdateStackedGraph()
g:Hide()
DPSMate_Details_AbsorbsTotal_DiagramLine:SetWidth(870)
DPSMate_Details_AbsorbsTotal_DiagramLegend:Hide()
local Data1 = {}
local label = {}
local maxX, maxY = 0,0
local p = {}
for cat, val in pairs(db) do
for qq, uu in pairs(val) do
local temp = {}
local ownername = DPSMate:GetUserById(qq)
if DPSMate:ApplyFilter(curKey, ownername) then
for ca, va in pairs(uu["i"]) do
local i, dmg = 1, 5
if DPSMateDamageTaken[1][cat] then
if DPSMateDamageTaken[1][cat][va[2]] then
if DPSMateDamageTaken[1][cat][va[2]][va[3]] then
dmg = DPSMateDamageTaken[1][cat][va[2]][va[3]][14]
if dmg>DPSMate.DB.FixedShieldAmounts[DPSMate:GetAbilityById(va[5])] then
dmg = DPSMate.DB.FixedShieldAmounts[DPSMate:GetAbilityById(va[5])]
end
end
end
end
if dmg==5 or dmg==0 then
dmg = ceil((1/15)*((DPSMateUser[ownername][8] or 70)/70)*DPSMate.DB.FixedShieldAmounts[DPSMate:GetAbilityById(va[5])]*0.33)
end
if va[4] then
dmg = dmg + va[4]
end
if dmg>0 then
local i = 1
while true do
if not temp[i] then
tinsert(temp, i, {va[1], dmg})
break
elseif va[1]<=temp[i][1] then
tinsert(temp, i, {va[1], dmg})
break
end
i=i+1
end
end
end
tinsert(label, 1, ownername)
tinsert(Data1, 1, temp)
end
end
end
for cat, val in pairs(p) do
if maxY<val then
maxY = val
end
end
g2:ResetData()
g2:SetGridSpacing(maxX/7,(maxY/2)/14)
g2:AddDataSeries(Data1,{1.0,0.0,0.0,0.8}, {}, label)
g2:Show()
toggle=true
end
function DPSMate.Modules.DetailsAbsorbsTotal:ToggleMode()
if toggle then
self:UpdateLineGraph()
toggle=false
else
self:UpdateStackedGraph()
toggle=true
end
end
function DPSMate.Modules.DetailsAbsorbsTotal:GetSummarizedTable(arr)
return DPSMate.Sync:GetSummarizedTable(arr)
end
function DPSMate.Modules.DetailsAbsorbsTotal:CreateGraphTable()
local lines = {}
for i=1, 8 do
-- Horizontal
lines[i] = DPSMate.Options.graph:DrawLine(DPSMate_Details_AbsorbsTotal_PlayerList, 10, 270-i*30, 860, 270-i*30, 20, {0.5,0.5,0.5,0.5}, "BACKGROUND")
lines[i]:Show()
end
-- Vertical
lines[9] = DPSMate.Options.graph:DrawLine(DPSMate_Details_AbsorbsTotal_PlayerList, 40, 260, 40, 10, 20, {0.5,0.5,0.5,0.5}, "BACKGROUND")
lines[9]:Show()
lines[10] = DPSMate.Options.graph:DrawLine(DPSMate_Details_AbsorbsTotal_PlayerList, 170, 260, 170, 10, 20, {0.5,0.5,0.5,0.5}, "BACKGROUND")
lines[10]:Show()
lines[11] = DPSMate.Options.graph:DrawLine(DPSMate_Details_AbsorbsTotal_PlayerList, 510, 260, 510, 10, 20, {0.5,0.5,0.5,0.5}, "BACKGROUND")
lines[11]:Show()
lines[12] = DPSMate.Options.graph:DrawLine(DPSMate_Details_AbsorbsTotal_PlayerList, 570, 260, 570, 10, 20, {0.5,0.5,0.5,0.5}, "BACKGROUND")
lines[12]:Show()
lines[13] = DPSMate.Options.graph:DrawLine(DPSMate_Details_AbsorbsTotal_PlayerList, 630, 260, 630, 10, 20, {0.5,0.5,0.5,0.5}, "BACKGROUND")
lines[13]:Show()
lines[14] = DPSMate.Options.graph:DrawLine(DPSMate_Details_AbsorbsTotal_PlayerList, 690, 260, 690, 10, 20, {0.5,0.5,0.5,0.5}, "BACKGROUND")
lines[14]:Show()
lines[15] = DPSMate.Options.graph:DrawLine(DPSMate_Details_AbsorbsTotal_PlayerList, 750, 260, 750, 10, 20, {0.5,0.5,0.5,0.5}, "BACKGROUND")
lines[15]:Show()
lines[16] = DPSMate.Options.graph:DrawLine(DPSMate_Details_AbsorbsTotal_PlayerList, 810, 260, 810, 10, 20, {0.5,0.5,0.5,0.5}, "BACKGROUND")
lines[16]:Show()
end
function DPSMate.Modules.DetailsAbsorbsTotal:AddTotalDataSeries()
local sumTable, newArr = {[0]=0}, {}
local temp = {}
for cat, val in pairs(db) do
for qq, uu in pairs(val) do
local ownername = DPSMate:GetUserById(qq)
if DPSMate:ApplyFilter(curKey, ownername) then
temp[ownername] = true
for ca, va in pairs(uu["i"]) do
local i, dmg = 1, 5
if DPSMateDamageTaken[1][cat] then
if DPSMateDamageTaken[1][cat][va[2]] then
if DPSMateDamageTaken[1][cat][va[2]][va[3]] then
dmg = DPSMateDamageTaken[1][cat][va[2]][va[3]][14]
if dmg>DPSMate.DB.FixedShieldAmounts[DPSMate:GetAbilityById(va[5])] then
dmg = DPSMate.DB.FixedShieldAmounts[DPSMate:GetAbilityById(va[5])]
end
end
end
end
if dmg==5 or dmg==0 then
dmg = ceil((1/15)*((DPSMateUser[ownername][8] or 70)/70)*DPSMate.DB.FixedShieldAmounts[DPSMate:GetAbilityById(va[5])]*0.33)
end
if va[4] then
dmg = dmg + va[4]
end
if dmg>0 then
if sumTable[va[1]] then
sumTable[va[1]] = sumTable[va[1]] + dmg
else
sumTable[va[1]] = dmg
end
end
end
end
end
end
local tl = DPSMate:TableLength(temp)
tl = ceil(tl-0.3*tl)
temp = nil
for cat, val in pairs(sumTable) do
local i=1
while true do
if (not newArr[i]) then
tinsert(newArr, i, {cat, val/tl})
break
end
if cat<newArr[i][1] then
tinsert(newArr, i, {cat, val/tl})
break
end
i=i+1
end
end
totSumTable = self:GetSummarizedTable(newArr)
totMax = DPSMate:GetMaxValue(totSumTable, 2)
totTime = DPSMate:GetMaxValue(totSumTable, 1)
g:SetXAxis(0,totTime)
g:SetYAxis(0,totMax)
g:SetGridSpacing(totTime/10,totMax/7)
g:AddDataSeries(totSumTable,{{1.0,0.0,0.0,0.8}, {1.0,1.0,0.0,0.8}}, {})
end
function DPSMate.Modules.DetailsAbsorbsTotal:GetTableValues()
local arr, total = {}, 0
local temp = {}
for cat, val in pairs(db) do -- 28 Target
local PerPlayerAbsorb = 0
local totHits = 0
for ca, va in pairs(val) do -- 28 Owner
local ownername = DPSMate:GetUserById(ca)
if DPSMate:ApplyFilter(curKey, ownername) then
local PerOwnerAbsorb = 0
local abAbsorb = {}
for c, v in pairs(va) do -- Power Word: Shield
if c~="i" then
local shieldname = DPSMate:GetAbilityById(c)
local PerAbilityAbsorb = 0
for ce, ve in pairs(v) do -- 1
local PerShieldAbsorb = 0
for cet, vel in pairs(ve) do
if cet~="i" then
local totalHits = 0
for qq,ss in pairs(vel) do
totalHits = totalHits + ss
end
for qq,ss in pairs(vel) do
local p = 5
if DPSMateDamageTaken[1][cat] then
if DPSMateDamageTaken[1][cat][cet] then
if DPSMateDamageTaken[1][cat][cet][qq] then
if DPSMateDamageTaken[1][cat][cet][qq][14]~=0 then
p=ceil(DPSMateDamageTaken[1][cat][cet][qq][14])
end
end
end
elseif DPSMateEDT[1][cat] then
if DPSMateEDT[1][cat][cet] then
if DPSMateEDT[1][cat][cet][qq] then
if DPSMateEDT[1][cat][cet][qq][4]~=0 then
p=ceil((DPSMateEDT[1][cat][cet][qq][4]+DPSMateEDT[1][cat][cet][qq][8])/2)
end
end
end
end
if p>DPSMate.DB.FixedShieldAmounts[shieldname] then
p = DPSMate.DB.FixedShieldAmounts[shieldname]
end
if p==5 or p==0 then
p = ceil((1/totalHits)*((DPSMateUser[ownername][8] or 70)/70)*DPSMate.DB.FixedShieldAmounts[shieldname]*0.33)
end
PerShieldAbsorb=PerShieldAbsorb+ss*p
end
totHits = totHits + totalHits
end
end
if ve["i"][1]==1 then
PerShieldAbsorb=PerShieldAbsorb+ve["i"][2]
end
PerAbilityAbsorb = PerAbilityAbsorb+PerShieldAbsorb
end
PerOwnerAbsorb = PerOwnerAbsorb+PerAbilityAbsorb
if abAbsorb[DPSMate.DB.ShieldFlags[shieldname] or 0] then
abAbsorb[DPSMate.DB.ShieldFlags[shieldname] or 0] = abAbsorb[DPSMate.DB.ShieldFlags[shieldname] or 0] + PerAbilityAbsorb
else
abAbsorb[DPSMate.DB.ShieldFlags[shieldname] or 0] = PerAbilityAbsorb
end
end
end
PerPlayerAbsorb = PerPlayerAbsorb+PerOwnerAbsorb
if temp[ownername] then
temp[ownername][2] = temp[ownername][2] + PerOwnerAbsorb
temp[ownername][3] = temp[ownername][3] + ((abAbsorb[0] or 0)+(abAbsorb[1] or 0))
temp[ownername][4] = temp[ownername][4] + (abAbsorb[3] or 0)
temp[ownername][5] = temp[ownername][5] + (abAbsorb[2] or 0)
temp[ownername][6] = temp[ownername][6] + (abAbsorb[4] or 0)
temp[ownername][7] = temp[ownername][7] + (abAbsorb[5] or 0)
temp[ownername][8] = temp[ownername][8] + (abAbsorb[6] or 0)
temp[ownername][9] = temp[ownername][9] + (abAbsorb[7] or 0)
else
temp[ownername] = {ownername, PerOwnerAbsorb, (abAbsorb[0] or 0)+(abAbsorb[1] or 0), abAbsorb[3] or 0, abAbsorb[2] or 0, abAbsorb[4] or 0, abAbsorb[5] or 0, abAbsorb[6] or 0, abAbsorb[7] or 0}
end
end
end
end
for ca, va in pairs(temp) do
if va then
tinsert(arr, va)
total = total + va[2]
end
end
temp = nil
local newArr = {}
for cat, val in pairs(arr) do
local i = 1
while true do
if (not newArr[i]) then
tinsert(newArr, i, val)
break
else
if newArr[i][2] < val[2] then
tinsert(newArr, i, val)
break
end
end
i=i+1
end
end
return newArr, total
end
function DPSMate.Modules.DetailsAbsorbsTotal:CheckButtonCheckAll(obj)
if obj.act then
obj.act = false
for i=1, 30 do
local ob = _G("DPSMate_Details_AbsorbsTotal_PlayerList_Child_R"..i)
if ob.user then
self:RemoveLinesButton(ob.user, ob)
_G("DPSMate_Details_AbsorbsTotal_PlayerList_Child_R"..i.."_CB"):SetChecked(obj.act)
end
end
else
obj.act = true
for i=1, 30 do
local ob = _G("DPSMate_Details_AbsorbsTotal_PlayerList_Child_R"..i)
if ob.user then
self:RemoveLinesButton(ob.user, ob)
self:AddLinesButton(ob.user, ob)
_G("DPSMate_Details_AbsorbsTotal_PlayerList_Child_R"..i.."_CB"):SetChecked(obj.act)
end
end
end
end
function DPSMate.Modules.DetailsAbsorbsTotal:SortLineTable(uid)
local newArr = {}
local ownername = DPSMate:GetUserById(uid)
for cat, val in pairs(db) do
if val[uid] then
for ca, va in pairs(val[uid]["i"]) do
local i, dmg = 1, 5
if DPSMateDamageTaken[1][cat] then
if DPSMateDamageTaken[1][cat][va[2]] then
if DPSMateDamageTaken[1][cat][va[2]][va[3]] then
dmg = DPSMateDamageTaken[1][cat][va[2]][va[3]][14]
if dmg>DPSMate.DB.FixedShieldAmounts[DPSMate:GetAbilityById(va[5])] then
dmg = DPSMate.DB.FixedShieldAmounts[DPSMate:GetAbilityById(va[5])]
end
end
end
end
if dmg==5 or dmg==0 then
dmg = ceil((1/15)*((DPSMateUser[ownername][8] or 70)/70)*DPSMate.DB.FixedShieldAmounts[DPSMate:GetAbilityById(va[5])]*0.33)
end
if va[4] then
dmg = dmg + va[4]
end
if dmg>0 then
while true do
if (not newArr[i]) then
tinsert(newArr, i, {va[1], dmg})
break
else
if newArr[i][1] > va[1] then
tinsert(newArr, i, {va[1], dmg})
break
end
end
i=i+1
end
end
end
end
end
return newArr
end
function DPSMate.Modules.DetailsAbsorbsTotal:AddLinesButton(uid, obj)
local sumTable = self:SortLineTable(uid)
sumTable = self:GetSummarizedTable(sumTable)
local Max = DPSMate:GetMaxValue(sumTable, 2)
if Max > totMax then
g:SetGridSpacing(totTime/10,Max/7)
end
g:AddDataSeries(sumTable, {ColorTable[1], {}}, {})
tinsert(buttons, {ColorTable[1], uid, sumTable})
tremove(ColorTable, 1)
g2:Hide()
DPSMate_Details_AbsorbsTotal_DiagramLine:SetWidth(770)
DPSMate_Details_AbsorbsTotal_DiagramLegend:Show()
g:Show()
toggle=false
obj.act = true
self:LoadLegendButtons()
end
function DPSMate.Modules.DetailsAbsorbsTotal:RemoveLinesButton(uid, obj)
obj.act = false
g:ResetData()
for cat, val in pairs(buttons) do
if val[2]==uid then
tinsert(ColorTable, 1, val[1])
tremove(buttons, cat)
break
end
end
local Max = totMax
g:AddDataSeries(totSumTable,{{1.0,0.0,0.0,0.8}, {1.0,1.0,0.0,0.8}}, {})
for cat, val in pairs(buttons) do
g:AddDataSeries(val[3], {val[1], {}}, {})
local temp = DPSMate:GetMaxValue(val[3], 2)
if temp>Max then
Max = temp
end
end
g:SetGridSpacing(totTime/10,Max/7)
g2:Hide()
DPSMate_Details_AbsorbsTotal_DiagramLine:SetWidth(770)
DPSMate_Details_AbsorbsTotal_DiagramLegend:Show()
g:Show()
toggle = false
self:LoadLegendButtons()
end
function DPSMate.Modules.DetailsAbsorbsTotal:LoadLegendButtons()
for i=1, 30 do
_G("DPSMate_Details_AbsorbsTotal_DiagramLegend_Child_C"..i):Hide()
end
for cat, val in pairs(buttons) do
local font = _G("DPSMate_Details_AbsorbsTotal_DiagramLegend_Child_C"..cat.."_Font")
font:SetText(val[2])
font:SetTextColor(DPSMate:GetClassColor(val[2]))
_G("DPSMate_Details_AbsorbsTotal_DiagramLegend_Child_C"..cat.."_SwatchBg"):SetTexture(val[1][1],val[1][2],val[1][3],1)
_G("DPSMate_Details_AbsorbsTotal_DiagramLegend_Child_C"..cat):Show()
end
end
function DPSMate.Modules.DetailsAbsorbsTotal:RoundToH(val)
if val>100 then
return 100
end
return val
end
function DPSMate.Modules.DetailsAbsorbsTotal:CompareVal(x,y)
if x>y then
return y
end
return x
end
function DPSMate.Modules.DetailsAbsorbsTotal:LoadTable()
local arr, total = self:GetTableValues()
local i = 0
for i=1, 30 do
_G("DPSMate_Details_AbsorbsTotal_PlayerList_Child_R"..i):Hide()
_G("DPSMate_Details_AbsorbsTotal_PlayerList_Child_R"..i.."_CB"):SetChecked(false)
_G("DPSMate_Details_AbsorbsTotal_PlayerList_Child_R"..i.."_CB").act = false
end
for cat, val in pairs(arr) do
if DPSMateUser[val[1]][4] then
i=i+1
else
if (cat-i)>30 then break end
local r,g,b = DPSMate:GetClassColor(DPSMateUser[val[1]][2])
_G("DPSMate_Details_AbsorbsTotal_PlayerList_Child"):SetHeight((cat-i)*30)
_G("DPSMate_Details_AbsorbsTotal_PlayerList_Child_R"..(cat-i).."_Name"):SetText(val[1])
_G("DPSMate_Details_AbsorbsTotal_PlayerList_Child_R"..(cat-i).."_Name"):SetTextColor(r,g,b)
_G("DPSMate_Details_AbsorbsTotal_PlayerList_Child_R"..(cat-i).."_Amount"):SetText(val[2])
_G("DPSMate_Details_AbsorbsTotal_PlayerList_Child_R"..(cat-i).."_StatusBar"):SetValue(100*val[2]/arr[1][2])
_G("DPSMate_Details_AbsorbsTotal_PlayerList_Child_R"..(cat-i).."_StatusBar"):SetStatusBarColor(r,g,b, 1)
_G("DPSMate_Details_AbsorbsTotal_PlayerList_Child_R"..(cat-i).."_AmountPerc"):SetText(strformat("%.1f", 100*val[2]/total).."%")
_G("DPSMate_Details_AbsorbsTotal_PlayerList_Child_R"..(cat-i).."_All"):SetText(strformat("%.1f", 100*val[3]/val[2]).."%")
_G("DPSMate_Details_AbsorbsTotal_PlayerList_Child_R"..(cat-i).."_FIR"):SetText(strformat("%.1f", 100*val[4]/val[2]).."%")
_G("DPSMate_Details_AbsorbsTotal_PlayerList_Child_R"..(cat-i).."_FRR"):SetText(strformat("%.1f", 100*val[5]/val[2]).."%")
_G("DPSMate_Details_AbsorbsTotal_PlayerList_Child_R"..(cat-i).."_NAR"):SetText(strformat("%.1f", 100*val[6]/val[2]).."%")
_G("DPSMate_Details_AbsorbsTotal_PlayerList_Child_R"..(cat-i).."_SHR"):SetText(strformat("%.1f", 100*val[7]/val[2]).."%")
_G("DPSMate_Details_AbsorbsTotal_PlayerList_Child_R"..(cat-i).."_ARR"):SetText(strformat("%.1f", 100*val[8]/val[2]).."%")
_G("DPSMate_Details_AbsorbsTotal_PlayerList_Child_R"..(cat-i)).user = val[1]
_G("DPSMate_Details_AbsorbsTotal_PlayerList_Child_R"..(cat-i)):Show()
end
end
end
function DPSMate.Modules.DetailsAbsorbsTotal:ShowTooltip(user, obj)
local a,b,c = DPSMate.Modules.Absorbs:EvalTable(DPSMateUser[user], curKey)
local pet = ""
GameTooltip:SetOwner(obj, "TOPLEFT")
GameTooltip:AddLine(user.."'s "..strlower(DPSMate.L["absorbeddmg"]), 1,1,1)
for i=1, DPSMateSettings["subviewrows"] do
if not a[i] then break end
GameTooltip:AddDoubleLine(i..". "..DPSMate:GetUserById(a[i]),c[i][1].." ("..strformat("%2.f", 100*c[i][1]/b).."%)",1,1,1,1,1,1)
for p=1, 3 do
if not c[i][2][p] then break end
GameTooltip:AddDoubleLine(" "..p..". "..DPSMate:GetAbilityById(c[i][2][p]),c[i][3][p][1].." ("..strformat("%.2f", 100*c[i][3][p][1]/c[i][1]).."%)",0.5,0.5,0.5,0.5,0.5,0.5)
end
end
GameTooltip:Show()
end
| gpl-3.0 |
mahdikord/mahdibk9 | plugins/twitter_send.lua | 627 | 1555 | do
local OAuth = require "OAuth"
local consumer_key = ""
local consumer_secret = ""
local access_token = ""
local access_token_secret = ""
local client = OAuth.new(consumer_key, consumer_secret, {
RequestToken = "https://api.twitter.com/oauth/request_token",
AuthorizeUser = {"https://api.twitter.com/oauth/authorize", method = "GET"},
AccessToken = "https://api.twitter.com/oauth/access_token"
}, {
OAuthToken = access_token,
OAuthTokenSecret = access_token_secret
})
function run(msg, matches)
if consumer_key:isempty() then
return "Twitter Consumer Key is empty, write it in plugins/twitter_send.lua"
end
if consumer_secret:isempty() then
return "Twitter Consumer Secret is empty, write it in plugins/twitter_send.lua"
end
if access_token:isempty() then
return "Twitter Access Token is empty, write it in plugins/twitter_send.lua"
end
if access_token_secret:isempty() then
return "Twitter Access Token Secret is empty, write it in plugins/twitter_send.lua"
end
if not is_sudo(msg) then
return "You aren't allowed to send tweets"
end
local response_code, response_headers, response_status_line, response_body =
client:PerformRequest("POST", "https://api.twitter.com/1.1/statuses/update.json", {
status = matches[1]
})
if response_code ~= 200 then
return "Error: "..response_code
end
return "Tweet sent"
end
return {
description = "Sends a tweet",
usage = "!tw [text]: Sends the Tweet with the configured account.",
patterns = {"^!tw (.+)"},
run = run
}
end
| gpl-2.0 |
rigeirani/btg | plugins/twitter_send.lua | 627 | 1555 | do
local OAuth = require "OAuth"
local consumer_key = ""
local consumer_secret = ""
local access_token = ""
local access_token_secret = ""
local client = OAuth.new(consumer_key, consumer_secret, {
RequestToken = "https://api.twitter.com/oauth/request_token",
AuthorizeUser = {"https://api.twitter.com/oauth/authorize", method = "GET"},
AccessToken = "https://api.twitter.com/oauth/access_token"
}, {
OAuthToken = access_token,
OAuthTokenSecret = access_token_secret
})
function run(msg, matches)
if consumer_key:isempty() then
return "Twitter Consumer Key is empty, write it in plugins/twitter_send.lua"
end
if consumer_secret:isempty() then
return "Twitter Consumer Secret is empty, write it in plugins/twitter_send.lua"
end
if access_token:isempty() then
return "Twitter Access Token is empty, write it in plugins/twitter_send.lua"
end
if access_token_secret:isempty() then
return "Twitter Access Token Secret is empty, write it in plugins/twitter_send.lua"
end
if not is_sudo(msg) then
return "You aren't allowed to send tweets"
end
local response_code, response_headers, response_status_line, response_body =
client:PerformRequest("POST", "https://api.twitter.com/1.1/statuses/update.json", {
status = matches[1]
})
if response_code ~= 200 then
return "Error: "..response_code
end
return "Tweet sent"
end
return {
description = "Sends a tweet",
usage = "!tw [text]: Sends the Tweet with the configured account.",
patterns = {"^!tw (.+)"},
run = run
}
end
| gpl-2.0 |
ibm2431/darkstar | scripts/globals/abilities/pets/armor_shatterer.lua | 14 | 1298 | ---------------------------------------------------
-- Armor Shatterer
---------------------------------------------------
require("scripts/globals/status")
require("scripts/globals/settings")
require("scripts/globals/automatonweaponskills")
---------------------------------------------------
function onMobSkillCheck(target, automaton, skill)
local master = automaton:getMaster()
return master:countEffect(dsp.effect.WIND_MANEUVER)
end
function onPetAbility(target, automaton, skill, master, action)
local params = {
numHits = 2,
atkmulti = 2.25,
accBonus = 50,
ftp100 = 6.0,
ftp200 = 6.0,
ftp300 = 6.0,
acc100 = 0.0,
acc200 = 0.0,
acc300 = 0.0,
str_wsc = 0.0,
dex_wsc = 0.5,
vit_wsc = 0.0,
agi_wsc = 0.0,
int_wsc = 0.0,
mnd_wsc = 0.0,
chr_wsc = 0.0
}
local damage = doAutoRangedWeaponskill(automaton, target, 0, params, skill:getTP(), true, skill, action)
if damage > 0 then
local bonusduration = 1 + 0.00033 * (skill:getTP() - 1000)
if not target:hasStatusEffect(dsp.effect.DEFENSE_DOWN) then
target:addStatusEffect(dsp.effect.DEFENSE_DOWN, 15, 0, 90*bonusduration)
end
end
return damage
end
| gpl-3.0 |
ibm2431/darkstar | scripts/zones/Apollyon/npcs/Armoury_Crate.lua | 10 | 22694 | -----------------------------------
-- Area: Apollyon
-- NPC: Armoury Crate
-----------------------------------
require("scripts/globals/titles")
require("scripts/globals/quests")
require("scripts/globals/limbus")
-----------------------------------
local loot =
{
-- SE_Apollyon floor 1
[110] =
{
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1939, droprate = 350},
{itemid = 1941, droprate = 278},
{itemid = 1959, droprate = 174},
{itemid = 1949, droprate = 200},
},
{
{itemid = 1945, droprate = 47},
{itemid = 1951, droprate = 49},
{itemid = 1955, droprate = 200},
{itemid = 2659, droprate = 62},
{itemid = 2715, droprate = 407},
},
},
-- SE_Apollyon floor 2
[111] =
{
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1959, droprate = 47},
{itemid = 1949, droprate = 30},
{itemid = 1943, droprate = 200},
{itemid = 1947, droprate = 460},
{itemid = 2661, droprate = 400},
},
{
{itemid = 1951, droprate = 20},
{itemid = 1955, droprate = 80},
{itemid = 1945, droprate = 90},
{itemid = 2659, droprate = 100},
{itemid = 2715, droprate = 120},
},
},
-- SE_Apollyon floor 3
[112] =
{
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1955, droprate = 59},
{itemid = 1959, droprate = 139},
{itemid = 1949, droprate = 39},
{itemid = 1681, droprate = 39},
{itemid = 645, droprate = 39},
{itemid = 1933, droprate = 627},
},
{
{itemid = 1945, droprate = 159},
{itemid = 1951, droprate = 139},
{itemid = 2659, droprate = 39},
{itemid = 664, droprate = 20},
{itemid = 646, droprate = 20},
{itemid = 1931, droprate = 200},
},
},
-- SE_Apollyon floor 4
[113] =
{
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1935, droprate = 220},
{itemid = 1937, droprate = 300},
{itemid = 1957, droprate = 260},
{itemid = 1953, droprate = 340},
},
{
{itemid = 2657, droprate = 220},
{itemid = 2717, droprate = 180},
{itemid = 1931, droprate = 300},
},
{
{itemid = 1909, droprate = 1000},
},
{
{itemid = 2127, droprate = 59},
{itemid = 1875, droprate = 100},
},
},
-- NE_Apollyon floor 1
[114] =
{
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1953, droprate = 304},
{itemid = 1943, droprate = 18},
{itemid = 1941, droprate = 200},
{itemid = 2715, droprate = 200},
{itemid = 2661, droprate = 36},
},
{
{itemid = 1933, droprate = 18},
{itemid = 1939, droprate = 36},
{itemid = 1935, droprate = 411},
{itemid = 2717, droprate = 482},
{itemid = 1947, droprate = 18},
},
},
-- NE_Apollyon floor 2
[115] =
{
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1947, droprate = 26},
{itemid = 1933, droprate = 53},
{itemid = 1943, droprate = 26},
{itemid = 2661, droprate = 26},
{itemid = 1937, droprate = 395},
},
{
{itemid = 1957, droprate = 289},
{itemid = 1941, droprate = 53},
{itemid = 1939, droprate = 112},
{itemid = 2657, droprate = 477},
},
},
-- NE_Apollyon floor 3
[116] =
{
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1931, droprate = 788},
{itemid = 1939, droprate = 30},
{itemid = 1953, droprate = 130},
{itemid = 1957, droprate = 100},
{itemid = 1947, droprate = 90},
},
{
{itemid = 1933, droprate = 30},
{itemid = 1941, droprate = 99},
{itemid = 2661, droprate = 61},
{itemid = 2715, droprate = 30},
{itemid = 1943, droprate = 160},
},
{
{itemid = 1633, droprate = 30},
{itemid = 821, droprate = 40},
},
{
{itemid = 1311, droprate = 50},
{itemid = 1883, droprate = 40},
{itemid = 2004, droprate = 20},
},
},
-- NE_Apollyon floor 4
[117] =
{
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1949, droprate = 326},
{itemid = 1945, droprate = 256},
{itemid = 1951, droprate = 395},
},
{
{itemid = 1959, droprate = 279},
{itemid = 1955, droprate = 256},
{itemid = 2659, droprate = 326},
},
},
-- NE_Apollyon floor 5
[118] =
{
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 100},
{itemid = 2127, droprate = 59},
},
{
{itemid = 1910, droprate = 1000},
},
},
-- SW_Apollyon floor 1
[119] =
{
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1949, droprate = 464},
{itemid = 1945, droprate = 250},
{itemid = 1953, droprate = 110},
{itemid = 1937, droprate = 71},
},
{
{itemid = 1931, droprate = 180},
{itemid = 2657, droprate = 210},
{itemid = 2717, droprate = 111},
{itemid = 1935, droprate = 107},
},
},
-- SW_Apollyon floor 2
[120] =
{
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1951, droprate = 154},
{itemid = 1935, droprate = 95},
{itemid = 1959, droprate = 269},
},
{
{itemid = 1937, droprate = 106},
{itemid = 1931, droprate = 77},
{itemid = 2659, droprate = 423},
{itemid = 1957, droprate = 110},
},
},
-- SW_Apollyon floor 3
[121] =
{
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1955, droprate = 595},
{itemid = 1957, droprate = 100},
{itemid = 1937, droprate = 24},
{itemid = 1953, droprate = 48},
},
{
{itemid = 1931, droprate = 120},
{itemid = 1953, droprate = 48},
{itemid = 1935, droprate = 24},
{itemid = 2657, droprate = 24},
{itemid = 2717, droprate = 71},
},
{
{itemid = 1311, droprate = 32},
{itemid = 1883, droprate = 40},
{itemid = 1681, droprate = 31},
{itemid = 1633, droprate = 71},
{itemid = 645, droprate = 31},
{itemid = 664, droprate = 63},
{itemid = 646, droprate = 31},
{itemid = 821, droprate = 63},
},
},
-- SW_Apollyon floor 4
[122] =
{
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1941, droprate = 468},
{itemid = 1947, droprate = 340},
{itemid = 1933, droprate = 255},
{itemid = 1939, droprate = 191},
},
{
{itemid = 1943, droprate = 170},
{itemid = 2661, droprate = 340},
{itemid = 2715, droprate = 170},
},
{
{itemid = 1987, droprate = 1000},
},
{
{itemid = 2127, droprate = 59},
{itemid = 1875, droprate = 100},
},
},
-- NW_Apollyon floor 1
[123] =
{
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1937, droprate = 25},
{itemid = 2657, droprate = 175},
{itemid = 1957, droprate = 100},
{itemid = 1943, droprate = 25},
{itemid = 1953, droprate = 250},
{itemid = 2717, droprate = 75},
{itemid = 1931, droprate = 225},
{itemid = 1935, droprate = 50},
},
},
-- NW_Apollyon floor 2
[124] =
{
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1943, droprate = 235},
{itemid = 2659, droprate = 59},
{itemid = 1945, droprate = 235},
{itemid = 1955, droprate = 147},
{itemid = 1951, droprate = 118},
{itemid = 1959, droprate = 176},
{itemid = 1935, droprate = 110},
},
},
-- NW_Apollyon floor 3
[125] =
{
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1947, droprate = 133},
{itemid = 1933, droprate = 133},
{itemid = 1943, droprate = 133},
{itemid = 2661, droprate = 133},
{itemid = 1939, droprate = 110},
{itemid = 1941, droprate = 400},
},
{
{itemid = 646, droprate = 50},
{itemid = 1633, droprate = 50},
{itemid = 664, droprate = 50},
{itemid = 645, droprate = 50},
{itemid = 1311, droprate = 50},
{itemid = 1681, droprate = 50},
{itemid = 821, droprate = 50},
{itemid = 1883, droprate = 50},
},
},
-- NW_Apollyon floor 4
[126] =
{
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1937, droprate = 80},
{itemid = 2657, droprate = 70},
{itemid = 1949, droprate = 48},
{itemid = 1947, droprate = 30},
{itemid = 2659, droprate = 25},
{itemid = 1957, droprate = 19},
{itemid = 1945, droprate = 48},
{itemid = 1933, droprate = 90},
{itemid = 1955, droprate = 00},
{itemid = 2661, droprate = 48},
{itemid = 1939, droprate = 136},
{itemid = 1951, droprate = 80},
{itemid = 1953, droprate = 110},
{itemid = 1959, droprate = 95},
{itemid = 2715, droprate = 123},
{itemid = 1935, droprate = 48},
},
},
-- NW_Apollyon floor 5
[127] =
{
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1937, droprate = 109},
{itemid = 2657, droprate = 152},
{itemid = 1949, droprate = 283},
{itemid = 1947, droprate = 109},
{itemid = 2659, droprate = 65},
{itemid = 2715, droprate = 130},
},
{
{itemid = 1957, droprate = 65},
{itemid = 1945, droprate = 174},
{itemid = 1933, droprate = 130},
{itemid = 1955, droprate = 196},
{itemid = 1943, droprate = 174},
{itemid = 2661, droprate = 174},
{itemid = 1939, droprate = 109},
},
{
{itemid = 1951, droprate = 130},
{itemid = 1953, droprate = 304},
{itemid = 2717, droprate = 87},
{itemid = 1959, droprate = 217},
{itemid = 1941, droprate = 174},
{itemid = 1931, droprate = 130},
{itemid = 1935, droprate = 109},
},
{
{itemid = 1988, droprate = 1000},
},
{
{itemid = 2127, droprate = 59},
{itemid = 1875, droprate = 100},
},
},
-- omega
[128] =
{
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1875, droprate = 1000},
},
{
{itemid = 1925, droprate = 659},
{itemid = 1927, droprate = 394},
{itemid = 1928, droprate = 388},
{itemid = 1929, droprate = 404},
},
{
{itemid = 1928, droprate = 394},
{itemid = 1929, droprate = 402},
{itemid = 1925, droprate = 659},
{itemid = 1927, droprate = 383},
},
{
{itemid = 1926, droprate = 265},
{itemid = 1875, droprate = 100},
},
},
-- pod
[129] =
{
{
{itemid = 1933, droprate = 9},
{itemid = 1931, droprate = 53},
{itemid = 1959, droprate = 6},
{itemid = 1935, droprate = 12},
{itemid = 1945, droprate = 29},
{itemid = 1957, droprate = 12},
{itemid = 1949, droprate = 35},
{itemid = 2659, droprate = 35},
{itemid = 1939, droprate = 12},
{itemid = 1951, droprate = 12},
{itemid = 2661, droprate = 12},
{itemid = 1937, droprate = 18},
{itemid = 1955, droprate = 29},
{itemid = 2717, droprate = 12},
{itemid = 1947, droprate = 12},
{itemid = 2657, droprate = 18},
{itemid = 2715, droprate = 5},
{itemid = 1953, droprate = 35},
{itemid = 1941, droprate = 41},
{itemid = 1943, droprate = 18},
{itemid = 1987, droprate = 53},
{itemid = 1988, droprate = 76},
{itemid = 1909, droprate = 64},
{itemid = 1910, droprate = 41},
},
{
{itemid = 646, droprate = 50},
{itemid = 1633, droprate = 50},
{itemid = 664, droprate = 50},
{itemid = 645, droprate = 50},
{itemid = 1311, droprate = 50},
{itemid = 1681, droprate = 50},
{itemid = 821, droprate = 50},
{itemid = 1883, droprate = 50},
},
}
}
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player, npc)
local battlefield = player:getBattlefield()
local CofferID = npc:getID()
local CofferType = 0
local lootID = 0
local InstanceRegion = 0
local addtime = 0
local DespawnOtherCoffer = false
local MimicID = 0
if not battlefield then
printf("Error: battlefield nil but we're opening a treasure box! "..player:getName())
printf("Illegal CofferID: "..CofferID)
return
end
for coffer = 1,#ARMOURY_CRATES_LIST_APOLLYON,2 do
if (ARMOURY_CRATES_LIST_APOLLYON[coffer]== CofferID-16932864) then
CofferType=ARMOURY_CRATES_LIST_APOLLYON[coffer+1][1]
InstanceRegion=ARMOURY_CRATES_LIST_APOLLYON[coffer+1][2]
addtime=ARMOURY_CRATES_LIST_APOLLYON[coffer+1][3]
DespawnOtherCoffer=ARMOURY_CRATES_LIST_APOLLYON[coffer+1][4]
MimicID=ARMOURY_CRATES_LIST_APOLLYON[coffer+1][5]
lootID=ARMOURY_CRATES_LIST_APOLLYON[coffer+1][6]
end
end
-- printf("CofferID : %u",CofferID-16932864)
-- printf("Coffertype %u",CofferType)
-- printf("InstanceRegion: %u",InstanceRegion)
-- printf("addtime: %u",addtime)
-- printf("MimicID: %u",MimicID)
-- printf("lootID: %u",lootID)
if (CofferType == cTIME) then
dsp.battlefield.ExtendTimeLimit(battlefield, addtime)
elseif (CofferType == cITEM) then
battlefield:setLocalVar("loot", 1)
battlefield:spawnLoot(npc)
dsp.battlefield.HandleLootRolls(battlefield, loot[lootID], nil, npc)
elseif (CofferType == cRESTORE) then
dsp.battlefield.HealPlayers(battlefield)
elseif (CofferType == cMIMIC) then
if (CofferID==16932864+210) then
GetNPCByID(16932864+195):setPos(npc:getXPos(),npc:getYPos(),npc:getZPos())
GetNPCByID(16932864+195):setStatus(dsp.status.NORMAL)
elseif (CofferID==16932864+211) then
GetMobByID(16932896):setPos(npc:getXPos(),npc:getYPos(),npc:getZPos())
GetMobByID(16932896):setSpawn(npc:getXPos(),npc:getYPos(),npc:getZPos())
GetMobByID(16932896):updateClaim(player)
elseif (CofferID==16932864+212) then
GetNPCByID(16932864+196):setPos(npc:getXPos(),npc:getYPos(),npc:getZPos())
GetNPCByID(16932864+196):setStatus(dsp.status.NORMAL)
elseif (CofferID==16932864+213) then
GetMobByID(16932897):setPos(npc:getXPos(),npc:getYPos(),npc:getZPos())
GetMobByID(16932897):setSpawn(npc:getXPos(),npc:getYPos(),npc:getZPos())
GetMobByID(16932897):updateClaim(player)
elseif (CofferID==16932864+214) then
GetNPCByID(16932864+197):setPos(npc:getXPos(),npc:getYPos(),npc:getZPos())
GetNPCByID(16932864+197):setStatus(dsp.status.NORMAL)
elseif (CofferID==16932864+215) then
GetMobByID(16932898):setPos(npc:getXPos(),npc:getYPos(),npc:getZPos())
GetMobByID(16932898):setSpawn(npc:getXPos(),npc:getYPos(),npc:getZPos())
GetMobByID(16932898):updateClaim(player)
elseif (CofferID==16932864+216) then
GetMobByID(16932899):setPos(npc:getXPos(),npc:getYPos(),npc:getZPos())
GetMobByID(16932899):setSpawn(npc:getXPos(),npc:getYPos(),npc:getZPos())
GetMobByID(16932899):updateClaim(player)
end
end
if (DespawnOtherCoffer==true) then
HideArmouryCrates(InstanceRegion,APOLLYON_SE_NE)
end
npc:setStatus(dsp.status.DISAPPEAR)
end
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
end
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
end
| gpl-3.0 |
ibm2431/darkstar | scripts/globals/spells/knights_minne_iii.lua | 10 | 1505 | -----------------------------------------
-- Spell: Knight's Minne III
-- Grants Defense bonus to all allies.
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0
end
function onSpellCast(caster,target,spell)
local sLvl = caster:getSkillLevel(dsp.skill.SINGING) -- Gets skill level of Singing
local iLvl = caster:getWeaponSkillLevel(dsp.slot.RANGED)
local power = 18 + math.floor((sLvl + iLvl)/10)
if (power >= 108) then
power = 108
end
local iBoost = caster:getMod(dsp.mod.MINNE_EFFECT) + caster:getMod(dsp.mod.ALL_SONGS_EFFECT)
if (iBoost > 0) then
power = power + iBoost*11
end
power = power + caster:getMerit(dsp.merit.MINNE_EFFECT)
if (caster:hasStatusEffect(dsp.effect.SOUL_VOICE)) then
power = power * 2
elseif (caster:hasStatusEffect(dsp.effect.MARCATO)) then
power = power * 1.5
end
caster:delStatusEffect(dsp.effect.MARCATO)
local duration = 120
duration = duration * ((iBoost * 0.1) + (caster:getMod(dsp.mod.SONG_DURATION_BONUS)/100) + 1)
if (caster:hasStatusEffect(dsp.effect.TROUBADOUR)) then
duration = duration * 2
end
if not (target:addBardSong(caster,dsp.effect.MINNE,power,0,duration,caster:getID(), 0, 3)) then
spell:setMsg(dsp.msg.basic.MAGIC_NO_EFFECT)
end
return dsp.effect.MINNE
end
| gpl-3.0 |
softer/prosody-modules | mod_mam/mamprefsxml.lib.lua | 36 | 1467 | -- XEP-0313: Message Archive Management for Prosody
-- Copyright (C) 2011-2013 Kim Alvefur
--
-- This file is MIT/X11 licensed.
local st = require"util.stanza";
local xmlns_mam = "urn:xmpp:mam:0";
local global_default_policy = module:get_option("default_archive_policy", false);
local default_attrs = {
always = true, [true] = "always",
never = false, [false] = "never",
roster = "roster",
}
local function tostanza(prefs)
local default = prefs[false];
default = default ~= nil and default_attrs[default] or global_default_policy;
local prefstanza = st.stanza("prefs", { xmlns = xmlns_mam, default = default });
local always = st.stanza("always");
local never = st.stanza("never");
for jid, choice in pairs(prefs) do
if jid then
(choice and always or never):tag("jid"):text(jid):up();
end
end
prefstanza:add_child(always):add_child(never);
return prefstanza;
end
local function fromstanza(prefstanza)
local prefs = {};
local default = prefstanza.attr.default;
if default then
prefs[false] = default_attrs[default];
end
local always = prefstanza:get_child("always");
if always then
for rule in always:childtags("jid") do
local jid = rule:get_text();
prefs[jid] = true;
end
end
local never = prefstanza:get_child("never");
if never then
for rule in never:childtags("jid") do
local jid = rule:get_text();
prefs[jid] = false;
end
end
return prefs;
end
return {
tostanza = tostanza;
fromstanza = fromstanza;
}
| mit |
greasydeal/darkstar | scripts/zones/Port_San_dOria/npcs/Brifalien.lua | 19 | 1772 | -----------------------------------
-- Area: Port San d'Oria
-- NPC: Brifalien
-- Involved in Quests: Riding on the Clouds
-- @zone 232
-- @pos -20 -4 -74
-----------------------------------
package.loaded["scripts/zones/Port_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/keyitems");
require("scripts/globals/quests");
require("scripts/zones/Port_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if(player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE) == QUEST_ACCEPTED) then
if(trade:hasItemQty(532,1) and trade:getItemCount() == 1) then -- Trade Magicmart Flyer
player:messageSpecial(FLYER_REFUSED);
end
end
if(player:getQuestStatus(JEUNO,RIDING_ON_THE_CLOUDS) == QUEST_ACCEPTED and player:getVar("ridingOnTheClouds_1") == 7) then
if(trade:hasItemQty(1127,1) and trade:getItemCount() == 1) then -- Trade Kindred seal
player:setVar("ridingOnTheClouds_1",0);
player:tradeComplete();
player:addKeyItem(SCOWLING_STONE);
player:messageSpecial(KEYITEM_OBTAINED,SCOWLING_STONE);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x024d);
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 |
greasydeal/darkstar | scripts/globals/spells/paralyze.lua | 11 | 1994 | -----------------------------------------
-- Spell: Paralyze
-- Spell accuracy is most highly affected by Enfeebling Magic Skill, Magic Accuracy, and MND.
-----------------------------------------
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
if(target:hasStatusEffect(EFFECT_PARALYSIS)) then --effect already on, do nothing
spell:setMsg(75);
else
-- Calculate duration.
local duration = math.random(20,120);
if (caster:hasStatusEffect(EFFECT_SABOTEUR)) then
duration = duration * 2;
end
-- Grabbing variables for paralyze potency
local pMND = caster:getStat(MOD_MND);
local mMND = target:getStat(MOD_MND);
local dMND = (pMND - mMND);
-- Calculate potency.
local potency = (pMND + dMND)/5; --simplified from (2 * (pMND + dMND)) / 10
if potency > 25 then
potency = 25;
end
if (caster:hasStatusEffect(EFFECT_SABOTEUR)) then
potency = potency * 2;
end
caster:delStatusEffect(EFFECT_SABOTEUR);
--printf("Duration : %u",duration);
--printf("Potency : %u",potency);
local resist = applyResistanceEffect(caster,spell,target,dMND,35,0,EFFECT_PARALYSIS);
if(resist >= 0.5) then --there are no quarter or less hits, if target resists more than .5 spell is resisted completely
if(target:addStatusEffect(EFFECT_PARALYSIS,potency,0,duration*resist)) then
spell:setMsg(236);
else
-- no effect
spell:setMsg(75);
end
else
-- resist
spell:setMsg(85);
end
end
return EFFECT_PARALYSIS;
end;
| gpl-3.0 |
naclander/tome | game/modules/tome/data/general/objects/cloak.lua | 3 | 1917 | -- ToME - Tales of Maj'Eyal
-- Copyright (C) 2009 - 2014 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
newEntity{
define_as = "BASE_CLOAK",
slot = "CLOAK",
type = "armor", subtype="cloak",
add_name = " (#ARMOR#)",
display = "(", color=colors.UMBER, image = resolvers.image_material("cloak", "cloth"),
moddable_tile = resolvers.moddable_tile("cloak"),
encumber = 2,
rarity = 6,
desc = [[A cloth coat typically worn as a loose outer garment. It is spacious enough to be worn even over bulky metal armour.]],
randart_able = "/data/general/objects/random-artifacts/generic.lua",
egos = "/data/general/objects/egos/cloak.lua", egos_chance = { prefix=resolvers.mbonus(40, 5), suffix=resolvers.mbonus(40, 5) },
}
newEntity{ base = "BASE_CLOAK",
name = "linen cloak", short_name = "linen",
level_range = {1, 20},
cost = 2,
material_level = 1,
wielder = {
combat_def = 1,
},
}
newEntity{ base = "BASE_CLOAK",
name = "cashmere cloak", short_name = "cashmere",
level_range = {20, 40},
cost = 4,
material_level = 3,
wielder = {
combat_def = 2,
},
}
newEntity{ base = "BASE_CLOAK",
name = "elven-silk cloak", short_name = "e.silk",
level_range = {40, 50},
cost = 7,
material_level = 5,
wielder = {
combat_def = 3,
},
}
| gpl-3.0 |
ibm2431/darkstar | scripts/zones/Upper_Jeuno/npcs/_6s2.lua | 9 | 3719 | -----------------------------------
-- Area: Upper Jeuno
-- NPC: Galmut's door
-- Starts and Finishes Quest: A Clock Most Delicate, Save the Clock Tower, The Clockmaster
-- !pos -80 0 104 244
-----------------------------------
local ID = require("scripts/zones/Upper_Jeuno/IDs");
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/shop");
require("scripts/globals/quests");
-----------------------------------
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
local aClockMostdelicate = player:getQuestStatus(JEUNO,dsp.quest.id.jeuno.A_CLOCK_MOST_DELICATE);
if (aClockMostdelicate == QUEST_AVAILABLE and player:getCharVar("aClockMostdelicateVar") == 1) then
player:startEvent(119); -- Start long cs quest with option "a clock most delicate"
elseif (aClockMostdelicate == QUEST_AVAILABLE and player:getCharVar("aClockMostdelicateVar") == 2) then
player:startEvent(118); -- Start short cs quest with option "a clock most delicate"
elseif (aClockMostdelicate == QUEST_ACCEPTED) then
if (player:hasKeyItem(dsp.ki.CLOCK_TOWER_OIL) == true) then
player:startEvent(202); -- Ending quest "a clock most delicate"
else
player:startEvent(117); -- During quest "a clock most delicate"
end
elseif (player:getQuestStatus(JEUNO,dsp.quest.id.jeuno.SAVE_THE_CLOCK_TOWER) == QUEST_COMPLETED and player:getQuestStatus(JEUNO,dsp.quest.id.jeuno.THE_CLOCKMASTER) == QUEST_AVAILABLE) then
player:startEvent(152); -- Start & finish quest "The Clockmaster"
elseif (player:getQuestStatus(JEUNO,dsp.quest.id.jeuno.THE_CLOCKMASTER) == QUEST_COMPLETED) then
player:startEvent(110); -- After quest "The Clockmaster"
else
player:startEvent(116); -- Standard dialog
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 119 and option == 1) then
player:addQuest(JEUNO,dsp.quest.id.jeuno.A_CLOCK_MOST_DELICATE);
player:setCharVar("aClockMostdelicateVar",0);
elseif (csid == 119 and option == 0) then
player:setCharVar("aClockMostdelicateVar",2);
elseif (csid == 118 and option == 1) then
player:addQuest(JEUNO,dsp.quest.id.jeuno.A_CLOCK_MOST_DELICATE);
player:setCharVar("aClockMostdelicateVar",0);
elseif (csid == 202) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED,12727);
else
player:addTitle(dsp.title.PROFESSIONAL_LOAFER);
player:delKeyItem(dsp.ki.CLOCK_TOWER_OIL);
player:addGil(1200);
player:messageSpecial(ID.text.GIL_OBTAINED,1200);
player:addItem(12727);
player:messageSpecial(ID.text.ITEM_OBTAINED,12727);
player:addFame(JEUNO,30);
player:completeQuest(JEUNO,dsp.quest.id.jeuno.A_CLOCK_MOST_DELICATE);
player:addQuest(JEUNO,dsp.quest.id.jeuno.SAVE_THE_CLOCK_TOWER); -- Start next quest "Save the Clock Tower"
end
elseif (csid == 152) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED,17083);
else
player:addQuest(JEUNO,dsp.quest.id.jeuno.THE_CLOCKMASTER);
player:addTitle(dsp.title.TIMEKEEPER);
player:addGil(1200);
player:messageSpecial(ID.text.GIL_OBTAINED,1200);
player:addItem(17083);
player:messageSpecial(ID.text.ITEM_OBTAINED,17083);
player:addFame(JEUNO,30);
player:completeQuest(JEUNO,dsp.quest.id.jeuno.THE_CLOCKMASTER);
end
end
end;
| gpl-3.0 |
ibm2431/darkstar | scripts/globals/chocobo.lua | 11 | 8350 | -----------------------------------
-- Chocobo functions
-- Info from:
-- http://wiki.ffxiclopedia.org/wiki/Chocobo_Renter
-- http://ffxi.allakhazam.com/wiki/Traveling_in_Vana'diel
-----------------------------------
require("scripts/globals/keyitems")
require("scripts/globals/missions")
require("scripts/globals/status")
require("scripts/globals/zone")
-----------------------------------
dsp = dsp or {}
dsp.chocobo = dsp.chocobo or {}
--[[
Description:
[1] Level required to rent a chocobo
[2] Base price
[3] Amount added to base price
[4] Amount discounted per time interval
[5] Amount of seconds before price decay
[6] Quest "A Chocobo Riding Game" chance
[7] Shadowreign zone flag
[8] Position player is sent to after event, if applicable
--]]
local chocoboInfo =
{
[dsp.zone.AL_ZAHBI] = {levelReq = 20, basePrice = 250, addedPrice = 25, decayPrice = 5, decayTime = 90, questChance = 0.00, past = false, pos = {610, -24, 356, 128, 51}},
[dsp.zone.WAJAOM_WOODLANDS] = {levelReq = 20, basePrice = 200, addedPrice = 20, decayPrice = 5, decayTime = 90, questChance = 0.00, past = false, pos = nil},
[dsp.zone.SOUTHERN_SAN_DORIA_S] = {levelReq = 15, basePrice = 150, addedPrice = 20, decayPrice = 5, decayTime = 90, questChance = 0.00, past = true , pos = {94, -62, 266, 40, 81}},
[dsp.zone.JUGNER_FOREST_S] = {levelReq = 20, basePrice = 200, addedPrice = 25, decayPrice = 5, decayTime = 90, questChance = 0.00, past = true , pos = nil},
[dsp.zone.BASTOK_MARKETS_S] = {levelReq = 15, basePrice = 150, addedPrice = 20, decayPrice = 5, decayTime = 90, questChance = 0.00, past = true , pos = {380, 0, 147, 192, 88}},
[dsp.zone.PASHHOW_MARSHLANDS_S] = {levelReq = 20, basePrice = 200, addedPrice = 25, decayPrice = 5, decayTime = 90, questChance = 0.00, past = true , pos = nil},
[dsp.zone.WINDURST_WATERS_S] = {levelReq = 15, basePrice = 150, addedPrice = 20, decayPrice = 5, decayTime = 90, questChance = 0.00, past = true , pos = {320, -4, -46, 192, 95}},
[dsp.zone.MERIPHATAUD_MOUNTAINS_S] = {levelReq = 20, basePrice = 200, addedPrice = 25, decayPrice = 5, decayTime = 90, questChance = 0.00, past = true , pos = nil},
[dsp.zone.LA_THEINE_PLATEAU] = {levelReq = 20, basePrice = 200, addedPrice = 25, decayPrice = 5, decayTime = 90, questChance = 0.00, past = false, pos = nil},
[dsp.zone.KONSCHTAT_HIGHLANDS] = {levelReq = 20, basePrice = 200, addedPrice = 25, decayPrice = 5, decayTime = 90, questChance = 0.00, past = false, pos = nil},
[dsp.zone.EASTERN_ALTEPA_DESERT] = {levelReq = 20, basePrice = 200, addedPrice = 25, decayPrice = 5, decayTime = 90, questChance = 0.00, past = false, pos = nil},
[dsp.zone.TAHRONGI_CANYON] = {levelReq = 20, basePrice = 200, addedPrice = 25, decayPrice = 5, decayTime = 90, questChance = 0.00, past = false, pos = nil},
[dsp.zone.YHOATOR_JUNGLE] = {levelReq = 20, basePrice = 200, addedPrice = 25, decayPrice = 5, decayTime = 90, questChance = 0.00, past = false, pos = nil},
[dsp.zone.SOUTHERN_SAN_DORIA] = {levelReq = 15, basePrice = 100, addedPrice = 20, decayPrice = 5, decayTime = 60, questChance = 0.10, past = false, pos = {-126, -62, 274, 101, 100}},
[dsp.zone.BASTOK_MINES] = {levelReq = 15, basePrice = 100, addedPrice = 20, decayPrice = 5, decayTime = 60, questChance = 0.10, past = false, pos = {580, 0, -305, 64, 107}},
[dsp.zone.WINDURST_WOODS] = {levelReq = 15, basePrice = 100, addedPrice = 20, decayPrice = 5, decayTime = 60, questChance = 0.10, past = false, pos = {-122, -4, -520, 0, 116}},
[dsp.zone.UPPER_JEUNO] = {levelReq = 20, basePrice = 200, addedPrice = 25, decayPrice = 5, decayTime = 90, questChance = 0.00, past = false, pos = {486, 8, -160, 128, 105}},
[dsp.zone.LOWER_JEUNO] = {levelReq = 20, basePrice = 200, addedPrice = 25, decayPrice = 5, decayTime = 90, questChance = 0.00, past = false, pos = {340, 24, 608, 112, 110}},
[dsp.zone.PORT_JEUNO] = {levelReq = 20, basePrice = 200, addedPrice = 25, decayPrice = 5, decayTime = 90, questChance = 0.00, past = false, pos = {-574, 2, 400, 0, 120}},
[dsp.zone.RABAO] = {levelReq = 20, basePrice = 90, addedPrice = 10, decayPrice = 5, decayTime = 60, questChance = 0.00, past = false, pos = {420, 8, 360, 64, 125}},
[dsp.zone.KAZHAM] = {levelReq = 20, basePrice = 90, addedPrice = 10, decayPrice = 5, decayTime = 60, questChance = 0.10, past = false, pos = {-240, 0, 528, 64, 123}},
[dsp.zone.NORG] = {levelReq = 20, basePrice = 90, addedPrice = 10, decayPrice = 5, decayTime = 60, questChance = 0.00, past = false, pos = {-456, 17, -348, 0, 123}},
}
---------------------------------------
-- Local functions
---------------------------------------
local function getPrice(zoneId, info)
local lastPrice = GetServerVariable("[CHOCOBO][" .. zoneId .. "]price")
local lastTime = GetServerVariable("[CHOCOBO][" .. zoneId .. "]time")
local decay = math.floor((os.time() - lastTime) / info.decayTime) * info.decayPrice
local price = math.max(lastPrice - decay, info.basePrice)
return price
end
function updatePrice(zoneId, info, price)
SetServerVariable("[CHOCOBO][" .. zoneId .. "]price", price + info.addedPrice)
SetServerVariable("[CHOCOBO][" .. zoneId .. "]time", os.time())
end
---------------------------------------
-- Public functions
---------------------------------------
dsp.chocobo.initZone = function(zone)
local zoneId = zone:getID()
local info = chocoboInfo[zoneId]
if info then
SetServerVariable("[CHOCOBO][" .. zoneId .. "]price", info.basePrice)
SetServerVariable("[CHOCOBO][" .. zoneId .. "]time", os.time())
else
printf("[warning] bad zoneId %i in dsp.chocobo.initZone", zoneId)
end
end
dsp.chocobo.renterOnTrigger = function(player, eventSucceed, eventFail)
local mLvl = player:getMainLvl()
local zoneId = player:getZoneID()
local info = chocoboInfo[zoneId]
if info then
if player:hasKeyItem(dsp.ki.CHOCOBO_LICENSE) and mLvl >= info.levelReq and (player:hasCompletedMission(WOTG, dsp.mission.id.wotg.BACK_TO_THE_BEGINNING) or not info.past) then
local price = getPrice(zoneId, info)
player:setLocalVar("[CHOCOBO]price", price)
local currency = 0
if info.past then
currency = player:getCurrency("allied_notes")
else
currency = player:getGil()
end
local lowLevel = (mLvl < 20) and 1 or 0
player:startEvent(eventSucceed, price, currency, lowLevel)
else
player:startEvent(eventFail)
end
else
printf("[warning] player %s passed bad zoneId %i in dsp.chocobo.renterOnTrigger", player:getName(), zoneId)
end
end
dsp.chocobo.renterOnEventFinish = function(player, csid, option, eventSucceed)
if csid == eventSucceed and option == 0 then
local mLvl = player:getMainLvl()
local zoneId = player:getZoneID()
local info = chocoboInfo[zoneId]
if info then
local price = player:getLocalVar("[CHOCOBO]price")
player:setLocalVar("[CHOCOBO]price", 0)
if price and (info.past and player:getCurrency("allied_notes") >= price) or (not info.past and player:delGil(price)) then
if info.past then
player:delCurrency("allied_notes", price)
end
updatePrice(zoneId, info, price)
local duration = 900
if mLvl >= 20 then
duration = 1800 + (player:getMod(dsp.mod.CHOCOBO_RIDING_TIME) * 60)
end
player:addStatusEffectEx(dsp.effect.MOUNTED, dsp.effect.MOUNTED, 0, 0, duration, true)
if info.pos then
player:setPos(unpack(info.pos))
end
else
printf("[warning] player %s reached succeed without enough currency in dsp.chocobo.renterOnEventFinish", player:getName())
end
else
printf("[warning] player %s passed bad zoneId %i in dsp.chocobo.renterOnEventFinish", player:getName(), zoneId)
end
end
end
| gpl-3.0 |
ibm2431/darkstar | scripts/globals/spells/curaga_iv.lua | 12 | 1397 | -----------------------------------------
-- Spell: Curaga IV
-- Restores HP of all party members within area of effect.
-----------------------------------------
require("scripts/globals/settings")
require("scripts/globals/status")
require("scripts/globals/magic")
require("scripts/globals/msg")
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0
end
function onSpellCast(caster,target,spell)
local minCure = 450
local divisor = 0.6666
local constant = 330
local power = getCurePowerOld(caster)
if (power > 560) then
divisor = 2.8333
constant = 591.2
elseif (power > 320) then
divisor = 1
constant = 410
end
local final = getCureFinal(caster,spell,getBaseCureOld(power,divisor,constant),minCure,false)
final = final + (final * (target:getMod(dsp.mod.CURE_POTENCY_RCVD)/100))
--Applying server mods....
final = final * CURE_POWER
local diff = (target:getMaxHP() - target:getHP())
if (final > diff) then
final = diff
end
target:addHP(final)
target:wakeUp()
caster:updateEnmityFromCure(target,final)
spell:setMsg(dsp.msg.basic.AOE_HP_RECOVERY)
local mpBonusPercent = (final*caster:getMod(dsp.mod.CURE2MP_PERCENT))/100
if (mpBonusPercent > 0) then
caster:addMP(mpBonusPercent)
end
return final
end
| gpl-3.0 |
ibm2431/darkstar | scripts/zones/Temenos/bcnms/temenos_eastern_tower.lua | 9 | 1847 | -----------------------------------
-- Area: Temenos
-- Name: Temenos Eastern Tower
-----------------------------------
require("scripts/globals/limbus");
require("scripts/globals/battlefield")
require("scripts/globals/keyitems");
-- After registering the BCNM via bcnmRegister(bcnmid)
function onBattlefieldTick(battlefield, tick)
dsp.battlefield.onBattlefieldTick(battlefield, tick)
end
function onBattlefieldRegister(player,battlefield)
if (GetMobByID(16928844):isSpawned()) then DespawnMob(16928844); end
if (GetMobByID(16928853):isSpawned()) then DespawnMob(16928853); end
if (GetMobByID(16928862):isSpawned()) then DespawnMob(16928862); end
if (GetMobByID(16928871):isSpawned()) then DespawnMob(16928871); end
if (GetMobByID(16928880):isSpawned()) then DespawnMob(16928880); end
if (GetMobByID(16928889):isSpawned()) then DespawnMob(16928889); end
if (GetMobByID(16928894):isSpawned()) then DespawnMob(16928894); end
SetServerVariable("[Temenos_E_Tower]UniqueID",os.time());
HideArmouryCrates(Temenos_Eastern_Tower,TEMENOS);
HideTemenosDoor(Temenos_Eastern_Tower);
end;
-- Physically entering the BCNM via bcnmEnter(bcnmid)
function onBattlefieldEnter(player,battlefield)
player:setCharVar("characterLimbusKey",GetServerVariable("[Temenos_E_Tower]UniqueID"));
player:delKeyItem(dsp.ki.COSMOCLEANSE);
player:delKeyItem(dsp.ki.WHITE_CARD);
end;
-- Leaving the Dynamis by every mean possible, given by the LeaveCode
-- 3=Disconnected or warped out (if dyna is empty: launch 4 after 3)
-- 4=Finish he dynamis
function onBattlefieldLeave(player,battlefield,leavecode)
--print("leave code "..leavecode);
if leavecode == dsp.battlefield.leaveCode.LOST then
SetServerVariable("[Temenos_E_Tower]UniqueID",0);
player:setPos(580,-1.5,4.452,192);
end
end; | gpl-3.0 |
ibm2431/darkstar | scripts/zones/Western_Adoulin/Zone.lua | 9 | 1605 | -----------------------------------
--
-- Zone: Western Adoulin
-- !zone 256
--
-----------------------------------
local ID = require("scripts/zones/Western_Adoulin/IDs")
require("scripts/globals/quests")
-----------------------------------
function onInitialize(zone)
end
function onZoneIn(player,prevZone)
local cs = -1
local heartwingsAndTheKindhearted = player:getCurrentMission(SOA) == dsp.mission.id.soa.HEARTWINGS_AND_THE_KINDHEARTED
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
player:setPos(-142, 4, -18, 4)
end
if (player:getCharVar("Raptor_Rapture_Status") == 2) then
-- Resuming cutscene for Quest: 'Raptor Rapture', after Pagnelle warps you to Rala Waterways mid-CS, then back here.
cs = 5056
end
if heartwingsAndTheKindhearted then
cs = 2
end
return cs
end
function onRegionEnter(player,region)
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
if csid == 5056 then
-- Successfully finished introduction CS event chain for Quest: 'Raptor Rapture'.
player:setCharVar("Raptor_Rapture_Status", 3)
if (option == 1) then
-- Starts Quest: 'Raptor Rapture'
player:addQuest(ADOULIN, dsp.quest.id.adoulin.RAPTOR_RAPTURE)
player:setCharVar("Raptor_Rapture_Status", 4)
end
elseif csid == 2 then
player:completeMission(SOA,dsp.mission.id.soa.HEARTWINGS_AND_THE_KINDHEARTED)
player:addMission(SOA,dsp.mission.id.soa.PIONEER_REGISTRATION)
end
end
| gpl-3.0 |
greasydeal/darkstar | scripts/globals/items/pumpkin_pie_+1.lua | 35 | 1372 | -----------------------------------------
-- ID: 4447
-- Item: pumpkin_pie_+1
-- Food Effect: 60Min, All Races
-----------------------------------------
-- Magic 45
-- Intelligence 4
-- Charisma -1
-- MP Recovered While Healing 1
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,3600,4447);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_MP, 45);
target:addMod(MOD_INT, 4);
target:addMod(MOD_CHR, -1);
target:addMod(MOD_MPHEAL, 1);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_MP, 45);
target:delMod(MOD_INT, 4);
target:delMod(MOD_CHR, -1);
target:delMod(MOD_MPHEAL, 1);
end;
| gpl-3.0 |
greasydeal/darkstar | scripts/globals/ability.lua | 17 | 15202 | -----------------------------------
--
-- ABILITIES
--
-----------------------------------
ABILITY_MIGHTY_STRIKES = 0;
ABILITY_HUNDRED_FISTS = 1;
ABILITY_BENEDICTION = 2;
ABILITY_MANAFONT = 3;
ABILITY_CHAINSPELL = 4;
ABILITY_PERFECT_DODGE = 5;
ABILITY_INVINCIBLE = 6;
ABILITY_BLOOD_WEAPON = 7;
ABILITY_FAMILIAR = 8;
ABILITY_SOUL_VOICE = 9;
ABILITY_EAGLE_EYE_SHOT = 10;
ABILITY_MEIKYO_SHISUI = 11;
ABILITY_MIJIN_GAKURE = 12;
ABILITY_SPIRIT_SURGE = 13;
ABILITY_ASTRAL_FLOW = 14;
ABILITY_BERSERK = 15;
ABILITY_WARCRY = 16;
ABILITY_DEFENDER = 17;
ABILITY_AGGRESSOR = 18;
ABILITY_PROVOKE = 19;
ABILITY_FOCUS = 20;
ABILITY_DODGE = 21;
ABILITY_CHAKRA = 22;
ABILITY_BOOST = 23;
ABILITY_COUNTERSTANCE = 24;
ABILITY_STEAL = 25;
ABILITY_FLEE = 26;
ABILITY_HIDE = 27;
ABILITY_SNEAK_ATTACK = 28;
ABILITY_MUG = 29;
ABILITY_SHIELD_BASH = 30;
ABILITY_HOLY_CIRCLE = 31;
ABILITY_SENTINEL = 32;
ABILITY_SOULEATER = 33;
ABILITY_ARCANE_CIRCLE = 34;
ABILITY_LAST_RESORT = 35;
ABILITY_CHARM = 36;
ABILITY_GAUGE = 37;
ABILITY_TAME = 38;
ABILITY_PET_COMMANDS = 39;
ABILITY_SCAVENGE = 40;
ABILITY_SHADOWBIND = 41;
ABILITY_CAMOUFLAGE = 42;
ABILITY_SHARPSHOT = 43;
ABILITY_BARRAGE = 44;
ABILITY_CALL_WYVERN = 45;
ABILITY_THIRD_EYE = 46;
ABILITY_MEDITATE = 47;
ABILITY_WARDING_CIRCLE = 48;
ABILITY_ANCIENT_CIRCLE = 49;
ABILITY_JUMP = 50;
ABILITY_HIGH_JUMP = 51;
ABILITY_SUPER_JUMP = 52;
ABILITY_FIGHT = 53;
ABILITY_HEEL = 54;
ABILITY_LEAVE = 55;
ABILITY_SIC = 56;
ABILITY_STAY = 57;
ABILITY_DIVINE_SEAL = 58;
ABILITY_ELEMENTAL_SEAL = 59;
ABILITY_TRICK_ATTACK = 60;
ABILITY_WEAPON_BASH = 61;
ABILITY_REWARD = 62;
ABILITY_COVER = 63;
ABILITY_SPIRIT_LINK = 64;
ABILITY_CHI_BLAST = 66;
ABILITY_CONVERT = 67;
ABILITY_ACCOMPLICE = 68;
ABILITY_CALL_BEAST = 69;
ABILITY_UNLIMITED_SHOT = 70;
ABILITY_DISMISS = 71;
ABILITY_ASSAULT = 72;
ABILITY_RETREAT = 73;
ABILITY_RELEASE = 74;
ABILITY_BLOOD_PACT_RAGE = 75;
ABILITY_RAMPART = 76;
ABILITY_AZURE_LORE = 77;
ABILITY_CHAIN_AFFINITY = 78;
ABILITY_BURST_AFFINITY = 79;
ABILITY_WILD_CARD = 80;
ABILITY_PHANTOM_ROLL = 81;
ABILITY_FIGHTERS_ROLL = 82;
ABILITY_MONKS_ROLL = 83;
ABILITY_HEALERS_ROLL = 84;
ABILITY_WIZARDS_ROLL = 85;
ABILITY_WARLOCKS_ROLL = 86;
ABILITY_ROGUES_ROLL = 87;
ABILITY_GALLANTS_ROLL = 88;
ABILITY_CHAOS_ROLL = 89;
ABILITY_BEAST_ROLL = 90;
ABILITY_CHORAL_ROLL = 91;
ABILITY_HUNTERS_ROLL = 92;
ABILITY_SAMURAI_ROLL = 93;
ABILITY_NINJA_ROLL = 94;
ABILITY_DRACHEN_ROLL = 95;
ABILITY_EVOKERS_ROLL = 96;
ABILITY_MAGUSS_ROLL = 97;
ABILITY_CORSAIRS_ROLL = 98;
ABILITY_PUPPET_ROLL = 99;
ABILITY_DANCERS_ROLL = 100;
ABILITY_SCHOLARS_ROLL = 101;
ABILITY_DOUBLE_UP = 107;
ABILITY_QUICK_DRAW = 108;
ABILITY_FIRE_SHOT = 109;
ABILITY_ICE_SHOT = 110;
ABILITY_WIND_SHOT = 111;
ABILITY_EARTH_SHOT = 112;
ABILITY_THUNDER_SHOT = 113;
ABILITY_WATER_SHOT = 114;
ABILITY_LIGHT_SHOT = 115;
ABILITY_DARK_SHOT = 116;
ABILITY_RANDOM_DEAL = 117;
ABILITY_OVERDRIVE = 119;
ABILITY_ACTIVATE = 120;
ABILITY_REPAIR = 121;
ABILITY_DEPLOY = 122;
ABILITY_DEACTIVATE = 123;
ABILITY_RETRIEVE = 124;
ABILITY_FIRE_MANEUVER = 125;
ABILITY_ICE_MANEUVER = 126;
ABILITY_WIND_MANEUVER = 127;
ABILITY_EARTH_MANEUVER = 128;
ABILITY_THUNDER_MANEUVER = 129;
ABILITY_WATER_MANEUVER = 130;
ABILITY_LIGHT_MANEUVER = 131;
ABILITY_DARK_MANEUVER = 132;
ABILITY_WARRIORS_CHARGE = 133;
ABILITY_TOMAHAWK = 134;
ABILITY_MANTRA = 135;
ABILITY_FORMLESS_STRIKES = 136;
ABILITY_MARTYR = 137;
ABILITY_DEVOTION = 138;
ABILITY_ASSASSINS_CHARGE = 139;
ABILITY_FEINT = 140;
ABILITY_FEALTY = 141;
ABILITY_CHIVALRY = 142;
ABILITY_DARK_SEAL = 143;
ABILITY_DIABOLIC_EYE = 144;
ABILITY_FERAL_HOWL = 145;
ABILITY_KILLER_INSTINCT = 146;
ABILITY_NIGHTINGALE = 147;
ABILITY_TROUBADOUR = 148;
ABILITY_STEALTH_SHOT = 149;
ABILITY_FLASHY_SHOT = 150;
ABILITY_SHIKIKOYO = 151;
ABILITY_BLADE_BASH = 152;
ABILITY_DEEP_BREATHING = 153;
ABILITY_ANGON = 154;
ABILITY_SANGE = 155;
ABILITY_BLOOD_PACT_WARD = 156;
ABILITY_HASSO = 157;
ABILITY_SEIGAN = 158;
ABILITY_CONVERGENCE = 159;
ABILITY_DIFFUSION = 160;
ABILITY_SNAKE_EYE = 161;
ABILITY_FOLD = 162;
ABILITY_ROLE_REVERSAL = 163;
ABILITY_VENTRILOQUY = 164;
ABILITY_TRANCE = 165;
ABILITY_SAMBAS = 166;
ABILITY_WALTZES = 167;
ABILITY_DRAIN_SAMBA = 168;
ABILITY_DRAIN_SAMBA_II = 169;
ABILITY_DRAIN_SAMBA_III = 170;
ABILITY_ASPIR_SAMBA = 171;
ABILITY_ASPIR_SAMBA_II = 172;
ABILITY_HASTE_SAMBA = 173;
ABILITY_CURING_WALTZ = 174;
ABILITY_CURING_WALTZ_II = 175;
ABILITY_CURING_WALTZ_III = 176;
ABILITY_CURING_WALTZ_IV = 177;
ABILITY_HEALING_WALTZ = 178;
ABILITY_DIVINE_WALTZ = 179;
ABILITY_SPECTRAL_JIG = 180;
ABILITY_CHOCOBO_JIG = 181;
ABILITY_JIGS = 182;
ABILITY_STEPS = 183;
ABILITY_FLOURISHES_I = 184;
ABILITY_QUICKSTEP = 185;
ABILITY_BOX_STEP = 186;
ABILITY_STUTTER_STEP = 187;
ABILITY_ANIMATED_FLOURISH = 188;
ABILITY_DESPERATE_FLOURISH = 189;
ABILITY_REVERSE_FLOURISH = 190;
ABILITY_VIOLENT_FLOURISH = 191;
ABILITY_BUILDING_FLOURISH = 192;
ABILITY_WILD_FLOURISH = 193;
ABILITY_TABULA_RASA = 194;
ABILITY_LIGHT_ARTS = 195;
ABILITY_DARK_ARTS = 196;
ABILITY_FLOURISHES_II = 197;
ABILITY_MODUS_VERITAS = 198;
ABILITY_PENURY = 199;
ABILITY_CELERITY = 200;
ABILITY_RAPTURE = 201;
ABILITY_ACCESSION = 202;
ABILITY_PARSIMONY = 203;
ABILITY_ALACRITY = 204;
ABILITY_EBULLIENCE = 205;
ABILITY_MANIFESTATION = 206;
ABILITY_STRATAGEMS = 207;
ABILITY_VELOCITY_SHOT = 208;
ABILITY_SNARL = 209;
ABILITY_RETALIATION = 210;
ABILITY_FOOTWORK = 211;
ABILITY_PIANISSIMO = 213;
ABILITY_SEKKANOKI = 214;
ABILITY_ELEMENTAL_SIPHON = 216;
ABILITY_SUBLIMATION = 217;
ABILITY_ADDENDUM_WHITE = 218;
ABILITY_ADDENDUM_BLACK = 219;
ABILITY_COLLABORATOR = 220;
ABILITY_SABER_DANCE = 221;
ABILITY_FAN_DANCE = 222;
ABILITY_NO_FOOT_RISE = 223;
ABILITY_ALTRUISM = 224;
ABILITY_FOCALIZATION = 225;
ABILITY_TRANQUILITY = 226;
ABILITY_EQUANIMITY = 227;
ABILITY_ENLIGHTENMENT = 228;
ABILITY_AFFLATUS_SOLACE = 229;
ABILITY_AFFLATUS_MISERY = 230;
ABILITY_COMPOSURE = 231;
ABILITY_YONIN = 232;
ABILITY_INNIN = 233;
ABILITY_AVATARS_FAVOR = 234;
ABILITY_READY = 235;
ABILITY_RESTRAINT = 236;
ABILITY_PERFECT_COUNTER = 237;
ABILITY_MANA_WALL = 238;
ABILITY_DIVINE_EMBLEM = 239;
ABILITY_NETHER_VOID = 240;
ABILITY_DOUBLE_SHOT = 241;
ABILITY_SENGIKORI = 242;
ABILITY_FUTAE = 243;
ABILITY_SPIRIT_JUMP = 244;
ABILITY_PRESTO = 245;
ABILITY_DIVINE_WALTZ_II = 246;
ABILITY_FLOURISHES_III = 247;
ABILITY_CLIMACTIC_FLOURISH = 248;
ABILITY_LIBRA = 249;
ABILITY_TACTICAL_SWITCH = 250;
ABILITY_BLOOD_RAGE = 251;
ABILITY_IMPETUS = 253;
ABILITY_DIVINE_CARESS = 254;
ABILITY_SANCROSANCTITY = 255;
ABILITY_ENMITY_DOUSE = 256;
ABILITY_MANAWELL = 257;
ABILITY_SABOTEUR = 258;
ABILITY_SPONTANEITY = 259;
ABILITY_CONSPIRATOR = 260;
ABILITY_SEPULCHER = 261;
ABILITY_PALISADE = 262;
ABILITY_ARCANE_CREST = 263;
ABILITY_SCARLET_DELIRIUM = 264;
ABILITY_SPUR = 265;
ABILITY_RUN_WILD = 266;
ABILITY_TENUTO = 267;
ABILITY_MARCATO = 268;
ABILITY_BOUNTY_SHOT = 269;
ABILITY_DECOY_SHOT = 270;
ABILITY_HAMANOHA = 271;
ABILITY_HAGAKURE = 272;
ABILITY_ISSEKIGAN = 275;
ABILITY_DRAGON_BREAKER = 276;
ABILITY_SOUL_JUMP = 277;
ABILITY_STEADY_WING = 279;
ABILITY_MANA_CEDE = 280;
ABILITY_EFFLUX = 281;
ABILITY_UNBRIDLED_LEARNING = 282;
ABILITY_TRIPLE_SHOT = 285;
ABILITY_ALLIES_ROLL = 286;
ABILITY_MISER_S_ROLL = 287;
ABILITY_COMPANION_S_ROLL = 288;
ABILITY_AVENGER_S_ROLL = 289;
ABILITY_COOLDOWN = 293;
ABILITY_DEUX_EX_AUTOMATA = 294;
ABILITY_CURING_WALTZ_V = 295;
ABILITY_FEATHER_STEP = 296;
ABILITY_STRIKING_FLOURISH = 297;
ABILITY_TERNARY_FLOURISH = 298;
ABILITY_PERPETUANCE = 300;
ABILITY_IMMANENCE = 301;
ABILITY_SMITING_BREATH = 302;
ABILITY_RESTORING_BREATH = 303;
ABILITY_KONZEN_ITTAI = 304;
ABILITY_BULLY = 305;
ABILITY_MAINTENANCE = 306;
--ABILITY_WAR_SP2 = 307;
--ABILITY_MNK_SP2 = 308;
--ABILITY_ASYLUM = 309;
--ABILITY_SUBLTE_SORCERY = 310; --yes; subtle is misspelled
--ABILITY_RDM_SP2 = 311;
--ABILITY_THF_SP2 = 312;
--ABILITY_PLD_SP2 = 313;
--ABILITY_SOUL_ENSLAVEMENT = 314;
--ABILITY_BST_SP2 = 315;
--ABILITY_BRD_SP2 = 316;
--ABILITY_RNG_SP2 = 317;
--ABILITY_YAEGASUMI = 318;
--ABILITY_NIN_SP2 = 319;
--ABILITY_DSG_SP2 = 320;
--ABILITY_ASTRAL_CONDUIT = 321;
--ABILITY_UNBRIDLED_WISDOM = 322;
--ABILITY_COR_SP2 = 323;
--ABILITY_HEADY_ARTIFICE = 324;
--ABILITY_GRAND_PAS = 325;
--ABILITY_CAPER_EMISSARIUS = 326;
ABILITY_BOLSTER = 327;
ABILITY_FULL_CIRCLE = 329;
ABILITY_LASTING_EMANATION = 330;
ABILITY_ECLIPTIC_ATTRITION = 331;
ABILITY_COLLIMATED_FERVOR = 332;
ABILITY_LIFE_CYCLE = 333;
ABILITY_BLAZE_OF_GLORY = 334;
ABILITY_DEMATERIALIZE = 335;
ABILITY_THEURGIC_FOCUS = 336;
ABILITY_CONCENTRIC_PULSE = 337;
ABILITY_ELEMENTAL_SFORZO = 340;
ABILITY_RUNE_ENCHANTMENT = 341;
ABILITY_IGNIS = 342;
ABILITY_GELUS = 343;
ABILITY_FLABRA = 344;
ABILITY_TELLUS = 345;
ABILITY_SULPOR = 346;
ABILITY_UNDA = 347;
ABILITY_LUX = 348;
ABILITY_TENEBRAE = 349;
ABILITY_VALLATION = 350;
ABILITY_SWORDPLAY = 351;
ABILITY_LUNGE = 352;
ABILITY_PFLUG = 353;
ABILITY_EMBOLDEN = 354;
ABILITY_VALIANCE = 355;
ABILITY_GAMBIT = 356;
ABILITY_LIEMENT = 357;
ABILITY_ONE_FOR_ALL = 358;
ABILITY_WARD = 363;
ABILITY_EFFUSION = 364;
ABILITY_HEALING_RUBY = 496;
ABILITY_POISON_NAILS = 497;
ABILITY_SHINING_RUBY = 498;
ABILITY_GLITTERING_RUBY = 499;
ABILITY_METEORITE = 500;
ABILITY_HEALING_RUBY_II = 501;
ABILITY_SEARING_LIGHT = 502;
ABILITY_MOONLIT_CHARGE = 512;
ABILITY_CRESCENT_FANG = 513;
ABILITY_LUNAR_CRY = 514;
ABILITY_LUNAR_ROAR = 515;
ABILITY_ECLIPTIC_GROWL = 516;
ABILITY_ECLIPTIC_HOWL = 517;
ABILITY_ECLIPSE_BITE = 518;
ABILITY_HOWLING_MOON = 520;
ABILITY_PUNCH = 528;
ABILITY_FIRE_II = 529;
ABILITY_BURNING_STRIKE = 530;
ABILITY_DOUBLE_PUNCH = 531;
ABILITY_CRIMSON_HOWL = 532;
ABILITY_FIRE_IV = 533;
ABILITY_FLAMING_CRUSH = 534;
ABILITY_METEOR_STRIKE = 535;
ABILITY_INFERNO = 536;
ABILITY_ROCK_THROW = 544;
ABILITY_STONE_II = 545;
ABILITY_ROCK_BUSTER = 546;
ABILITY_MEGALITH_THROW = 547;
ABILITY_EARTHEN_WARD = 548;
ABILITY_STONE_IV = 549;
ABILITY_MOUNTAIN_BUSTER = 550;
ABILITY_GEOCRUSH = 551;
ABILITY_EARTHEN_FURY = 552;
ABILITY_BARRACUDA_DIVE = 560;
ABILITY_WATER_II = 561;
ABILITY_TAIL_WHIP = 562;
ABILITY_SLOWGA = 564;
ABILITY_SPRING_WATER = 563;
ABILITY_WATER_IV = 565;
ABILITY_SPINNING_DIVE = 566;
ABILITY_GRAND_FALL = 567;
ABILITY_TIDAL_WAVE = 568;
ABILITY_CLAW = 576;
ABILITY_AERO_II = 577;
ABILITY_WHISPERING_WIND = 578;
ABILITY_HASTEGA = 579;
ABILITY_AERIAL_ARMOR = 580;
ABILITY_AERO_IV = 581;
ABILITY_PREDATOR_CLAWS = 582;
ABILITY_WIND_BLADE = 583;
ABILITY_AERIAL_BLAST = 584;
ABILITY_AXE_KICK = 592;
ABILITY_BLIZZARD_II = 593;
ABILITY_FROST_ARMOR = 594;
ABILITY_SLEEPGA = 595;
ABILITY_DOUBLE_SLAP = 596;
ABILITY_BLIZZARD_IV = 597;
ABILITY_RUSH = 598;
ABILITY_HEAVENLY_STRIKE = 599;
ABILITY_DIAMOND_DUST = 600;
ABILITY_SHOCK_STRIKE = 608;
ABILITY_THUNDER_II = 609;
ABILITY_THUNDERSPARK = 611;
ABILITY_ROLLING_THUNDER = 610;
ABILITY_LIGHTNING_ARMOR = 612;
ABILITY_THUNDER_IV = 613;
ABILITY_CHAOTIC_STRIKE = 614;
ABILITY_THUNDERSTORM = 615;
ABILITY_JUDGMENT_BOLT = 616;
| gpl-3.0 |
ibm2431/darkstar | scripts/zones/Ghelsba_Outpost/bcnms/save_the_children.lua | 9 | 1619 | -----------------------------------
-- Save the Children
-- Ghelsba Outpost mission battlefield
-- !pos -162 -11 78 140
-----------------------------------
require("scripts/globals/battlefield")
require("scripts/globals/keyitems")
require("scripts/globals/missions")
require("scripts/globals/npc_util")
require("scripts/globals/titles")
-----------------------------------
function onBattlefieldTick(battlefield, tick)
dsp.battlefield.onBattlefieldTick(battlefield, tick)
end
function onBattlefieldRegister(player, battlefield)
end
function onBattlefieldEnter(player, battlefield)
end
function onBattlefieldLeave(player, battlefield, leavecode)
if leavecode == dsp.battlefield.leaveCode.WON then
local name, clearTime, partySize = battlefield:getRecord()
local arg8 = (player:hasCompletedMission(SANDORIA, dsp.mission.id.sandoria.SAVE_THE_CHILDREN)) and 1 or 0
player:startEvent(32001, battlefield:getArea(), clearTime, partySize, battlefield:getTimeInside(), 1, battlefield:getLocalVar("[cs]bit"), arg8)
elseif leavecode == dsp.battlefield.leaveCode.LOST then
player:startEvent(32002)
end
end
function onEventUpdate(player, csid, option)
end
function onEventFinish(player, csid, option)
if
csid == 32001 and
option == 0 and
player:getCurrentMission(SANDORIA) == dsp.mission.id.sandoria.SAVE_THE_CHILDREN and
player:getCharVar("MissionStatus") == 2
then
npcUtil.giveKeyItem(player, dsp.ki.ORCISH_HUT_KEY)
player:setTitle(dsp.title.FODDERCHIEF_FLAYER)
player:setCharVar("MissionStatus", 3)
end
end
| gpl-3.0 |
ibm2431/darkstar | scripts/globals/spells/tornado_ii.lua | 6 | 1270 | -----------------------------------------
-- Spell: Tornado II
-- Deals wind damage to an enemy and lowers its resistance against ice.
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/magic")
-----------------------------------------
function onMagicCastingCheck(caster, target, spell)
return 0
end
function onSpellCast(caster, target, spell)
local spellParams = {}
spellParams.hasMultipleTargetReduction = false
spellParams.resistBonus = 1.0
spellParams.V = 710
spellParams.V0 = 800
spellParams.V50 = 900
spellParams.V100 = 1000
spellParams.V200 = 1200
spellParams.M = 2
spellParams.M0 = 2
spellParams.M50 = 2
spellParams.M100 = 2
spellParams.M200 = 2
spellParams.I = 780
if (caster:getMerit(dsp.merit.TORNADO_II) ~= 0) then
spellParams.AMIIburstBonus = (caster:getMerit(dsp.merit.TORNADO_II) - 1) * 0.03
spellParams.AMIIaccBonus = (caster:getMerit(dsp.merit.TORNADO_II) - 1) * 5
end
-- no point in making a separate function for this if the only thing they won't have in common is the name
handleNinjutsuDebuff(caster,target,spell,30,10,dsp.mod.ICERES)
return doElementalNuke(caster, spell, target, spellParams)
end
| gpl-3.0 |
LegionXI/darkstar | scripts/zones/Port_Bastok/npcs/Oggbi.lua | 26 | 3415 | -----------------------------------
-- Area: Port Bastok
-- NPC: Oggbi
-- Starts and Finishes: Ghosts of the Past, The First Meeting
-- @zone 236
-- @pos -159 -7 5
-----------------------------------
package.loaded["scripts/zones/Port_Bastok/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
require("scripts/zones/Port_Bastok/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:getQuestStatus(BASTOK,GHOSTS_OF_THE_PAST) == QUEST_ACCEPTED) then
if (trade:hasItemQty(13122,1) and trade:getItemCount() == 1) then -- Trade Miner's Pendant
player:startEvent(0x00e8); -- Finish Quest "Ghosts of the Past"
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
ghostsOfThePast = player:getQuestStatus(BASTOK,GHOSTS_OF_THE_PAST);
theFirstMeeting = player:getQuestStatus(BASTOK,THE_FIRST_MEETING);
mLvl = player:getMainLvl();
mJob = player:getMainJob();
if (ghostsOfThePast == QUEST_AVAILABLE and mJob == 2 and mLvl >= 40) then
player:startEvent(0x00e7); -- Start Quest "Ghosts of the Past"
elseif (ghostsOfThePast == QUEST_COMPLETED and player:needToZone() == false and theFirstMeeting == QUEST_AVAILABLE and mJob == 2 and mLvl >= 50) then
player:startEvent(0x00e9); -- Start Quest "The First Meeting"
elseif (player:hasKeyItem(LETTER_FROM_DALZAKK) and player:hasKeyItem(SANDORIAN_MARTIAL_ARTS_SCROLL)) then
player:startEvent(0x00ea); -- Finish Quest "The First Meeting"
else
player:startEvent(0x00e6); -- 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 == 0x00e7) then
player:addQuest(BASTOK,GHOSTS_OF_THE_PAST);
elseif (csid == 0x00e8) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,17478); -- Beat Cesti
else
player:tradeComplete();
player:addItem(17478);
player:messageSpecial(ITEM_OBTAINED,17478); -- Beat Cesti
player:needToZone(true);
player:addFame(BASTOK,AF1_FAME);
player:completeQuest(BASTOK,GHOSTS_OF_THE_PAST);
end
elseif (csid == 0x00e9) then
player:addQuest(BASTOK,THE_FIRST_MEETING);
elseif (csid == 0x00ea) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,14090); -- Temple Gaiters
else
player:delKeyItem(LETTER_FROM_DALZAKK);
player:delKeyItem(SANDORIAN_MARTIAL_ARTS_SCROLL);
player:addItem(14090);
player:messageSpecial(ITEM_OBTAINED,14090); -- Temple Gaiters
player:addFame(BASTOK,AF2_FAME);
player:completeQuest(BASTOK,THE_FIRST_MEETING);
end
end
end; | gpl-3.0 |
LegionXI/darkstar | scripts/zones/Inner_Horutoto_Ruins/Zone.lua | 12 | 4654 | -----------------------------------
--
-- Zone: Inner_Horutoto_Ruins (192)
--
-----------------------------------
package.loaded["scripts/zones/Inner_Horutoto_Ruins/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Inner_Horutoto_Ruins/TextIDs");
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/zone");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
zone:registerRegion(1, -261, -1, -31, -257, 1, -27); -- Red
zone:registerRegion(2, -265, -1, -26, -261, 1, -22); -- White
zone:registerRegion(3, -258, -1, -26, -254, 1, -22); -- Black
zone:registerRegion(4, -261, -3, 182, -257, -1, 186); -- Teleport at H-6
UpdateTreasureSpawnPoint(17563914);
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
player:setPos(-259.996,6.399,242.859,67);
end
return cs;
end;
-----------------------------------
-- onConquestUpdate
-----------------------------------
function onConquestUpdate(zone, updatetype)
local players = zone:getPlayers();
for name, player in pairs(players) do
conquestUpdate(zone, player, updatetype, CONQUEST_BASE);
end
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
local circle= 17563861;
local red = GetNPCByID(circle);
local white = GetNPCByID(circle+1);
local black = GetNPCByID(circle+2);
-- Prevent negatives..
if (region:GetCount() < 0) then
region:AddCount( math.abs( region:GetCount() ) );
end
switch (region:GetRegionID()): caseof
{
[1] = function (x) -- Red Circle
if (player:getMainJob() == JOBS.RDM and region:AddCount(1) == 1) then
red:setAnimation(8);
if (white:getAnimation() == 8 and black:getAnimation() == 8) then
GetNPCByID(circle+3):openDoor(30);
GetNPCByID(circle+4):openDoor(30);
end
end
end,
[2] = function (x) -- White Circle
if (player:getMainJob() == JOBS.WHM and region:AddCount(1) == 1) then
white:setAnimation(8);
if (red:getAnimation() == 8 and black:getAnimation() == 8) then
GetNPCByID(circle+3):openDoor(30);
GetNPCByID(circle+4):openDoor(30);
end
end
end,
[3] = function (x) -- Black Circle
if (player:getMainJob() == JOBS.BLM and region:AddCount(1) == 1) then
black:setAnimation(8);
if (red:getAnimation() == 8 and white:getAnimation() == 8) then
GetNPCByID(circle+3):openDoor(30);
GetNPCByID(circle+4):openDoor(30);
end
end
end,
[4] = function (x) -- Teleport at H-6
player:setPos(-260,0,-21,65);
end,
}
end;
-----------------------------------
-- onRegionLeave
-----------------------------------
function onRegionLeave(player,region)
local circle= 17563860;
local red = GetNPCByID(circle);
local white = GetNPCByID(circle+1);
local black = GetNPCByID(circle+2);
switch (region:GetRegionID()): caseof
{
[1] = function (x) -- Red Circle
if (player:getMainJob() == JOBS.RDM and region:DelCount(1) == 0) then
red:setAnimation(9);
end
end,
[2] = function (x) -- White Circle
if (player:getMainJob() == JOBS.WHM and region:DelCount(1) == 0) then
white:setAnimation(9);
end
end,
[3] = function (x) -- Black Circle
if (player:getMainJob() == JOBS.BLM and region:DelCount(1) == 0) then
black:setAnimation(9);
end
end,
}
-- Prevent negatives..
if (region:GetCount() < 0) then
region:AddCount( math.abs( region:GetCount() ) );
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 |
greasydeal/darkstar | scripts/zones/Inner_Horutoto_Ruins/npcs/_5cb.lua | 6 | 1300 | -----------------------------------
-- Area: Inner Horutoto Ruins
-- NPC: _5cb (Gate of Darkness)
-- @pos -228 0 99 192
-----------------------------------
package.loaded["scripts/zones/Inner_Horutoto_Ruins/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Inner_Horutoto_Ruins/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if(player:getCurrentMission(WINDURST) == THE_JESTER_WHO_D_BE_KING and player:getVar("MissionStatus") == 9) then
player:startEvent(0x004B);
else
player:messageSpecial(DOOR_FIRMLY_CLOSED);
end
return 1;
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if(csid == 0x004B) then
player:setVar("MissionStatus",10)
end
end; | gpl-3.0 |
naclander/tome | game/engines/default/engine/dialogs/Chat.lua | 3 | 4648 | -- TE4 - T-Engine 4
-- Copyright (C) 2009 - 2014 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
require "engine.class"
local Dialog = require "engine.ui.Dialog"
local VariableList = require "engine.ui.VariableList"
local Textzone = require "engine.ui.Textzone"
local Separator = require "engine.ui.Separator"
local ActorFrame = require "engine.ui.ActorFrame"
module(..., package.seeall, class.inherit(Dialog))
show_portraits = false
function _M:init(chat, id)
self.cur_id = id
self.chat = chat
self.npc = chat.npc
self.player = chat.player
Dialog.init(self, self.npc.name, 500, 400)
local xoff = 0
if self.show_portraits then
xoff = 64
end
self:generateList()
self.c_desc = Textzone.new{width=self.iw - 10 - xoff, height=1, auto_height=true, text=self.text.."\n"}
self.c_list = VariableList.new{width=self.iw - 10 - xoff, max_height=game.h * 0.70 - self.c_desc.h, list=self.list, fct=function(item) self:use(item) end, select=function(item) self:select(item) end}
local uis = {
{left=0, top=0, ui=self.c_desc},
{left=0, bottom=0, ui=self.c_list},
{left=5, top=self.c_desc.h - 10, ui=Separator.new{dir="vertical", size=self.iw - 10}},
}
if self.show_portraits then
uis[#uis+1] = {right=0, top=0, ui=ActorFrame.new{actor=self.npc.chat_display_entity or self.npc, w=64, h=64}}
uis[#uis+1] = {left=0, bottom=0, ui=ActorFrame.new{actor=self.player.chat_display_entity or self.player, w=64, h=64}}
uis[2].left = nil uis[2].right = 0
uis[3].top = math.max(self.c_desc.h, uis[4].ui.h) + 5
end
self:loadUI(uis)
self:setFocus(self.c_list)
self:setupUI(false, true)
self.key:addCommands{
__TEXTINPUT = function(c)
if self.list and self.list.chars[c] then
self:use(self.list[self.list.chars[c]])
end
end,
}
end
function _M:on_register()
game:onTickEnd(function() self.key:unicodeInput(true) end)
end
function _M:select(item)
local a = self.chat:get(self.cur_id).answers[item.answer]
if not a then return end
if a.on_select then
a.on_select(self.npc, self.player, self)
end
end
function _M:use(item, a)
a = a or self.chat:get(self.cur_id).answers[item.answer]
if not a then return end
print("[CHAT] selected", a[1], a.action, a.jump)
if a.switch_npc then self.chat:switchNPC(a.switch_npc) end
if a.action then
local id = a.action(self.npc, self.player, self)
if id then
self.cur_id = id
self:regen()
return
end
end
if a.jump and not self.killed then
self.cur_id = a.jump
self:regen()
else
game:unregisterDialog(self)
return
end
end
function _M:regen()
local d = new(self.chat, self.cur_id)
d.__showup = false
game:replaceDialog(self, d)
self.next_dialog = d
end
function _M:resolveAuto()
--[[
if not self.chat:get(self.cur_id).auto then return end
for i, a in ipairs(self.chat:get(self.cur_id).answers) do
if not a.cond or a.cond(self.npc, self.player) then
if not self:use(nil, a) then return
else return self:resolveAuto()
end
end
end
]]
end
function _M:generateList()
self:resolveAuto()
-- Makes up the list
local list = { chars={} }
local nb = 1
for i, a in ipairs(self.chat:get(self.cur_id).answers) do
if not a.fallback and (not a.cond or a.cond(self.npc, self.player)) then
list[#list+1] = { name=string.char(string.byte('a')+nb-1)..") "..self.chat:replace(a[1]), answer=i, color=a.color}
list.chars[string.char(string.byte('a')+nb-1)] = #list
nb = nb + 1
end
end
if #list == 0 then
for i, a in ipairs(self.chat:get(self.cur_id).answers) do
if a.fallback and (not a.cond or a.cond(self.npc, self.player)) then
list[#list+1] = { name=string.char(string.byte('a')+nb-1)..") "..self.chat:replace(a[1]), answer=i, color=a.color}
list.chars[string.char(string.byte('a')+nb-1)] = #list
nb = nb + 1
end
end
end
self.list = list
self.text = self.chat:replace(self.chat:get(self.cur_id).text)
if self.chat:get(self.cur_id).action then
self.chat:get(self.cur_id).action(self.npc, self.player)
end
return true
end
| gpl-3.0 |
ibm2431/darkstar | scripts/zones/Waughroon_Shrine/bcnms/hills_are_alive.lua | 9 | 1072 | -----------------------------------
-- The Hills are Alive
-- Waughroon Shrine KSNM99, Themis Orb
-- !additem 1553
-----------------------------------
require("scripts/globals/battlefield")
-----------------------------------
function onBattlefieldInitialise(battlefield)
battlefield:setLocalVar("loot", 1)
end
function onBattlefieldTick(battlefield, tick)
dsp.battlefield.onBattlefieldTick(battlefield, tick)
end
function onBattlefieldRegister(player, battlefield)
end
function onBattlefieldEnter(player, battlefield)
end
function onBattlefieldLeave(player, battlefield, leavecode)
if leavecode == dsp.battlefield.leaveCode.WON then
local name, clearTime, partySize = battlefield:getRecord()
player:startEvent(32001, battlefield:getArea(), clearTime, partySize, battlefield:getTimeInside(), 1, battlefield:getLocalVar("[cs]bit"), 0)
elseif leavecode == dsp.battlefield.leaveCode.LOST then
player:startEvent(32002)
end
end
function onEventUpdate(player, csid, option)
end
function onEventFinish(player, csid, option)
end
| gpl-3.0 |
ibm2431/darkstar | scripts/zones/Mine_Shaft_2716/npcs/_0d0.lua | 9 | 1256 | -----------------------------------
-- Area: Mine_Shaft_2716
-- NPC: Shaft entrance
-----------------------------------
require("scripts/globals/bcnm");
require("scripts/globals/missions");
function onTrade(player,npc,trade)
if (player:getCurrentMission(COP) == dsp.mission.id.cop.THREE_PATHS and ( player:getCharVar("COP_Louverance_s_Path") == 7 or player:getCharVar("COP_Louverance_s_Path") == 8 )) then
if (trade:getItemCount() == 1 and trade:hasItemQty(1684,1)) then
player:startEvent(3);
end
else
TradeBCNM(player,npc,trade);
end
end;
function onTrigger(player,npc)
if (player:getCurrentMission(COP) == dsp.mission.id.cop.FIRE_IN_THE_EYES_OF_MEN and player:getCharVar("PromathiaStatus")==0) then
player:startEvent(4);
else
EventTriggerBCNM(player,npc);
end
end;
function onEventUpdate(player,csid,option,extras)
EventUpdateBCNM(player,csid,option,extras);
end;
function onEventFinish(player,csid,option)
if csid == 3 then
player:setCharVar("COP_Louverance_s_Path",9);
player:tradeComplete();
elseif csid == 4 then
player:setCharVar("PromathiaStatus",1);
else
EventFinishBCNM(player,csid,option);
end
end;
| gpl-3.0 |
greasydeal/darkstar | scripts/zones/Rabao/npcs/Guinavie.lua | 28 | 1788 | -----------------------------------
-- Area: Rabao
-- NPC: Guinavie
-- Chocobo Vendor
-----------------------------------
require("scripts/globals/chocobo");
require("scripts/globals/keyitems");
require("scripts/globals/settings");
require("scripts/globals/status");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local level = player:getMainLvl();
local gil = player:getGil();
if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 20) then
local price = getChocoboPrice(player);
player:setLocalVar("chocoboPriceOffer",price);
player:startEvent(0x004F,price,gil);
else
player:startEvent(0x0050);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
local price = player:getLocalVar("chocoboPriceOffer");
if (csid == 0x004F and option == 0) then
if (player:delGil(price)) then
updateChocoboPrice(player, price);
local duration = 1800 + (player:getMod(MOD_CHOCOBO_RIDING_TIME) * 60)
player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,duration,true);
player:setPos(420,8,360,0x40,0x7D);
end
end
end; | gpl-3.0 |
LegionXI/darkstar | scripts/zones/West_Ronfaure/npcs/Aaveleon.lua | 14 | 1533 | -----------------------------------
-- Area: West Ronfaure
-- NPC: Aaveleon
-- Involved in Quest: A Sentry's Peril
-- @pos -431 -45 343 100
-----------------------------------
package.loaded["scripts/zones/West_Ronfaure/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/quests");
require("scripts/zones/West_Ronfaure/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:getQuestStatus(SANDORIA,A_SENTRY_S_PERIL) == QUEST_ACCEPTED) then
if (trade:hasItemQty(600,1) and trade:getItemCount() == 1) then
player:startEvent(0x0064);
else
player:startEvent(118);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x0065);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0064) then
player:tradeComplete();
player:addItem(601);
player:messageSpecial(ITEM_OBTAINED,601);
end
end;
| gpl-3.0 |
greasydeal/darkstar | scripts/globals/items/purple_polypore.lua | 36 | 1156 | -----------------------------------------
-- ID: 5682
-- Item: Purple Polypore
-- Food Effect: 5 Min, All Races
-----------------------------------------
-- Strength -6
-- Mind +4
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,14400,5156);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_STR, -6);
target:addMod(MOD_MND, 4);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_STR, -6);
target:delMod(MOD_MND, 4);
end;
| gpl-3.0 |
greasydeal/darkstar | scripts/zones/Tavnazian_Safehold/npcs/_0qa.lua | 17 | 2001 | -----------------------------------
-- Area: Tavnazian Safehold
-- NPC: walnut door
-- Involved in mission 2-4
-- @pos 111 -41 41 26
-----------------------------------
package.loaded["scripts/zones/Tavnazian_Safehold/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/keyitems");
require("scripts/globals/missions");
require("scripts/zones/Tavnazian_Safehold/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if(player:getCurrentMission(COP) == AN_ETERNAL_MELODY and player:getVar("PromathiaStatus") == 0)then
player:startEvent(0x0068);
elseif(player:getCurrentMission(COP) == THE_SECRETS_OF_WORSHIP and player:getVar("PromathiaStatus") == 0) then
player:startEvent(0x006F);
elseif(player:getCurrentMission(COP) == CHAINS_AND_BONDS and player:getVar("PromathiaStatus")==4)then
player:startEvent(0x0073);
elseif(player:getCurrentMission(COP) == DAWN and player:getVar("PromathiaStatus")==5)then
player:startEvent(0x021F);
end
return 1;
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if(csid == 0x0068 or csid == 0x006F)then
player:setVar("PromathiaStatus",1);
elseif(csid == 0x0073)then
player:setVar("PromathiaStatus",0);
player:completeMission(COP,CHAINS_AND_BONDS);
player:addMission(COP,FLAMES_IN_THE_DARKNESS);
elseif(csid == 0x021F)then
player:setVar("PromathiaStatus",6);
end
end; | gpl-3.0 |
LegionXI/darkstar | scripts/zones/Kuftal_Tunnel/mobs/Phantom_Worm.lua | 23 | 1639 | -----------------------------------
-- Area: Kuftal Tunnel (173)
-- Mob: Phantom Worm
-----------------------------------
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
end;
-----------------------------------
-- onMobDespawn
-----------------------------------
function onMobDespawn(mob)
local npc = GetNPCByID(17490253);
npc:updateNPCHideTime(FORCE_SPAWN_QM_RESET_TIME);
local randpos = math.random(1,16);
switch (randpos): caseof
{
[1] = function (x) npc:setPos(75.943,29.969,118.854); end,
[2] = function (x) npc:setPos(75.758,30.000,125.815); end,
[3] = function (x) npc:setPos(65.222,29.364,131.645); end,
[4] = function (x) npc:setPos(53.088,25.033,138.725); end,
[5] = function (x) npc:setPos(85.658,30.155,123.941); end,
[6] = function (x) npc:setPos(91.153,30.146,113.657); end,
[7] = function (x) npc:setPos(86.549,29.875,107.232); end,
[8] = function (x) npc:setPos(94.763,29.054,105.138); end,
[9] = function (x) npc:setPos(102.719,26.751,102.816); end,
[10] = function (x) npc:setPos(71.571,30.241,110.704); end,
[11] = function (x) npc:setPos(65.642,28.018,99.2442); end,
[12] = function (x) npc:setPos(62.090,25.421,93.4702); end,
[13] = function (x) npc:setPos(60.740,22.638,86.1781); end,
[14] = function (x) npc:setPos(80.460,30.293,112.721); end,
[15] = function (x) npc:setPos(76.929,30.050,127.630); end,
[16] = function (x) npc:setPos(68.810,30.175,123.516); end,
}
end; | gpl-3.0 |
Igalia/snabbswitch | lib/ljndpi/ndpi/wrap.lua | 10 | 3898 | #! /usr/bin/env luajit
--
-- wrap.lua
-- Copyright (C) 2016-2017 Adrian Perez <aperez@igalia.com>
--
-- Distributed under terms of the Apache License 2.0.
--
local ndpi_c = require("ndpi.c")
local lib_version, lib = ndpi_c.version, ndpi_c.lib
local ffi = require("ffi")
local C = ffi.C
---------------------------------------------------------- Identifier ------
local id_struct_ptr_t = ffi.typeof("ndpi_id_t*")
local id_struct_size = lib.ndpi_detection_get_sizeof_ndpi_id_struct()
local function id_new(ctype)
local id = ffi.cast(id_struct_ptr_t, C.malloc(id_struct_size))
ffi.fill(id, id_struct_size)
return id
end
local id_type = ffi.metatype("ndpi_id_t", {
__new = id_new;
__gc = C.free;
})
---------------------------------------------------------------- Flow ------
local flow_struct_ptr_t = ffi.typeof("ndpi_flow_t*")
local flow_struct_size = lib.ndpi_detection_get_sizeof_ndpi_flow_struct()
local function flow_new(ctype)
local flow = ffi.cast(flow_struct_ptr_t, C.malloc(flow_struct_size))
ffi.fill(flow, flow_struct_size)
return flow
end
local flow_type = ffi.metatype("ndpi_flow_t", {
__new = flow_new;
__gc = lib.ndpi_free_flow;
})
---------------------------------------------------- Detection Module ------
local detection_module_free, detection_module_new
local detection_module = {
load_protocols_file = function (self, path)
if lib.ndpi_load_protocols_file(self, path) ~= 0 then
error("Unable to open file '" .. path .. "'")
end
return self -- Allow chaining calls
end;
set_protocol_bitmask = function (self, bitmask)
lib.ndpi_set_protocol_detection_bitmask2(self, bitmask)
return self -- Allow chaining calls
end;
process_packet = function (...)
local proto = lib.ndpi_detection_process_packet(...)
return proto.master_protocol, proto.protocol
end;
guess_undetected_protocol = function (...)
local proto = lib.ndpi_guess_undetected_protocol(...)
return proto.master_protocol, proto.protocol
end;
get_protocol_id = function (...)
local ret = lib.ndpi_get_protocol_id(...)
return (ret == -1) and nil or ret
end;
get_protocol_breed_name = lib.ndpi_get_proto_breed_name;
get_protocol_breed = lib.ndpi_get_proto_breed;
dump_protocols = lib.ndpi_dump_protocols;
}
if lib_version.minor == 7 then
detection_module_free = function (dm)
lib.ndpi_exit_detection_module(ffi.gc(dm, nil), C.free)
end
detection_module_new = function (ctype, ticks_per_second)
return lib.ndpi_init_detection_module(ticks_per_second, C.malloc, C.free, nil)
end
detection_module.find_port_based_protocol = function (...)
local proto = lib.ndpi_find_port_based_protocol(...)
return proto.master_protocol, proto.protocol
end
else
detection_module_free = lib.ndpi_exit_detection_module
detection_module_new = function (ctype, ticks_per_second)
-- XXX: No ticks_per_second parameter here?
return lib.ndpi_init_detection_module()
end
-- In nDPI 1.8 the second parameter (uint8_t proto) has been dropped.
detection_module.find_port_based_protocol = function (dm, dummy, ...)
local proto = lib.ndpi_find_port_based_protocol(dm, ...)
return proto.master_protocol, proto.protocol
end
end
local detection_module_type = ffi.metatype("ndpi_detection_module_t", {
__index = detection_module;
__new = detection_module_new;
__gc = detection_module_free;
})
------------------------------------------------------------- Exports ------
return {
lib_version = lib_version;
id = id_type;
flow = flow_type;
detection_module = detection_module_type;
protocol_bitmask = require("ndpi.protocol_bitmask").bitmask;
protocol = require("ndpi.protocol_ids_" .. lib_version.major .. "_" .. lib_version.minor);
}
| apache-2.0 |
LegionXI/darkstar | scripts/zones/Batallia_Downs/Zone.lua | 11 | 3985 | -----------------------------------
--
-- Zone: Batallia_Downs (105)
--
-----------------------------------
package.loaded[ "scripts/zones/Batallia_Downs/TextIDs"] = nil;
package.loaded["scripts/globals/chocobo_digging"] = nil;
-----------------------------------
require( "scripts/zones/Batallia_Downs/TextIDs");
require("scripts/globals/zone");
require( "scripts/globals/icanheararainbow");
require("scripts/globals/chocobo_digging");
-----------------------------------
-- Chocobo Digging vars
-----------------------------------
local itemMap = {
-- itemid, abundance, requirement
{ 847, 69, DIGREQ_NONE },
{ 880, 137, DIGREQ_NONE },
{ 845, 4, DIGREQ_NONE },
{ 640, 82, DIGREQ_NONE },
{ 768, 133, DIGREQ_NONE },
{ 643, 82, DIGREQ_NONE },
{ 17296, 137, DIGREQ_NONE },
{ 774, 26, DIGREQ_NONE },
{ 106, 69, DIGREQ_NONE },
{ 4449, 3, DIGREQ_NONE },
{ 4096, 100, DIGREQ_NONE }, -- all crystals
{ 656, 106, DIGREQ_BURROW },
{ 748, 8, DIGREQ_BURROW },
{ 749, 30, DIGREQ_BURROW },
{ 750, 136, DIGREQ_BURROW },
{ 1237, 30, DIGREQ_BORE },
{ 2235, 60, DIGREQ_BORE },
{ 2364, 150, DIGREQ_BORE },
{ 4570, 10, DIGREQ_MODIFIER },
{ 4487, 11, DIGREQ_MODIFIER },
{ 4409, 12, DIGREQ_MODIFIER },
{ 1188, 10, DIGREQ_MODIFIER },
{ 4532, 12, DIGREQ_MODIFIER },
};
local messageArray = { DIG_THROW_AWAY, FIND_NOTHING, ITEM_OBTAINED };
-----------------------------------
-- onChocoboDig
-----------------------------------
function onChocoboDig(player, precheck)
return chocoboDig(player, itemMap, precheck, messageArray);
end;
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
-- Ahtu
SetRespawnTime(17207657, 900, 10800);
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn( player, prevZone)
local cs = -1;
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
player:setPos( -693.609, -14.583, 173.59, 30);
end
if (triggerLightCutscene(player)) then -- Quest: I Can Hear A Rainbow
cs = 0x0385;
elseif (player:getCurrentMission(WINDURST) == VAIN and player:getVar("MissionStatus") ==1) then
cs = 0x0387;
end
return cs;
end;
-----------------------------------
-- onConquestUpdate
-----------------------------------
function onConquestUpdate(zone, updatetype)
local players = zone:getPlayers();
for name, player in pairs(players) do
conquestUpdate(zone, player, updatetype, CONQUEST_BASE);
end
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter( player, region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate( player, csid, option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0385) then
lightCutsceneUpdate(player); -- Quest: I Can Hear A Rainbow
end
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish( player, csid, option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0385) then
lightCutsceneFinish(player); -- Quest: I Can Hear A Rainbow
elseif (csid == 0x0387) then
if (player:getZPos() > -331) then
player:updateEvent(0,0,0,0,0,3);
else
player:updateEvent(0,0,0,0,0,2);
end
end
end; | gpl-3.0 |
greasydeal/darkstar | scripts/zones/Lower_Jeuno/npcs/Derrick.lua | 12 | 4331 | -----------------------------------
-- Area: Lower Jeuno
-- NPC: Derrick
-- Involved in Quests and finish : Save the Clock Tower
-- @zone 245
-- @pos -32 -1 -7
-----------------------------------
package.loaded["scripts/zones/Lower_Jeuno/TextIDs"] = nil;
package.loaded["scripts/globals/settings"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/shop");
require("scripts/globals/quests");
require("scripts/zones/Lower_Jeuno/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
TotalNPC = player:getVar("saveTheClockTowerNPCz1") + player:getVar("saveTheClockTowerNPCz2");
if(TotalNPC == 1023 and trade:hasItemQty(555,1) == true and trade:getItemCount() == 1) then
player:startEvent(0x00e7); -- Ending quest "save the clock tower"
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
AirshipKI = player:hasKeyItem(AIRSHIP_PASS);
saveTheClockTower = player:getQuestStatus(JEUNO,SAVE_THE_CLOCK_TOWER);
NPCNumber = player:getVar("saveTheClockTowerVar"); -- Quest step & number of npc
AgreeSignPetition = player:getVar("saveTheClockTowerVar2"); -- Sum of all NPC
if(AirshipKI == false and saveTheClockTower == QUEST_ACCEPTED and NPCNumber >= 1 and NPCNumber <= 11) then
player:startEvent(0x00e6,4,10); -- airship + petition help/restart
elseif(AirshipKI == true and saveTheClockTower == QUEST_ACCEPTED and NPCNumber >= 1 and NPCNumber <= 11) then
player:startEvent(0x00e6,6,10); -- petition help/restart
elseif(AirshipKI == false and saveTheClockTower == QUEST_ACCEPTED and NPCNumber == 0) then
player:startEvent(0x00e6,8,10); -- airship + petition
elseif(AirshipKI == true and saveTheClockTower == QUEST_ACCEPTED and NPCNumber == 0) then
player:startEvent(0x00e6,10,10); -- petition
elseif(AirshipKI == false) then
player:startEvent(0x00e6,12); -- airship
else
player:startEvent(0x00e6,14); -- rien
end
end;
-----------------------------------
-- onEventUpdate Action
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x00e6 and option == 10) then
if (player:delGil(500000)) then
player:addKeyItem(AIRSHIP_PASS);
player:updateEvent(0, 1);
else
player:updateEvent(0, 0);
end
end
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x00e6 and option == 10) then
if (player:hasKeyItem(AIRSHIP_PASS) == true) then
player:messageSpecial(KEYITEM_OBTAINED,AIRSHIP_PASS);
end
elseif(csid == 0x00e6 and option == 20) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,555);
else
player:addItem(555);
player:messageSpecial(ITEM_OBTAINED,555);
player:setVar("saveTheClockTowerVar",1);
player:setVar("saveTheClockTowerNPCz1",0);
player:setVar("saveTheClockTowerNPCz2",0);
end
elseif(csid == 0x00e6 and option == 30) then
if(player:hasItem(555) == true) then
player:messageSpecial(ITEM_OBTAINED,555);
player:setVar("saveTheClockTowerVar",1);
player:setVar("saveTheClockTowerNPCz1",0);
player:setVar("saveTheClockTowerNPCz2",0);
else
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,555);
else
player:addItem(555);
player:messageSpecial(ITEM_OBTAINED,555);
player:setVar("saveTheClockTowerVar",1);
player:setVar("saveTheClockTowerNPCz1",0);
player:setVar("saveTheClockTowerNPCz2",0);
end
end
elseif(csid == 0x00e7) then
player:setVar("saveTheClockTowerVar",0);
player:setVar("saveTheClockTowerNPCz1",0);
player:setVar("saveTheClockTowerNPCz2",0);
player:addTitle(CLOCK_TOWER_PRESERVATIONIST);
player:addFame(JEUNO, JEUNO_FAME*30);
player:tradeComplete(trade);
player:completeQuest(JEUNO,SAVE_THE_CLOCK_TOWER);
end
end;
| gpl-3.0 |
GENRALVS/GENRAL-VS | plugins/msg_checks.lua | 1 | 11546 | --[[
โโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโ โโ โโ โโ
โโ โโ BY xx_hetler_xx โโ โโ
โโ โโ BY hetler (hetler_ip) โโ โโ
โโ โโ JUST WRITED BY hetler โโ โโ
โโ โโ โโ โโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
--]]
--Begin msg_checks.lua
--Begin pre_process function
local function pre_process(msg)
-- Begin 'RondoMsgChecks' text checks by @rondoozle
if is_chat_msg(msg) or is_super_group(msg) then
if msg and not is_momod(msg) and not is_whitelisted(msg.from.id) then --if regular user
local data = load_data(_config.moderation.data)
local print_name = user_print_name(msg.from):gsub("โฎ", "") -- get rid of rtl in names
local name_log = print_name:gsub("_", " ") -- name for log
local to_chat = msg.to.type == 'chat'
if data[tostring(msg.to.id)] and data[tostring(msg.to.id)]['settings'] then
settings = data[tostring(msg.to.id)]['settings']
else
return
end
if settings.lock_arabic then
lock_arabic = settings.lock_arabic
else
lock_arabic = 'no'
end
if settings.lock_rtl then
lock_rtl = settings.lock_rtl
else
lock_rtl = 'no'
end
if settings.lock_tgservice then
lock_tgservice = settings.lock_tgservice
else
lock_tgservice = 'no'
end
if settings.lock_link then
lock_link = settings.lock_link
else
lock_link = 'no'
end
if settings.lock_member then
lock_member = settings.lock_member
else
lock_member = 'no'
end
if settings.lock_spam then
lock_spam = settings.lock_spam
else
lock_spam = 'no'
end
if settings.lock_sticker then
lock_sticker = settings.lock_sticker
else
lock_sticker = 'no'
end
if settings.lock_contacts then
lock_contacts = settings.lock_contacts
else
lock_contacts = 'no'
end
if settings.strict then
strict = settings.strict
else
strict = 'no'
end
if msg and not msg.service and is_muted(msg.to.id, 'All: yes') or is_muted_user(msg.to.id, msg.from.id) and not msg.service then
delete_msg(msg.id, ok_cb, false)
if to_chat then
-- kick_user(msg.from.id, msg.to.id)
end
end
if msg.text then -- msg.text checks
local _nl, ctrl_chars = string.gsub(msg.text, '%c', '')
local _nl, real_digits = string.gsub(msg.text, '%d', '')
if lock_spam == "yes" and string.len(msg.text) > 2049 or ctrl_chars > 40 or real_digits > 2000 then
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
delete_msg(msg.id, ok_cb, false)
kick_user(msg.from.id, msg.to.id)
end
end
local is_link_msg = msg.text:match("[Tt][Ee][Ll][Ee][Gg][Rr][Aa][Mm].[Mm][Ee]/") or msg.text:match("[Tt][Ll][Gg][Rr][Mm].[Mm][Ee]/")
local is_bot = msg.text:match("?[Ss][Tt][Aa][Rr][Tt]=")
if is_link_msg and lock_link == "yes" and not is_bot then
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
kick_user(msg.from.id, msg.to.id)
end
end
if msg.service then
if lock_tgservice == "yes" then
delete_msg(msg.id, ok_cb, false)
if to_chat then
return
end
end
end
local is_squig_msg = msg.text:match("[\216-\219][\128-\191]")
if is_squig_msg and lock_arabic == "yes" then
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
kick_user(msg.from.id, msg.to.id)
end
end
local print_name = msg.from.print_name
local is_rtl = print_name:match("โฎ") or msg.text:match("โฎ")
if is_rtl and lock_rtl == "yes" then
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
kick_user(msg.from.id, msg.to.id)
end
end
if is_muted(msg.to.id, "Text: yes") and msg.text and not msg.media and not msg.service then
delete_msg(msg.id, ok_cb, false)
if to_chat then
kick_user(msg.from.id, msg.to.id)
end
end
end
if msg.media then -- msg.media checks
if msg.media.title then
local is_link_title = msg.media.title:match("[Tt][Ee][Ll][Ee][Gg][Rr][Aa][Mm].[Mm][Ee]/") or msg.media.title:match("[Tt][Ll][Gg][Rr][Mm].[Mm][Ee]/")
if is_link_title and lock_link == "yes" then
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
kick_user(msg.from.id, msg.to.id)
end
end
local is_squig_title = msg.media.title:match("[\216-\219][\128-\191]")
if is_squig_title and lock_arabic == "yes" then
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
kick_user(msg.from.id, msg.to.id)
end
end
end
if msg.media.description then
local is_link_desc = msg.media.description:match("[Tt][Ee][Ll][Ee][Gg][Rr][Aa][Mm].[Mm][Ee]/") or msg.media.description:match("[Tt][Ll][Gg][Rr][Mm].[Mm][Ee]/")
if is_link_desc and lock_link == "yes" then
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
kick_user(msg.from.id, msg.to.id)
end
end
local is_squig_desc = msg.media.description:match("[\216-\219][\128-\191]")
if is_squig_desc and lock_arabic == "yes" then
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
kick_user(msg.from.id, msg.to.id)
end
end
end
if msg.media.caption then -- msg.media.caption checks
local is_link_caption = msg.media.caption:match("[Tt][Ee][Ll][Ee][Gg][Rr][Aa][Mm].[Mm][Ee]/") or msg.media.caption:match("[Tt][Ll][Gg][Rr][Mm].[Mm][Ee]/")
if is_link_caption and lock_link == "yes" then
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
kick_user(msg.from.id, msg.to.id)
end
end
local is_squig_caption = msg.media.caption:match("[\216-\219][\128-\191]")
if is_squig_caption and lock_arabic == "yes" then
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
kick_user(msg.from.id, msg.to.id)
end
end
local is_username_caption = msg.media.caption:match("^@[%a%d]")
if is_username_caption and lock_link == "yes" then
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
kick_user(msg.from.id, msg.to.id)
end
end
if lock_sticker == "yes" and msg.media.caption:match("sticker.webp") then
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
kick_user(msg.from.id, msg.to.id)
end
end
end
if msg.media.type:match("contact") and lock_contacts == "yes" then
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
kick_user(msg.from.id, msg.to.id)
end
end
local is_photo_caption = msg.media.caption and msg.media.caption:match("photo")--".jpg",
if is_muted(msg.to.id, 'Photo: yes') and msg.media.type:match("photo") or is_photo_caption and not msg.service then
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
-- kick_user(msg.from.id, msg.to.id)
end
end
local is_gif_caption = msg.media.caption and msg.media.caption:match(".mp4")
if is_muted(msg.to.id, 'Gifs: yes') and is_gif_caption and msg.media.type:match("document") and not msg.service then
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
-- kick_user(msg.from.id, msg.to.id)
end
end
if is_muted(msg.to.id, 'Audio: yes') and msg.media.type:match("audio") and not msg.service then
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
kick_user(msg.from.id, msg.to.id)
end
end
local is_video_caption = msg.media.caption and msg.media.caption:lower(".mp4","video")
if is_muted(msg.to.id, 'Video: yes') and msg.media.type:match("video") and not msg.service then
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
kick_user(msg.from.id, msg.to.id)
end
end
if is_muted(msg.to.id, 'Documents: yes') and msg.media.type:match("document") and not msg.service then
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
kick_user(msg.from.id, msg.to.id)
end
end
end
if msg.fwd_from then
if msg.fwd_from.title then
local is_link_title = msg.fwd_from.title:match("[Tt][Ee][Ll][Ee][Gg][Rr][Aa][Mm].[Mm][Ee]/") or msg.fwd_from.title:match("[Tt][Ll][Gg][Rr][Mm].[Mm][Ee]/")
if is_link_title and lock_link == "yes" then
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
kick_user(msg.from.id, msg.to.id)
end
end
local is_squig_title = msg.fwd_from.title:match("[\216-\219][\128-\191]")
if is_squig_title and lock_arabic == "yes" then
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
kick_user(msg.from.id, msg.to.id)
end
end
end
if is_muted_user(msg.to.id, msg.fwd_from.peer_id) then
delete_msg(msg.id, ok_cb, false)
end
end
if msg.service then -- msg.service checks
local action = msg.action.type
if action == 'chat_add_user_link' then
local user_id = msg.from.id
local _nl, ctrl_chars = string.gsub(msg.text, '%c', '')
if string.len(msg.from.print_name) > 70 or ctrl_chars > 40 and lock_group_spam == 'yes' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] joined and Service Msg deleted (#spam name)")
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] joined and kicked (#spam name)")
kick_user(msg.from.id, msg.to.id)
end
end
local print_name = msg.from.print_name
local is_rtl_name = print_name:match("โฎ")
if is_rtl_name and lock_rtl == "yes" then
savelog(msg.to.id, name_log.." User ["..msg.from.id.."] joined and kicked (#RTL char in name)")
kick_user(user_id, msg.to.id)
end
if lock_member == 'yes' then
savelog(msg.to.id, name_log.." User ["..msg.from.id.."] joined and kicked (#lockmember)")
kick_user(user_id, msg.to.id)
delete_msg(msg.id, ok_cb, false)
end
end
if action == 'chat_add_user' and not is_momod2(msg.from.id, msg.to.id) then
local user_id = msg.action.user.id
if string.len(msg.action.user.print_name) > 70 and lock_group_spam == 'yes' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] added ["..user_id.."]: Service Msg deleted (#spam name)")
delete_msg(msg.id, ok_cb, false)
if strict == "yes" or to_chat then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] added ["..user_id.."]: added user kicked (#spam name) ")
delete_msg(msg.id, ok_cb, false)
kick_user(msg.from.id, msg.to.id)
end
end
local print_name = msg.action.user.print_name
local is_rtl_name = print_name:match("โฎ")
if is_rtl_name and lock_rtl == "yes" then
savelog(msg.to.id, name_log.." User ["..msg.from.id.."] added ["..user_id.."]: added user kicked (#RTL char in name)")
kick_user(user_id, msg.to.id)
end
if msg.to.type == 'channel' and lock_member == 'yes' then
savelog(msg.to.id, name_log.." User ["..msg.from.id.."] added ["..user_id.."]: added user kicked (#lockmember)")
kick_user(user_id, msg.to.id)
delete_msg(msg.id, ok_cb, false)
end
end
end
end
end
-- End 'RondoMsgChecks' text checks by @Rondoozle
return msg
end
--End pre_process function
return {
patterns = {},
pre_process = pre_process
}
--End msg_checks.lua
--By @Rondoozle
| gpl-2.0 |
greasydeal/darkstar | scripts/zones/Ghoyus_Reverie/Zone.lua | 36 | 1119 | -----------------------------------
--
-- Zone: Ghoyus_Reverie
--
-----------------------------------
require("scripts/globals/settings");
package.loaded["scripts/zones/Ghoyus_Reverie/TextIDs"] = nil;
require("scripts/zones/Ghoyus_Reverie/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 |
LegionXI/darkstar | scripts/zones/Horlais_Peak/npcs/Hot_springs.lua | 9 | 1978 | -----------------------------------
-- Area: Northern San d'Oria
-- NPC: Hot Springs
-- @zone 139
-- @pos 444 -37 -18
-----------------------------------
package.loaded["scripts/zones/Horlais_Peak/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/settings");
require("scripts/zones/Horlais_Peak/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:getQuestStatus(OUTLANDS,SECRET_OF_THE_DAMP_SCROLL) == QUEST_ACCEPTED and trade:hasItemQty(1210,1) and trade:getItemCount() == 1) then
player:startEvent(0x0002,1210);
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getQuestStatus(SANDORIA,THE_GENERAL_S_SECRET) == 1) and (player:hasKeyItem(CURILLAS_BOTTLE_EMPTY) == true) then
player:addKeyItem(CURILLAS_BOTTLE_FULL)
player:messageSpecial(KEYITEM_OBTAINED,CURILLAS_BOTTLE_FULL);
player:delKeyItem(CURILLAS_BOTTLE_EMPTY);
else
player:messageSpecial(NOTHING_OUT_OF_ORDINARY);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0002) then
player:tradeComplete();
player:addItem(4949); -- Scroll of Jubaku: Ichi
player:messageSpecial(ITEM_OBTAINED, 4949);
player:addFame(NORG,75);
player:addTitle(CRACKER_OF_THE_SECRET_CODE);
player:completeQuest(OUTLANDS,SECRET_OF_THE_DAMP_SCROLL);
end
end; | gpl-3.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.