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 |
|---|---|---|---|---|---|
ibm2431/darkstar | scripts/zones/Lower_Jeuno/npcs/Yoskolo.lua | 12 | 1247 | -----------------------------------
-- Area: Lower Jeuno
-- NPC: Yoskolo
-- Standard Merchant NPC
-----------------------------------
local ID = require("scripts/zones/Lower_Jeuno/IDs")
require("scripts/globals/shop")
function onTrade(player,npc,trade)
end
function onTrigger(player,npc)
local stock =
{
4509, 10, -- Distilled Water
4422, 184, -- Orange Juice
4423, 276, -- Apple Juice
4424, 1012, -- Melon Juice
4441, 855, -- Grape Juice
4442, 368, -- Pineapple Juice
4556, 5544, -- Icecap Rolanberry
5046, 6380, -- Scroll of Fire Carol
5047, 7440, -- Scroll of Ice Carol
5048, 5940, -- Scroll of Wind Carol
5049, 4600, -- Scroll of Earth Carol
5050, 7920, -- Scroll of Lightning Carol
5051, 5000, -- Scroll of Water Carol
5052, 4200, -- Scroll of Light Carol
5053, 8400, -- Scroll of Dark Carol
5078, 60000, -- Scroll of Sentinel's Scherzo
}
player:showText(npc, ID.text.YOSKOLO_SHOP_DIALOG)
dsp.shop.general(player, stock)
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
end
| gpl-3.0 |
ricker75/Global-Server | data/spells/scripts/attack/curse.lua | 27 | 1206 | local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_SMALLCLOUDS)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
local condition = createConditionObject(CONDITION_CURSED)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 1, 3000, -45)
addDamageCondition(condition, 1, 3000, -40)
addDamageCondition(condition, 1, 3000, -35)
addDamageCondition(condition, 1, 3000, -34)
addDamageCondition(condition, 2, 3000, -33)
addDamageCondition(condition, 2, 3000, -32)
addDamageCondition(condition, 2, 3000, -31)
addDamageCondition(condition, 2, 3000, -30)
addDamageCondition(condition, 3, 3000, -29)
addDamageCondition(condition, 3, 3000, -25)
addDamageCondition(condition, 3, 3000, -24)
addDamageCondition(condition, 4, 3000, -23)
addDamageCondition(condition, 4, 3000, -20)
addDamageCondition(condition, 5, 3000, -19)
addDamageCondition(condition, 5, 3000, -15)
addDamageCondition(condition, 6, 3000, -10)
addDamageCondition(condition, 10, 3000, -5)
setCombatCondition(combat, condition)
function onCastSpell(cid, var)
return doCombat(cid, combat, var)
end | gpl-2.0 |
naclander/tome | game/modules/tome/data/maps/tutorial/tutorial1.lua | 3 | 4920 | -- 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
startx = 49
starty = 24
defineTile("&", "TREE", nil, nil, nil)
defineTile(")", "GRASS", {random_filter={name="ash longbow"}}, nil, nil)
defineTile("s", "GRASS", nil, "TUTORIAL_NPC_MAGE", nil)
defineTile(",", "GRASS", nil, nil, nil)
defineTile("S", "GRASS", nil, {random_filter={type="animal", subtype="snake", max_ood=2}}, nil)
defineTile("T", "GRASS", nil, "TUTORIAL_NPC_TROLL", nil)
defineTile("L", "GRASS", nil, "TUTORIAL_NPC_LONE_WOLF", nil)
defineTile("1", "GRASS", nil, nil, "TUTORIAL_MELEE")
defineTile("|", "GRASS", {random_filter={name="quiver of elm arrows"}}, nil, nil)
defineTile("2", "GRASS", {random_filter={name="regeneration infusion"}}, nil, "TUTORIAL_OBJECTS")
defineTile("3", "GRASS", nil, nil, "TUTORIAL_TALENTS")
defineTile("4", "GRASS", nil, nil, "TUTORIAL_LEVELUP")
defineTile("~", "DEEP_WATER", nil, nil, nil)
defineTile("5", "DEEP_WATER", nil, nil, "TUTORIAL_TERRAIN")
defineTile("6", "GRASS", nil, nil, "TUTORIAL_TACTICS1")
defineTile("7", "GRASS", nil, nil, "TUTORIAL_TACTICS2")
defineTile("8", "GRASS", nil, nil, "TUTORIAL_RANGED")
defineTile("9", "GRASS", nil, nil, "TUTORIAL_QUESTS")
defineTile("j", "GRASS", nil, {random_filter={type="immovable", subtype="jelly", max_ood=2}}, nil)
defineTile(" ", "DEEP_WATER", nil, {random_filter={type="immovable", subtype="jelly", max_ood=2}}, nil)
defineTile("!", "GRASS", {random_filter={name="healing infusion"}}, nil, nil)
defineTile('"', "DEEP_WATER", nil, {random_filter={type="immovable", subtype="jelly", max_ood=2}}, nil)
defineTile("#", "DEEP_WATER", {random_filter={name="shielding rune"}}, nil, nil)
return [[
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&~&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&~~&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&~~&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&~~&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&~~&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&~~~,,,&&&&&&&&
&&&&&&&&&,,,,,&&&&&&&&&&&&&&&&&&~~&&~~~&&,,,&&&&&&
&&&&&&&&,T,,,,,,,,,,,,&&&&&&&&&&~~~~~~~&&&&,&&&&&&
&&&&&&&&,T,,,,,,,,,,,,,&&&&&&&&&~~~~~~&&&&&,&&&&&&
&&&&&&&&,T,,T,,,,,,,,,,&&&&&&&&&~~~&~~&&&&&,&&&&&&
&&&&&&&,,,,,T,,,,,,,,,,,&&&&&&&&&~~~~&&&s&,,&&&&&&
&&&&&&&,,T,,T,,,,,,,,,,,,,,&&&&&,~&~~&&&,,,,&&&&&&
&&&&&&&&,T,,,,,,,,,,,,,,,&,&&&,,,~~~~&&,,,,,!&&&&&
&&&&&&&&,T,,,,,,,,,,,,,,&&,|)8,&&&~~&&&&,,,,,&&&&&
&&&&&&&&,,,,,,,,,,,,,,,&&&&&&&&&&&&&&&&&,,,,,&&&&&
&&&&&&&&&,,,,,,,,,,,,,&&&&&&&&&&,,,,,,,,7,,,&&&&&&
&&&&&&&&&&&&&&,,,,,&&&&&&&&&&&&,,&&&&&&&,,,,&&&&&&
&&&&&&&&&&&&&&&,&&&&&&&&&&&&&&,,&&&&&&&&,,,&&&&&&&
&&&&&&&&&&&&&&&,&&&&&&&&&&&&&,,&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&,&&&&&&&&&&&&&,&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&9&&&&&&&&&&&&&,&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&,,&&&&&&&&&&&&,,&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&,,&&&&&&&&&&&&&,&&&&&&&&,,,,,,,&&&&&&
&&&&&&&&&&&&&,&&&&&&&&&&&&&&,&&&&&&&,,j,,,,,,&&&&&
&&&&&&&&&&&&&,&&&&&&&&&&&&&&,&&&&&&,,,2,,,,,,1,,,,
&&&&&&&&&,,,,,,&&&&&&&&&&&&&,&&&,,,,,,j,,,,,&&&&&&
&&&&&&&&,,,,,,,,&&&&&&&&&&&&,&&&,&&&,,,,,,,,&&&&&&
&&&&&&&&,,,,,&,,,&&&&&&&&&&&,&&&,&&&&,,,,,,&&&&&&&
&&&&&&&,,&,,,,,,,,&&&&&&&&&&,&&&,&&&&&&&&&&&&&&&&&
&&&&&,,,,,,,,,&&,&,,&&&&&&&,,&&&,,&&&&&&&&&&&&&&&&
&&&&&&,,&,,,,,,,,,&,,&&&&&&,&&&&&,,&&&&&&&&&&&&&&&
&&&&&,,,,,,&&,,,,&,,&&&&&SSS&&&&&&,,,&&&&&&&&&&&&&
&&&&&&,,,,,,,,,,&,&&&&&&SSSSSS&&&&&&,,,&&&&&&&&&&&
&&&&&&,,&,&,,&&,,,&&&&&&SSSSSSS&&&&&&&,,j,j3,,&&&&
&&&&&&&,,,,,,&&&,&&&&&&SSSSSSSS&&&&&&&&&&&&&&j,&&&
&&&&&&&&,L,,,,,,,,&&&&&SSSSSS,,&&&&&&&&&&&&&&&,&&&
&&&&&&&,,,,,,&&&&&&&&&&&SSS,,,,&&&&&&&&&&&&&&&,,&&
&&&&&&&&&&&&&&&&&&&&&&&SS,,,!,&&&&&&&&&&&&&&&&&4&&
&&&&&&&&&&&&&&&&&&&&&&&&,,,,,,&&&&&&&&&~~~&&&&&,,&
&&&&&&&&&&&&&&&&&&&&&&&&&,,,,,&&&&&&&&&~~~~~&&&&j&
&&&&&&&&&&&&&&&&&&&&&&&&&&,,,&&&&&&&&~~~~&~~ &&,,&
&&&&&&&&&&&&&&&&&&&&&&&&&&&6&&&&&&&&&~~~&&&~~~5,&&
&&&&&&&&&&&&&&&&&&&&&&&&&,,,&&&&&&,,,,~~~&~~~~&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&,&&&&&&&&,&&&~~~~~~"~&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&,,,&&&&&&,&&&&~~~~~~&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&,,&&&&,,&&&&&&&~~~&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&,,,,,,&&&&&&&&&~&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&,&&&&&&&&&&&&~&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&#&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&]]
| gpl-3.0 |
ibm2431/darkstar | scripts/zones/Aht_Urhgan_Whitegate/npcs/Shahau.lua | 12 | 1159 | -----------------------------------
-- Area: Aht Urhgan Whitegate
-- NPC: Shahau
-- Type: Alchemy Image Support
-- !pos -10.470 -6.25 -141.700 241
-----------------------------------
local ID = require("scripts/zones/Aht_Urhgan_Whitegate/IDs")
require("scripts/globals/status")
require("scripts/globals/crafting")
-----------------------------------
function onTrade(player,npc,trade)
end
function onTrigger(player,npc)
local guildMember = isGuildMember(player,1)
local SkillLevel = player:getSkillLevel(dsp.skill.ALCHEMY)
if guildMember == 1 then
if player:hasStatusEffect(dsp.effect.ALCHEMY_IMAGERY) == false then
player:startEvent(638,4,SkillLevel,2,511,0,0,7,2184)
else
player:startEvent(638,4,SkillLevel,2,511,5662,7154,7,2184)
end
else
player:startEvent(638,0,0,0,0,0,0,7,0) -- Standard Dialogue
end
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
if csid == 638 and option == 1 then
player:messageSpecial(ID.text.IMAGE_SUPPORT,0,7,2)
player:addStatusEffect(dsp.effect.ALCHEMY_IMAGERY,1,0,120)
end
end | gpl-3.0 |
LegionXI/darkstar | scripts/zones/Abyssea-Attohwa/npcs/qm4.lua | 9 | 1341 | -----------------------------------
-- Zone: Abyssea-Attohwa
-- NPC: qm4 (???)
-- Spawns Kharon
-- @pos ? ? ? 215
-----------------------------------
require("scripts/globals/status");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
--[[
if (trade:hasItemQty(3076,1) and trade:getItemCount() == 1) then -- Player has all the required items.
if (GetMobAction(17658265) == ACTION_NONE) then -- Mob not already spawned from this
SpawnMob(17658265):updateClaim(player); -- Spawn NM, Despawn after inactive for 5 minutes (pt has to reclaim within 5 of a wipe)
player:tradeComplete();
end
end
]]
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(1010, 3076); -- Inform player what items they need.
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/globals/weaponskills/knights_of_round.lua | 10 | 1784 | -----------------------------------
-- Knights Of Round
-- Sword Weapon Skill
-- Skill Level: N/A
-- Caliburn/Excalibur: Additional Effect: Regen.
-- Regen 10HP/Tick, duration varies with TP.
-- Available only when equipped with the Relic Weapons Caliburn (Dynamis use only) or Excalibur.
-- Also available without aftermath as a latent effect on Corbenic Sword.
-- Aligned with the Flame Gorget & Light Gorget.
-- Aligned with the Flame Belt & Light Belt.
-- Element: None
-- Modifiers: STR:40% MND:40%
-- 100%TP 200%TP 300%TP
-- 3.00 3.00 3.00
-----------------------------------
require("scripts/globals/aftermath")
require("scripts/globals/settings")
require("scripts/globals/status")
require("scripts/globals/weaponskills")
-----------------------------------
function onUseWeaponSkill(player, target, wsID, tp, primary, action, taChar)
local params = {}
params.numHits = 1
params.ftp100 = 3 params.ftp200 = 3 params.ftp300 = 3
params.str_wsc = 0.4 params.dex_wsc = 0.0 params.vit_wsc = 0.0 params.agi_wsc = 0.0 params.int_wsc = 0.0 params.mnd_wsc = 0.4 params.chr_wsc = 0.0
params.crit100 = 0.0 params.crit200 = 0.0 params.crit300 = 0.0
params.canCrit = false
params.acc100 = 0.0 params.acc200 = 0.0 params.acc300 = 0.0
params.atk100 = 1; params.atk200 = 1; params.atk300 = 1;
if USE_ADOULIN_WEAPON_SKILL_CHANGES then
params.ftp100 = 5 params.ftp200 = 5 params.ftp300 = 5
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, params, tp, action, primary, taChar)
-- Apply aftermath
if damage > 0 then
dsp.aftermath.addStatusEffect(player, tp, dsp.slot.MAIN, dsp.aftermath.type.RELIC)
end
return tpHits, extraHits, criticalHit, damage
end
| gpl-3.0 |
ibm2431/darkstar | scripts/zones/Temple_of_Uggalepih/IDs.lua | 9 | 4614 | -----------------------------------
-- Area: Temple_of_Uggalepih
-----------------------------------
require("scripts/globals/zone")
-----------------------------------
zones = zones or {}
zones[dsp.zone.TEMPLE_OF_UGGALEPIH] =
{
text =
{
NOTHING_HAPPENS = 119, -- Nothing happens...
ITEM_CANNOT_BE_OBTAINED = 6382, -- You cannot obtain the <item>. Come back after sorting your inventory.
ITEM_OBTAINED = 6388, -- Obtained: <item>.
GIL_OBTAINED = 6389, -- Obtained <number> gil.
KEYITEM_OBTAINED = 6391, -- Obtained key item: <keyitem>.
NOTHING_OUT_OF_ORDINARY = 6402, -- There is nothing out of the ordinary here.
CONQUEST_BASE = 7049, -- Tallying conquest results...
FISHING_MESSAGE_OFFSET = 7208, -- You can't fish here.
CHEST_UNLOCKED = 7316, -- You unlock the chest!
NO_REASON_TO_INVESTIGATE = 7324, -- There is no reason to investigate further.
THE_BOX_IS_LOCKED = 7325, -- The box is locked.
PAINTBRUSH_OFFSET = 7328, -- When the <keyitem> projects the deepest, darkest corner of your soul onto the blank canvas...only then will the doors to rancor open.
FALLS_FROM_THE_BOOK = 7338, -- <item> falls from the book!
THE_DOOR_IS_LOCKED = 7352, -- The door is locked. You might be able to open it with <item>.
PROTECTED_BY_UNKNOWN_FORCE = 7353, -- The door is protected by some unknown force.
YOUR_KEY_BREAKS = 7355, -- Your <item> breaks!
DOOR_LOCKED = 7373, -- The door is locked.
HATE_RESET = 7426, -- The built-up hate has been cleansed...!
DOOR_SHUT = 7428, -- The door is firmly shut.
NO_HATE = 7429, -- You have no built-up hate to cleanse.
SOME_SORT_OF_CEREMONY = 7445, -- Some sort of ceremony was performed here...
NM_OFFSET = 7495, -- It looks like some sort of device. A thin thread leads down to the floor...
IT_IS_A_BEEHIVE = 7499, -- It is a beehive...
BITS_OF_VEGETABLE = 7500, -- Bits of vegetable matter are strewn around. They appear to have been gnawed on by insects...
SENSE_OMINOUS_PRESENCE = 7502, -- You sense an ominous presence...
PLAYER_OBTAINS_ITEM = 8437, -- <name> obtains <item>!
UNABLE_TO_OBTAIN_ITEM = 8438, -- You were unable to obtain the item.
PLAYER_OBTAINS_TEMP_ITEM = 8439, -- <name> obtains the temporary item: <item>!
ALREADY_POSSESS_TEMP = 8440, -- You already possess that temporary item.
NO_COMBINATION = 8445, -- You were unable to enter a combination.
REGIME_REGISTERED = 10523, -- New training regime registered!
COMMON_SENSE_SURVIVAL = 11583, -- It appears that you have arrived at a new survival guide provided by the Adventurers' Mutual Aid Network. Common sense dictates that you should now be able to teleport here from similar tomes throughout the world.
},
mob =
{
SOZU_SARBERRY_PH =
{
[17428551] = 17428554, -- 89 0.499 -23
},
SOZU_TERBERRY_PH =
{
[17428608] = 17428611, -- -122 0.028 -13
},
TONBERRY_KINQ_PH =
{
[17428673] = 17428677, -- -221.717 0.996 12.819
[17428675] = 17428677 -- -218 -0.792 24
},
FLAUROS_PH =
{
[17428740] = 17428737, -- 259 0.03 80
},
TEMPLE_GUARDIAN = 17428494,
NIO_A = 17428495,
NIO_HUM = 17428496,
MIMIC = 17428497,
SOZU_ROGBERRY = 17428751,
CLEUVARION_M_RESOAIX = 17428807,
ROMPAULION_S_CITALLE = 17428808,
BERYL_FOOTED_MOLBERRY = 17428809,
DEATH_FROM_ABOVE = 17428810,
HABETROT = 17428811,
CRIMSON_TOOTHED_PAWBERRY = 17428813,
SACRIFICIAL_GOBLET = 17428816,
YALLERY_BROWN = 17428817,
},
npc =
{
CASKET_BASE = 17428875,
PLONGEUR_MONBERRY = 17428933,
BOOK_OFFSET = 17428973,
TEMPLE_GUARDIAN_DOOR = 17428978,
DOOR_TO_RANCOR = 17428989,
TREASURE_COFFER = 17429007,
},
}
return zones[dsp.zone.TEMPLE_OF_UGGALEPIH] | gpl-3.0 |
naclander/tome | game/modules/example_realtime/class/Actor.lua | 3 | 8501 | -- ToME - Tales of Middle-Earth
-- 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"
require "engine.Actor"
require "engine.Autolevel"
require "engine.interface.ActorTemporaryEffects"
require "engine.interface.ActorLife"
require "engine.interface.ActorProject"
require "engine.interface.ActorLevel"
require "engine.interface.ActorStats"
require "engine.interface.ActorTalents"
require "engine.interface.ActorResource"
require "engine.interface.ActorFOV"
require "mod.class.interface.Combat"
local Map = require "engine.Map"
module(..., package.seeall, class.inherit(
engine.Actor,
engine.interface.ActorTemporaryEffects,
engine.interface.ActorLife,
engine.interface.ActorProject,
engine.interface.ActorLevel,
engine.interface.ActorStats,
engine.interface.ActorTalents,
engine.interface.ActorResource,
engine.interface.ActorFOV,
mod.class.interface.Combat
))
function _M:init(t, no_default)
-- Define some basic combat stats
self.combat_armor = 0
-- Default regen
t.power_regen = t.power_regen or 1
t.life_regen = t.life_regen or 0.25 -- Life regen real slow
-- Default melee barehanded damage
self.combat = { dam=1 }
engine.Actor.init(self, t, no_default)
engine.interface.ActorTemporaryEffects.init(self, t)
engine.interface.ActorLife.init(self, t)
engine.interface.ActorProject.init(self, t)
engine.interface.ActorTalents.init(self, t)
engine.interface.ActorResource.init(self, t)
engine.interface.ActorStats.init(self, t)
engine.interface.ActorLevel.init(self, t)
engine.interface.ActorFOV.init(self, t)
end
function _M:act()
if not engine.Actor.act(self) then return end
self.changed = true
-- Cooldown talents
self:cooldownTalents()
-- Regen resources
self:regenLife()
self:regenResources()
-- Compute timed effects
self:timedEffects()
-- Still enough energy to act ?
if self.energy.value < game.energy_to_act then return false end
return true
end
function _M:move(x, y, force)
local moved = false
local ox, oy = self.x, self.y
if force or self:enoughEnergy() then
moved = engine.Actor.move(self, x, y, force)
if not force and moved and (self.x ~= ox or self.y ~= oy) and not self.did_energy then self:useEnergy(game.energy_to_act * 0.3) end
end
self.did_energy = nil
return moved
end
function _M:tooltip()
return ([[%s%s
#00ffff#Level: %d
#ff0000#HP: %d (%d%%)
Stats: %d / %d / %d
%s]]):format(
self:getDisplayString(),
self.name,
self.level,
self.life, self.life * 100 / self.max_life,
self:getStr(),
self:getDex(),
self:getCon(),
self.desc or ""
)
end
function _M:onTakeHit(value, src)
return value
end
function _M:die(src)
engine.interface.ActorLife.die(self, src)
-- Gives the killer some exp for the kill
if src and src.gainExp then
src:gainExp(self:worthExp(src))
end
return true
end
function _M:levelup()
self.max_life = self.max_life + 2
self:incMaxPower(3)
-- Heal upon new level
self.life = self.max_life
self.power = self.max_power
end
--- Notifies a change of stat value
function _M:onStatChange(stat, v)
if stat == self.STAT_CON then
self.max_life = self.max_life + 2
end
end
function _M:attack(target)
self:bumpInto(target)
end
--- Called before a talent is used
-- Check the actor can cast it
-- @param ab the talent (not the id, the table)
-- @return true to continue, false to stop
function _M:preUseTalent(ab, silent)
if not self:enoughEnergy() then print("fail energy") return false end
if ab.mode == "sustained" then
if ab.sustain_power and self.max_power < ab.sustain_power and not self:isTalentActive(ab.id) then
game.logPlayer(self, "You do not have enough power to activate %s.", ab.name)
return false
end
else
if ab.power and self:getPower() < ab.power then
game.logPlayer(self, "You do not have enough power to cast %s.", ab.name)
return false
end
end
if not silent then
-- Allow for silent talents
if ab.message ~= nil then
if ab.message then
game.logSeen(self, "%s", self:useTalentMessage(ab))
end
elseif ab.mode == "sustained" and not self:isTalentActive(ab.id) then
game.logSeen(self, "%s activates %s.", self.name:capitalize(), ab.name)
elseif ab.mode == "sustained" and self:isTalentActive(ab.id) then
game.logSeen(self, "%s deactivates %s.", self.name:capitalize(), ab.name)
else
game.logSeen(self, "%s uses %s.", self.name:capitalize(), ab.name)
end
end
return true
end
--- Called before a talent is used
-- Check if it must use a turn, mana, stamina, ...
-- @param ab the talent (not the id, the table)
-- @param ret the return of the talent action
-- @return true to continue, false to stop
function _M:postUseTalent(ab, ret)
if not ret then return end
self:useEnergy()
if ab.mode == "sustained" then
if not self:isTalentActive(ab.id) then
if ab.sustain_power then
self.max_power = self.max_power - ab.sustain_power
end
else
if ab.sustain_power then
self.max_power = self.max_power + ab.sustain_power
end
end
else
if ab.power then
self:incPower(-ab.power)
end
end
return true
end
--- Return the full description of a talent
-- You may overload it to add more data (like power usage, ...)
function _M:getTalentFullDescription(t)
local d = {}
if t.mode == "passive" then d[#d+1] = "#6fff83#Use mode: #00FF00#Passive"
elseif t.mode == "sustained" then d[#d+1] = "#6fff83#Use mode: #00FF00#Sustained"
else d[#d+1] = "#6fff83#Use mode: #00FF00#Activated"
end
if t.power or t.sustain_power then d[#d+1] = "#6fff83#Power cost: #7fffd4#"..(t.power or t.sustain_power) end
if self:getTalentRange(t) > 1 then d[#d+1] = "#6fff83#Range: #FFFFFF#"..self:getTalentRange(t)
else d[#d+1] = "#6fff83#Range: #FFFFFF#melee/personal"
end
if t.cooldown then d[#d+1] = "#6fff83#Cooldown: #FFFFFF#"..t.cooldown end
return table.concat(d, "\n").."\n#6fff83#Description: #FFFFFF#"..t.info(self, t)
end
--- How much experience is this actor worth
-- @param target to whom is the exp rewarded
-- @return the experience rewarded
function _M:worthExp(target)
if not target.level or self.level < target.level - 3 then return 0 end
local mult = 2
if self.unique then mult = 6
elseif self.egoed then mult = 3 end
return self.level * mult * self.exp_worth
end
--- Can the actor see the target actor
-- This does not check LOS or such, only the actual ability to see it.<br/>
-- Check for telepathy, invisibility, stealth, ...
function _M:canSee(actor, def, def_pct)
if not actor then return false, 0 end
-- Check for stealth. Checks against the target cunning and level
if actor:attr("stealth") and actor ~= self then
local def = self.level / 2 + self:getCun(25)
local hit, chance = self:checkHit(def, actor:attr("stealth") + (actor:attr("inc_stealth") or 0), 0, 100)
if not hit then
return false, chance
end
end
if def ~= nil then
return def, def_pct
else
return true, 100
end
end
--- Can the target be applied some effects
-- @param what a string describing what is being tried
function _M:canBe(what)
if what == "poison" and rng.percent(100 * (self:attr("poison_immune") or 0)) then return false end
if what == "cut" and rng.percent(100 * (self:attr("cut_immune") or 0)) then return false end
if what == "confusion" and rng.percent(100 * (self:attr("confusion_immune") or 0)) then return false end
if what == "blind" and rng.percent(100 * (self:attr("blind_immune") or 0)) then return false end
if what == "stun" and rng.percent(100 * (self:attr("stun_immune") or 0)) then return false end
if what == "fear" and rng.percent(100 * (self:attr("fear_immune") or 0)) then return false end
if what == "knockback" and rng.percent(100 * (self:attr("knockback_immune") or 0)) then return false end
if what == "instakill" and rng.percent(100 * (self:attr("instakill_immune") or 0)) then return false end
return true
end
| gpl-3.0 |
LegionXI/darkstar | scripts/zones/Port_Jeuno/npcs/Challoux.lua | 17 | 1132 | -----------------------------------
-- Area: Port Jeuno
-- NPC: Challoux
-- Standard Merchant NPC
-----------------------------------
require("scripts/globals/shop");
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)
player:showText(npc,CHALLOUX_SHOP_DIALOG);
stock = {0x11C1,62, --Gysahl Greens
0x0348,4, --Chocobo Feather
0x439B,9} --Dart
showShop(player, STATIC, stock);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
greasydeal/darkstar | scripts/globals/items/felicifruit.lua | 36 | 1158 | -----------------------------------------
-- ID: 5964
-- Item: Felicifruit
-- Food Effect: 5Min, All Races
-----------------------------------------
-- Agility -7
-- Intelligence 5
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,300,5964);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_AGI, -7);
target:addMod(MOD_INT, 5);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_AGI, -7);
target:delMod(MOD_INT, 5);
end;
| gpl-3.0 |
LegionXI/darkstar | scripts/zones/Temenos/mobs/Goblin_Slaughterman.lua | 23 | 1065 | -----------------------------------
-- Area: Temenos N T
-- NPC: Goblin_Slaughterman
-----------------------------------
package.loaded["scripts/zones/Temenos/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/limbus");
require("scripts/zones/Temenos/TextIDs");
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
end;
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
local mobID = mob:getID();
-- print(mobID);
local mobX = mob:getXPos();
local mobY = mob:getYPos();
local mobZ = mob:getZPos();
if (mobID ==16928773) then
GetNPCByID(16928768+18):setPos(330,70,468);
GetNPCByID(16928768+18):setStatus(STATUS_NORMAL);
elseif (mobID ==16928772) then
GetNPCByID(16928770+450):setStatus(STATUS_NORMAL);
end
end;
| gpl-3.0 |
greasydeal/darkstar | scripts/zones/Port_San_dOria/npcs/_6g7.lua | 20 | 1144 | -----------------------------------
-- Area: Port San d'Oria
-- NPC: Door: Arrivals Entrance
-- @zone 232
-- @pos -24 -8 15
-----------------------------------
package.loaded["scripts/zones/Port_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/zones/Port_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if(player:getZPos() >= 12) then
player:startEvent(0x0206);
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);
end;
| gpl-3.0 |
LegionXI/darkstar | scripts/zones/Port_Windurst/npcs/Sattsuh_Ahkanpari.lua | 17 | 1565 | -----------------------------------
-- Area: Port Windurst
-- NPC: Sattsuh Ahkanpari
-- Regional Marchant NPC
-- Only sells when Windurst controlls Elshimo Uplands
-- Confirmed shop stock, August 2013
-----------------------------------
require("scripts/globals/shop");
require("scripts/globals/conquest");
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)
RegionOwner = GetRegionOwner(ELSHIMOUPLANDS);
if (RegionOwner ~= NATION_WINDURST) then
player:showText(npc,SATTSUHAHKANPARI_CLOSED_DIALOG);
else
player:showText(npc,SATTSUHAHKANPARI_OPEN_DIALOG);
stock = {
0x0585, 1656, --Cattleya
0x0274, 239, --Cinnamon
0x1174, 73, --Pamamas
0x02d1, 147 --Rattan Lumber
}
showShop(player,WINDURST,stock);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
naclander/tome | game/modules/tome/data/texts/tutorial/stats-calc/calc5.lua | 3 | 1092 | -- 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
return [[
There's an orc ahead with some prodigous health regeneration.
Compare your #LIGHT_GREEN#Accuracy#WHITE# and #LIGHT_GREEN#Defense#WHITE# to its #LIGHT_GREEN#Defense#WHITE# and #LIGHT_GREEN#Accuracy#WHITE#.
Do you expect to be successful attacking it?
Do you expect it to be successful attacking you?
]]
| gpl-3.0 |
naclander/tome | game/modules/tome/data/chats/arena-start.lua | 3 | 6688 | -- 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
--[[
local give_boots_rush = function(self, player)
local o = game.zone:makeEntityByName(game.level, "object", "ARENA_BOOTS_RUSH")
if o then
o:identify(true)
player:addObject(player.INVEN_INVEN, o)
game.zone:addEntity(game.level, o, "object")
game.level.arena.perk = "Rush"..game.level.arena.modeString
end
end
local give_boots_phas = function(self, player)
local o = game.zone:makeEntityByName(game.level, "object", "ARENA_BOOTS_PHAS")
if o then
o:identify(true)
player:addObject(player.INVEN_INVEN, o)
game.zone:addEntity(game.level, o, "object")
game.level.arena.perk = "Phasing"..game.level.arena.modeString
end
end
local give_boots_dise = function(self, player)
local o = game.zone:makeEntityByName(game.level, "object", "ARENA_BOOTS_DISE")
if o then
o:identify(true)
player:addObject(player.INVEN_INVEN, o)
game.zone:addEntity(game.level, o, "object")
game.level.arena.perk = "Disengage"..game.level.arena.modeString
end
end
local give_boots_lspeed = function(self, player)
local o = game.zone:makeEntityByName(game.level, "object", "ARENA_BOOTS_LSPEED")
if o then
o:identify(true)
player:addObject(player.INVEN_INVEN, o)
game.zone:addEntity(game.level, o, "object")
game.level.arena.perk = "LSpeed"..game.level.arena.modeString
end
end
local give_bow = function(self, player)
local o = game.zone:makeEntityByName(game.level, "object", "ARENA_BOW")
if o then
o:identify(true)
player:addObject(player.INVEN_INVEN, o)
game.zone:addEntity(game.level, o, "object")
game.level.arena.perk = "Bow"..game.level.arena.modeString
end
end
local give_sling = function(self, player)
local o = game.zone:makeEntityByName(game.level, "object", "ARENA_SLING")
if o then
o:identify(true)
player:addObject(player.INVEN_INVEN, o)
game.zone:addEntity(game.level, o, "object")
game.level.arena.perk = "Sling"..game.level.arena.modeString
end
end
local give_healinfu = function(self, player)
local o = game.zone:makeEntity(game.level, "object", {name="healing infusion"}, 1, true)
if o then
o:identify(true)
o.inscription_data.heal = 350
o.inscription_data.cooldown = o.inscription_data.cooldown + 5
player:addObject(player.INVEN_INVEN, o)
game.zone:addEntity(game.level, o, "object")
game.level.arena.perk = "Heal"..game.level.arena.modeString
end
end
local give_moveinfu = function(self, player)
local o = game.zone:makeEntity(game.level, "object", {name="movement infusion"}, 1, true)
if o then
o:identify(true)
player:addObject(player.INVEN_INVEN, o)
o.inscription_data.dur = o.inscription_data.dur + 2
game.zone:addEntity(game.level, o, "object")
game.level.arena.perk = "Move"..game.level.arena.modeString
end
end
local give_imbue = function(self, player)
player:learnTalent(player.T_IMBUE_ITEM, true, 4, {no_unlearn=true})
player.changed = true
game.level.arena.perk = "Imbue"..game.level.arena.modeString
end
local give_debugarms = function(self, player)
local debugarms = { "ARENA_DEBUG_CANNON", "ARENA_DEBUG_ARMOR", "BARRAGE", "RAPTOR", "ARENA_BOOTS_JUMPING", "WARDING", "HEATEATER", "PRISM" }
local o
for i = 0, #debugarms do
o = game.zone:makeEntityByName(game.level, "object", debugarms[i])
if o then
o:identify(true)
player:addObject(player.INVEN_INVEN, o)
game.zone:addEntity(game.level, o, "object")
end
end
game.level.arena.perk = "Debug"..game.level.arena.modeString
end
]]--
local arena_3 = function(self, player)
game.level.arena.eventWave = 2
game.level.arena.finalWave = 3
game.level.arena.modeString = "3"
local arenashop = game:getStore("ARENA_SHOP")
arenashop:loadup(game.level, game.zone)
arenashop:interact(game.player, "Gladiator's wares")
arenashop = nil
end
local arena_30 = function(self, player)
game.level.arena.eventWave = 5
game.level.arena.finalWave = 31
game.level.arena.modeString = "30"
local arenashop = game:getStore("ARENA_SHOP")
arenashop:loadup(game.level, game.zone)
arenashop:interact(game.player, "Gladiator's wares")
arenashop = nil
end
local arena_60 = function(self, player)
game.level.arena.eventWave = 5
game.level.arena.finalWave = 61
game.level.arena.modeString = "60"
local arenashop = game:getStore("ARENA_SHOP")
arenashop:loadup(game.level, game.zone)
arenashop:interact(game.player, "Gladiator's wares")
arenashop = nil
end
local give_bonus = function(self, player)
game.level.arena.bonusMin = 1.1
game.level.arena.bonusMultiplier = 1.1
game.level.arena.perk = "None"..game.level.arena.modeString
end
local save_clear = function(self, player)
world.arena = nil
if not world.arena then
local emptyScore = {name = nil, score = 0, perk = nil, wave = 1, sex = nil, race = nil, class = nil}
world.arena = {
master30 = nil,
master60 = nil,
lastScore = emptyScore,
bestWave = 1,
ver = 1
}
world.arena.scores = {[1] = emptyScore}
end
local o = game.zone:makeEntityByName(game.level, "object", "ARENA_SCORING")
if o then game.zone:addEntity(game.level, o, "object", 7, 3) end
local arenashop = game:getStore("ARENA_SHOP")
arenashop:loadup(game.level, game.zone)
arenashop:interact(game.player, "Gladiator's wares")
arenashop = nil
end
newChat{ id="welcome",
text = "#LIGHT_GREEN#You take a look at the ranking boards before entering.\n"..text,
answers = {
--{"Enter the arena for 3 rounds[DEBUG]", action=arena_3, jump="perks"},
{"Enter the arena (60 waves)", action=arena_60},
{"Enter the arena (shorter mode, 30 rounds)", action=arena_30},
--{"Enter the arena for as long as you can last", action=arena_inf, jump="perks"},
{"#LIGHT_RED#[Reset all arena save data]", action=save_clear},
}
}
newChat{ id="welcome2",
text = "What will you do now?",
answers = {
{"Enter the arena for 60 rounds", action=arena_60},
{"Enter the arena for 30 rounds", action=arena_30},
--{"Enter the arena for as long as you can last", action=arena_inf, jump="perks"},
}
}
return "welcome" | gpl-3.0 |
ibm2431/darkstar | scripts/zones/Aht_Urhgan_Whitegate/npcs/Isdebaaq.lua | 11 | 2577 | -----------------------------------
-- Area: Aht Urhgan Whitegate
-- NPC: Isdebaaq
-- Type: Assault Mission Giver
-- !pos 127.565 0.161 -43.846 50
-----------------------------------
require("scripts/globals/keyitems")
local ID = require("scripts/zones/Aht_Urhgan_Whitegate/IDs")
require("scripts/globals/besieged")
require("scripts/globals/missions")
require("scripts/globals/npc_util")
-----------------------------------
function onTrade(player,npc,trade)
end
function onTrigger(player,npc)
local rank = dsp.besieged.getMercenaryRank(player)
local haveimperialIDtag
local assaultPoints = player:getAssaultPoint(MAMOOL_ASSAULT_POINT)
if (player:hasKeyItem(dsp.ki.IMPERIAL_ARMY_ID_TAG)) then
haveimperialIDtag = 1
else
haveimperialIDtag = 0
end
--[[ if (rank > 0) then
player:startEvent(274,rank,haveimperialIDtag,assaultPoints,player:getCurrentAssault())
else]]
player:startEvent(280) -- no rank
--end
end
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
if (csid == 274) then
local selectiontype = bit.band(option, 0xF)
if (selectiontype == 1) then
-- taken assault mission
player:addAssault(bit.rshift(option,4))
player:delKeyItem(dsp.ki.IMPERIAL_ARMY_ID_TAG)
player:addKeyItem(dsp.ki.MAMOOL_JA_ASSAULT_ORDERS)
player:messageSpecial(ID.text.KEYITEM_OBTAINED,dsp.ki.MAMOOL_JA_ASSAULT_ORDERS)
elseif (selectiontype == 2) then
-- purchased an item
local item = bit.rshift(option,14)
local itemID = 0
local price = 0
local items =
{
[1] = {itemid = 15971, price = 3000},
[2] = {itemid = 15776, price = 5000},
[3] = {itemid = 15522, price = 8000},
[4] = {itemid = 15885, price = 10000},
[5] = {itemid = 15491, price = 10000},
[6] = {itemid = 17715, price = 15000},
[7] = {itemid = 18113, price = 15000},
[8] = {itemid = 17591, price = 15000},
[9] = {itemid = 14935, price = 20000},
[10] = {itemid = 15688, price = 20000},
[11] = {itemid = 15609, price = 20000},
}
local choice = items[item]
if choice and npcUtil.giveItem(player, choice.itemid) then
player:delAssaultPoint("MAMOOL_ASSAULT_POINT", choice.price)
end
end
end
end | gpl-3.0 |
aginor/wesnoth | data/ai/micro_ais/cas/ca_fast_combat.lua | 6 | 5874 | local H = wesnoth.require "lua/helper.lua"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local FAU = wesnoth.require "ai/micro_ais/cas/ca_fast_attack_utils.lua"
local LS = wesnoth.require "lua/location_set.lua"
local ca_fast_combat = {}
function ca_fast_combat:evaluation(ai, cfg, self)
self.data.move_cache = { turn = wesnoth.current.turn }
self.data.gamedata = FAU.gamedata_setup()
local filter_own = cfg.filter
local filter_enemy = cfg.filter_second
if (not filter_own) and (not filter_enemy) then
local ai_tag = H.get_child(wesnoth.sides[wesnoth.current.side].__cfg, 'ai')
for aspect in H.child_range(ai_tag, 'aspect') do
if (aspect.id == 'attacks') then
local facet = H.get_child(aspect, 'facet')
if facet then
filter_own = H.get_child(facet, 'filter_own')
filter_enemy = H.get_child(facet, 'filter_enemy')
end
end
end
end
if (not self.data.fast_combat_units) or (not self.data.fast_combat_units[1]) then
self.data.fast_combat_units = wesnoth.get_units {
side = wesnoth.current.side,
canrecruit = 'no',
{ "and", filter_own }
}
if (not self.data.fast_combat_units[1]) then return 0 end
-- For speed reasons, we'll go through the arrays from the end, so they are sorted backwards
if cfg.weak_units_first then
table.sort(self.data.fast_combat_units, function(a,b) return a.hitpoints > b.hitpoints end)
else
table.sort(self.data.fast_combat_units, function(a,b) return a.hitpoints < b.hitpoints end)
end
end
local excluded_enemies_map = LS.create()
-- Exclude enemies not matching [filter_enemy]
if filter_enemy then
local excluded_enemies = wesnoth.get_units {
{ "filter_side", { { "enemy_of", { side = wesnoth.current.side } } } },
{ "not", filter_enemy }
}
for _,e in ipairs(excluded_enemies) do
excluded_enemies_map:insert(e.x, e.y)
end
end
-- Exclude hidden enemies, except if attack_hidden_enemies=yes is set in [micro_ai] tag
if (not cfg.attack_hidden_enemies) then
local hidden_enemies = wesnoth.get_units {
{ "filter_side", { { "enemy_of", { side = wesnoth.current.side } } } },
{ "filter_vision", { side = wesnoth.current.side, visible = 'no' } }
}
for _,e in ipairs(hidden_enemies) do
excluded_enemies_map:insert(e.x, e.y)
end
end
local aggression = ai.get_aggression()
if (aggression > 1) then aggression = 1 end
local own_value_weight = 1. - aggression
-- Get the locations to be avoided
local avoid_map = FAU.get_avoid_map(cfg)
for i = #self.data.fast_combat_units,1,-1 do
local unit = self.data.fast_combat_units[i]
local unit_info = FAU.get_unit_info(unit, self.data.gamedata)
local unit_copy = FAU.get_unit_copy(unit.id, self.data.gamedata)
if (unit.attacks_left > 0) and (H.get_child(unit.__cfg, 'attack')) then
local attacks = AH.get_attacks({ unit }, { include_occupied = cfg.include_occupied_attack_hexes })
if (#attacks > 0) then
local max_rating, best_target, best_dst = -9e99
for _,attack in ipairs(attacks) do
if (not excluded_enemies_map:get(attack.target.x, attack.target.y))
and (not avoid_map:get(attack.dst.x, attack.dst.y))
then
local target = wesnoth.get_unit(attack.target.x, attack.target.y)
local target_info = FAU.get_unit_info(target, self.data.gamedata)
local att_stat, def_stat = FAU.battle_outcome(
unit_copy, target, { attack.dst.x, attack.dst.y },
unit_info, target_info, self.data.gamedata, self.data.move_cache
)
local rating, attacker_rating, defender_rating, extra_rating = FAU.attack_rating(
{ unit_info }, target_info, { { attack.dst.x, attack.dst.y } },
{ att_stat }, def_stat, self.data.gamedata,
{
own_value_weight = own_value_weight,
leader_weight = cfg.leader_weight
}
)
local acceptable_attack = FAU.is_acceptable_attack(attacker_rating, defender_rating, own_value_weight)
if acceptable_attack and (rating > max_rating) then
max_rating, best_target, best_dst = rating, target, attack.dst
end
end
end
if best_target then
self.data.fast_combat_unit_i = i
self.data.fast_target, self.data.fast_dst = best_target, best_dst
return cfg.ca_score
end
end
end
self.data.fast_combat_units[i] = nil
end
return 0
end
function ca_fast_combat:execution(ai, cfg, self)
local unit = self.data.fast_combat_units[self.data.fast_combat_unit_i]
AH.movefull_outofway_stopunit(ai, unit, self.data.fast_dst.x, self.data.fast_dst.y)
if (not unit) or (not unit.valid) then return end
if (not self.data.fast_target) or (not self.data.fast_target.valid) then return end
if (H.distance_between(unit.x, unit.y, self.data.fast_target.x, self.data.fast_target.y) ~= 1) then return end
AH.checked_attack(ai, unit, self.data.fast_target)
self.data.fast_combat_units[self.data.fast_combat_unit_i] = nil
end
return ca_fast_combat
| gpl-2.0 |
greasydeal/darkstar | scripts/zones/Metalworks/npcs/Hugues.lua | 24 | 1864 | -----------------------------------
-- Area: Metalworks
-- NPC: Hugues
-- Type: Smithing Synthesis Image Support
-- @pos -106.336 2.000 26.117 237
-----------------------------------
package.loaded["scripts/zones/Metalworks/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/crafting");
require("scripts/zones/Metalworks/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local guildMember = isGuildMember(player,8);
local SkillCap = getCraftSkillCap(player,SKILL_SMITHING);
local SkillLevel = player:getSkillLevel(SKILL_SMITHING);
if (guildMember == 1) then
if (player:hasStatusEffect(EFFECT_SMITHING_IMAGERY) == false) then
player:startEvent(0x0068,SkillCap,SkillLevel,1,207,player:getGil(),0,4095,0);
else
player:startEvent(0x0068,SkillCap,SkillLevel,1,207,player:getGil(),7101,4095,0);
end
else
player:startEvent(0x0068); -- Standard Dialogue
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0068 and option == 1) then
player:messageSpecial(SMITHING_SUPPORT,0,2,1);
player:addStatusEffect(EFFECT_SMITHING_IMAGERY,1,0,120);
end
end; | gpl-3.0 |
LegionXI/darkstar | scripts/globals/items/serving_of_royal_jelly.lua | 12 | 1140 | -----------------------------------------
-- ID: 4508
-- Item: Serving of Royal Jelly
-- Food Effect: 3 Hrs, All Races
-----------------------------------------
-- MP Recovery 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,10800,4508);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_MPHEAL, 3);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_MPHEAL, 3);
end;
| gpl-3.0 |
icyxp/kong | kong/plugins/ldap-auth/asn1.lua | 6 | 8467 | require "lua_pack"
local bpack = string.pack
local bunpack = string.unpack
local math = math
local bit = bit
local setmetatable = setmetatable
local table = table
local string_reverse = string.reverse
local string_char = string.char
local _M = {}
_M.BERCLASS = {
Universal = 0,
Application = 64,
ContextSpecific = 128,
Private = 192
}
_M.ASN1Decoder = {
new = function(self,o)
o = o or {}
setmetatable(o, self)
self.__index = self
o:registerBaseDecoders()
return o
end,
decode = function(self, encStr, pos)
local etype, elen
local newpos = pos
newpos, etype = bunpack(encStr, "X1", newpos)
newpos, elen = self.decodeLength(encStr, newpos)
if self.decoder[etype] then
return self.decoder[etype](self, encStr, elen, newpos)
else
return newpos, nil
end
end,
setStopOnError = function(self, val)
self.stoponerror = val
end,
registerBaseDecoders = function(self)
self.decoder = {}
self.decoder["0A"] = function(self, encStr, elen, pos)
return self.decodeInt(encStr, elen, pos)
end
self.decoder["8A"] = function(self, encStr, elen, pos)
return bunpack(encStr, "A" .. elen, pos)
end
self.decoder["31"] = function(self, encStr, elen, pos)
return pos, nil
end
-- Boolean
self.decoder["01"] = function(self, encStr, elen, pos)
local val = bunpack(encStr, "X", pos)
if val ~= "FF" then
return pos, true
else
return pos, false
end
end
-- Integer
self.decoder["02"] = function(self, encStr, elen, pos)
return self.decodeInt(encStr, elen, pos)
end
-- Octet String
self.decoder["04"] = function(self, encStr, elen, pos)
return bunpack(encStr, "A" .. elen, pos)
end
-- Null
self.decoder["05"] = function(self, encStr, elen, pos)
return pos, false
end
-- Object Identifier
self.decoder["06"] = function(self, encStr, elen, pos)
return self:decodeOID(encStr, elen, pos)
end
-- Context specific tags
self.decoder["30"] = function(self, encStr, elen, pos)
return self:decodeSeq(encStr, elen, pos)
end
end,
registerTagDecoders = function(self, tagDecoders)
self:registerBaseDecoders()
for k, v in pairs(tagDecoders) do
self.decoder[k] = v
end
end,
decodeLength = function(encStr, pos)
local elen
pos, elen = bunpack(encStr, 'C', pos)
if elen > 128 then
elen = elen - 128
local elenCalc = 0
local elenNext
for i = 1, elen do
elenCalc = elenCalc * 256
pos, elenNext = bunpack(encStr, 'C', pos)
elenCalc = elenCalc + elenNext
end
elen = elenCalc
end
return pos, elen
end,
decodeSeq = function(self, encStr, len, pos)
local seq = {}
local sPos = 1
local sStr
pos, sStr = bunpack(encStr, "A" .. len, pos)
while (sPos < len) do
local newSeq
sPos, newSeq = self:decode(sStr, sPos)
if not newSeq and self.stoponerror then
break
end
table.insert(seq, newSeq)
end
return pos, seq
end,
decode_oid_component = function(encStr, pos)
local octet
local n = 0
repeat
pos, octet = bunpack(encStr, "b", pos)
n = n * 128 + bit.band(0x7F, octet)
until octet < 128
return pos, n
end,
decodeOID = function(self, encStr, len, pos)
local last
local oid = {}
local octet
last = pos + len - 1
if pos <= last then
oid._snmp = '06'
pos, octet = bunpack(encStr, "C", pos)
oid[2] = math.fmod(octet, 40)
octet = octet - oid[2]
oid[1] = octet/40
end
while pos <= last do
local c
pos, c = self.decode_oid_component(encStr, pos)
oid[#oid + 1] = c
end
return pos, oid
end,
decodeInt = function(encStr, len, pos)
local hexStr
pos, hexStr = bunpack(encStr, "X" .. len, pos)
local value = tonumber(hexStr, 16)
if value >= math.pow(256, len)/2 then
value = value - math.pow(256, len)
end
return pos, value
end
}
_M.ASN1Encoder = {
new = function(self)
local o = {}
setmetatable(o, self)
self.__index = self
o:registerBaseEncoders()
return o
end,
encodeSeq = function(self, seqData)
return bpack('XAA' , '30', self.encodeLength(#seqData), seqData)
end,
encode = function(self, val)
local vtype = type(val)
if self.encoder[vtype] then
return self.encoder[vtype](self,val)
end
end,
registerTagEncoders = function(self, tagEncoders)
self:registerBaseEncoders()
for k, v in pairs(tagEncoders) do
self.encoder[k] = v
end
end,
registerBaseEncoders = function(self)
self.encoder = {}
self.encoder['table'] = function(self, val)
if val._ldap == '0A' then
local ival = self.encodeInt(val[1])
local len = self.encodeLength(#ival)
return bpack('XAA', '0A', len, ival)
end
if val._ldaptype then
local len
if val[1] == nil or #val[1] == 0 then
return bpack('XC', val._ldaptype, 0)
else
len = self.encodeLength(#val[1])
return bpack('XAA', val._ldaptype, len, val[1])
end
end
local encVal = ""
for _, v in ipairs(val) do
encVal = encVal .. self.encode(v) -- todo: buffer?
end
local tableType = "\x30"
if val["_snmp"] then
tableType = bpack("X", val["_snmp"])
end
return bpack('AAA', tableType, self.encodeLength(#encVal), encVal)
end
-- Boolean encoder
self.encoder['boolean'] = function(self, val)
if val then
return bpack('X','01 01 FF')
else
return bpack('X', '01 01 00')
end
end
-- Integer encoder
self.encoder['number'] = function(self, val)
local ival = self.encodeInt(val)
local len = self.encodeLength(#ival)
return bpack('XAA', '02', len, ival)
end
-- Octet String encoder
self.encoder['string'] = function(self, val)
local len = self.encodeLength(#val)
return bpack('XAA', '04', len, val)
end
-- Null encoder
self.encoder['nil'] = function(self, val)
return bpack('X', '05 00')
end
end,
encode_oid_component = function(n)
local parts = {}
parts[1] = string_char(bit.mod(n, 128))
while n >= 128 do
n = bit.rshift(n, 7)
parts[#parts + 1] = string_char(bit.mod(n, 128) + 0x80)
end
return string_reverse(table.concat(parts))
end,
encodeInt = function(val)
local lsb = 0
if val > 0 then
local valStr = ""
while (val > 0) do
lsb = math.fmod(val, 256)
valStr = valStr .. bpack('C', lsb)
val = math.floor(val/256)
end
if lsb > 127 then
valStr = valStr .. "\0"
end
return string_reverse(valStr)
elseif val < 0 then
local i = 1
local tcval = val + 256
while tcval <= 127 do
tcval = tcval + (math.pow(256, i) * 255)
i = i+1
end
local valStr = ""
while (tcval > 0) do
lsb = math.fmod(tcval, 256)
valStr = valStr .. bpack("C", lsb)
tcval = math.floor(tcval/256)
end
return string_reverse(valStr)
else -- val == 0
return bpack("x")
end
end,
encodeLength = function(len)
if len < 128 then
return string_char(len)
else
local parts = {}
while len > 0 do
parts[#parts + 1] = string_char(bit.mod(len, 256))
len = bit.rshift(len, 8)
end
return string_char(#parts + 0x80) .. string_reverse(table.concat(parts))
end
end
}
function _M.BERtoInt(class, constructed, number)
local asn1_type = class + number
if constructed == true then
asn1_type = asn1_type + 32
end
return asn1_type
end
function _M.intToBER(i)
local ber = {}
if bit.band(i, _M.BERCLASS.Application) == _M.BERCLASS.Application then
ber.class = _M.BERCLASS.Application
elseif bit.band(i, _M.BERCLASS.ContextSpecific) == _M.BERCLASS.ContextSpecific then
ber.class = _M.BERCLASS.ContextSpecific
elseif bit.band(i, _M.BERCLASS.Private) == _M.BERCLASS.Private then
ber.class = _M.BERCLASS.Private
else
ber.class = _M.BERCLASS.Universal
end
if bit.band(i, 32) == 32 then
ber.constructed = true
ber.number = i - ber.class - 32
else
ber.primitive = true
ber.number = i - ber.class
end
return ber
end
return _M
| apache-2.0 |
ibm2431/darkstar | scripts/globals/items/galette_des_rois.lua | 11 | 1198 | -----------------------------------------
-- ID: 5875
-- Item: Galette Des Rois
-- Food Effect: 180 Min, All Races
-----------------------------------------
-- HP +8
-- MP +3% (cap13)
-- Intelligence +2
-- Random Jewel
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if target:hasStatusEffect(dsp.effect.FOOD) then
result = dsp.msg.basic.IS_FULL
end
if target:getFreeSlotsCount() == 0 then
result = dsp.msg.basic.ITEM_NO_USE_INVENTORY
end
return result
end
function onItemUse(target)
target:addStatusEffect(dsp.effect.FOOD,0,0,10800,5875)
local rand = math.random(784,815)
target:addItem(rand) -- Random Jewel
end
function onEffectGain(target,effect)
target:addMod(dsp.mod.HP, 8)
target:addMod(dsp.mod.FOOD_MPP, 3)
target:addMod(dsp.mod.FOOD_MP_CAP, 13)
target:addMod(dsp.mod.INT, 2)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.HP, 8)
target:delMod(dsp.mod.FOOD_MPP, 3)
target:delMod(dsp.mod.FOOD_MP_CAP, 13)
target:delMod(dsp.mod.INT, 2)
end
| gpl-3.0 |
ibm2431/darkstar | scripts/globals/spells/esuna.lua | 12 | 4287 | -----------------------------------------
-- Spell: Esuna
--
-----------------------------------------
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)
if (caster:getID() == target:getID()) then -- much of this should only run once per cast, otherwise it would only delete the debuffs from the caster.
local statusNum = -1
local removables = {dsp.effect.FLASH, dsp.effect.BLINDNESS, dsp.effect.PARALYSIS, dsp.effect.POISON, dsp.effect.CURSE_I, dsp.effect.CURSE_II, dsp.effect.DISEASE, dsp.effect.PLAGUE}
if (caster:hasStatusEffect(dsp.effect.AFFLATUS_MISERY)) then -- add extra statuses to the list of removables. Elegy and Requiem are specifically absent.
removables = {dsp.effect.FLASH, dsp.effect.BLINDNESS, dsp.effect.PARALYSIS, dsp.effect.POISON, dsp.effect.CURSE_I, dsp.effect.CURSE_II, dsp.effect.DISEASE, dsp.effect.PLAGUE, dsp.effect.WEIGHT, dsp.effect.BIND, dsp.effect.BIO, dsp.effect.DIA, dsp.effect.BURN, dsp.effect.FROST, dsp.effect.CHOKE, dsp.effect.RASP, dsp.effect.SHOCK, dsp.effect.DROWN, dsp.effect.STR_DOWN, dsp.effect.DEX_DOWN, dsp.effect.VIT_DOWN, dsp.effect.AGI_DOWN, dsp.effect.INT_DOWN, dsp.effect.MND_DOWN, dsp.effect.CHR_DOWN, dsp.effect.ADDLE, dsp.effect.SLOW, dsp.effect.HELIX, dsp.effect.ACCURACY_DOWN, dsp.effect.ATTACK_DOWN, dsp.effect.EVASION_DOWN, dsp.effect.DEFENSE_DOWN, dsp.effect.MAGIC_ACC_DOWN, dsp.effect.MAGIC_ATK_DOWN, dsp.effect.MAGIC_EVASION_DOWN, dsp.effect.MAGIC_DEF_DOWN, dsp.effect.MAX_TP_DOWN, dsp.effect.MAX_MP_DOWN, dsp.effect.MAX_HP_DOWN}
end
local has = {}
-- collect a list of what caster currently has
for i, effect in ipairs(removables) do
if (caster:hasStatusEffect(effect)) then
statusNum = statusNum + 1
has[statusNum] = removables[i]
end
end
if (statusNum >= 0) then -- make sure this happens once instead of for every target
local delEff = math.random(0,statusNum) -- pick a random status to delete
caster:setLocalVar("esunaDelEff",has[delEff]) -- this can't be a local because it would only delete from the caster if it were.
else -- clear it if the caster has no eligible statuses, otherwise it will remove the status from others if it was previously removed.
caster:setLocalVar("esunaDelEff",0)
caster:setLocalVar("esunaDelEffMis",0) -- again, this can't be a local because it would only delete from the caster if it were. For extra status deletion under Misery
end
if (statusNum >= 1 and caster:hasStatusEffect(dsp.effect.AFFLATUS_MISERY)) then -- Misery second status removal.
caster:delStatusEffect(has[delEff]) -- delete the first selected effect so it doesn't get selected again. Won't impact the ability to delete it from others at this point.
local statusNumMis = - 1 -- need a new var to track the amount of debuffs for the array
-- collect a list of what caster currently has, again.
has = {}
for i, effect in ipairs(removables) do
if (caster:hasStatusEffect(effect)) then
statusNumMis = statusNumMis + 1
has[statusNumMis] = removables[i]
end
end
local delEffMis = math.random(0,statusNumMis) -- pick another random status to delete
caster:setLocalVar("esunaDelEffMis",has[delEffMis])
else
caster:setLocalVar("esunaDelEffMis",0)
end
end
local statusDel = caster:getLocalVar("esunaDelEff")
local statusDelMis = caster:getLocalVar("esunaDelEffMis")
if (statusDel == 0) then -- this gets set to 0 if there's no status to delete.
spell:setMsg(dsp.msg.basic.MAGIC_NO_EFFECT) -- no effect
elseif (statusDelMis ~= 0) then -- no need to check for statusDelMis because it can't be 0 if this isn't
target:delStatusEffect(statusDel)
target:delStatusEffect(statusDelMis)
else
target:delStatusEffect(statusDel)
end
return statusDel
end
| gpl-3.0 |
greasydeal/darkstar | scripts/zones/Nashmau/npcs/Yohj_Dukonlhy.lua | 24 | 1449 | -----------------------------------
-- Area: Nashmau
-- NPC: Yohj Dukonlhy
-- Standard Info NPC
-----------------------------------
package.loaded["scripts/zones/Nashmau/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Nashmau/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
-- Based on scripts/zones/Mhaura/Dieh_Yamilsiah.lua
local timer = 1152 - ((os.time() - 1009810800)%1152);
local direction = 0; -- Arrive, 1 for depart
local waiting = 431; -- Offset for Nashmau
if (timer <= waiting) then
direction = 1; -- Ship arrived, switch dialog from "arrive" to "depart"
else
timer = timer - waiting; -- Ship hasn't arrived, subtract waiting time to get time to arrival
end
player:startEvent(231,timer,direction);
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/Port_Windurst/npcs/Panja-Nanja.lua | 12 | 1374 | -----------------------------------
-- Area: Port Windurst
-- NPC: Panja-Nanja
-- Type: Fishing Adv. Image Support
-- !pos -194.499 -3 58.692 240
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/crafting");
local ID = require("scripts/zones/Port_Windurst/IDs");
-----------------------------------
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
local guildMember = isGuildMember(player,8);
local SkillLevel = player:getSkillLevel(dsp.skill.FISHING);
local Cost = getAdvImageSupportCost(player,dsp.skill.FISHING);
if (guildMember == 1) then
if (player:hasStatusEffect(dsp.effect.FISHING_IMAGERY) == false) then
player:startEvent(10011,Cost,SkillLevel,0,239,player:getGil(),0,0,0); -- p1 = skill level
else
player:startEvent(10011,Cost,SkillLevel,0,239,player:getGil(),38586,30,0);
end
else
player:startEvent(10011); -- Standard Dialogue, incorrect
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
local Cost = getAdvImageSupportCost(player,256);
if (csid == 10011 and option == 1) then
player:delGil(Cost);
player:messageSpecial(ID.text.FISHING_SUPPORT,0,0,0);
player:addStatusEffect(dsp.effect.FISHING_IMAGERY,2,0,7200);
end
end; | gpl-3.0 |
LegionXI/darkstar | scripts/zones/Ifrits_Cauldron/npcs/qm1.lua | 14 | 1346 | -----------------------------------
-- Area: Ifrit's Cauldron
-- NPC: qm1 (???)
-- Notes: Used to spawn Tarasque
-- @pos 126 18 166 0
-----------------------------------
package.loaded["scripts/zones/Ifrits_Cauldron/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Ifrits_Cauldron/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
-- Trade a Rattling Egg to pop Tarasque
if(GetMobAction(17617164) == 0 and trade:hasItemQty(1189,1) and trade:getItemCount() == 1) then
player:tradeComplete();
SpawnMob(17617164):updateClaim(player); -- Spawn Tarasque
npc:setStatus(STATUS_DISAPPEAR);
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:messageSpecial(EGGSHELLS_LIE_SCATTERED);
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 |
ricker75/Global-Server | data/npc/scripts/Morgan.lua | 2 | 4683 | local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
-- Storage IDs --
fknight = 22007
sknight = 22008
fwarrior = 22038
swarrior = 22041
forge = 76682
newaddon = 'Ah, right! The knight sword! Here you go.'
newaddon1 = 'Ah, right! The warrior sword! Here you go.'
noitems = 'You do not have all the required items.'
noitems2 = 'You do not have all the required items or you do not have the outfit, which by the way, is a requirement for this addon.'
already = 'You already have this outfit!'
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local player = Player(cid)
if(msgcontains(msg, 'addon')) then
selfSay('I can forge the finest {weapons} for knights and warriors. They may wear them proudly and visible to everyone.', cid)
npcHandler.topic[cid] = 1
elseif msgcontains(msg, "firebird") then
if player:getStorageValue(10055) == 4 then
selfSay("Ahh. So Duncan sent you, eh? You must have done something really impressive. Okay, take this fine sabre from me, mate.", cid)
player:setStorageValue(10055, 5)
player:addOutfitAddon(151, 1)
player:addOutfitAddon(155, 1)
end
elseif(msgcontains(msg, 'weapons') and npcHandler.topic[cid] == 1) then
selfSay('Would you rather be interested in a {knight\'s sword} or in a {warrior\'s sword}?', cid)
npcHandler.topic[cid] = 2
elseif (msgcontains(msg, 'warrior\'s sword') or msgcontains(msg, 'warriors sword')) then
if npcHandler.topic[cid] == 2 and getPlayerStorageValue(cid, swarrior) < 1 then
selfSay('Great! Simply bring me 100 iron ore and one royal steel and I will happily {forge} it for you.', cid)
player:setStorageValue(forge,1)
elseif npcHandler.topic[cid] == 4 and player:getStorageValue(swarrior) < 1 then
if player:removeItem(5887,1) and player:removeItem(5880,100) then
selfSay('Alright! As a matter of fact, I have one in store. Here you go!', cid)
player:getPosition():sendMagicEffect(13)
player:setStorageValue(swarrior,1)
player:setStorageValue(12010, 1) --this for default start of Outfit and Addon Quests
player:addOutfitAddon(134, 2)
player:addOutfitAddon(142, 2)
local cStorage = Storage.Achievements.WildWarrior
if player:getStorageValue(cStorage) < 1 then
player:setStorageValue(cStorage, 1)
elseif player:getStorageValue(cStorage) == 1 then
player:addAchievement('Wild Warrior')
player:setStorageValue(cStorage, 2)
end
npcHandler.topic[cid] = 0
else
selfSay(noitems, cid)
npcHandler.topic[cid] = 0
end
elseif npcHandler.topic[cid] > 1 then
selfSay(already, cid)
npcHandler.topic[cid] = 0
end
elseif (msgcontains(msg, 'knights sword') or msgcontains(msg, 'knight\'s sword')) then
if npcHandler.topic[cid] == 2 and player:getStorageValue(fknight) < 1 then
selfSay('Great! Simply bring me 100 iron ore and one royal steel and I will happily {forge} it for you.', cid)
player:setStorageValue(forge,1)
elseif npcHandler.topic[cid] == 4 and player:getStorageValue(fknight) < 1 then
if player:removeItem(5892,1) and player:removeItem(5880,100) then
selfSay('Alright! As a matter of fact, I have one in store. Here you go!', cid)
player:getPosition():sendMagicEffect(13)
player:setStorageValue(fknight,1)
player:setStorageValue(12010, 1) --this for default start of Outfit and Addon Quests
player:addOutfitAddon(131, 1)
player:addOutfitAddon(139, 1)
npcHandler.topic[cid] = 0
else
selfSay(noitems, cid)
npcHandler.topic[cid] = 0
end
elseif npcHandler.topic[cid] > 1 then
selfSay(already, cid)
npcHandler.topic[cid] = 0
end
elseif(msgcontains(msg, 'forge') or msgcontains(msg, 'forge weapon')) then
if player:getStorageValue(forge) == 1 then
selfSay('What would you like me to forge for you? A {knight\'s sword} or a {warrior\'s sword}?', cid)
npcHandler.topic[cid] = 4
end
end
if (msgcontains(msg, "bye") or msgcontains(msg, "farewell")) then
npcHandler:say("Finally.", cid)
npcHandler.topic[cid] = 0
npcHandler:releaseFocus(cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new()) | gpl-2.0 |
mhmjhamyargroup44233/hamyargroup63635567 | plugins/img_google.lua | 660 | 3196 | do
local mime = require("mime")
local google_config = load_from_file('data/google.lua')
local cache = {}
--[[
local function send_request(url)
local t = {}
local options = {
url = url,
sink = ltn12.sink.table(t),
method = "GET"
}
local a, code, headers, status = http.request(options)
return table.concat(t), code, headers, status
end]]--
local function get_google_data(text)
local url = "http://ajax.googleapis.com/ajax/services/search/images?"
url = url.."v=1.0&rsz=5"
url = url.."&q="..URL.escape(text)
url = url.."&imgsz=small|medium|large"
if google_config.api_keys then
local i = math.random(#google_config.api_keys)
local api_key = google_config.api_keys[i]
if api_key then
url = url.."&key="..api_key
end
end
local res, code = http.request(url)
if code ~= 200 then
print("HTTP Error code:", code)
return nil
end
local google = json:decode(res)
return google
end
-- Returns only the useful google data to save on cache
local function simple_google_table(google)
local new_table = {}
new_table.responseData = {}
new_table.responseDetails = google.responseDetails
new_table.responseStatus = google.responseStatus
new_table.responseData.results = {}
local results = google.responseData.results
for k,result in pairs(results) do
new_table.responseData.results[k] = {}
new_table.responseData.results[k].unescapedUrl = result.unescapedUrl
new_table.responseData.results[k].url = result.url
end
return new_table
end
local function save_to_cache(query, data)
-- Saves result on cache
if string.len(query) <= 7 then
local text_b64 = mime.b64(query)
if not cache[text_b64] then
local simple_google = simple_google_table(data)
cache[text_b64] = simple_google
end
end
end
local function process_google_data(google, receiver, query)
if google.responseStatus == 403 then
local text = 'ERROR: Reached maximum searches per day'
send_msg(receiver, text, ok_cb, false)
elseif google.responseStatus == 200 then
local data = google.responseData
if not data or not data.results or #data.results == 0 then
local text = 'Image not found.'
send_msg(receiver, text, ok_cb, false)
return false
end
-- Random image from table
local i = math.random(#data.results)
local url = data.results[i].unescapedUrl or data.results[i].url
local old_timeout = http.TIMEOUT or 10
http.TIMEOUT = 5
send_photo_from_url(receiver, url)
http.TIMEOUT = old_timeout
save_to_cache(query, google)
else
local text = 'ERROR!'
send_msg(receiver, text, ok_cb, false)
end
end
function run(msg, matches)
local receiver = get_receiver(msg)
local text = matches[1]
local text_b64 = mime.b64(text)
local cached = cache[text_b64]
if cached then
process_google_data(cached, receiver, text)
else
local data = get_google_data(text)
process_google_data(data, receiver, text)
end
end
return {
description = "Search image with Google API and sends it.",
usage = "!img [term]: Random search an image with Google API.",
patterns = {
"^!img (.*)$"
},
run = run
}
end
| gpl-2.0 |
ibm2431/darkstar | scripts/zones/The_Shrine_of_RuAvitau/Zone.lua | 9 | 4797 | -----------------------------------
--
-- Zone: The_Shrine_of_RuAvitau (178)
--
-----------------------------------
local ID = require("scripts/zones/The_Shrine_of_RuAvitau/IDs");
require("scripts/globals/conquest");
require("scripts/globals/settings");
require("scripts/globals/missions");
require("scripts/globals/keyitems");
require("scripts/globals/zone");
-----------------------------------
function onInitialize(zone)
-- MAP 1 ------------------------
zone:registerRegion(1, -21, 29, -61, -16, 31, -57); --> F (H-10)
zone:registerRegion(2, 16, 29, 57, 21, 31, 61); --> E (H-7)
-- MAP 3 ------------------------
zone:registerRegion(3, -89, -19, 83, -83, -15, 89); --> L (F-5)
zone:registerRegion(3, -143, -19, -22, -137, -15, -16); --> L (D-8)
zone:registerRegion(4, -143, -19, 55, -137, -15, 62); --> G (D-6)
zone:registerRegion(4, 83, -19, -89, 89, -15, -83); --> G (J-10)
zone:registerRegion(5, -89, -19, -89, -83, -15, -83); --> J (F-10)
zone:registerRegion(6, 137, -19, -22, 143, -15, -16); --> H (L-8)
zone:registerRegion(7, 136, -19, 56, 142, -15, 62); --> I (L-6)
zone:registerRegion(8, 83, -19, 83, 89, -15, 89); --> K (J-5)
-- MAP 4 ------------------------
zone:registerRegion(9, 723, 96, 723, 729, 100, 729); --> L'(F-5)
zone:registerRegion(10, 870, 96, 723, 876, 100, 729); --> O (J-5)
zone:registerRegion(6, 870, 96, 470, 876, 100, 476); --> H (J-11)
zone:registerRegion(11, 723, 96, 470, 729, 100, 476); --> N (F-11)
-- MAP 5 ------------------------
zone:registerRegion(12, 817, -3, 57, 823, 1, 63); --> D (I-7)
zone:registerRegion(13, 736, -3, 16, 742, 1, 22); --> P (F-8)
zone:registerRegion(14, 857, -3, -23, 863, 1, -17); --> M (J-9)
zone:registerRegion(15, 776, -3, -63, 782, 1, -57); --> C (G-10)
-- MAP 6 ------------------------
zone:registerRegion(2, 777, -103, -503, 783, -99, -497); --> E (G-6)
zone:registerRegion(1, 816, -103, -503, 822, -99, -497); --> F (I-6)
end;
function onZoneIn(player,prevZone)
local cs = -1;
local xPos = player:getXPos();
local yPos = player:getYPos();
local zPos = player:getZPos();
local ZilartMission = player:getCurrentMission(ZILART);
-- Checked here to be fair to new players
local DMEarrings = 0;
for i=14739, 14743 do
if (player:hasItem(i)) then
DMEarrings = DMEarrings + 1;
end
end
-- ZM 15 -> ZM 16
if (ZilartMission == dsp.mission.id.zilart.THE_SEALED_SHRINE and player:getCharVar("ZilartStatus") == 1 and
xPos >= -45 and yPos >= -4 and zPos >= -240 and
xPos <= -33 and yPos <= 0 and zPos <= -226 and DMEarrings <= NUMBER_OF_DM_EARRINGS) then -- Entered through main gate
cs = 51;
end
if ((xPos == 0) and (yPos == 0) and (zPos == 0)) then
player:setPos(-3.38,46.326,60,122);
end
return cs;
end;
function onConquestUpdate(zone, updatetype)
dsp.conq.onConquestUpdate(zone, updatetype)
end;
function onRegionEnter(player,region)
switch (region:GetRegionID()): caseof
{
[1] = function (x)
player:startEvent(17); --> F
end,
[2] = function (x)
player:startEvent(16); --> E
end,
[3] = function (x)
player:startEvent(5); --> L --> Kirin !
end,
[4] = function (x)
player:startEvent(4); --> G
end,
[5] = function (x)
player:startEvent(1); --> J
end,
[6] = function (x)
player:startEvent(3); --> H
end,
[7] = function (x)
player:startEvent(7); --> I
end,
[8] = function (x)
player:startEvent(6); --> K
end,
[9] = function (x)
player:startEvent(10); --> L'
end,
[10] = function (x)
player:startEvent(11);
end,
[11] = function (x)
player:startEvent(8);
end,
[12] = function (x)
player:startEvent(15); --> D
end,
[13] = function (x)
player:startEvent(14); --> P
end,
[14] = function (x)
player:startEvent(13); --> M
end,
[15] = function (x)
player:startEvent(12); --> C
end,
default = function (x)
end,
}
end;
function onRegionLeave(player,region)
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 51) then
player:completeMission(ZILART,dsp.mission.id.zilart.THE_SEALED_SHRINE);
player:addMission(ZILART,dsp.mission.id.zilart.THE_CELESTIAL_NEXUS);
player:setCharVar("ZilartStatus",0);
end
end; | gpl-3.0 |
ibm2431/darkstar | scripts/globals/items/hypno_staff.lua | 12 | 1059 | -----------------------------------------
-- ID: 17117
-- Item: Hypno Staff
-- Additional Effect: Sleep
-----------------------------------------
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 applyResistanceAddEffect(player,target,dsp.magic.ele.DARK,0) <= 0.5) then
return 0,0,0
else
local duration = 25
if (target:getMainLvl() > player:getMainLvl()) then
duration = duration - (target:getMainLvl() - player:getMainLvl())
end
duration = utils.clamp(duration,1,25)
duration = duration * applyResistanceAddEffect(player,target,dsp.magic.ele.DARK,0)
if (not target:hasStatusEffect(dsp.effect.SLEEP_I)) then
target:addStatusEffect(dsp.effect.SLEEP_I, 1, 0, duration)
end
return dsp.subEffect.SLEEP, dsp.msg.basic.ADD_EFFECT_STATUS, dsp.effect.SLEEP_I
end
end | gpl-3.0 |
aginor/wesnoth | data/ai/micro_ais/cas/ca_healer_move.lua | 26 | 5637 | local H = wesnoth.require "lua/helper.lua"
local LS = wesnoth.require "lua/location_set.lua"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local BC = wesnoth.require "ai/lua/battle_calcs.lua"
local ca_healer_move = {}
function ca_healer_move:evaluation(ai, cfg, self)
-- Should happen with higher priority than attacks, except at beginning of turn,
-- when we want attacks (by other units) done first
-- This is done so that it is possible for healers to attack, if they do not
-- find an appropriate hex to back up other units
local score = self.data.HS_healer_move_score or 105000
local all_healers = wesnoth.get_units {
side = wesnoth.current.side,
ability = "healing",
{ "and", cfg.filter }
}
local healers, healers_noMP = {}, {}
for _,healer in ipairs(all_healers) do
if (healer.moves > 0) then
table.insert(healers, healer)
else
table.insert(healers_noMP, healer)
end
end
if (not healers[1]) then return 0 end
local all_healees = wesnoth.get_units {
side = wesnoth.current.side,
{ "and", cfg.filter_second }
}
local healees, healees_MP = {}, {}
for _,healee in ipairs(all_healees) do
-- Potential healees are units without MP that don't already have a healer (also without MP) next to them
-- Also, they cannot be on a village or regenerate
if (healee.moves == 0) then
if (not wesnoth.match_unit(healee, { ability = "regenerates" })) then
local is_village = wesnoth.get_terrain_info(wesnoth.get_terrain(healee.x, healee.y)).village
if (not is_village) then
local is_healee = true
for _,healer in ipairs(healers_noMP) do
if (H.distance_between(healee.x, healee.y, healer.x, healer.y) == 1) then
is_healee = false
break
end
end
if is_healee then table.insert(healees, healee) end
end
end
else
table.insert(healees_MP, healee)
end
end
local enemies = wesnoth.get_units {
{ "filter_side", { { "enemy_of", { side = wesnoth.current.side } } } }
}
for _,healee in ipairs(healees_MP) do wesnoth.extract_unit(healee) end
local enemy_attack_map = BC.get_attack_map(enemies)
for _,healee in ipairs(healees_MP) do wesnoth.put_unit(healee) end
local avoid_map = LS.of_pairs(ai.get_avoid())
local max_rating, best_healer, best_hex = -9e99
for _,healer in ipairs(healers) do
local reach = wesnoth.find_reach(healer)
for _,loc in ipairs(reach) do
-- Only consider hexes that are next to at least one noMP unit that
-- - either can be attacked by an enemy (15 points per enemy)
-- - or has non-perfect HP (1 point per missing HP)
local rating, adjacent_healer = 0
if (not avoid_map:get(loc[1], loc[2])) then
local unit_in_way = wesnoth.get_unit(loc[1], loc[2])
if (not unit_in_way) or (unit_in_way == healer) then
for _,healee in ipairs(healees) do
if (H.distance_between(healee.x, healee.y, loc[1], loc[2]) == 1) then
-- Note: These ratings have to be positive or the method doesn't work
rating = rating + healee.max_hitpoints - healee.hitpoints
-- If injured_units_only = true then don't count units with full HP
if (healee.max_hitpoints - healee.hitpoints > 0) or (not cfg.injured_units_only) then
rating = rating + 15 * (enemy_attack_map.units:get(healee.x, healee.y) or 0)
end
end
end
end
end
-- Number of enemies that can threaten the healer at that position
-- This has to be no larger than cfg.max_threats for hex to be considered
local enemies_in_reach = enemy_attack_map.units:get(loc[1], loc[2]) or 0
-- If this hex fulfills those requirements, 'rating' is now greater than 0
-- and we do the rest of the rating, otherwise set rating to below max_rating
if (rating == 0) or (enemies_in_reach > (cfg.max_threats or 9999)) then
rating = max_rating - 1
else
-- Strongly discourage hexes that can be reached by enemies
rating = rating - enemies_in_reach * 1000
-- All else being more or less equal, prefer villages and strong terrain
local is_village = wesnoth.get_terrain_info(wesnoth.get_terrain(loc[1], loc[2])).village
if is_village then rating = rating + 2 end
local defense = 100 - wesnoth.unit_defense(healer, wesnoth.get_terrain(loc[1], loc[2]))
rating = rating + defense / 10.
end
if (rating > max_rating) then
max_rating, best_healer, best_hex = rating, healer, { loc[1], loc[2] }
end
end
end
if best_healer then
self.data.HS_unit, self.data.HS_hex = best_healer, best_hex
return score
end
return 0
end
function ca_healer_move:execution(ai, cfg, self)
AH.movefull_outofway_stopunit(ai, self.data.HS_unit, self.data.HS_hex)
self.data.HS_unit, self.data.HS_hex = nil, nil
end
return ca_healer_move
| gpl-2.0 |
LegionXI/darkstar | scripts/zones/Xarcabard/Zone.lua | 11 | 2954 | -----------------------------------
--
-- Zone: Xarcabard (112)
--
-----------------------------------
package.loaded[ "scripts/zones/Xarcabard/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Xarcabard/TextIDs");
require("scripts/globals/icanheararainbow");
require("scripts/globals/keyitems");
require("scripts/globals/zone");
require("scripts/globals/conquest");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
SetRegionalConquestOverseers(zone:getRegionID())
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn( player, prevZone)
local cs = -1;
local UnbridledPassionCS = player:getVar("unbridledPassion");
if (prevZone == 135) then -- warp player to a correct position after dynamis
player:setPos(569.312,-0.098,-270.158,90);
end
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
player:setPos( -136.287, -23.268, 137.302, 91);
end
if (player:hasKeyItem( VIAL_OF_SHROUDED_SAND) == false and player:getRank() >= 6 and player:getMainLvl() >= 65 and player:getVar( "Dynamis_Status") == 0) then
player:setVar( "Dynamis_Status", 1);
cs = 0x000D;
elseif (triggerLightCutscene(player)) then -- Quest: I Can Hear A Rainbow
cs = 0x0009;
elseif (UnbridledPassionCS == 3) then
cs = 0x0004;
elseif (player:getCurrentMission(WINDURST) == VAIN and player:getVar("MissionStatus") ==1) then
cs = 0x000b;
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 == 0x0009) then
lightCutsceneUpdate(player); -- Quest: I Can Hear A Rainbow
elseif (csid == 0x000b) then
if (player:getPreviousZone() == 111) then
player:updateEvent(0,0,0,0,0,2);
else
player:updateEvent(0,0,0,0,0,3);
end
end
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish( player, csid, option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0009) then
lightCutsceneFinish(player); -- Quest: I Can Hear A Rainbow
elseif (csid == 0x0004) then
player:setVar("unbridledPassion",4);
end
end; | gpl-3.0 |
peymankhanas8487/Horror-Avatar | plugins/domaintools.lua | 359 | 1494 | local ltn12 = require "ltn12"
local https = require "ssl.https"
-- Edit data/mashape.lua with your Mashape API key
-- http://docs.mashape.com/api-keys
local mashape = load_from_file('data/mashape.lua', {
api_key = ''
})
local function check(name)
local api = "https://domainsearch.p.mashape.com/index.php?"
local param = "name="..name
local url = api..param
local api_key = mashape.api_key
if api_key:isempty() then
return 'Configure your Mashape API Key'
end
local headers = {
["X-Mashape-Key"] = api_key,
["Accept"] = "application/json"
}
local respbody = {}
local body, code = https.request{
url = url,
method = "GET",
headers = headers,
sink = ltn12.sink.table(respbody),
protocol = "tlsv1"
}
if code ~= 200 then return code end
local body = table.concat(respbody)
local body = json:decode(body)
--vardump(body)
local domains = "List of domains for '"..name.."':\n"
for k,v in pairs(body) do
print(k)
local status = " ❌ "
if v == "Available" then
status = " ✔ "
end
domains = domains..k..status.."\n"
end
return domains
end
local function run(msg, matches)
if matches[1] == "check" then
local name = matches[2]
return check(name)
end
end
return {
description = "Domain tools",
usage = {"!domain check [domain] : Check domain name availability.",
},
patterns = {
"^!domain (check) (.*)$",
},
run = run
}
| gpl-2.0 |
greasydeal/darkstar | scripts/zones/Aht_Urhgan_Whitegate/npcs/Wazyih.lua | 34 | 1031 | -----------------------------------
-- Area: Aht Urhgan Whitegate
-- NPC: Wazyih
-- Standard Info NPC
-----------------------------------
package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x02AC);
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 |
Igalia/snabbswitch | lib/ljsyscall/syscall/libc.lua | 24 | 2992 | -- things that are libc only, not syscalls
-- this file will not be included if not running with libc eg for rump
local require, error, assert, tonumber, tostring,
setmetatable, pairs, ipairs, unpack, rawget, rawset,
pcall, type, table, string =
require, error, assert, tonumber, tostring,
setmetatable, pairs, ipairs, unpack, rawget, rawset,
pcall, type, table, string
local function init(S)
local c = S.c
local types = S.types
local t, s, pt = types.t, types.s, types.pt
local ffi = require "ffi"
local h = require "syscall.helpers"
local zeropointer = pt.void(0)
local function retbool(ret)
if ret == -1 then return nil, t.error() end
return true
end
-- if getcwd not defined, fall back to libc implementation (currently osx, freebsd)
-- freebsd implementation fairly complex
if not S.getcwd then
ffi.cdef [[
char *getcwd(char *buf, size_t size);
]]
function S.getcwd(buf, size)
size = size or c.PATH_MAX
buf = buf or t.buffer(size)
local ret = ffi.C.getcwd(buf, size)
if ret == zeropointer then return nil, t.error() end
return ffi.string(buf)
end
end
-- in NetBSD, OSX exit defined in libc, no _exit syscall available
if not S.exit then
function S.exit(status) return retbool(ffi.C.exit(c.EXIT[status or 0])) end
end
if not S._exit then
S._exit = S.exit -- provide syscall exit if possible
end
ffi.cdef [[
int __cxa_atexit(void (*func) (void *), void * arg, void * dso_handle);
]]
local function inlibc(k) return ffi.C[k] end
if pcall(inlibc, "exit") and pcall(inlibc, "__cxa_atexit") then
function S.exit(status) return retbool(ffi.C.exit(c.EXIT[status or 0])) end -- use libc exit instead
function S.atexit(f) return retbool(ffi.C.__cxa_atexit(f, nil, nil)) end
end
--[[ -- need more types defined
int uname(struct utsname *buf);
time_t time(time_t *t);
]]
--[[
int gethostname(char *name, size_t namelen);
int sethostname(const char *name, size_t len);
int getdomainname(char *name, size_t namelen);
int setdomainname(const char *name, size_t len);
--]]
-- environment
ffi.cdef [[
// environment
extern char **environ;
int setenv(const char *name, const char *value, int overwrite);
int unsetenv(const char *name);
int clearenv(void);
char *getenv(const char *name);
]]
function S.environ() -- return whole environment as table
local environ = ffi.C.environ
if not environ then return nil end
local r = {}
local i = 0
while environ[i] ~= zeropointer do
local e = ffi.string(environ[i])
local eq = e:find('=')
if eq then
r[e:sub(1, eq - 1)] = e:sub(eq + 1)
end
i = i + 1
end
return r
end
function S.getenv(name)
return S.environ()[name]
end
function S.unsetenv(name) return retbool(ffi.C.unsetenv(name)) end
function S.setenv(name, value, overwrite)
overwrite = h.booltoc(overwrite) -- allows nil as false/0
return retbool(ffi.C.setenv(name, value, overwrite))
end
function S.clearenv() return retbool(ffi.C.clearenv()) end
S.errno = ffi.errno
return S
end
return {init = init}
| apache-2.0 |
pokemoncentral/wiki-lua-modules | Learnlist-entry8.lua | 1 | 6982 | --[[
Learnlist entries for 8th gen.
Below are described parameters of each kind of entry.
NOTE: STAB is autocomputed if empty. If you want to force an empty value (eg.
because autocompting is wrong) you should use the special value "no". To
autocompute the stab the Pokémon name is taken as ROOTPAGENAME, so outside of
Pokémon (sub)pages this will result in a script error. To fix this, just force
a value for the stab in every entry.
Level entry:
1 is the move name. 2 is the STAB (if empty is autocomputed),
3 are optional notes, 4 is the level in SpSc, 5 is the level
in BDSP
Tm entry:
1 is the move name, 2 is the STAB (if empty is autocomputed),
3 are optional notes, 4 is the MT of the move in SpSc, 5 is
the MT of the move in DLPS. Both are autocomputed if empty, to
force empty use the value "no"
Breed entry:
1 is the list of parents, 2 is the move name, 3 is the STAB
(if empty is autocomputed), 4 to 6 are optional notes
Tutor entry:
1 is the move name. 2 is the STAB (if empty is autocomputed),
3 are optional notes, 4 is yes/no for SpSc, 5 is yes/no for IA
6 is yes/no for DLPS
Preevo entry:
1 is the move name. 2 is the STAB (if empty is autocomputed),
2 is ndex, 3 (optional) notes of the first evolution that learn the move,
4 and 5 are the same for the second
Event entry:
1 is move name, 2 is the STAB (if empty is autocomputed),
3 are optional notes, 4 is the event
--]]
local z = {}
local mw = require('mw')
local txt = require('Wikilib-strings') -- luacheck: no unused
local lib = require('Wikilib-learnlists')
local multigen = require('Wikilib-multigen')
local moves = require("Move-data")
local sup = require("Sup-data")
local strings = {
TMENTRYCELL = [=[|-
| class="black-text" style="padding: 0.1em 0.3em;" | ${content} ]=],
TMIMGLINK = [=[<span class="hidden-xs">[[File:${kind} ${tipo} VIII Sprite Zaino.png]]</span>[[${kind}${num}]]]=],
TMSLASH = [[ / ]],
BREEDENTRY = '|-\n| style="padding: 0.1em 0.3em;" | ${p1}',
-- EVENTENTRY = '|-\n| style="padding: 0.1em 0.3em;" | ${p1}${p10}',
}
-- Compute the displayed STAB from the input.
-- "move" is the move name, "stabval" is the value of stab passed to the call
local getSTAB = function(move, stabval)
if stabval == "No" then
return ""
elseif stabval and stabval ~= "" then
return stabval
else
return lib.computeSTAB(mw.title.getCurrentTitle().rootText:lower(), move, nil, 8)
end
end
local entry = function(mossa, stab, notes)
local data = multigen.getGen(moves[string.lower(mossa)])
return lib.categoryentry(getSTAB(mossa, stab),
mossa, notes,
string.fu(data.type), string.fu(data.category),
data.power, data.accuracy, data.pp)
end
-- Level entry
z.level = function(frame)
local p = lib.sanitize(mw.clone(frame.args))
return table.concat{
'|-\n',
lib.gameslevel(lib.makeEvoText(p[4]), lib.makeEvoText(p[5])),
entry(p[1] or 'Geloraggio', p[2], lib.makeNotes(p[3] or ''))
}
end
z.Level = z.level
-- MT/DT moves entry
z.tm = function(frame)
local p = lib.sanitize(mw.clone(frame.args))
local movename = p[1] or "geloraggio"
-- Autocompute the MT/DT number for both SpSc and DLPS
local tmkind1, tmnum1
if p[4] and p[4] ~= "no" then
tmkind1, tmnum1 = string.match(p[4], '^([MD][TN])(%d+)')
elseif not p[4] then
tmkind1, tmnum1 = lib.getTMNum(movename:lower(), 8, "SpSc")
end
local tmkind2, tmnum2
if p[5] and p[5] ~= "no" then
tmkind2, tmnum2 = string.match(p[5], '^([MD][TN])(%d+)')
elseif not p[5] then
tmkind2, tmnum2 = lib.getTMNum(movename:lower(), 8, "DLPS")
end
local movetype = string.fu(multigen.getGenValue(moves[string.lower(movename)].type, 8))
local cellcnt, notes
if tmkind1 == tmkind2 and tmnum1 == tmnum2 then
-- Same MT in both games
cellcnt = string.interp(strings.TMIMGLINK, {
kind = tmkind1,
num = tostring(tmnum1),
tipo = movetype,
})
notes = ""
elseif not tmkind1 or not tmkind2 then
-- MT only in one game
notes = tmkind1 and "SpSc" or "DLPS"
local tmkind = tmkind1 or tmkind2
local tmnum = tmnum1 or tmnum2
cellcnt = string.interp(strings.TMIMGLINK, {
kind = tmkind,
num = tostring(tmnum),
tipo = movetype,
}) .. sup[notes]
else
-- MT in both games, but different numbers
local tm1str = string.interp(strings.TMIMGLINK, {
kind = tmkind1,
num = tostring(tmnum1),
tipo = movetype,
}) .. sup.SpSc
local tm2str = string.interp(strings.TMIMGLINK, {
kind = tmkind2,
num = tostring(tmnum2),
tipo = movetype,
}) .. sup.DLPS
cellcnt = table.concat({tm1str, strings.TMSLASH, tm2str})
end
return table.concat{
string.interp(strings.TMENTRYCELL, { content = cellcnt }),
entry(movename, p[2], lib.makeNotes(p[3] or notes or '')),
}
end
z.Tm = z.tm
-- Entry per le mosse apprese tramite accoppiamento
z.breed = function(frame)
local p = lib.sanitize(mw.clone(frame.args))
return table.concat{
string.interp(strings.BREEDENTRY, {
p1 = lib.mslistToModal(p[1] or '', '8', nil, 6)
}),
entry(p[2] or 'Lanciafiamme',
p[3],
lib.makeNotes(p[4] or '',
lib.makeNotes(p[5] or '',
lib.makeNotes(p[6] or '')))
),
}
end
z.Breed = z.breed
-- Entry per le mosse apprese tramite esperto mosse
z.tutor = function(frame)
local p = lib.sanitize(mw.clone(frame.args))
return table.concat{
lib.tutorgames{ {'SpSc', p[4]}, {'IA', p[5]}, {'DLPS', p[6]} },
' ',
entry(p[1] or 'Tuono',
p[2],
lib.makeNotes(p[3] or '')
)
}
end
z.Tutor = z.tutor
-- Entry per le mosse apprese tramite evoluzioni precedenti
z.preevo = function(frame)
local p = lib.sanitize(mw.clone(frame.args))
return table.concat{
lib.autopreevo(p, 3, '8'),
' ',
entry(p[1] or 'Bora', p[2], '')
}
end
z.Preevo, z.prevo, z.Prevo = z.preevo, z.preevo, z.preevo
-- Entry per le mosse apprese tramite eventi
z.event = function(frame)
local p = lib.sanitize(mw.clone(frame.args))
return table.concat{
string.interp(strings.BREEDENTRY, {
p1 = p[4] or 'Evento',
-- p10 = lib.makeLevel(p[5]),
}
),
entry(p[1] or 'Bora', p[2], lib.makeNotes(p[3] or ''))
}
end
z.Event = z.event
-- Entry per i Pokémon che non imparano mosse aumentando di livello
z.levelnull = function(_)
return lib.entrynull('level', '11')
end
z.Levelnull = z.levenull
-- Entry per i Pokémon che non imparano mosse tramite MT/MN
z.tmnull = function(_)
return lib.entrynull('tm', '11')
end
z.Tmnull = z.tmnull
-- Entry per i Pokémon che non imparano mosse tramite accoppiamento
z.breednull = function(_)
return lib.entrynull('breed', '10')
end
z.Breednull = z.breednull
-- Entry per i Pokémon che non imparano mosse dall'esperto mosse
z.tutornull = function(_)
return lib.entrynull('tutor', '13')
end
z.Tutornull = z.tutornull
-- Entry per i Pokémon che non imparano mosse tramite evoluzioni precedenti
z.preevonull = function(_)
return lib.entrynull('preevo', '10')
end
z.Preevonull, z.prevonull, z.Prevonull = z.preevonull, z.preevonull, z.preevonull
return z
| cc0-1.0 |
LegionXI/darkstar | scripts/globals/effects/aftermath.lua | 30 | 2749 | -----------------------------------
--
-- EFFECT_AFTERMATH
--
-----------------------------------
require("scripts/globals/status");
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
local power = effect:getPower();
if (effect:getSubPower() == 1) then
target:addMod(MOD_SUBTLE_BLOW,power);
elseif (effect:getSubPower() == 2) then
target:addMod(MOD_CRITHITRATE,power)
elseif (effect:getSubPower() == 3) then
target:addMod(MOD_REGEN,power)
elseif (effect:getSubPower() == 4) then
target:addMod(MOD_ATTP,power)
elseif (effect:getSubPower() == 5) then
target:addMod(MOD_DMG,power)
elseif (effect:getSubPower() == 6) then
target:addMod(MOD_HASTE_GEAR,power)
elseif (effect:getSubPower() == 7) then
target:addMod(MOD_SPIKES,5)
target:addMod(MOD_SPIKES_DMG,power)
elseif (effect:getSubPower() == 8) then
target:addMod(MOD_STORETP,power)
elseif (effect:getSubPower() == 9) then
target:addMod(MOD_ACC,power)
elseif (effect:getSubPower() == 10) then
target:addMod(MOD_REFRESH,power)
elseif (effect:getSubPower() == 11) then
target:addMod(MOD_ENMITY,power)
elseif (effect:getSubPower() == 12) then
target:addMod(MOD_RACC,power)
end
end;
-----------------------------------
-- onEffectTick Action
-----------------------------------
function onEffectTick(target,effect)
end;
-----------------------------------
-- onEffectLose Action
-----------------------------------
function onEffectLose(target,effect)
local power = effect:getPower();
if (effect:getSubPower() == 1) then
target:delMod(MOD_SUBTLE_BLOW,power);
elseif (effect:getSubPower() == 2) then
target:delMod(MOD_CRITHITRATE,power)
elseif (effect:getSubPower() == 3) then
target:delMod(MOD_REGEN,power)
elseif (effect:getSubPower() == 4) then
target:delMod(MOD_ATTP,power)
elseif (effect:getSubPower() == 5) then
target:delMod(MOD_DMG,power)
elseif (effect:getSubPower() == 6) then
target:delMod(MOD_HASTE_GEAR,power)
elseif (effect:getSubPower() == 7) then
target:delMod(MOD_SPIKES,5);
target:delMod(MOD_SPIKES_DMG,power)
elseif (effect:getSubPower() == 8) then
target:delMod(MOD_STORETP,power)
elseif (effect:getSubPower() == 9) then
target:delMod(MOD_ACC,power)
elseif (effect:getSubPower() == 10) then
target:delMod(MOD_REFRESH,power)
elseif (effect:getSubPower() == 11) then
target:delMod(MOD_ENMITY,power)
elseif (effect:getSubPower() == 12) then
target:delMod(MOD_RACC,power)
end
end; | gpl-3.0 |
rigeirani/btg | plugins/webshot.lua | 919 | 1473 | local helpers = require "OAuth.helpers"
local base = 'https://screenshotmachine.com/'
local url = base .. 'processor.php'
local function get_webshot_url(param)
local response_body = {}
local request_constructor = {
url = url,
method = "GET",
sink = ltn12.sink.table(response_body),
headers = {
referer = base,
dnt = "1",
origin = base,
["User-Agent"] = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36"
},
redirect = false
}
local arguments = {
urlparam = param,
size = "FULL"
}
request_constructor.url = url .. "?" .. helpers.url_encode_arguments(arguments)
local ok, response_code, response_headers, response_status_line = https.request(request_constructor)
if not ok or response_code ~= 200 then
return nil
end
local response = table.concat(response_body)
return string.match(response, "href='(.-)'")
end
local function run(msg, matches)
local find = get_webshot_url(matches[1])
if find then
local imgurl = base .. find
local receiver = get_receiver(msg)
send_photo_from_url(receiver, imgurl)
end
end
return {
description = "Send an screenshot of a website.",
usage = {
"!webshot [url]: Take an screenshot of the web and send it back to you."
},
patterns = {
"^!webshot (https?://[%w-_%.%?%.:/%+=&]+)$",
},
run = run
}
| gpl-2.0 |
greasydeal/darkstar | scripts/zones/Caedarva_Mire/npcs/Jazaraat_s_Headstone.lua | 4 | 1889 | -----------------------------------
-- Area: Caedarva Mire
-- NPC: Jazaraat's Headstone
-- Involved in mission: The Lost Kingdom (TOAUM 13)
-- @pos -389 6 -570 79
-----------------------------------
package.loaded["scripts/zones/Caedarva_Mire/TextIDs"] = nil;
require("scripts/zones/Caedarva_Mire/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if(player:getCurrentMission(TOAU) == LOST_KINGDOM and player:hasKeyItem(VIAL_OF_SPECTRAL_SCENT) and player:getVar("TOAUM13") == 0)then
player:startEvent(0x0008);
elseif(player:getVar("TOAUM13") == 1)then
if(GetMobAction(17101146) == 0) then
SpawnMob(17101146):updateEnmity(player);
end
elseif(player:getVar("TOAUM13") ==2)then
player:startEvent(0x0009);
elseif(player:getVar("TOAUM13") ==3)then
player:setVar("TOAUM13",0);
player:addKeyItem(EPHRAMADIAN_GOLD_COIN);
player:messageSpecial(KEYITEM_OBTAINED,EPHRAMADIAN_GOLD_COIN);
player:completeMission(TOAU,LOST_KINGDOM);
player:addMission(TOAU,THE_DOLPHIN_CREST);
else
player:messageSpecial(JAZARAATS_HEADSTONE);
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 == 0x0008)then
player:setVar("TOAUM13",1);
elseif(csid == 0x0009)then
player:setVar("TOAUM13",3);
end
end;
| gpl-3.0 |
LegionXI/darkstar | scripts/zones/Temenos/mobs/Fire_Elemental.lua | 28 | 1740 | -----------------------------------
-- Area: Temenos E T
-- NPC: Fire_Elemental
-----------------------------------
package.loaded["scripts/zones/Temenos/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/limbus");
require("scripts/zones/Temenos/TextIDs");
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
end;
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
local mobID = mob:getID();
local mobX = mob:getXPos();
local mobY = mob:getYPos();
local mobZ = mob:getZPos();
switch (mobID): caseof {
[16928840] = function (x)
GetNPCByID(16928768+173):setPos(mobX,mobY,mobZ);
GetNPCByID(16928768+173):setStatus(STATUS_NORMAL);
end ,
[16928841] = function (x)
GetNPCByID(16928768+215):setPos(mobX,mobY,mobZ);
GetNPCByID(16928768+215):setStatus(STATUS_NORMAL);
end ,
[16928842] = function (x)
GetNPCByID(16928768+284):setPos(mobX,mobY,mobZ);
GetNPCByID(16928768+284):setStatus(STATUS_NORMAL);
end ,
[16928843] = function (x)
GetNPCByID(16928768+40):setPos(mobX,mobY,mobZ);
GetNPCByID(16928768+40):setStatus(STATUS_NORMAL);
end ,
[16929033] = function (x)
if (IsMobDead(16929034)==false) then -- ice
DespawnMob(16929034);
SpawnMob(16929040);
end
end ,
}
end; | gpl-3.0 |
naclander/tome | game/modules/tome/data/lore/iron-throne.lua | 1 | 12097 | -- 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
--------------------------------------------------------------------------
-- Iron Throne
--------------------------------------------------------------------------
newLore{
id = "iron-throne-profits-1",
category = "iron throne",
name = "Iron Throne Profits History: Age of Allure",
lore = [[#{bold}#3800: #{normal}#Gold accepted as standard unit of currency amongst all races after heavy lobbying. This is greatly to our favour, as our vein resources are high and the material otherwise has no practical usage. Must continue to stockpile more.
#{bold}#4200: #{normal}#New smelting techniques developed allow more stralite to be recovered from existing veins. Techniques must be kept hidden from other races.
#{bold}#4362: #{normal}#Grand Smith Dakhtun has discovered new methods of infusing magical effects in weapons and armour. Potential for profit growth in this area very high.
#{bold}#4550: #{normal}#First special meeting of Iron Throne Profits Committee. War with humans and halflings worrying, as it is reducing potential market size. Threat of complete market elimination forces us to drastic action - all weapons trade must cease. Increase stockpiles of construction materials in hope of eventual reconciliation.
#{bold}#5967: #{normal}#Shaloren involvement in war is becoming too grave a risk - legends of Sher'Tul destruction are a pertinent reminder of the dangers of high magic. Increasing investment in new Ziguranth order in hopes of opposing this problem.
#{bold}#6550: #{normal}#War ended. Opportunity presents itself - now reopening trade, with high prices on all construction items. Profits forecast is very high.
#{bold}#6827: #{normal}#Killed Kroltar the Crimson Wyrm and recovered his hoard. Value of hoard: 2 million gold. Resources lost in recovery effort: 700,000 gold (estimation based on standard assessment of 350 gold per capita lost). Net profit: 1.3 million gold. Profit margin is 186%!
#{bold}#6980: #{normal}#Resources based on dragon hoards are dwindling. Must reduce cull targets to allow recovery of numbers.
#{bold}#7420: #{normal}#Major orc attacks are ruining trade arrangements. Cutting off all contracts until markets settle.
#{bold}#7494: #{normal}#Disastrous use of magic by Shaloren elves has had an unprecedented impact on profitability of our operations. Increasing protectionist measures to prevent economic ruin.]],
}
newLore{
id = "iron-throne-profits-2",
category = "iron throne",
name = "Iron Throne Profits History: Age of Dusk",
lore = [[#{bold}#412: #{normal}#Diseases and food shortages force increased trade with other races. For the first time in our great history we are in the red. Morale amongst the people is at an all-time low, and is badly affecting productivity.
#{bold}#1430: #{normal}#Several mages visited and used their arts to cure many of the plagues we have suffered for centuries. When offered payment they refused. How very odd...
#{bold}#1490: #{normal}#Production now nearing pre-Spellblaze levels. Profits high, and commerce with other races increasing.
#{bold}#1567: #{normal}#Gigantic earthquakes have completely destroyed many of our major production facilities. Loss of personnel resources is also very tragic, especially key production experts. This is having a very negative effect on our forecasts.]],
}
newLore{
id = "iron-throne-profits-3",
category = "iron throne",
name = "Iron Throne Profits History: Age of Pyre",
lore = [[#{bold}#240: #{normal}#Market forecasts recovering better than expected. Increasing expansion in external trade areas.
#{bold}#490: #{normal}#Orcish attacks have become much worse - seem to be using higher magic and some demonic forces. Potential threat to resources.
#{bold}#581: #{normal}#Several key cities overwhelmed from underground by attacks from orcs and strange horrors. Have collapsed lower caverns to prevent further penetration. Working on continued resource protection measures.
#{bold}#711: #{normal}#Developed key strategic agreements with outside races to help contain orcish threat to resources and infrastructure. Relations with Toknor of the humans are seen to be especially important - have sent him some of our best armour and weapons to ensure a good return on our investments. In hindsight we should have charged more for these.
#{bold}#713: #{normal}#Orcish threat eliminated. Profits beginning to soar due to increased external trade relations.
]],
}
newLore{
id = "iron-throne-profits-4",
category = "iron throne",
name = "Iron Throne Profits History: Age of Ascendancy",
lore = [[#{bold}#28: #{normal}#Mutual defence treaty signed with newly formed Allied Kingdom, and further trade routes opened. Highest ever recorded profit in final quarter of this year.
#{bold}#115: #{normal}#Noted a return of an orcish presence in the collapsed caverns beneath the Iron Throne. Also increased reports of horrors and demons affecting mining operations. Key strategic decision taken: these must be kept hidden from the other races. Uncertainty will only destabilise the markets. Increase stockpiles of weapons and armour, especially voratun and stralite materials, in case of new war trade.
#{bold}#120: #{normal}#Orcish raid has stolen many of our stockpiled weapons. Pressures on mining operations have increased, cutting off key stralite veins. Resource protection measures need increasing, whilst threat must be contained beneath us. Profits are stable, but under heavy threat.]],
}
newLore{
id = "iron-throne-reknor-edict",
category = "iron throne",
name = "Iron Throne Edict",
lore = [[#{bold}#AN EDICT TO ALL CITIZENS OF THE IRON THRONE. LONG MAY OUR EMPIRE ENDURE.#{normal}#
The rumours you have heard are true. It is with a heavy heart that I confirm one of our mines, Reknor, has been overtaken and inhabited by a large and organised orcish force. How there could be such a decisive and total failure on our part to stop this threat remains a mystery - the source of the orcish invasion remains unknown. A battalion of soldiers will form a defensive perimeter around Reknor until a force to retake the mine and exterminate the orcs can be mustered. All civilians residing within the surrounding halls are to be evacuated.
This is a grave and unprecedented issue, so I decree an oath of silence to be laid upon all citizens of the Iron Throne, regardless of class and station: NO NEWS OF THIS INVASION MUST REACH FOREIGN EARS. We must maintain an image of stability and strength with the Allied Kingdom, as any signs of weakness or internal strife would be catastrophic to our alliance and future trade agreements. Any citizen found divulging this information to any outside party will be punished with exile. Rest assured, I will personally send messages to those outside the Throne who can be trusted with this information, and I trust this orcish intrusion shall be dealt with swiftly and decisively. So speaks the ruler of the Iron Throne, long may our empire endure.]]
}
newLore{
id = "iron-throne-trade-ledger",
category = "iron throne",
name = "Iron Throne trade ledger",
lore = [[#{bold}#IRON THRONE TRADE LEDGER - Allied Kingdom#{normal}#
#{italic}#Age of Ascendancy, 121#{normal}#
#{bold}#Last Hope - Exports#{normal}#
Steel Plate Armour (Human) - 500pcs.
Steel Plate Armour (Halfling) - 460pcs.
Steel Armaments -
* Longswords - 170pcs.
* Spears - 200pcs.
* Maces - 150pcs.
Crafts, Sundries - 2,200pcs.
#{bold}#Derth - Exports#{normal}#
Iron Hatchets - 50pcs.
Tools, Sundries - 65pcs.
#{bold}#Last Hope - Imports#{normal}#
Gold - 500,000pcs.
Grains, Etc. - 1,000tons
#{bold}#CONFIDENTIAL: Angolwen - Exports#{normal}#
Garnets - 50pcs.
Rubies - 40pcs.
Diamonds - 20pcs.
low diamond yield this year - +50% charge? ziguranth raided our last ang. caravan - more guards? - D.
yes to diamonds. arm our merchants in the caravan, no extra guards. profits are thin enough as it is! - S.]]
}
newLore{
id = "iron-throne-last-words",
category = "iron throne",
name = "Iron Throne Reknor expedition, last words",
lore = [[...We are lost. The orcish forces are too great. No matter how many our squad slays, yet more surge from the depths. Where are the cursed creatures coming from?! We have spied their leader, but have had no hope in killing him; he is a beast, a destroyer, burning with fire infernal and ice cruel and chilling. The power these orcs wield now fills me with dread... perhaps they have found new, mighty allies? This news must reach our ruler. My comrades... I am sorry. I will flee once the opportunity arises, but know that your sacrifices will not be in vain. Long may our empire endure.]]
}
--------------------------------------------------------------------------
-- Iron Throne: Deep Bellow
--------------------------------------------------------------------------
newLore{
id = "deep-bellow-1",
category = "iron throne",
name = "Deep Bellow excavation report 1",
lore = [[10 days into initial site survey, hmm! Recent tremors have opened deep new chasms, but we must work cautiously to ensure they're stable before conducting major operations, oh yes! Proceeding well at start, with supports being put in place and no flammable gases detected, hmm hmm.
Some Sher'Tul relics have been found. Perhaps great profit to be had here! High margins on Shaloren market, yes yes.
Some miners saying they feel ill, hrm hrm. The drem fools have likely been gorging on too much mead. Will deduct it from their pay, yes yes!
-- Foreman Tamoth]]
}
newLore{
id = "deep-bellow-2",
category = "iron throne",
name = "Deep Bellow excavation report 2",
bloodstains = 3,
lore = [[Chasms go deep, yes yes. More relics found, oh yes. Will be mighty profitable! But ah, my secret treasure is even better, indeed! Gold! Beautiful lovely gold, buried deep, so deep... Have kept it hidden, sealed, yes. Looks like the remains of a giant throne. I touched it, yes, I even put my lips to it - ahhh, the taste!
But must stay focussed, much work to be done. Miners are rowdy, hrm! One of the drem fools went mad and killed himself with a pickaxe - messy business. Must restore order, yes yes! More Sher'Tul artifacts found, possibly even remains of weapons. Imagine the profit! Will keep them hidden yes, the dreams say yes, in the darkness, secret, waiting waiting, for the right time...
Hmm, that fellow's blood was so red, spilling on the cavernous floor. I wonder where they buried him? My mouth... it wants to taste, yes yes...
-- Foreman Tamoth]]
}
newLore{
id = "deep-bellow-3",
category = "iron throne",
name = "Deep Bellow excavation report 3",
bloodstains = 12,
lore = [[Hah, my mouth, it tastes, it feels, hmm hmm. It grows, yes yes! The others are changing, flying, screaming, squelching, warping. Bad for profit, hmm hmm. My teeth, they grow, they hunger, yes. They want to escape!
I can feel in my dreams, the dark depths. Bound, buried, forgotten. My mouth wants to open, to scream, to destroy! Hmm hmm, deep below, yes... Want to get out!
Must stay down here to be close to the dreams, yes yes. Must plant my mouth in the soil and watch it grow! It will devour me, and grow and grow, hmm hmm. It will call from the dark place, and bring back Him from the deepest below, oh yes.
-- Ta...moth... The mouth... yes yes!]]
}
| gpl-3.0 |
everhopingandwaiting/telegram-bot | plugins/time.lua | 771 | 2865 | -- Implement a command !time [area] which uses
-- 2 Google APIs to get the desired result:
-- 1. Geocoding to get from area to a lat/long pair
-- 2. Timezone to get the local time in that lat/long location
-- Globals
-- If you have a google api key for the geocoding/timezone api
api_key = nil
base_api = "https://maps.googleapis.com/maps/api"
dateFormat = "%A %d %B - %H:%M:%S"
-- Need the utc time for the google api
function utctime()
return os.time(os.date("!*t"))
end
-- Use the geocoding api to get the lattitude and longitude with accuracy specifier
-- CHECKME: this seems to work without a key??
function get_latlong(area)
local api = base_api .. "/geocode/json?"
local parameters = "address=".. (URL.escape(area) or "")
if api_key ~= nil then
parameters = parameters .. "&key="..api_key
end
-- Do the request
local res, code = https.request(api..parameters)
if code ~=200 then return nil end
local data = json:decode(res)
if (data.status == "ZERO_RESULTS") then
return nil
end
if (data.status == "OK") then
-- Get the data
lat = data.results[1].geometry.location.lat
lng = data.results[1].geometry.location.lng
acc = data.results[1].geometry.location_type
types= data.results[1].types
return lat,lng,acc,types
end
end
-- Use timezone api to get the time in the lat,
-- Note: this needs an API key
function get_time(lat,lng)
local api = base_api .. "/timezone/json?"
-- Get a timestamp (server time is relevant here)
local timestamp = utctime()
local parameters = "location=" ..
URL.escape(lat) .. "," ..
URL.escape(lng) ..
"×tamp="..URL.escape(timestamp)
if api_key ~=nil then
parameters = parameters .. "&key="..api_key
end
local res,code = https.request(api..parameters)
if code ~= 200 then return nil end
local data = json:decode(res)
if (data.status == "ZERO_RESULTS") then
return nil
end
if (data.status == "OK") then
-- Construct what we want
-- The local time in the location is:
-- timestamp + rawOffset + dstOffset
local localTime = timestamp + data.rawOffset + data.dstOffset
return localTime, data.timeZoneId
end
return localTime
end
function getformattedLocalTime(area)
if area == nil then
return "The time in nowhere is never"
end
lat,lng,acc = get_latlong(area)
if lat == nil and lng == nil then
return 'It seems that in "'..area..'" they do not have a concept of time.'
end
local localTime, timeZoneId = get_time(lat,lng)
return "The local time in "..timeZoneId.." is: ".. os.date(dateFormat,localTime)
end
function run(msg, matches)
return getformattedLocalTime(matches[1])
end
return {
description = "Displays the local time in an area",
usage = "!time [area]: Displays the local time in that area",
patterns = {"^!time (.*)$"},
run = run
}
| gpl-2.0 |
fegimanam/sa | plugins/time.lua | 771 | 2865 | -- Implement a command !time [area] which uses
-- 2 Google APIs to get the desired result:
-- 1. Geocoding to get from area to a lat/long pair
-- 2. Timezone to get the local time in that lat/long location
-- Globals
-- If you have a google api key for the geocoding/timezone api
api_key = nil
base_api = "https://maps.googleapis.com/maps/api"
dateFormat = "%A %d %B - %H:%M:%S"
-- Need the utc time for the google api
function utctime()
return os.time(os.date("!*t"))
end
-- Use the geocoding api to get the lattitude and longitude with accuracy specifier
-- CHECKME: this seems to work without a key??
function get_latlong(area)
local api = base_api .. "/geocode/json?"
local parameters = "address=".. (URL.escape(area) or "")
if api_key ~= nil then
parameters = parameters .. "&key="..api_key
end
-- Do the request
local res, code = https.request(api..parameters)
if code ~=200 then return nil end
local data = json:decode(res)
if (data.status == "ZERO_RESULTS") then
return nil
end
if (data.status == "OK") then
-- Get the data
lat = data.results[1].geometry.location.lat
lng = data.results[1].geometry.location.lng
acc = data.results[1].geometry.location_type
types= data.results[1].types
return lat,lng,acc,types
end
end
-- Use timezone api to get the time in the lat,
-- Note: this needs an API key
function get_time(lat,lng)
local api = base_api .. "/timezone/json?"
-- Get a timestamp (server time is relevant here)
local timestamp = utctime()
local parameters = "location=" ..
URL.escape(lat) .. "," ..
URL.escape(lng) ..
"×tamp="..URL.escape(timestamp)
if api_key ~=nil then
parameters = parameters .. "&key="..api_key
end
local res,code = https.request(api..parameters)
if code ~= 200 then return nil end
local data = json:decode(res)
if (data.status == "ZERO_RESULTS") then
return nil
end
if (data.status == "OK") then
-- Construct what we want
-- The local time in the location is:
-- timestamp + rawOffset + dstOffset
local localTime = timestamp + data.rawOffset + data.dstOffset
return localTime, data.timeZoneId
end
return localTime
end
function getformattedLocalTime(area)
if area == nil then
return "The time in nowhere is never"
end
lat,lng,acc = get_latlong(area)
if lat == nil and lng == nil then
return 'It seems that in "'..area..'" they do not have a concept of time.'
end
local localTime, timeZoneId = get_time(lat,lng)
return "The local time in "..timeZoneId.." is: ".. os.date(dateFormat,localTime)
end
function run(msg, matches)
return getformattedLocalTime(matches[1])
end
return {
description = "Displays the local time in an area",
usage = "!time [area]: Displays the local time in that area",
patterns = {"^!time (.*)$"},
run = run
}
| gpl-2.0 |
LegionXI/darkstar | scripts/zones/RuLude_Gardens/npcs/Rainhard.lua | 14 | 1050 | -----------------------------------
-- Area: Ru'Lude Gardens
-- NPC: Rainhard
-- Type: Standard NPC
-- @zone 243
-- @pos -2.397 -5.999 68.749
--
-- Auto-Script: Requires Verification (Verfied by Brawndo)
-----------------------------------
package.loaded["scripts/zones/RuLude_Gardens/TextIDs"] = nil;
-----------------------------------
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x0022);
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/Davoi/npcs/Bernal.lua | 14 | 1152 | -----------------------------------
-- Area: Davoi
-- NPC: Bernal
-- @pos 177 -3 -127 149
-----------------------------------
package.loaded["scripts/zones/Davoi/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/zones/Davoi/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x001e);
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 == 0x002a and option == 0) then
player:messageSpecial(POWER_OF_THE_ORB_ALLOW_PASS);
end
end; | gpl-3.0 |
raymond-w-ko/moonscheme | tests/run_tests.lua | 1 | 2924 | package.path = './?.lua;./?/init.lua'
require('tests.strict')
local util = require('moonscheme.util')
local moonscheme = require('moonscheme')
local InputStringPort = moonscheme.InputStringPort
local OutputStringPort = moonscheme.OutputStringPort
local port = InputStringPort.new('')
assert(port:read_char() == moonscheme.EOF)
assert(port:peek_char() == moonscheme.EOF)
assert(port:read_char() == moonscheme.EOF)
local port = InputStringPort.new('a')
assert(port:read_char() == 'a')
local port = InputStringPort.new('a')
assert(port:peek_char() == 'a')
assert(port:read_char() == 'a')
assert(port:peek_char() == moonscheme.EOF)
assert(port:read_char() == moonscheme.EOF)
local function read(text)
local port = InputStringPort.new(text)
local data = moonscheme.read(port)
-- print(data)
return data
end
assert(read('1') == 1)
assert(read('1.1') == 1.1)
assert(read('0xffff') == 65535)
assert(read('+42') == 42)
assert(read('-42') == -42)
-- print(util.show(read('foo')))
-- read('[]')
-- read('{}')
assert(read([["\\"]]) == [[\]])
assert(read([["\""]]) == [["]])
assert(read([["Here's text \
containing just one line"]]) ==
[[Here's text containing just one line]])
assert(read([[#t]]) == true)
assert(read([[#true]]) == true)
assert(read([[#f]]) == false)
assert(read([[#false]]) == false)
assert(read('||').name == '||')
assert(read('|Hello|').name == 'Hello')
local function serialize_check(text)
local inport = InputStringPort.new(text)
local data = moonscheme.read(inport)
-- print(util.show(data))
local outport = OutputStringPort.new()
moonscheme.write(data, outport)
local serialized_text = outport:get_output_string()
-- print(serialized_text)
assert(serialized_text == text)
end
serialize_check([[#t]])
serialize_check([[#f]])
serialize_check([["asdf"]])
serialize_check([["\t"]])
serialize_check([[foo]])
-- samples from official whitepaper
serialize_check([[...]])
serialize_check([[+]])
serialize_check([[-]])
serialize_check([[+soup+]])
serialize_check([[<=?]])
serialize_check([[->string]])
serialize_check([[a34kTMNs]])
serialize_check([[lambda]])
serialize_check([[list->vector]])
serialize_check([[q]])
serialize_check([[V17a]])
serialize_check([[()]])
serialize_check([[(list)]])
serialize_check([[(foo bar)]])
serialize_check([[(foo . bar)]])
serialize_check([[(foo bar (fizz buzz))]])
-- read('(. 2)')
serialize_check([[(1 . 2)]])
assert(moonscheme.car(read([[(1 . 2)]])) == 1)
assert(moonscheme.cdr(read([[(1 . 2)]])) == 2)
local function eval(text)
print(text)
local port = InputStringPort.new(text)
local data = moonscheme.read(port)
while data ~= moonscheme.EOF do
local ret = moonscheme.eval(data)
local out_port = moonscheme.stdout_port
moonscheme.write(ret, out_port)
print("")
data = moonscheme.read(port)
end
print("\n----------------------------------------")
end
moonscheme.require("tests.test0")
| mit |
greasydeal/darkstar | scripts/globals/items/demonic_sword.lua | 16 | 1039 | -----------------------------------------
-- ID: 16936
-- Item: Demonic Sword
-- Additional Effect: Darkness Damage
-----------------------------------------
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------
-- onAdditionalEffect Action
-----------------------------------
function onAdditionalEffect(player,target,damage)
local chance = 10;
if (math.random(0,99) >= chance) then
return 0,0,0;
else
local dmg = math.random(5,21);
local params = {};
params.bonusmab = 0;
params.includemab = false;
dmg = addBonusesAbility(player, ELE_DARK, target, dmg, params);
dmg = dmg * applyResistanceAddEffect(player,target,ELE_DARK,0);
dmg = adjustForTarget(target,dmg,ELE_DARK);
dmg = finalMagicNonSpellAdjustments(player,target,ELE_DARK,dmg);
local message = 163;
if (dmg < 0) then
message = 167;
end
return SUBEFFECT_DARKNESS_DAMAGE,message,dmg;
end
end; | gpl-3.0 |
LegionXI/darkstar | scripts/zones/Bastok_Mines/npcs/Echo_Hawk.lua | 14 | 1624 | -----------------------------------
-- Area: Bastok Mines
-- NPC: Echo Hawk
-- Standard Info NPC
-- Involved in Quest: The Siren's Tear
-- @pos -0.965 5.999 -15.567 234
-----------------------------------
package.loaded["scripts/zones/Bastok_Mines/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/zones/Bastok_Mines/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local SirensTear = player:getQuestStatus(BASTOK,THE_SIREN_S_TEAR);
local WildcatBastok = player:getVar("WildcatBastok");
if (player:getQuestStatus(BASTOK,LURE_OF_THE_WILDCAT_BASTOK) == QUEST_ACCEPTED and player:getMaskBit(WildcatBastok,17) == false) then
player:startEvent(0x01f9);
elseif (SirensTear == QUEST_AVAILABLE) then
player:startEvent(0x0005);
else
player:startEvent(0x000d);
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 == 0x01f9) then
player:setMaskBit(player:getVar("WildcatBastok"),"WildcatBastok",17,true);
end
end; | gpl-3.0 |
Wargus/wargus | scripts/lib/classes.lua | 2 | 1087 | function class(base, init)
local c = {} -- a new class instance
if not init and type(base) == 'function' then
init = base
base = nil
elseif type(base) == 'table' then
-- our new class is a shallow copy of the base class!
for i,v in pairs(base) do
c[i] = v
end
c._base = base
end
-- the class will be the metatable for all its objects,
-- and they will look up their methods in it.
c.__index = c
-- expose a constructor which can be called by <classname>(<args>)
local mt = {}
mt.__call = function(class_tbl, ...)
local obj = {}
setmetatable(obj,c)
if init then
init(obj,...)
else
-- make sure that any stuff from the base class is initialized!
if base and base.init then
base.init(obj, ...)
end
end
return obj
end
c.init = init
c.is_a = function(self, klass)
local m = getmetatable(self)
while m do
if m == klass then return true end
m = m._base
end
return false
end
setmetatable(c, mt)
return c
end
| gpl-2.0 |
LegionXI/darkstar | scripts/globals/items/roast_carp.lua | 12 | 1370 | -----------------------------------------
-- ID: 4537
-- Item: roast_carp
-- Food Effect: 30Min, All Races
-----------------------------------------
-- Dexterity 1
-- Mind -1
-- Ranged ATT % 14 (cap 40)
-----------------------------------------
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,4537);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_DEX, 1);
target:addMod(MOD_MND, -1);
target:addMod(MOD_FOOD_RATTP, 14);
target:addMod(MOD_FOOD_RATT_CAP, 40);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_DEX, 1);
target:delMod(MOD_MND, -1);
target:delMod(MOD_FOOD_RATTP, 14);
target:delMod(MOD_FOOD_RATT_CAP, 40);
end;
| gpl-3.0 |
greasydeal/darkstar | scripts/zones/Horlais_Peak/npcs/Hot_springs.lua | 17 | 1948 | -----------------------------------
-- 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(OUTLANDS,NORG_FAME*75);
player:addTitle(CRACKER_OF_THE_SECRET_CODE);
player:completeQuest(OUTLANDS,SECRET_OF_THE_DAMP_SCROLL);
end
end; | gpl-3.0 |
ibm2431/darkstar | scripts/zones/Bastok_Markets/npcs/Pavel.lua | 9 | 1198 | -----------------------------------
-- Area: Bastok Markets
-- NPC: Pavel
-- Involved in Quest: Stamp Hunt
-- !pos -349.798 -10.002 -181.296 235
-----------------------------------
require("scripts/globals/quests");
-----------------------------------
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
local WildcatBastok = player:getCharVar("WildcatBastok");
local StampHunt = player:getQuestStatus(BASTOK,dsp.quest.id.bastok.STAMP_HUNT);
if (player:getQuestStatus(BASTOK,dsp.quest.id.bastok.LURE_OF_THE_WILDCAT) == QUEST_ACCEPTED and player:getMaskBit(WildcatBastok,14) == false) then
player:startEvent(431);
elseif (StampHunt == QUEST_ACCEPTED and player:getMaskBit(player:getCharVar("StampHunt_Mask"),2) == false) then
player:startEvent(227);
else
player:startEvent(128);
end
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 431) then
player:setMaskBit(player:getCharVar("WildcatBastok"),"WildcatBastok",14,true);
elseif (csid == 227) then
player:setMaskBit(player:getCharVar("StampHunt_Mask"),"StampHunt_Mask",2,true);
end
end;
| gpl-3.0 |
Wargus/wargus | scripts/missiles.lua | 1 | 10667 | -- _________ __ __
-- / _____// |_____________ _/ |______ ____ __ __ ______
-- \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
-- / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \
-- /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
-- \/ \/ \//_____/ \/
-- ______________________ ______________________
-- T H E W A R B E G I N S
-- Stratagus - A free fantasy real time strategy game engine
--
-- missiles.lua - Define the used missiles.
--
-- (c) Copyright 1998-2004 by Lutz Sammer, Fabrice Rossi,
-- Jimmy Salmon and Crestez Leonard
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
MissileParabolicClass = "missile-class-point-to-point"
if (wc2.preferences.EnhancedEffects) then
MissileParabolicClass = "missile-class-parabolic"
end
DefineMissileType("missile-lightning",
{ File = "missiles/lightning.png", Size = {32, 32}, Frames = 30, NumDirections = 9,
Class = "missile-class-point-to-point-with-hit", Sleep = 1, Speed = 16, Range = 1,
DrawLevel = 50 } )
DefineMissileType("missile-griffon-hammer",
{ File = "missiles/gryphon_hammer.png", Size = {32, 32}, Frames = 15, NumDirections = 9,
ImpactSound = "fireball hit",
Class = "missile-class-point-to-point-bounce", NumBounces = 3, Sleep = 1, Speed = 16, Range = 2,
DrawLevel = 50, ImpactMissile = "missile-explosion", SplashFactor = 2 } )
DefineMissileType("missile-dragon-breath",
{ File = "missiles/dragon_breath.png", Size = {32, 32}, Frames = 5, NumDirections = 9,
ImpactSound = "fireball hit",
Class = "missile-class-point-to-point-bounce", NumBounces = 3, Sleep = 1, Speed = 16, Range = 2,
DrawLevel = 70, ImpactMissile = "missile-explosion", SplashFactor = 2 } )
DefineMissileType("missile-fireball",
{ File = "missiles/fireball.png", Size = {32, 32}, Frames = 5, NumDirections = 9,
ImpactSound = "fireball hit",
DrawLevel = 50, Class = "missile-class-point-to-point-bounce", NumBounces = 5, Sleep = 1, Speed = 16, Range = 2,
ImpactMissile = "missile-explosion", SplashFactor = 2 } )
DefineMissileType("missile-flame-shield",
{ File = "missiles/flame_shield.png", Size = {32, 48}, Frames = 6, NumDirections = 1,
DrawLevel = 50, Class = "missile-class-flame-shield", Sleep = 1, Speed = 4, Range = 1 } )
DefineMissileType("missile-blizzard",
{ File = "missiles/blizzard.png", Size = {32, 32}, Damage = Rand(10), Frames = 4, NumDirections = 1, ImpactSound = "fireball hit",
Class = "missile-class-point-to-point-with-hit", Sleep = 1, BlizzardSpeed = 4, Speed = 16, Range = 1,
DrawLevel = 100 } )
DefineMissileType("missile-death-and-decay",
{ File = "missiles/death_and_decay.png", Size = {32, 32}, Damage = Rand(10), Frames = 8, NumDirections = 1,
DrawLevel = 100, Class = "missile-class-stay", Sleep = 1, Speed = 0, Range = 1 } )
DefineMissileType("missile-big-cannon",
{ File = "missiles/big_cannon.png", Size = {16, 16}, Frames = 20, NumDirections = 9,
DrawLevel = 50, ImpactSound = "explosion",
Class = "missile-class-point-to-point", Sleep = 1, Speed = 16, Range = 2,
ImpactMissile = "missile-cannon-tower-explosion", SplashFactor = 4 } )
DefineMissileType("missile-exorcism",
{ File = "missiles/exorcism.png", Size = {48, 48}, Frames = 10, NumDirections = 1,
DrawLevel = 50, Class = "missile-class-point-to-point", Sleep = 1, Speed = 16, Range = 1 } )
DefineMissileType("missile-heal-effect",
{ File = "missiles/heal_effect.png", Size = {48, 48}, Frames = 10, NumDirections = 1,
DrawLevel = 50, Class = "missile-class-stay", Sleep = 1, Speed = 16, Range = 1 } )
DefineMissileType("missile-touch-of-death",
{ File = "missiles/touch_of_death.png", Size = {32, 32}, Frames = 30, NumDirections = 9,
DrawLevel = 50, Class = "missile-class-point-to-point-with-hit", Sleep = 1, Speed = 16, Range = 1 } )
DefineMissileType("missile-rune",
{ File = "missiles/rune.png", Size = {16, 16}, Frames = 4, NumDirections = 1,
DrawLevel = 20, Class = "missile-class-land-mine", Sleep = 5, Speed = 16, Range = 1,
ImpactMissile = "missile-explosion", CanHitOwner = true } )
DefineMissileType("missile-whirlwind",
{ File = "missiles/tornado.png", Size = {56, 56}, Frames = 4, NumDirections = 1,
DrawLevel = 50, Class = "missile-class-whirlwind", Sleep = 1, Speed = 2, Range = 2 } )
DefineMissileType("missile-catapult-rock",
{ File = "missiles/catapult_rock.png", Size = {32, 32}, Frames = 15, NumDirections = 9,
ImpactSound = "explosion",
DrawLevel = 50, Class = MissileParabolicClass, Sleep = 1, Speed = 8, Range = 2,
ImpactMissile = "missile-impact", SplashFactor = 4 } )
DefineMissileType("missile-ballista-bolt",
{ File = "missiles/ballista_bolt.png", Size = {64, 64}, Frames = 5, NumDirections = 9,
DrawLevel = 50, ImpactSound = "explosion",
Class = "missile-class-point-to-point", Sleep = 1, Speed = 8, Range = 2,
ImpactMissile = "missile-impact", SplashFactor = 4 } )
DefineMissileType("missile-arrow",
{ File = "missiles/arrow.png", Size = {40, 40}, Frames = 5, NumDirections = 9,
DrawLevel = 50, ImpactSound = "bow hit",
Class = "missile-class-point-to-point", Sleep = 1, Speed = 32, Range = 0 } )
DefineMissileType("missile-arrow-super",
{ File = "missiles/arrow.png", Size = {40, 40}, Frames = 5, NumDirections = 9,
DrawLevel = 50, ImpactSound = "bow hit",
Class = "missile-class-point-to-point", Sleep = 1, Speed = 64, Range = 0 } )
DefineMissileType("missile-axe",
{ File = "missiles/axe.png", Size = {32, 32}, Frames = 15, NumDirections = 9,
ImpactSound = "bow hit",
DrawLevel = 50, Class = "missile-class-point-to-point", Sleep = 1, Speed = 32, Range = 0 } )
DefineMissileType("missile-submarine-missile",
{ File = "missiles/submarine_missile.png", Size = {40, 40}, Frames = 5, NumDirections = 9,
ImpactSound = "explosion",
DrawLevel = 50, Class = "missile-class-point-to-point", Sleep = 1, Speed = 16, Range = 1,
ImpactMissile = "missile-impact" } )
DefineMissileType("missile-turtle-missile",
{ File = "missiles/turtle_missile.png", Size = {40, 40}, Frames = 5, NumDirections = 9,
DrawLevel = 50, ImpactSound = "explosion",
Class = "missile-class-point-to-point", Sleep = 1, Speed = 16, Range = 1,
ImpactMissile = "missile-impact" } )
DefineMissileType("missile-small-fire",
{ File = "missiles/small_fire.png", Size = {32, 48}, Frames = 6, NumDirections = 1,
DrawLevel = 45, Class = "missile-class-fire", Sleep = 2, Speed = 16, Range = 1 } )
DefineMissileType("missile-big-fire",
{ File = "missiles/big_fire.png", Size = {48, 48}, Frames = 10, NumDirections = 1,
DrawLevel = 45, Class = "missile-class-fire", Sleep = 2, Speed = 16, Range = 1 } )
DefineMissileType("missile-impact",
{ File = "missiles/ballista-catapult_impact.png", Size = {48, 48}, Frames = 10, NumDirections = 1,
DrawLevel = 50, Class = "missile-class-stay", Sleep = 1, Speed = 16, Range = 1 } )
DefineMissileType("missile-normal-spell",
{ File = "missiles/normal_spell.png", Size = {32, 32}, Frames = 6, NumDirections = 1,
DrawLevel = 50, Class = "missile-class-stay", Sleep = 5, Speed = 0, Range = 1 } )
DefineMissileType("missile-explosion",
{ File = "missiles/explosion.png", Size = {64, 64}, Frames = 20, NumDirections = 1,
DrawLevel = 50, Class = "missile-class-stay", Sleep = 1, Speed = 16, Range = 1 } )
DefineMissileType("missile-small-cannon",
{ File = "missiles/cannon.png", Size = {32, 32}, Frames = 15, NumDirections = 9,
DrawLevel = 50, ImpactSound = "explosion",
Class = MissileParabolicClass, Sleep = 1, Speed = 22, Range = 2,
ImpactMissile = "missile-cannon-tower-explosion", SplashFactor = 3 } )
DefineMissileType("missile-small-cannon-super",
{ File = "missiles/cannon.png", Size = {32, 32}, Frames = 15, NumDirections = 9,
DrawLevel = 50, ImpactSound = "explosion",
Class = MissileParabolicClass, Sleep = 1, Speed = 44, Range = 2,
ImpactMissile = "missile-cannon-tower-explosion", SplashFactor = 3 } )
DefineMissileType("missile-cannon-explosion",
{ File = "missiles/cannon_explosion.png", Size = {32, 32}, Frames = 4, NumDirections = 1,
DrawLevel = 50, Class = "missile-class-stay", Sleep = 2, Speed = 16, Range = 1 } )
DefineMissileType("missile-cannon-tower-explosion",
{ File = "missiles/cannon-tower_explosion.png", Size = {32, 32}, Frames = 4, NumDirections = 1,
DrawLevel = 50, Class = "missile-class-stay", Sleep = 2, Speed = 16, Range = 1 } )
DefineMissileType("missile-daemon-fire",
{ File = "missiles/daemon_fire.png", Size = {32, 32}, Frames = 15, NumDirections = 9,
DrawLevel = 70, ImpactSound = "fireball hit",
Class = "missile-class-point-to-point", Sleep = 1, Speed = 16, Range = 1 } )
DefineMissileType("missile-green-cross",
{ File = "missiles/green_cross.png", Size = {32, 32}, Frames = 4, NumDirections = 1,
DrawLevel = 150, Class = "missile-class-cycle-once", Sleep = 1, Speed = 16, Range = 1 } )
DefineMissileType("missile-none",
{ Size = {32, 32}, DrawLevel = 50,
Class = "missile-class-none", Sleep = 1, Speed = 16, Range = 1 } )
DefineMissileType("missile-death-coil",
{ File = "missiles/touch_of_death.png", Size = {32, 32}, Frames = 30, NumDirections = 9,
DrawLevel = 50, Class = "missile-class-death-coil", Sleep = 1, Speed = 16, Range = 1 } )
DefineMissileType("missile-hit",
{ Size = {15, 15}, DrawLevel = 150,
Class = "missile-class-hit", Sleep = 1, Speed = 1, Range = 16 } )
DefineMissileType("missile-critter-explosion",
{ File = "missiles/explosion.png", Size = {64, 64}, Frames = 20, NumDirections = 1, FiredSound = "explosion",
DrawLevel = 50, Class = "missile-class-stay", Sleep = 1, Speed = 16, Range = 1 } )
DefineBurningBuilding(
{"percent", 0, "missile", "missile-big-fire"},
{"percent", 50, "missile", "missile-small-fire"},
{"percent", 75 } -- no missile
)
| gpl-2.0 |
pleonex/telegram-bot | plugins/rae.lua | 616 | 1312 | do
function getDulcinea( text )
-- Powered by https://github.com/javierhonduco/dulcinea
local api = "http://dulcinea.herokuapp.com/api/?query="
local query_url = api..text
local b, code = http.request(query_url)
if code ~= 200 then
return "Error: HTTP Connection"
end
dulcinea = json:decode(b)
if dulcinea.status == "error" then
return "Error: " .. dulcinea.message
end
while dulcinea.type == "multiple" do
text = dulcinea.response[1].id
b = http.request(api..text)
dulcinea = json:decode(b)
end
local text = ""
local responses = #dulcinea.response
if responses == 0 then
return "Error: 404 word not found"
end
if (responses > 5) then
responses = 5
end
for i = 1, responses, 1 do
text = text .. dulcinea.response[i].word .. "\n"
local meanings = #dulcinea.response[i].meanings
if (meanings > 5) then
meanings = 5
end
for j = 1, meanings, 1 do
local meaning = dulcinea.response[i].meanings[j].meaning
text = text .. meaning .. "\n\n"
end
end
return text
end
function run(msg, matches)
return getDulcinea(matches[1])
end
return {
description = "Spanish dictionary",
usage = "!rae [word]: Search that word in Spanish dictionary.",
patterns = {"^!rae (.*)$"},
run = run
}
end | gpl-2.0 |
ibm2431/darkstar | scripts/zones/Vunkerl_Inlet_[S]/npcs/qm7.lua | 9 | 1940 | -----------------------------------
-- Area: Vunkerl Inlet (S) (H-6)
-- NPC: ???
-- Involved in Quests
-- !pos -26 -31 364
-----------------------------------
local ID = require("scripts/zones/Vunkerl_Inlet_[S]/IDs");
require("scripts/globals/quests");
-----------------------------------
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
if (player:getQuestStatus(CRYSTAL_WAR, dsp.quest.id.crystalWar.BOY_AND_THE_BEAST) == QUEST_AVAILABLE and player:getCharVar("BoyAndTheBeast") == 2) then
player:startEvent(105);
elseif (player:getQuestStatus(CRYSTAL_WAR, dsp.quest.id.crystalWar.BOY_AND_THE_BEAST) == QUEST_ACCEPTED and player:getCharVar("BoyAndTheBeast") == 3) then
player:startEvent(108);
elseif (player:getQuestStatus(CRYSTAL_WAR, dsp.quest.id.crystalWar.BOY_AND_THE_BEAST) == QUEST_ACCEPTED and player:getCharVar("BoyAndTheBeast") == 4) then
player:startEvent(109);
end
end;
function onEventUpdate(player,csid,option)
end
function onEventFinish(player,csid,option)
if (csid == 105) then
player:addQuest(CRYSTAL_WAR, dsp.quest.id.crystalWar.BOY_AND_THE_BEAST);
player:addKeyItem(dsp.ki.VUNKERL_HERB_MEMO);
player:messageSpecial(ID.text.KEYITEM_OBTAINED, dsp.ki.VUNKERL_HERB_MEMO);
elseif (csid == 108) then
if(player:getFreeSlotsCount() == 0) then
player:messageSpecial(ID.text.ITEM_CANNOT_BE_OBTAINED,17384); -- Carbon Fishing Rod
else
player:completeQuest(CRYSTAL_WAR, dsp.quest.id.crystalWar.BOY_AND_THE_BEAST);
player:delKeyItem(dsp.ki.VUNKERL_HERB_MEMO);
player:delKeyItem(dsp.ki.VUNKERL_HERB);
player:addItem(17384);
player:messageSpecial(ID.text.ITEM_OBTAINED,17384); --Carbon Fishing Rod
end
elseif (csid == 109) then
player:delKeyItem(dsp.ki.VUNKERL_HERB);
player:setCharVar("BoyAndTheBeast",2);
end
end;
| gpl-3.0 |
LegionXI/darkstar | scripts/zones/Aht_Urhgan_Whitegate/npcs/Sorrowful_Sage.lua | 14 | 2481 | -----------------------------------
-- Area: Aht Urhgan Whitegate
-- NPC: Sorrowful Sage
-- Type: Assault Mission Giver
-- @pos 134.096 0.161 -30.401 50
-----------------------------------
package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/keyitems");
require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs");
require("scripts/globals/besieged");
require("scripts/globals/missions");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local rank = getMercenaryRank(player);
local haveimperialIDtag;
local tokens = 3;--player:getAssaultPoint(ILRUSI_ASSAULT_POINT);
if (player:hasKeyItem(IMPERIAL_ARMY_ID_TAG)) then
haveimperialIDtag = 1;
else
haveimperialIDtag = 0;
end
--[[ if (rank > 0) then
player:startEvent(278,rank,haveimperialIDtag,tokens,player:getCurrentAssault());
else]]
player:startEvent(284); -- no rank
--end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 278) then
local categorytype = bit.band(option, 0x0F);
if (categorytype == 3) then
-- low grade item
local item = bit.rshift(option, 16);
elseif (categorytype == 4) then
-- medium grade item
local item = bit.rshift(option, 16);
elseif (categorytype == 5) then
-- high grade item
local item = bit.rshift(option, 16);
end
end
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 278) then
local selectiontype = bit.band(option, 0xF);
if (selectiontype == 1) then
-- taken assault mission
player:addAssault(bit.rshift(option,4));
player:delKeyItem(IMPERIAL_ARMY_ID_TAG);
player:addKeyItem(NYZUL_ISLE_ASSAULT_ORDERS);
player:messageSpecial(KEYITEM_OBTAINED,NYZUL_ISLE_ASSAULT_ORDERS);
end
end
end;
| gpl-3.0 |
ibm2431/darkstar | scripts/zones/Apollyon/mobs/Thunder_Elemental.lua | 9 | 2119 | -----------------------------------
-- Area: Apollyon SW
-- Mob: Thunder Elemental
-----------------------------------
require("scripts/globals/limbus");
-----------------------------------
function onMobDeath(mob, player, isKiller)
end;
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(dsp.status.NORMAL);
end
end; | gpl-3.0 |
GENRALVS/GENRAL-VS | data/config.lua | 1 | 1612 | do local _ = {
about_text = "Welcome to DevPoint For more information Subscribe to the channel @DevPointTeam",
enabled_plugins = {
"admin",
"onservice",
"inrealm",
"ingroup",
"inpm",
"banhammer",
"stats",
"anti_spam",
"owners",
"arabic_lock",
"set",
"get",
"broadcast",
"invite",
"all",
"leave_ban",
"supergroup",
"whitelist",
"msg_checks",
"cleanmsg",
"helps.pv",
"me",
"plugins",
"rebot",
"short_link",
"redis",
"list1",
"help",
"list",
"list3",
"writer",
"lock_emoji",
"lock_english",
"lock_badword",
"lock_fwd",
"lock_join",
"lock_media",
"lock_reply",
"lock_tag",
"lock_username",
"set_type",
"serverinfo",
"welcome",
"dowelcome",
"lock_badword",
"azan",
"filter",
"music_eng",
"short_link",
"tag_english",
"translate",
"infoeng",
"textphoto",
"image23",
"sticker23",
"instagram",
"voice",
"bye",
"dobye",
"weather",
"time",
"echo",
"send",
"linkpv",
"sudolist",
"rm",
"lock_fdw",
"fwd",
"reply",
"simsimi",
"myinfo",
"shadolist",
"h5",
"crp",
"htlr",
"rmmsg",
"lockreply",
"lockreply1",
"h1",
"h3",
"h4",
"h2",
"hetler",
"shado",
"welcm",
"q",
"feed",
"sors"
},
help_text = "",
help_text_realm = "",
help_text_super = "",
moderation = {
data = "data/moderation.json"
},
sudo_users = {
229048568,
186504119
}
}
return _
end | gpl-2.0 |
gwlim/luci | contrib/luadoc/lua/luadoc/taglet/standard/tags.lua | 93 | 5221 | -------------------------------------------------------------------------------
-- Handlers for several tags
-- @release $Id: tags.lua,v 1.8 2007/09/05 12:39:09 tomas Exp $
-------------------------------------------------------------------------------
local luadoc = require "luadoc"
local util = require "luadoc.util"
local string = require "string"
local table = require "table"
local assert, type, tostring = assert, type, tostring
module "luadoc.taglet.standard.tags"
-------------------------------------------------------------------------------
local function author (tag, block, text)
block[tag] = block[tag] or {}
if not text then
luadoc.logger:warn("author `name' not defined [["..text.."]]: skipping")
return
end
table.insert (block[tag], text)
end
-------------------------------------------------------------------------------
-- Set the class of a comment block. Classes can be "module", "function",
-- "table". The first two classes are automatic, extracted from the source code
local function class (tag, block, text)
block[tag] = text
end
-------------------------------------------------------------------------------
local function cstyle (tag, block, text)
block[tag] = text
end
-------------------------------------------------------------------------------
local function copyright (tag, block, text)
block[tag] = text
end
-------------------------------------------------------------------------------
local function description (tag, block, text)
block[tag] = text
end
-------------------------------------------------------------------------------
local function field (tag, block, text)
if block["class"] ~= "table" then
luadoc.logger:warn("documenting `field' for block that is not a `table'")
end
block[tag] = block[tag] or {}
local _, _, name, desc = string.find(text, "^([_%w%.]+)%s+(.*)")
assert(name, "field name not defined")
table.insert(block[tag], name)
block[tag][name] = desc
end
-------------------------------------------------------------------------------
-- Set the name of the comment block. If the block already has a name, issue
-- an error and do not change the previous value
local function name (tag, block, text)
if block[tag] and block[tag] ~= text then
luadoc.logger:error(string.format("block name conflict: `%s' -> `%s'", block[tag], text))
end
block[tag] = text
end
-------------------------------------------------------------------------------
-- Processes a parameter documentation.
-- @param tag String with the name of the tag (it must be "param" always).
-- @param block Table with previous information about the block.
-- @param text String with the current line beeing processed.
local function param (tag, block, text)
block[tag] = block[tag] or {}
-- TODO: make this pattern more flexible, accepting empty descriptions
local _, _, name, desc = string.find(text, "^([_%w%.]+)%s+(.*)")
if not name then
luadoc.logger:warn("parameter `name' not defined [["..text.."]]: skipping")
return
end
local i = table.foreachi(block[tag], function (i, v)
if v == name then
return i
end
end)
if i == nil then
luadoc.logger:warn(string.format("documenting undefined parameter `%s'", name))
table.insert(block[tag], name)
end
block[tag][name] = desc
end
-------------------------------------------------------------------------------
local function release (tag, block, text)
block[tag] = text
end
-------------------------------------------------------------------------------
local function ret (tag, block, text)
tag = "ret"
if type(block[tag]) == "string" then
block[tag] = { block[tag], text }
elseif type(block[tag]) == "table" then
table.insert(block[tag], text)
else
block[tag] = text
end
end
-------------------------------------------------------------------------------
-- @see ret
local function see (tag, block, text)
-- see is always an array
block[tag] = block[tag] or {}
-- remove trailing "."
text = string.gsub(text, "(.*)%.$", "%1")
local s = util.split("%s*,%s*", text)
table.foreachi(s, function (_, v)
table.insert(block[tag], v)
end)
end
-------------------------------------------------------------------------------
-- @see ret
local function usage (tag, block, text)
if type(block[tag]) == "string" then
block[tag] = { block[tag], text }
elseif type(block[tag]) == "table" then
table.insert(block[tag], text)
else
block[tag] = text
end
end
-------------------------------------------------------------------------------
local handlers = {}
handlers["author"] = author
handlers["class"] = class
handlers["cstyle"] = cstyle
handlers["copyright"] = copyright
handlers["description"] = description
handlers["field"] = field
handlers["name"] = name
handlers["param"] = param
handlers["release"] = release
handlers["return"] = ret
handlers["see"] = see
handlers["usage"] = usage
-------------------------------------------------------------------------------
function handle (tag, block, text)
if not handlers[tag] then
luadoc.logger:error(string.format("undefined handler for tag `%s'", tag))
return
end
-- assert(handlers[tag], string.format("undefined handler for tag `%s'", tag))
return handlers[tag](tag, block, text)
end
| apache-2.0 |
ashkanpj/sajad | plugins/stats.lua | 866 | 4001 | do
-- Returns a table with `name` and `msgs`
local function get_msgs_user_chat(user_id, chat_id)
local user_info = {}
local uhash = 'user:'..user_id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..user_id..':'..chat_id
user_info.msgs = tonumber(redis:get(um_hash) or 0)
user_info.name = user_print_name(user)..' ['..user_id..']'
return user_info
end
local function chat_stats(chat_id)
-- Users on chat
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
local users_info = {}
-- Get user info
for i = 1, #users do
local user_id = users[i]
local user_info = get_msgs_user_chat(user_id, chat_id)
table.insert(users_info, user_info)
end
-- Sort users by msgs number
table.sort(users_info, function(a, b)
if a.msgs and b.msgs then
return a.msgs > b.msgs
end
end)
local text = 'users in this chat \n'
for k,user in pairs(users_info) do
text = text..user.name..' = '..user.msgs..'\n'
end
local file = io.open("./groups/lists/"..chat_id.."stats.txt", "w")
file:write(text)
file:flush()
file:close()
send_document("chat#id"..chat_id,"./groups/lists/"..chat_id.."stats.txt", ok_cb, false)
return --text
end
local function chat_stats2(chat_id)
-- Users on chat
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
local users_info = {}
-- Get user info
for i = 1, #users do
local user_id = users[i]
local user_info = get_msgs_user_chat(user_id, chat_id)
table.insert(users_info, user_info)
end
-- Sort users by msgs number
table.sort(users_info, function(a, b)
if a.msgs and b.msgs then
return a.msgs > b.msgs
end
end)
local text = 'users in this chat \n'
for k,user in pairs(users_info) do
text = text..user.name..' = '..user.msgs..'\n'
end
return text
end
-- Save stats, ban user
local function bot_stats()
local redis_scan = [[
local cursor = '0'
local count = 0
repeat
local r = redis.call("SCAN", cursor, "MATCH", KEYS[1])
cursor = r[1]
count = count + #r[2]
until cursor == '0'
return count]]
-- Users
local hash = 'msgs:*:'..our_id
local r = redis:eval(redis_scan, 1, hash)
local text = 'Users: '..r
hash = 'chat:*:users'
r = redis:eval(redis_scan, 1, hash)
text = text..'\nGroups: '..r
return text
end
local function run(msg, matches)
if matches[1]:lower() == 'teleseed' then -- Put everything you like :)
local about = _config.about_text
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] used /teleseed ")
return about
end
if matches[1]:lower() == "statslist" then
if not is_momod(msg) then
return "For mods only !"
end
local chat_id = msg.to.id
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested group stats ")
return chat_stats2(chat_id)
end
if matches[1]:lower() == "stats" then
if not matches[2] then
if not is_momod(msg) then
return "For mods only !"
end
if msg.to.type == 'chat' then
local chat_id = msg.to.id
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested group stats ")
return chat_stats(chat_id)
else
return
end
end
if matches[2] == "teleseed" then -- Put everything you like :)
if not is_admin(msg) then
return "For admins only !"
else
return bot_stats()
end
end
if matches[2] == "group" then
if not is_admin(msg) then
return "For admins only !"
else
return chat_stats(matches[3])
end
end
end
end
return {
patterns = {
"^[!/]([Ss]tats)$",
"^[!/]([Ss]tatslist)$",
"^[!/]([Ss]tats) (group) (%d+)",
"^[!/]([Ss]tats) (teleseed)",-- Put everything you like :)
"^[!/]([Tt]eleseed)"-- Put everything you like :)
},
run = run
}
end
| gpl-2.0 |
Igalia/snabbswitch | src/lib/lpm/lpm4_poptrie.lua | 9 | 6227 | module(..., package.seeall)
local ffi = require("ffi")
local C = ffi.C
local bit = require("bit")
local lpm4_trie = require("lib.lpm.lpm4_trie").LPM4_trie
local bor, band, lshift, rshift, bnot = bit.bor, bit.band, bit.lshift, bit.rshift, bit.bnot
local tohex = bit.tohex
local ip4 = require("lib.lpm.ip4")
local masked = ip4.masked
LPM4_poptrie = setmetatable({}, { __index = lpm4_trie })
local node = ffi.typeof([[
struct {
int32_t jumpn;
int32_t jumpl;
uint64_t maskn;
uint64_t maskl;
}
]])
function get_bits (ip, offset)
assert(offset >= 0 and offset < 27)
return band(rshift(ip, 26-offset), 0x3f)
end
function mask_set_bit (mask, offset)
return bor(mask, lshift(1ull, 63 - offset))
end
function mask_clear_bit (mask, offset)
return band(mask, bnot(lshift(1ull, 63 - offset)))
end
function mask_get_bit (mask, offset)
return band(1, rshift(mask, 63 - offset))
end
function mask_popcnt (mask)
local c = 0
for i = 0,63 do
if mask_get_bit(mask, i) == 1 then
c = c + 1
end
end
return c
end
function LPM4_poptrie:new ()
self = lpm4_trie.new(self)
return self
end
function LPM4_poptrie:print_nodes ()
local n = self.poptrie_nodes
local i = 0
repeat
print("node", i, "jumpn", n[i].jumpn)
print("node", i, "maskn", tohex(n[i].maskn))
print("node", i, "jumpl", n[i].jumpl)
print("node", i, "maskl", tohex(n[i].maskl))
i = i + 1
until n[i].jumpl == 0 and n[i].maskl == 0 and n[i].maskn and n[i].jumpn == 0
end
function LPM4_poptrie:build ()
self:alloc("poptrie_nodes", ffi.typeof(node), 1000)
self:alloc("poptrie_leaves", ffi.typeof("uint16_t"), 1000)
local nodes = self.poptrie_nodes
local leaves = self.poptrie_leaves
local ts = self.trie
local nextleaf = 0
local nextnode = 1
local function add(ip, len, key)
local p = 0
local offset = 0
local ts = self.lpm4_trie
while true do
local e = nodes[p]
if e.jumpl == 0 and e.maskl == 0 and e.maskn == 0 and e.jumpn == 0 then
-- then nothing has been initialised :(
e.jumpl = nextleaf
e.jumpn = nextnode
local lastleaf
local base = masked(ip, offset)
for i=0,63 do
local slotip = bit.bor(base, lshift(i, 32 - (offset + 6)))
if self:has_child(slotip, offset + 6) then
e.maskn = mask_set_bit(e.maskn, get_bits(slotip, offset), 1)
nextnode = nextnode + 1
else
-- This prefix is a leaf
local t = self:search_trie(slotip, offset + 6)
local key = 0
if t then key = ts[t].key end
if lastleaf ~= key then
local bits = get_bits(slotip, offset)
e.maskl = mask_set_bit(e.maskl, bits, 1)
leaves[nextleaf] = key
nextleaf = nextleaf + 1
lastleaf = key
end
end
end
end
local bits = get_bits(ip, offset)
if mask_get_bit(nodes[p].maskn, bits) == 0 then return end
p = nodes[p].jumpn + mask_popcnt(bit.band(lshift(bit.bnot(0LL), 63 - bits), nodes[p].maskn)) - 1
offset = offset + 6
end
end
for e in self:entries() do
self:print_entry(e)
add(e.ip, e.length, e.key)
end
return self
end
function LPM4_poptrie:search (ip)
local offset = 0
local nodes = self.poptrie_nodes
local leaves = self.poptrie_leaves
local i = 0
while true do
local bits = get_bits(ip, offset)
if mask_get_bit(nodes[i].maskn, bits) == 1 then
-- a node keep going
i = nodes[i].jumpn - 1 + mask_popcnt(bit.band(lshift(bit.bnot(0LL), 63 - bits), nodes[i].maskn))
offset = offset + 6
else
return leaves[nodes[i].jumpl - 1 + mask_popcnt(bit.band(lshift(bit.bnot(0LL), 63 - bits), nodes[i].maskl, bit.bnot(nodes[i].maskn)))]
end
end
end
function selftest_masks ()
print("selftest_masks()")
local msb = mask_set_bit
local mgb = mask_get_bit
local mcb = mask_clear_bit
local popcnt = mask_popcnt
assert(mgb(0, 63) == 0)
assert(mgb(1, 63) == 1)
assert(mgb(2, 62) == 1)
assert(mgb(3, 62) == 1)
assert(msb(0, 0) == 0x8000000000000000ull)
assert(msb(0, 1) == 0x4000000000000000ull)
assert(msb(1, 62) == 0x0000000000000003ull)
assert(msb(1, 31) == 0x0000000100000001ull)
assert(msb(1, 30) == 0x0000000200000001ull)
assert(msb(1, 0) == 0x8000000000000001ull)
assert(mcb(1, 63) == 0)
assert(mcb(msb(0,0), 0) == 0)
assert(popcnt(3ull) == 2)
assert(popcnt(msb(255, 0)) == 9)
end
function selftest_get_bits ()
print("selftest_get_bits()")
local p = ip4.parse
local g = get_bits
assert(g(p("63.0.0.0"),2) == 63)
assert(g(p("0.63.0.0"),10) == 63)
assert(g(p("0.0.63.0"),18) == 63)
assert(g(p("0.0.0.63"),26) == 63)
assert(g(p("0.3.0.0"),14) == 48)
assert(g(p("0.3.128.0"),14) == 56)
assert(g(p("192.0.0.0"),0) == 48)
local pmu = require("lib.pmu")
local avail, err = pmu.is_available()
if not avail then
print("PMU not available:")
print(" "..err)
print("Skipping benchmark.")
else
local n = 0
pmu.profile(function()
for i =0, 1000*1000*1000 do n = n + g(i, 7) end
end)
end
end
function selftest ()
local n = LPM4_poptrie:new()
n:add_string("128.0.0.0/1", 2)
n:add_string("192.0.0.0/2", 3)
n:add_string("224.0.0.0/3", 4)
n:add_string("240.0.0.0/4", 5)
n:add_string("240.128.0.0/10", 6)
n:build()
assert(n:search_string("128.0.0.0") == 2)
assert(n:search_string("192.0.0.0") == 3)
assert(n:search_string("224.0.0.0") == 4)
assert(n:search_string("240.0.0.0") == 5)
assert(n:search_string("241.0.0.0") == 5)
assert(n:search_string("242.0.0.0") == 5)
assert(n:search_string("243.0.0.0") == 5)
assert(n:search_string("244.0.0.0") == 5)
assert(n:search_string("240.128.0.0") == 6)
assert(n:search_string("240.129.0.0") == 6)
assert(n:search_string("240.192.0.0") == 5)
selftest_get_bits()
selftest_masks()
end
| apache-2.0 |
naclander/tome | game/modules/tome/data/rooms/forest_clearing.lua | 3 | 3897 | -- 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
local Heightmap = require "engine.Heightmap"
return function(gen, id)
local w = rng.range(6, 10)
local h = rng.range(6, 10)
local function make_hmap(self, x, y, is_lit)
-- make the fractal heightmap
local hm = Heightmap.new(self.w, self.h, 2, {middle=Heightmap.min, up_left=Heightmap.max, down_left=Heightmap.max, up_right=Heightmap.max, down_right=Heightmap.max})
hm:generate()
local ispit = gen.data.rooms_config and gen.data.rooms_config.forest_clearing and rng.percent(gen.data.rooms_config.forest_clearing.pit_chance)
if ispit then ispit = rng.table(gen.data.rooms_config.forest_clearing.filters) end
-- Floodfill to eliminate dead zones
local dmap = {}
local opens = {}
local list = {}
for i = 1, self.w do
opens[i] = {}
dmap[i] = {}
for j = 1, self.h do if hm.hmap[i][j] < Heightmap.max * 5 / 6 then
dmap[i][j] = true
opens[i][j] = #list+1
list[#list+1] = {x=i, y=j}
end end
end
-- print("Flooding with", #list)
local floodFill floodFill = function(x, y)
local q = {{x=x,y=y}}
local closed = {}
while #q > 0 do
local n = table.remove(q, 1)
-- print("Flooding!", x, y, "::", #q, n.x, n.y)
if opens[n.x] and opens[n.x][n.y] then
closed[#closed+1] = n
list[opens[n.x][n.y]] = nil
opens[n.x][n.y] = nil
q[#q+1] = {x=n.x-1, y=n.y}
q[#q+1] = {x=n.x, y=n.y+1}
q[#q+1] = {x=n.x+1, y=n.y}
q[#q+1] = {x=n.x, y=n.y-1}
q[#q+1] = {x=n.x+1, y=n.y-1}
q[#q+1] = {x=n.x+1, y=n.y+1}
q[#q+1] = {x=n.x-1, y=n.y-1}
q[#q+1] = {x=n.x-1, y=n.y+1}
end
end
return closed
end
-- Process all open spaces
local groups = {}
while next(list) do
local i, l = next(list)
local closed = floodFill(l.x, l.y)
groups[#groups+1] = {id=id, list=closed}
-- print("Floodfill group", i, #closed)
end
-- If nothing exists, regen
if #groups == 0 then return make_hmap(self, x, y, is_lit) end
-- Sort to find the biggest group
table.sort(groups, function(a,b) return #a.list < #b.list end)
local g = groups[#groups]
if #g.list >= 2 then
-- print("Ok floodfill", #g.list)
for i = 1, #groups-1 do
for j = 1, #groups[i].list do
local jn = groups[i].list[j]
dmap[jn.x][jn.y] = nil
end
end
else
return make_hmap(self, x, y, is_lit)
end
-- Materialize the map
for i = 1, self.w do
for j = 1, self.h do
if not dmap[i][j] then
-- gen.map.room_map[i-1+x][j-1+y].can_open = true
gen.map(i-1+x, j-1+y, Map.TERRAIN, gen:resolve('#'))
else
gen.map.room_map[i-1+x][j-1+y].room = id
gen.map(i-1+x, j-1+y, Map.TERRAIN, gen:resolve('.'))
if ispit then
local e = gen.zone:makeEntity(gen.level, "actor", ispit, nil, true)
if e then
if e then
gen:roomMapAddEntity(i-1+x, j-1+y, "actor", e)
e:setEffect(e.EFF_VAULTED, 1, {})
end
gen.map.attrs(i-1+x, j-1+y, "no_decay", true)
end
end
end
if is_lit then gen.map.lites(i-1+x, j-1+y, true) end
end
end
-- print("Done!")
end
return { name="forest_clearing"..w.."x"..h, w=w, h=h, generator = make_hmap}
end
| gpl-3.0 |
LegionXI/darkstar | scripts/zones/Castle_Oztroja/npcs/_47j.lua | 14 | 1628 | -----------------------------------
-- Area: Castle Oztroja
-- NPC: _47j (Torch Stand)
-- Notes: Opens door _472 near password #1
-- @pos -62.533 -1.859 -30.634 151
-----------------------------------
package.loaded["scripts/zones/Castle_Oztroja/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Castle_Oztroja/TextIDs");
require("scripts/globals/settings");
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local DoorID = npc:getID() - 4;
local DoorA = GetNPCByID(DoorID):getAnimation();
local TorchStandA = npc:getAnimation();
local Torch2 = npc:getID();
local Torch1 = npc:getID() - 1;
if (DoorA == 9 and TorchStandA == 9) then
player:startEvent(0x000a);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
local Torch2 = GetNPCByID(17396169):getID();
local Torch1 = GetNPCByID(Torch2):getID() - 1;
local DoorID = GetNPCByID(Torch2):getID() - 4;
if (option == 1) then
GetNPCByID(Torch1):openDoor(10); -- Torch Lighting
GetNPCByID(Torch2):openDoor(10); -- Torch Lighting
GetNPCByID(DoorID):openDoor(6);
end
end;
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option); | gpl-3.0 |
lache/RacingKingLee | crazyclient/frameworks/cocos2d-x/cocos/scripting/lua-bindings/auto/api/ParticleSpiral.lua | 11 | 1380 |
--------------------------------
-- @module ParticleSpiral
-- @extend ParticleSystemQuad
-- @parent_module cc
--------------------------------
--
-- @function [parent=#ParticleSpiral] init
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
--
-- @function [parent=#ParticleSpiral] initWithTotalParticles
-- @param self
-- @param #int numberOfParticles
-- @return bool#bool ret (return value: bool)
--------------------------------
-- Create a spiral particle system.<br>
-- return An autoreleased ParticleSpiral object.
-- @function [parent=#ParticleSpiral] create
-- @param self
-- @return ParticleSpiral#ParticleSpiral ret (return value: cc.ParticleSpiral)
--------------------------------
-- Create a spiral particle system withe a fixed number of particles.<br>
-- param numberOfParticles A given number of particles.<br>
-- return An autoreleased ParticleSpiral object.<br>
-- js NA
-- @function [parent=#ParticleSpiral] createWithTotalParticles
-- @param self
-- @param #int numberOfParticles
-- @return ParticleSpiral#ParticleSpiral ret (return value: cc.ParticleSpiral)
--------------------------------
-- js ctor
-- @function [parent=#ParticleSpiral] ParticleSpiral
-- @param self
-- @return ParticleSpiral#ParticleSpiral self (return value: cc.ParticleSpiral)
return nil
| mit |
naclander/tome | game/modules/tome/data/gfx/particles/earth_beam.lua | 3 | 1915 | -- 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
-- Make the ray
local ray = {}
local tiles = math.ceil(math.sqrt(tx*tx+ty*ty))
local tx = tx * engine.Map.tile_w
local ty = ty * engine.Map.tile_h
ray.dir = math.atan2(ty, tx)
ray.size = math.sqrt(tx*tx+ty*ty)
-- Populate the beam based on the forks
return { generator = function()
local a = ray.dir
local r = rng.range(1, ray.size - 32)
local side = rng.chance(2)
local ra = a + (side and math.rad(-90) or math.rad(90))
local rr = rng.float(2, engine.Map.tile_w * 0.30)
local vel = rng.float(1.2, 6)
return {
life = 38 / vel,
size = rng.float(8, 20), sizev = -0.1, sizea = 0,
x = r * math.cos(a) + rr * math.cos(ra), xv = 0, xa = 0,
y = r * math.sin(a) + rr * math.sin(ra), yv = 0, ya = 0,
dir = ray.dir + math.rad(180) + (side and 1 or -1) * rng.float(0, 1), dirv = 0, dira = 0,
vel = vel, velv = -0.1, vela = 0.01,
r = 1, rv = 0, ra = 0,
g = 1, gv = 0, ga = 0,
b = 1, bv = 0, ba = 0,
a = rng.range(25, 220)/255, av = -0.034, aa = 0.005,
}
end, },
function(self)
self.nb = (self.nb or 0) + 1
if self.nb < 6 then
self.ps:emit(9*tiles)
end
end,
32*9*tiles,
"particles_images/particle_stone"
| gpl-3.0 |
mohammad25253/teamstar | plugins/Location.lua | 185 | 1565 | -- Implement a command !loc [area] which uses
-- the static map API to get a location image
-- Not sure if this is the proper way
-- Intent: get_latlong is in time.lua, we need it here
-- loadfile "time.lua"
-- Globals
-- If you have a google api key for the geocoding/timezone api
do
local api_key = nil
local base_api = "https://maps.googleapis.com/maps/api"
function get_staticmap(area)
local api = base_api .. "/staticmap?"
-- Get a sense of scale
local lat,lng,acc,types = get_latlong(area)
local scale = types[1]
if scale=="locality" then zoom=8
elseif scale=="country" then zoom=4
else zoom = 13 end
local parameters =
"size=600x300" ..
"&zoom=" .. zoom ..
"¢er=" .. URL.escape(area) ..
"&markers=color:red"..URL.escape("|"..area)
if api_key ~=nil and api_key ~= "" then
parameters = parameters .. "&key="..api_key
end
return lat, lng, api..parameters
end
function run(msg, matches)
local receiver = get_receiver(msg)
local lat,lng,url = get_staticmap(matches[1])
-- Send the actual location, is a google maps link
send_location(receiver, lat, lng, ok_cb, false)
-- Send a picture of the map, which takes scale into account
send_photo_from_url(receiver, url)
-- Return a link to the google maps stuff is now not needed anymore
return nil
end
return {
description = "Gets information about a location, maplink and overview",
usage = "!loc (location): Gets information about a location, maplink and overview",
patterns = {"^!loc (.*)$"},
run = run
}
end
| gpl-2.0 |
naclander/tome | game/modules/tome/data/zones/trollmire/objects.lua | 3 | 1255 | -- 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/objects/objects-maj-eyal.lua")
for i = 1, 2 do
newEntity{ base = "BASE_LORE",
define_as = "NOTE"..i,
name = "tattered paper scrap", lore="trollmire-note-"..i,
desc = [[A paper scrap, left by an adventurer.]],
rarity = false,
encumberance = 0,
}
end
newEntity{ base = "BASE_LORE",
define_as = "PROX_NOTE",
name = "tattered paper scrap", lore="trollmire-note-3",
desc = [[A paper scrap, left by an adventurer.]],
rarity = false,
encumberance = 0,
}
| gpl-3.0 |
LegionXI/darkstar | scripts/zones/Selbina/TextIDs.lua | 7 | 1895 | -- Variable TextID Description text
-- General Texts
ITEM_CANNOT_BE_OBTAINED = 6379; -- You cannot obtain the item <item>. Come back after sorting your inventory.
ITEM_OBTAINED = 6384; -- Obtained: <item>.
GIL_OBTAINED = 6385; -- Obtained <number> gil.
KEYITEM_OBTAINED = 6387; -- Obtained key item: <keyitem>.
NOT_HAVE_ENOUGH_GIL = 6389; -- You do not have enough gil.
HOMEPOINT_SET = 6475; -- Home point set!
FISHING_MESSAGE_OFFSET = 6550; -- You can't fish here.
SUBJOB_UNLOCKED = 6853; -- You can now designate a support job.
-- NPC texts
NOMAD_MOOGLE_DIALOG = 6650; -- I'm a traveling moogle, kupo. I help adventurers in the Outlands access items they have stored in a Mog House elsewhere, kupo.
-- Shop Texts
HERMINIA_SHOP_DIALOG = 7027; -- Hello there. What can I do for you?
TORAPIONT_SHOP_DIALOG = 7028; -- Arm yourself before you step outside.
DOHDJUMA_SHOP_DIALOG = 7029; -- I'm Dohdjuma, and I sell all kinds of things.
CLOTHCRAFT_SHOP_DIALOG = 7030; -- Welcome to the Weavers' Guild salesroom.
FISHING_SHOP_DIALOG = 7031; -- Welcome to the Fishermen's Guild salesroom.
QUELPIA_SHOP_DIALOG = 7032; -- In need of otherworldly protection?
CHUTARMIRE_SHOP_DIALOG = 7033; -- I have items for those who delve in the black arts!
FALGIMA_SHOP_DIALOG = 7034; -- In the market for spells, hexes, and incantations? Well, you've come to the right place!
-- Item Delivery
WENZEL_DELIVERY_DIALOG = 7581; -- My independent survey confirms the town entrance as the preferred location from which adventurers send parcels.
BORIS_DELIVERY_DIALOG = 7582; -- My independent survey confirms the inn as the preferred location from which adventurers send parcels.
-- conquest Base
CONQUEST_BASE = 7098; -- Tallying conquest results...
-- Porter Moogle
RETRIEVE_DIALOG_ID = 7742; -- You retrieve$ from the porter moogle's care.
| gpl-3.0 |
ibm2431/darkstar | scripts/globals/effects/auspice.lua | 12 | 1611 | --------------------------------------
--
-- dsp.effect.AUSPICE
--
-- Power: Used for Enspell Effect
-- SubPower: Tracks Subtle Blow Bonus
-- Tier: Used for Enspell Calculation
--
--------------------------------------
function onEffectGain(target,effect)
--Auspice Reduces TP via adding to your Subtle Blow Mod
local subtleBlowBonus = 10 + target:getMod(dsp.mod.AUSPICE_EFFECT)
--printf("AUSPICE: Adding Subtle Blow +%d!", subtleBlowBonus)
effect:setSubPower(subtleBlowBonus)
target:addMod(dsp.mod.SUBTLE_BLOW, subtleBlowBonus)
--Afflatus Misery Bonuses
if (target:hasStatusEffect(dsp.effect.AFFLATUS_MISERY)) then
target:getStatusEffect(dsp.effect.AFFLATUS_MISERY):setSubPower(0)
target:addMod(dsp.mod.ENSPELL,18)
target:addMod(dsp.mod.ENSPELL_DMG,effect:getPower())
end
end
function onEffectTick(target,effect)
end
function onEffectLose(target,effect)
local subtleBlow = effect:getSubPower()
--printf("AUSPICE: Removing Subtle Blow +%d!", subtleBlow)
target:delMod(dsp.mod.SUBTLE_BLOW, subtleBlow)
--Clean Up Any Bonuses That From Afflatus Misery Combo
if (target:hasStatusEffect(dsp.effect.AFFLATUS_MISERY)) then
local accuracyBonus = target:getStatusEffect(dsp.effect.AFFLATUS_MISERY):getSubPower()
--printf("AUSPICE: Removing Accuracy Bonus +%d!", accuracyBonus)
target:delMod(dsp.mod.ACC, accuracyBonus)
local accuracyBonus = target:getStatusEffect(dsp.effect.AFFLATUS_MISERY):setSubPower(0)
target:setMod(dsp.mod.ENSPELL_DMG,0)
target:setMod(dsp.mod.ENSPELL,0)
end
end | gpl-3.0 |
LegionXI/darkstar | scripts/zones/Port_San_dOria/npcs/Deguerendars.lua | 17 | 2163 | -----------------------------------
-- Area: Port San d'Oria
-- NPC: Deguerendars
-- Only sells when San d'Oria contrls Tavnazian Archipelago
-- Only available to those with CoP Ch. 4.1 or higher
-----------------------------------
package.loaded["scripts/zones/Port_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Port_San_dOria/TextIDs");
require("scripts/globals/conquest");
require("scripts/globals/quests");
require("scripts/globals/shop");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
-- "Flyers for Regine" conditional script
local FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE);
if (FlyerForRegine == 1) then
local count = trade:getItemCount();
local MagicFlyer = trade:hasItemQty(532,1);
if (MagicFlyer == true and count == 1) then
player:messageSpecial(FLYER_REFUSED);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local RegionOwner = GetRegionOwner(TAVNAZIANARCH);
cop = 40; --player:getVar("chainsOfPromathiaMissions");
if (cop >= 40) then
if (RegionOwner ~= NATION_SANDORIA) then
player:showText(npc,DEGUERENDARS_CLOSED_DIALOG);
else
player:showText(npc,DEGUERENDARS_OPEN_DIALOG);
local stock = {0x05f3,290, --Apple Mint
0x142c,1945, --Ground Wasabi
0x426d,99, --Lufaise Fly
0x144b,233} --Misareaux Parsley
showShop(player,SANDORIA,stock);
end
else
player:showText(npc,DEGUERENDARS_COP_NOT_COMPLETED);
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/Castle_Oztroja/npcs/_m75.lua | 17 | 2229 | -----------------------------------
-- Area: Castle Oztroja
-- NPC: _m75 (Torch Stand)
-- Notes: Opens door _477 when _m72 to _m75 are lit
-- @pos -139.643 -72.113 -62.682 151
-----------------------------------
package.loaded["scripts/zones/Castle_Oztroja/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Castle_Oztroja/TextIDs");
require("scripts/globals/settings");
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
DoorID = npc:getID() - 5;
Torch1 = npc:getID() - 3;
Torch2 = npc:getID() - 2;
Torch3 = npc:getID() - 1;
Torch4 = npc:getID();
DoorA = GetNPCByID(DoorID):getAnimation();
TorchStand1A = GetNPCByID(Torch1):getAnimation();
TorchStand2A = GetNPCByID(Torch2):getAnimation();
TorchStand3A = GetNPCByID(Torch3):getAnimation();
TorchStand4A = npc:getAnimation();
if(DoorA == 9 and TorchStand4A == 9) then
player:startEvent(0x000a);
else
player:messageSpecial(TORCH_LIT);
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);
if (option == 1) then
GetNPCByID(Torch4):openDoor(55);
if((DoorA == 9) and (TorchStand1A == 8) and (TorchStand2A == 8) and (TorchStand3A == 8)) then
GetNPCByID(DoorID):openDoor(35);
-- The lamps shouldn't go off here, but I couldn't get the torches to update animation times without turning them off first
-- They need to be reset to the door open time(35s) + 4s (39 seconds)
GetNPCByID(Torch1):setAnimation(9);
GetNPCByID(Torch2):setAnimation(9);
GetNPCByID(Torch3):setAnimation(9);
GetNPCByID(Torch4):setAnimation(9);
GetNPCByID(Torch1):openDoor(39);
GetNPCByID(Torch2):openDoor(39);
GetNPCByID(Torch3):openDoor(39);
GetNPCByID(Torch4):openDoor(39);
end
end
end;
| gpl-3.0 |
CuteOne/meta | meta/lists/runeforge.lua | 1 | 4561 | -- Required to access other files.
local meta = ...
-- Legendaries based on https://wow.tools/dbc/?dbc=runeforgelegendaryability
-- mapping bonus id to legendary power id
local runeforge = {}
runeforge.bonusToPowerId = {
[6823] = 2,
[6828] = 3,
[6829] = 4,
[6830] = 5,
[6831] = 6,
[6832] = 7,
[6937] = 8,
[6834] = 9,
[6931] = 10,
[6932] = 11,
[6933] = 12,
[6934] = 13,
[6926] = 14,
[6927] = 15,
[6928] = 16,
[6936] = 17,
[7041] = 18,
[7042] = 19,
[7043] = 20,
[7044] = 21,
[7049] = 22,
[7050] = 23,
[7051] = 24,
[7052] = 25,
[7045] = 26,
[7046] = 27,
[7047] = 28,
[7048] = 29,
[6953] = 30,
[6954] = 31,
[6947] = 32,
[6948] = 33,
[6940] = 34,
[6941] = 35,
[6943] = 36,
[6942] = 37,
[6944] = 38,
[6945] = 39,
[6946] = 40,
[7160] = 41,
[6949] = 42,
[6950] = 43,
[6951] = 44,
[6952] = 45,
[7086] = 46,
[7085] = 47,
[7110] = 48,
[7084] = 49,
[7087] = 50,
[7088] = 51,
[7107] = 52,
[7108] = 53,
[7109] = 54,
[7091] = 55,
[7090] = 56,
[7089] = 57,
[7092] = 58,
[7093] = 59,
[7094] = 60,
[7095] = 61,
[7096] = 62,
[7097] = 63,
[7098] = 64,
[7099] = 65,
[7003] = 66,
[7004] = 67,
[7005] = 68,
[7006] = 69,
[7007] = 70,
[7008] = 71,
[7009] = 72,
[7010] = 73,
[7011] = 74,
[7012] = 75,
[7013] = 76,
[7014] = 77,
[7015] = 78,
[7016] = 79,
[7017] = 80,
[7018] = 81,
[7184] = 82,
[7082] = 83,
[7080] = 84,
[7081] = 85,
[7076] = 86,
[7077] = 87,
[7078] = 88,
[7079] = 89,
[7075] = 90,
[7073] = 91,
[7074] = 92,
[7072] = 93,
[7070] = 94,
[7068] = 95,
[7071] = 96,
[7069] = 97,
[7053] = 98,
[7055] = 100,
[7056] = 101,
[7128] = 102,
[7059] = 103,
[7057] = 104,
[7058] = 105,
[7060] = 106,
[7061] = 107,
[7062] = 108,
[7063] = 109,
[7067] = 110,
[7066] = 111,
[7065] = 112,
[7064] = 113,
[7114] = 114,
[7113] = 115,
[7112] = 116,
[7111] = 117,
[7115] = 118,
[7116] = 119,
[7117] = 120,
[7118] = 121,
[7122] = 122,
[7121] = 123,
[7120] = 124,
[7119] = 125,
[7123] = 126,
[7124] = 127,
[7125] = 128,
[7126] = 129,
[6985] = 130,
[6986] = 131,
[6987] = 132,
[6988] = 133,
[6989] = 134,
[6990] = 135,
[6991] = 136,
[6992] = 137,
[6993] = 138,
[6994] = 139,
[6995] = 140,
[6996] = 141,
[6997] = 142,
[6998] = 143,
[6999] = 144,
[7000] = 145,
[7161] = 146,
[7002] = 147,
[6975] = 148,
[6972] = 149,
[6976] = 150,
[6978] = 151,
[6979] = 152,
[6980] = 153,
[6984] = 154,
[6977] = 155,
[6974] = 156,
[6973] = 157,
[6981] = 158,
[6982] = 159,
[6983] = 160,
[7162] = 161,
[7025] = 162,
[7026] = 163,
[7027] = 164,
[7028] = 165,
[7029] = 166,
[7030] = 167,
[7031] = 168,
[7032] = 169,
[7033] = 170,
[7034] = 171,
[7035] = 172,
[7036] = 173,
[7037] = 174,
[7038] = 175,
[7039] = 176,
[7040] = 177,
[6955] = 178,
[6971] = 179,
[6958] = 180,
[6959] = 181,
[6962] = 182,
[6960] = 183,
[6961] = 184,
[6970] = 185,
[6963] = 186,
[6964] = 187,
[6965] = 188,
[6966] = 189,
[6956] = 190,
[6957] = 191,
[6967] = 192,
[6969] = 193,
[7054] = 196,
[7100] = 199,
[7101] = 200,
[7102] = 201,
[7103] = 202,
[7104] = 203,
[7105] = 204,
[7106] = 205,
[7159] = 206,
}
return runeforge
| gpl-3.0 |
ibm2431/darkstar | scripts/globals/effects/magic_shield.lua | 12 | 1748 | -----------------------------------
--
-- Magic Shield BLOCKS all magic attacks
--
-----------------------------------
require("scripts/globals/status")
function onEffectGain(target,effect)
if effect:getPower() == 3 then -- arcane stomp
target:addMod(dsp.mod.FIRE_ABSORB, 100)
target:addMod(dsp.mod.EARTH_ABSORB, 100)
target:addMod(dsp.mod.WATER_ABSORB, 100)
target:addMod(dsp.mod.WIND_ABSORB, 100)
target:addMod(dsp.mod.ICE_ABSORB, 100)
target:addMod(dsp.mod.LTNG_ABSORB, 100)
target:addMod(dsp.mod.LIGHT_ABSORB, 100)
target:addMod(dsp.mod.DARK_ABSORB, 100)
elseif effect:getPower() < 2 then
target:addMod(dsp.mod.UDMGMAGIC, -101)
if target:isPC() and target:hasTrait(77) then -- Iron Will
target:addMod(dsp.mod.SPELLINTERRUPT, target:getMerit(dsp.merit.IRON_WILL))
end
else
target:addMod(dsp.mod.MAGIC_ABSORB, 100)
end
end
function onEffectLose(target,effect)
if effect:getPower() == 3 then -- arcane stomp
target:delMod(dsp.mod.FIRE_ABSORB, 100)
target:delMod(dsp.mod.EARTH_ABSORB, 100)
target:delMod(dsp.mod.WATER_ABSORB, 100)
target:delMod(dsp.mod.WIND_ABSORB, 100)
target:delMod(dsp.mod.ICE_ABSORB, 100)
target:delMod(dsp.mod.LTNG_ABSORB, 100)
target:delMod(dsp.mod.LIGHT_ABSORB, 100)
target:delMod(dsp.mod.DARK_ABSORB, 100)
elseif effect:getPower() < 2 then
target:delMod(dsp.mod.UDMGMAGIC, -101)
if target:isPC() and target:hasTrait(77) then -- Iron Will
target:delMod(dsp.mod.SPELLINTERRUPT, target:getMerit(dsp.merit.IRON_WILL))
end
else
target:delMod(dsp.mod.MAGIC_ABSORB, 100)
end
end
| gpl-3.0 |
ibm2431/darkstar | scripts/globals/items/sazanbaligi.lua | 11 | 1050 | -----------------------------------------
-- ID: 5459
-- Item: Sazanbaligi
-- Food Effect: 5Min, Mithra only
-----------------------------------------
-- Dexterity 4
-- Mind -6
-----------------------------------------
require("scripts/globals/status")
require("scripts/globals/msg")
-----------------------------------------
function onItemCheck(target)
local result = 0
if (target:getRace() ~= dsp.race.MITHRA) then
result = dsp.msg.basic.CANNOT_EAT
end
if (target:getMod(dsp.mod.EAT_RAW_FISH) == 1) then
result = 0
end
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,300,5459)
end
function onEffectGain(target, effect)
target:addMod(dsp.mod.DEX, 4)
target:addMod(dsp.mod.MND, -6)
end
function onEffectLose(target, effect)
target:delMod(dsp.mod.DEX, 4)
target:delMod(dsp.mod.MND, -6)
end
| gpl-3.0 |
greasydeal/darkstar | scripts/zones/Valkurm_Dunes/Zone.lua | 6 | 4998 | -----------------------------------
--
-- Zone: Valkurm_Dunes (103)
--
-----------------------------------
package.loaded["scripts/zones/Valkurm_Dunes/TextIDs"] = nil;
package.loaded["scripts/globals/chocobo_digging"] = nil;
-----------------------------------
require("scripts/zones/Valkurm_Dunes/TextIDs");
require("scripts/globals/zone");
require("scripts/globals/icanheararainbow");
require("scripts/globals/status");
require("scripts/globals/weather");
require("scripts/globals/conquest");
require("scripts/globals/chocobo_digging");
-----------------------------------
-- Chocobo Digging vars
-----------------------------------
local itemMap = {
-- itemid, abundance, requirement
{ 880, 224, DIGREQ_NONE },
{ 887, 39, DIGREQ_NONE },
{ 645, 14, DIGREQ_NONE },
{ 893, 105, DIGREQ_NONE },
{ 737, 17, DIGREQ_NONE },
{ 643, 64, DIGREQ_NONE },
{ 17296, 122, DIGREQ_NONE },
{ 942, 6, DIGREQ_NONE },
{ 642, 58, DIGREQ_NONE },
{ 864, 22, DIGREQ_NONE },
{ 843, 4, DIGREQ_NONE },
{ 4096, 100, DIGREQ_NONE }, -- all crystals
{ 845, 122, DIGREQ_BURROW },
{ 844, 71, DIGREQ_BURROW },
{ 1845, 33, DIGREQ_BURROW },
{ 838, 11, DIGREQ_BURROW },
{ 902, 6, DIGREQ_BORE },
{ 886, 3, DIGREQ_BORE },
{ 867, 3, DIGREQ_BORE },
{ 1587, 19, DIGREQ_BORE },
{ 888, 25, DIGREQ_BORE },
{ 1586, 8, DIGREQ_BORE },
{ 885, 10, DIGREQ_BORE },
{ 866, 3, 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)
local manuals = {17199751,17199752,17199753};
SetFieldManual(manuals);
SetRegionalConquestOverseers(zone:getRegionID())
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn( player, prevZone)
local cs = -1;
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
player:setPos( 60.989, -4.898, -151.001, 198);
end
if (triggerLightCutscene(player)) then -- Quest: I Can Hear A Rainbow
cs = 0x0003;
elseif(player:getCurrentMission(WINDURST) == VAIN and player:getVar("MissionStatus") ==1)then
cs = 0x0005;
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 == 0x0003) then
lightCutsceneUpdate(player); -- Quest: I Can Hear A Rainbow
elseif (csid == 0x0005) then
if(player:getZPos() > 45) then
if(player:getZPos() > -301) then
player:updateEvent(0,0,0,0,0,1);
else
player:updateEvent(0,0,0,0,0,3);
end
end
end
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish( player, csid, option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0003) then
lightCutsceneFinish(player); -- Quest: I Can Hear A Rainbow
end
end;
-----------------------------------
-- onZoneWeatherChange
-----------------------------------
function onZoneWeatherChange(weather)
local qm1 = GetNPCByID(17199699); -- Quest: An Empty Vessel
if (weather == WEATHER_DUST_STORM) then
qm1:setStatus(STATUS_NORMAL);
else
qm1:setStatus(STATUS_DISAPPEAR);
end
end; | gpl-3.0 |
Disslove-bot/D.J-BOT | plugins/id.lua | 355 | 2795 | local function user_print_name(user)
if user.print_name then
return user.print_name
end
local text = ''
if user.first_name then
text = user.last_name..' '
end
if user.lastname then
text = text..user.last_name
end
return text
end
local function returnids(cb_extra, success, result)
local receiver = cb_extra.receiver
--local chat_id = "chat#id"..result.id
local chat_id = result.id
local chatname = result.print_name
local text = 'IDs for chat '..chatname
..' ('..chat_id..')\n'
..'There are '..result.members_num..' members'
..'\n---------\n'
i = 0
for k,v in pairs(result.members) do
i = i+1
text = text .. i .. ". " .. string.gsub(v.print_name, "_", " ") .. " (" .. v.id .. ")\n"
end
send_large_msg(receiver, text)
end
local function username_id(cb_extra, success, result)
local receiver = cb_extra.receiver
local qusername = cb_extra.qusername
local text = 'User '..qusername..' not found in this group!'
for k,v in pairs(result.members) do
vusername = v.username
if vusername == qusername then
text = 'ID for username\n'..vusername..' : '..v.id
end
end
send_large_msg(receiver, text)
end
local function run(msg, matches)
local receiver = get_receiver(msg)
if matches[1] == "!id" then
local text = 'Name : '.. string.gsub(user_print_name(msg.from),'_', ' ') .. '\nID : ' .. msg.from.id
if is_chat_msg(msg) then
text = text .. "\n\nYou are in group " .. string.gsub(user_print_name(msg.to), '_', ' ') .. " (ID: " .. msg.to.id .. ")"
end
return text
elseif matches[1] == "chat" then
-- !ids? (chat) (%d+)
if matches[2] and is_sudo(msg) then
local chat = 'chat#id'..matches[2]
chat_info(chat, returnids, {receiver=receiver})
else
if not is_chat_msg(msg) then
return "You are not in a group."
end
local chat = get_receiver(msg)
chat_info(chat, returnids, {receiver=receiver})
end
else
if not is_chat_msg(msg) then
return "Only works in group"
end
local qusername = string.gsub(matches[1], "@", "")
local chat = get_receiver(msg)
chat_info(chat, username_id, {receiver=receiver, qusername=qusername})
end
end
return {
description = "Know your id or the id of a chat members.",
usage = {
"!id: Return your ID and the chat id if you are in one.",
"!ids chat: Return the IDs of the current chat members.",
"!ids chat <chat_id>: Return the IDs of the <chat_id> members.",
"!id <username> : Return the id from username given."
},
patterns = {
"^!id$",
"^!ids? (chat) (%d+)$",
"^!ids? (chat)$",
"^!id (.*)$"
},
run = run
}
| gpl-2.0 |
ibm2431/darkstar | scripts/globals/mobskills/hydro_canon.lua | 11 | 1388 | ---------------------------------------------------
-- Hydro_Canon
-- Description:
-- Type: Magical
-- additional effect : 40hp/tick Poison
---------------------------------------------------
require("scripts/globals/settings")
require("scripts/globals/status")
require("scripts/globals/monstertpmoves")
---------------------------------------------------
function onMobSkillCheck(target,mob,skill)
-- skillList 54 = Omega
-- skillList 727 = Proto-Omega
-- skillList 728 = Ultima
-- skillList 729 = Proto-Ultima
local skillList = mob:getMobMod(dsp.mobMod.SKILL_LIST)
local mobhp = mob:getHPP()
local phase = mob:getLocalVar("battlePhase")
if ((skillList == 729 and phase >= 1 and phase <= 2) or (skillList == 728 and mobhp < 70 and mobhp >= 40)) then
return 0
end
return 1
end
function onMobWeaponSkill(target, mob, skill)
local typeEffect = dsp.effect.POISON
local power = 40
MobPhysicalStatusEffectMove(mob, target, skill, typeEffect, power, 3, 60)
local dmgmod = 2
local info = MobMagicalMove(mob,target,skill,mob:getWeaponDmg()*3,dsp.magic.ele.WATER,dmgmod,TP_MAB_BONUS,1)
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,dsp.attackType.MAGICAL,dsp.damageType.WATER,MOBPARAM_IGNORE_SHADOWS)
target:takeDamage(dmg, mob, dsp.attackType.MAGICAL, dsp.damageType.WATER)
return dmg
end | gpl-3.0 |
LegionXI/darkstar | scripts/zones/Kazham/npcs/Thali_Mhobrum.lua | 15 | 1659 | -----------------------------------
-- Area: Kazham
-- NPC: Thali Mhobrum
-- Standard Info NPC
-----------------------------------
package.loaded["scripts/zones/Kazham/TextIDs"] = nil;
require("scripts/zones/Kazham/TextIDs");
local path = {
55.816410, -11.000000, -43.992680,
54.761787, -11.000000, -44.046181,
51.805824, -11.000000, -44.200321,
52.922001, -11.000000, -44.186420,
51.890709, -11.000000, -44.224312,
47.689358, -11.000000, -44.374969,
52.826096, -11.000000, -44.191029,
47.709465, -11.000000, -44.374393,
52.782181, -11.000000, -44.192482,
47.469643, -11.000000, -44.383091
};
function onSpawn(npc)
npc:initNpcAi();
npc:setPos(pathfind.first(path));
onPath(npc);
end;
function onPath(npc)
pathfind.patrol(npc, path);
end;
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getVar("BathedInScent") == 1) then
player:startEvent(0x00A3); -- scent from Blue Rafflesias
npc:wait(-1);
else
player:startEvent(0x00BE);
npc:wait(-1);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option,npc)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
npc:wait(0);
end;
| gpl-3.0 |
naclander/tome | game/modules/tome/data/gfx/particles/bolt_acid.lua | 3 | 1650 | -- 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
return { generator = function()
local radius = 0
local sradius = (radius + 0.5) * (engine.Map.tile_w + engine.Map.tile_h) / 2
local ad = rng.float(0, 360)
local a = math.rad(ad)
local r = rng.float(0, sradius / 4)
local x = r * math.cos(a)
local y = r * math.sin(a)
local bx = math.floor(x / engine.Map.tile_w)
local by = math.floor(y / engine.Map.tile_h)
local static = rng.percent(40)
return {
trail = 1,
life = 6,
size = 3, sizev = 0, sizea = 0,
x = x, xv = 0, xa = 0,
y = y, yv = 0, ya = 0,
dir = a, dirv = 0, dira = 0,
vel = sradius / 2 / 6, velv = 0, vela = 0,
r = rng.range(0, 0)/255, rv = 0, ra = 0,
g = rng.range(80, 200)/255, gv = 0.005, ga = 0.0005,
b = rng.range(0, 0)/255, bv = 0, ba = 0,
a = rng.range(255, 255)/255, av = static and -0.034 or 0, aa = 0.005,
}
end, },
function(self)
self.ps:emit(30)
end,
30*6
| gpl-3.0 |
LegionXI/darkstar | scripts/zones/Western_Adoulin/npcs/HomePoint#1.lua | 27 | 1255 | -----------------------------------
-- Area: Western_Adoulin
-- NPC: HomePoint#1
-- @pos
-----------------------------------
package.loaded["scripts/zones/Western_Adoulin/TextIDs"] = nil;
require("scripts/globals/settings");
require("scripts/zones/Western_Adoulin/TextIDs");
require("scripts/globals/homepoint");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
homepointMenu( player, 0x21fc, 44);
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 |
naclander/tome | game/modules/example/load.lua | 3 | 2608 | -- ToME - Tales of Middle-Earth
-- 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
-- This file loads the game module, and loads data
local KeyBind = require "engine.KeyBind"
local DamageType = require "engine.DamageType"
local ActorStats = require "engine.interface.ActorStats"
local ActorResource = require "engine.interface.ActorResource"
local ActorTalents = require "engine.interface.ActorTalents"
local ActorAI = require "engine.interface.ActorAI"
local ActorLevel = require "engine.interface.ActorLevel"
local ActorTemporaryEffects = require "engine.interface.ActorTemporaryEffects"
local Birther = require "engine.Birther"
-- Useful keybinds
KeyBind:load("move,hotkeys,inventory,actions,interface,debug")
-- Damage types
DamageType:loadDefinition("/data/damage_types.lua")
-- Talents
ActorTalents:loadDefinition("/data/talents.lua")
-- Timed Effects
ActorTemporaryEffects:loadDefinition("/data/timed_effects.lua")
-- Actor resources
ActorResource:defineResource("Power", "power", nil, "power_regen", "Power represent your ability to use special talents.")
-- Actor stats
ActorStats:defineStat("Strength", "str", 10, 1, 100, "Strength defines your character's ability to apply physical force. It increases your melee damage, damage with heavy weapons, your chance to resist physical effects, and carrying capacity.")
ActorStats:defineStat("Dexterity", "dex", 10, 1, 100, "Dexterity defines your character's ability to be agile and alert. It increases your chance to hit, your ability to avoid attacks and your damage with light weapons.")
ActorStats:defineStat("Constitution", "con", 10, 1, 100, "Constitution defines your character's ability to withstand and resist damage. It increases your maximum life and physical resistance.")
-- Actor AIs
ActorAI:loadDefinition("/engine/ai/")
-- Birther descriptor
Birther:loadDefinition("/data/birth/descriptors.lua")
return {require "mod.class.Game" }
| gpl-3.0 |
greasydeal/darkstar | scripts/globals/items/serving_of_leadafry.lua | 35 | 1203 | -----------------------------------------
-- ID: 5161
-- Item: serving_of_leadafry
-- Food Effect: 240Min, All Races
-----------------------------------------
-- Agility 5
-- Vitality 2
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,14400,5161);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_AGI, 5);
target:addMod(MOD_VIT, 2);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_AGI, 5);
target:delMod(MOD_VIT, 2);
end;
| gpl-3.0 |
DarkRedemption/GUnit | lua/gunit/main/generators/sv_fakeplayer.lua | 1 | 3257 | --[[
Creates a fake player class. Generally for database testing purposes.
Currently only makes fake SteamIds since that's the way you tend to look them up in a database,
as well as generating player roles for TTT.
Features and configurations to be added as requested/personally needed.
]]
local fakePlayer = {}
fakePlayer.__index = fakePlayer
function fakePlayer:GetClass()
return "player"
end
function fakePlayer:GetName()
return self.name
end
function fakePlayer:SetName(name)
self.name = name
end
function fakePlayer:IsPlayer()
return true
end
--[[
Returns the player's role as an integer ID.
GetRole() is only found in the Player class in TTT to my knowledge.
]]
function fakePlayer:GetRole()
return self.role
end
function fakePlayer:IsTerror()
return self.role == 1
end
function fakePlayer:SetRole(roleInt)
self.role = roleInt
end
function fakePlayer:GetNWBool(boolName, default)
return self.nwBools[boolName] or default
end
function fakePlayer:SetNWBool(boolName, value)
GUnit.assert(value):isType("boolean")
self.nwBools[boolName] = value
end
function fakePlayer:GetActiveWeapon()
return self.activeWeapon
end
function fakePlayer:SetActiveWeapon(wep)
self.activeWeapon = wep
end
--[[
Generates a table containing the SteamID along with all of its components as separate values.
SteamID compositions are described at https://developer.valvesoftware.com/wiki/SteamID
]]
local function generateSteamIdInfo()
--TODO (maybe): Force universe/account values to always be values a user can actually have,
--as opposed to the entire range of valid values. May not matter for testing.
local steamIdInfo = {}
steamIdInfo.universe = math.random(0, 4)
steamIdInfo.accountType = math.random(0, 10)
steamIdInfo.accountId = math.random(0, 2147483647) --0 to INT32_MAX
return steamIdInfo
end
function fakePlayer:getHighestIdBits()
return bit.rshift(self.steamIdInfo.accountId, 1)
end
function fakePlayer:SteamID()
local universe = self.steamIdInfo.universe
local smallestBit = self.steamIdInfo.accountId % 2
local highestBits = self:getHighestIdBits()
local steamId = "STEAM_" .. universe .. ":" .. smallestBit .. ":" .. highestBits
return steamId
end
function fakePlayer:SteamID64()
error("Not yet implemented.")
end
--Unique IDs are a transform of the SteamID in an unknown way.
--Since it's unknown, I'm just going to add a large number to the highest bits.
--Should be just fine for testing purposes since it's still just a large int.
function fakePlayer:UniqueID()
return self:getHighestIdBits() + 15000000
end
function fakePlayer:IsUserGroup(groupName)
return self.userGroup == groupName
end
function fakePlayer:SetUserGroup(groupName)
self.userGroup = groupName
end
function fakePlayer:IsBot()
return self:SteamID() == "BOT"
end
function fakePlayer:new()
local newFakePlayer = {}
setmetatable(newFakePlayer, self)
newFakePlayer.role = math.random(0, 2)
newFakePlayer.steamIdInfo = generateSteamIdInfo()
newFakePlayer.name = GUnit.Generators.StringGen.generateAlphaNum()
newFakePlayer.nwBools = {}
newFakePlayer.activeWeapon = GUnit.Generators.FakeEntity:new()
newFakePlayer.userGroup = "user"
return newFakePlayer
end
GUnit.Generators.FakePlayer = fakePlayer | mit |
ibm2431/darkstar | scripts/globals/weaponskills/burning_blade.lua | 10 | 1308 | -----------------------------------
-- Burning Blade
-- Sword weapon skill
-- Skill Level: 30
-- Desription: Deals Fire elemental damage to enemy. Damage varies with TP.
-- Aligned with the Flame Gorget.
-- Aligned with the Flame Belt.
-- Element: Fire
-- Modifiers: STR:20% INT:20%
-- 100%TP 200%TP 300%TP
-- 1.00 2.00 2.50
-----------------------------------
require("scripts/globals/magic")
require("scripts/globals/status")
require("scripts/globals/settings")
require("scripts/globals/weaponskills")
-----------------------------------
function onUseWeaponSkill(player, target, wsID, tp, primary, action, taChar)
local params = {}
params.ftp100 = 1 params.ftp200 = 2 params.ftp300 = 2.5
params.str_wsc = 0.2 params.dex_wsc = 0.0 params.vit_wsc = 0.0 params.agi_wsc = 0.0 params.int_wsc = 0.2 params.mnd_wsc = 0.0 params.chr_wsc = 0.0
params.ele = dsp.magic.ele.FIRE
params.skill = dsp.skill.SWORD
params.includemab = true
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.ftp200 = 2.1 params.ftp300 = 3.4
params.str_wsc = 0.4 params.int_wsc = 0.4
end
local damage, criticalHit, tpHits, extraHits = doMagicWeaponskill(player, target, wsID, params, tp, action, primary)
return tpHits, extraHits, criticalHit, damage
end
| gpl-3.0 |
LegionXI/darkstar | scripts/globals/items/angler_stewpot.lua | 12 | 1879 | -----------------------------------------
-- ID: 5611
-- Item: Angler's Stewpot
-- Food Effect: 3 Hrs, All Races
-----------------------------------------
-- TODO: Group Effect
-- HP +10% (cap 200)
-- MP +10
-- HP Recoverd while healing 5
-- MP Recovered while healing 1
-- Accuracy +15% Cap 15
-- Ranged Accuracy 15% Cap 15
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,10800,5611);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_FOOD_HPP, 10);
target:addMod(MOD_FOOD_HP_CAP, 200);
target:addMod(MOD_MP, 10);
target:addMod(MOD_HPHEAL, 5);
target:addMod(MOD_MPHEAL, 1);
target:addMod(MOD_FOOD_ACCP, 15);
target:addMod(MOD_FOOD_ACC_CAP, 15);
target:addMod(MOD_FOOD_RACCP, 15);
target:addMod(MOD_FOOD_RACC_CAP, 15);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_FOOD_HPP, 10);
target:delMod(MOD_FOOD_HP_CAP, 200);
target:delMod(MOD_MP, 10);
target:delMod(MOD_HPHEAL, 5);
target:delMod(MOD_MPHEAL, 1);
target:delMod(MOD_FOOD_ACCP, 15);
target:delMod(MOD_FOOD_ACC_CAP, 15);
target:delMod(MOD_FOOD_RACCP, 15);
target:delMod(MOD_FOOD_RACC_CAP, 15);
end;
| gpl-3.0 |
bittorf/luci | protocols/luci-proto-qmi/luasrc/model/cbi/admin_network/proto_qmi.lua | 17 | 1270 | -- Copyright 2016 David Thornley <david.thornley@touchstargroup.com>
-- Licensed to the public under the Apache License 2.0.
local map, section, net = ...
local device, apn, pincode, username, password
local auth, ipv6
device = section:taboption("general", Value, "device", translate("Modem device"))
device.rmempty = false
local device_suggestions = nixio.fs.glob("/dev/cdc-wdm*")
if device_suggestions then
local node
for node in device_suggestions do
device:value(node)
end
end
apn = section:taboption("general", Value, "apn", translate("APN"))
pincode = section:taboption("general", Value, "pincode", translate("PIN"))
username = section:taboption("general", Value, "username", translate("PAP/CHAP username"))
password = section:taboption("general", Value, "password", translate("PAP/CHAP password"))
password.password = true
auth = section:taboption("general", Value, "auth", translate("Authentication Type"))
auth:value("", translate("-- Please choose --"))
auth:value("both", "PAP/CHAP (both)")
auth:value("pap", "PAP")
auth:value("chap", "CHAP")
auth:value("none", "NONE")
if luci.model.network:has_ipv6() then
ipv6 = section:taboption("advanced", Flag, "ipv6", translate("Enable IPv6 negotiation"))
ipv6.default = ipv6.disabled
end
| apache-2.0 |
LegionXI/darkstar | scripts/zones/Sacrarium/npcs/Treasure_Chest.lua | 17 | 2934 | -----------------------------------
-- Area: Sacrarium
-- NPC: Treasure Chest
-- @zone 28
-----------------------------------
package.loaded["scripts/zones/Sacrarium/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/treasure");
require("scripts/zones/Sacrarium/TextIDs");
local TreasureType = "Chest";
local TreasureLvL = 53;
local TreasureMinLvL = 43;
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
-- trade:hasItemQty(1061,1); -- Treasure Key
-- trade:hasItemQty(1115,1); -- Skeleton Key
-- trade:hasItemQty(1023,1); -- Living Key
-- trade:hasItemQty(1022,1); -- Thief's Tools
local questItemNeeded = 0;
-- Player traded a key.
if ((trade:hasItemQty(1061,1) or trade:hasItemQty(1115,1) or trade:hasItemQty(1023,1) or trade:hasItemQty(1022,1)) and trade:getItemCount() == 1) then
local zone = player:getZoneID();
local pack = openChance(player,npc,trade,TreasureType,TreasureLvL,TreasureMinLvL,questItemNeeded);
local success = 0;
if (pack[2] ~= nil) then
player:messageSpecial(pack[2]);
success = pack[1];
else
success = pack[1];
end
if (success ~= -2) then
player:tradeComplete();
if (math.random() <= success) then
-- Succeded to open the coffer
player:messageSpecial(CHEST_UNLOCKED);
player:setVar("["..zone.."]".."Treasure_"..TreasureType,os.time() + math.random(CHEST_MIN_ILLUSION_TIME,CHEST_MAX_ILLUSION_TIME));
local loot = chestLoot(zone,npc);
-- print("loot array: "); -- debug
-- print("[1]", loot[1]); -- debug
-- print("[2]", loot[2]); -- debug
if (loot[1]=="gil") then
player:addGil(loot[2]*GIL_RATE);
player:messageSpecial(GIL_OBTAINED,loot[2]*GIL_RATE);
else
-- Item
player:addItem(loot[2]);
player:messageSpecial(ITEM_OBTAINED,loot[2]);
end
UpdateTreasureSpawnPoint(npc:getID());
end
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:messageSpecial(CHEST_LOCKED,1061);
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 |
atheurer/MoonGen | lua/include/proto/ah.lua | 5 | 8699 | ------------------------------------------------------------------------
--- @file ah.lua
--- @brief AH utility.
--- Utility functions for the ah_header structs
--- defined in \ref headers.lua . \n
--- Includes:
--- - AH constants
--- - IPsec ICV
--- - AH header utility
--- - Definition of AH packets
------------------------------------------------------------------------
local ffi = require "ffi"
local pkt = require "packet"
require "headers"
---------------------------------------------------------------------------
---- ah constants
---------------------------------------------------------------------------
local ah = {}
-------------------------------------------------------------------------------------
---- IPsec IV -> see proto/esp.lua
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
---- IPsec ICV
-------------------------------------------------------------------------------------
local ipsecICV = {}
ipsecICV.__index = ipsecICV
local ipsecICVType = ffi.typeof("union ipsec_icv")
--- Set the IPsec ICV.
--- @param iv IPsec ICV in 'union ipsec_icv' format.
function ipsecICV:set(icv)
-- For AH hw offload the ICV has to be zero
local offload_icv = ffi.new("union ipsec_icv")
offload_icv.uint32[0] = 0x0
offload_icv.uint32[1] = 0x0
offload_icv.uint32[2] = 0x0
offload_icv.uint32[3] = 0x0
icv = icv or offload_icv
self.uint32[0] = hton(icv.uint32[3])
self.uint32[1] = hton(icv.uint32[2])
self.uint32[2] = hton(icv.uint32[1])
self.uint32[3] = hton(icv.uint32[0])
end
--- Retrieve the IPsec ICV
--- @return ICV in 'union ipsec_icv' format.
function ipsecICV:get()
local icv = ipsecICVType()
icv.uint32[0] = hton(self.uint32[3])
icv.uint32[1] = hton(self.uint32[2])
icv.uint32[2] = hton(self.uint32[1])
icv.uint32[3] = hton(self.uint32[0])
return icv
end
--- Get the IPsec string.
--- @param icv IPsec ICV in string format.
function ipsecICV:getString(doByteSwap)
doByteSwap = doByteSwap or false
if doByteSwap then
self = self:get()
end
return ("0x%08x%08x%08x%08x"):format(self.uint32[3], self.uint32[2], self.uint32[1], self.uint32[0])
end
---------------------------------------------------------------------------
---- ah header
---------------------------------------------------------------------------
local ahHeader = {}
ahHeader.__index = ahHeader
--- Set the SPI.
--- @param int SPI of the ah header as A bit integer.
function ahHeader:setSPI(int)
int = int or 0
self.spi = hton(int)
end
--- Retrieve the SPI.
--- @return SPI as A bit integer.
function ahHeader:getSPI()
return hton(self.spi)
end
--- Retrieve the SPI as string.
--- @return SPI as string.
function ahHeader:getSPIString()
return self:getSPI()
end
--- Set the SQN.
--- @param int SQN of the ah header as A bit integer.
function ahHeader:setSQN(int)
int = int or 0
self.sqn = hton(int)
end
--- Retrieve the SQN.
--- @return SQN as A bit integer.
function ahHeader:getSQN()
return hton(self.sqn)
end
--- Retrieve the SQN as string.
--- @return SQN as string.
function ahHeader:getSQNString()
return self:getSQN()
end
--- Set the IV.
--- @param int IV of the ah header as 'union ipsec_iv'.
function ahHeader:setIV(iv)
self.iv:set(iv)
end
--- Retrieve the IV.
--- @return SPI as 'union ipsec_iv'.
function ahHeader:getIV()
return self.iv:get()
end
--- Retrieve the IV as string.
--- @return IV as string.
function ahHeader:getIVString()
return self.iv:getString(true)
end
--- Set the ICV.
--- @param int ICV of the ah header as...
function ahHeader:setICV(icv)
self.icv:set(icv)
end
--- Retrieve the ICV.
--- @return SPI as...
function ahHeader:getICV()
return self.icv:get()
end
--- Retrieve the ICV as string.
--- @return ICV as string.
function ahHeader:getICVString()
return self.icv:getString(true)
end
--- Set the Next Header.
--- @param int Next Header of the ah header as A bit integer.
function ahHeader:setNextHeader(int)
int = int or 0
self.nextHeader = int
end
--- Retrieve the Next Header.
--- @return Next Header as A bit integer.
function ahHeader:getNextHeader()
return self.nextHeader
end
--- Retrieve the Next Header as string.
--- @return Next Header as string.
function ahHeader:getNextHeaderString()
return self:getNextHeader()
end
--- Set the Length.
--- @param int Length of the ah header as A bit integer.
function ahHeader:setLength(int)
-- The AH header has a fixed length for AES-GMAC
-- (cf. chapter 16.5.1 "AH Formats" of X540 Datasheet)
-- Authentication header length in 32-bit Dwords units, minus 2,
-- such as for AES-128 its value is 7 for IPv4 and 8 for IPv6.
int = int or 7 -- IPv4: 7 = (9-2)
self.len = int
end
--- Retrieve the Length.
--- @return Length as A bit integer.
function ahHeader:getLength()
return self.len
end
--- Retrieve the Length as string.
--- @return Length as string.
function ahHeader:getLengthString()
return self:getLength()
end
--- Set all members of the ah header.
--- Per default, all members are set to default values specified in the respective set function.
--- Optional named arguments can be used to set a member to a user-provided value.
--- @param args Table of named arguments. Available arguments: ahSPI, ahSQN, ahIV, ahICV
--- @param pre prefix for namedArgs. Default 'ah'.
--- @usage fill() -- only default values
--- @usage fill{ ahXYZ=1 } -- all members are set to default values with the exception of ahXYZ, ...
function ahHeader:fill(args, pre)
args = args or {}
pre = pre or "ah"
self:setSPI(args[pre .. "SPI"])
self:setSQN(args[pre .. "SQN"])
self:setIV(args[pre .. "IV"])
self:setICV(args[pre .. "ICV"])
self:setNextHeader(args[pre .. "NextHeader"])
self:setLength(args[pre .. "Length"])
end
--- Retrieve the values of all members.
--- @param pre prefix for namedArgs. Default 'ah'.
--- @return Table of named arguments. For a list of arguments see "See also".
--- @see ahHeader:fill
function ahHeader:get(pre)
pre = pre or "ah"
local args = {}
args[pre .. "SPI"] = self:getSPI()
args[pre .. "SQN"] = self:getSQN()
args[pre .. "IV"] = self:getIV()
args[pre .. "ICV"] = self:getICV()
args[pre .. "NextHeader"] = self:getNextHeader()
args[pre .. "Length"] = self:getLength()
return args
end
--- Retrieve the values of all members.
--- @return Values in string format.
function ahHeader:getString()
return "AH spi " .. self:getSPIString() .. " sqn " .. self:getSQNString() .. " iv " .. self:getIVString() .. " icv " .. self:getICVString() .. " next_hdr " .. self:getNextHeader() .. " len " .. self:getLength()
end
--- Resolve which header comes after this one (in a packet)
--- For instance: in tcp/udp based on the ports
--- This function must exist and is only used when get/dump is executed on
--- an unknown (mbuf not yet casted to e.g. tcpv6 packet) packet (mbuf)
--- @return String next header (e.g. 'eth', 'ip4', nil)
function ahHeader:resolveNextHeader()
return nil
--TODO: return self:getNextHeader()
end
--- Change the default values for namedArguments (for fill/get)
--- This can be used to for instance calculate a length value based on the total packet length
--- See proto/ip4.setDefaultNamedArgs as an example
--- This function must exist and is only used by packet.fill
--- @param pre The prefix used for the namedArgs, e.g. 'ah'
--- @param namedArgs Table of named arguments (see See more)
--- @param nextHeader The header following after this header in a packet
--- @param accumulatedLength The so far accumulated length for previous headers in a packet
--- @return Table of namedArgs
--- @see ahHeader:fill
function ahHeader:setDefaultNamedArgs(pre, namedArgs, nextHeader, accumulatedLength)
return namedArgs
end
----------------------------------------------------------------------------------
---- Packets
----------------------------------------------------------------------------------
-- Ah4 packets should not be shorter than 70 bytes (cf. x540 datasheet page 308: SECP field)
pkt.getAh4Packet = packetCreate("eth", "ip4", "ah")
-- Ah6 packets should not be shorter than 94 bytes (cf. x540 datasheet page 308: SECP field)
pkt.getAh6Packet = nil --packetCreate("eth", "ip6", "ah6") --TODO: AH6 needs to be implemented
pkt.getAhPacket = function(self, ip4) ip4 = ip4 == nil or ip4 if ip4 then return pkt.getAh4Packet(self) else return pkt.getAh6Packet(self) end end
------------------------------------------------------------------------
---- Metatypes
------------------------------------------------------------------------
--ffi.metatype("union ipsec_iv", ipsecIV)
ffi.metatype("union ipsec_icv", ipsecICV)
ffi.metatype("struct ah_header", ahHeader)
return ah
| mit |
lbthomsen/openwrt-luci | applications/luci-app-dockerman/luasrc/model/cbi/dockerman/images.lua | 3 | 7928 | --[[
LuCI - Lua Configuration Interface
Copyright 2019 lisaac <https://github.com/lisaac/luci-app-dockerman>
]]--
local docker = require "luci.model.docker"
local dk = docker.new()
local containers, images, res
local m, s, o
res = dk.images:list()
if res.code < 300 then
images = res.body
else
return
end
res = dk.containers:list({
query = {
all=true
}
})
if res.code < 300 then
containers = res.body
else
return
end
function get_images()
local data = {}
for i, v in ipairs(images) do
local index = v.Created .. v.Id
data[index]={}
data[index]["_selected"] = 0
data[index]["id"] = v.Id:sub(8)
data[index]["_id"] = '<a href="javascript:new_tag(\''..v.Id:sub(8,20)..'\')" class="dockerman-link" title="'..translate("New tag")..'">' .. v.Id:sub(8,20) .. '</a>'
if v.RepoTags and next(v.RepoTags)~=nil then
for i, v1 in ipairs(v.RepoTags) do
data[index]["_tags"] =(data[index]["_tags"] and ( data[index]["_tags"] .. "<br />" )or "") .. ((v1:match("<none>") or (#v.RepoTags == 1)) and v1 or ('<a href="javascript:un_tag(\''..v1..'\')" class="dockerman_link" title="'..translate("Remove tag")..'" >' .. v1 .. '</a>'))
if not data[index]["tag"] then
data[index]["tag"] = v1
end
end
else
data[index]["_tags"] = v.RepoDigests[1] and v.RepoDigests[1]:match("^(.-)@.+")
data[index]["_tags"] = (data[index]["_tags"] and data[index]["_tags"] or "<none>" ).. ":<none>"
end
data[index]["_tags"] = data[index]["_tags"]:gsub("<none>","<none>")
for ci,cv in ipairs(containers) do
if v.Id == cv.ImageID then
data[index]["_containers"] = (data[index]["_containers"] and (data[index]["_containers"] .. " | ") or "")..
'<a href='..luci.dispatcher.build_url("admin/docker/container/"..cv.Id)..' class="dockerman_link" title="'..translate("Container detail")..'">'.. cv.Names[1]:sub(2).."</a>"
end
end
data[index]["_size"] = string.format("%.2f", tostring(v.Size/1024/1024)).."MB"
data[index]["_created"] = os.date("%Y/%m/%d %H:%M:%S",v.Created)
end
return data
end
local image_list = get_images()
m = SimpleForm("docker",
translate("Docker - Images"),
translate("On this page all images are displayed that are available on the system and with which a container can be created."))
m.submit=false
m.reset=false
local pull_value={
_image_tag_name="",
_registry="index.docker.io"
}
s = m:section(SimpleSection,
translate("Pull Image"),
translate("By entering a valid image name with the corresponding version, the docker image can be downloaded from the configured registry."))
s.template="cbi/nullsection"
o = s:option(Value, "_image_tag_name")
o.template = "dockerman/cbi/inlinevalue"
o.placeholder="lisaac/luci:latest"
o.write = function(self, section, value)
local hastag = value:find(":")
if not hastag then
value = value .. ":latest"
end
pull_value["_image_tag_name"] = value
end
o = s:option(Button, "_pull")
o.inputtitle= translate("Pull")
o.template = "dockerman/cbi/inlinebutton"
o.inputstyle = "add"
o.write = function(self, section)
local tag = pull_value["_image_tag_name"]
local json_stringify = luci.jsonc and luci.jsonc.stringify
if tag and tag ~= "" then
docker:write_status("Images: " .. "pulling" .. " " .. tag .. "...\n")
local res = dk.images:create({query = {fromImage=tag}}, docker.pull_image_show_status_cb)
if res and res.code == 200 and (res.body[#res.body] and not res.body[#res.body].error and res.body[#res.body].status and (res.body[#res.body].status == "Status: Downloaded newer image for ".. tag)) then
docker:clear_status()
else
docker:append_status("code:" .. res.code.." ".. (res.body[#res.body] and res.body[#res.body].error or (res.body.message or res.message)).. "\n")
end
else
docker:append_status("code: 400 please input the name of image name!")
end
luci.http.redirect(luci.dispatcher.build_url("admin/docker/images"))
end
s = m:section(SimpleSection,
translate("Import Image"),
translate("When pressing the Import button, both a local image can be loaded onto the system and a valid image tar can be downloaded from remote."))
o = s:option(DummyValue, "_image_import")
o.template = "dockerman/images_import"
s = m:section(Table, image_list, translate("Images overview"))
o = s:option(Flag, "_selected","")
o.disabled = 0
o.enabled = 1
o.default = 0
o.write = function(self, section, value)
image_list[section]._selected = value
end
o = s:option(DummyValue, "_tags", translate("RepoTags"))
o.rawhtml = true
o = s:option(DummyValue, "_containers", translate("Containers"))
o.rawhtml = true
o = s:option(DummyValue, "_size", translate("Size"))
o = s:option(DummyValue, "_created", translate("Created"))
o = s:option(DummyValue, "_id", translate("ID"))
o.rawhtml = true
local remove_action = function(force)
local image_selected = {}
for k in pairs(image_list) do
if image_list[k]._selected == 1 then
image_selected[#image_selected+1] = (image_list[k]["_tags"]:match("<br />") or image_list[k]["_tags"]:match("<none>")) and image_list[k].id or image_list[k].tag
end
end
if next(image_selected) ~= nil then
local success = true
docker:clear_status()
for _, img in ipairs(image_selected) do
local query
docker:append_status("Images: " .. "remove" .. " " .. img .. "...")
if force then
query = {force = true}
end
local msg = dk.images:remove({
id = img,
query = query
})
if msg.code ~= 200 then
docker:append_status("code:" .. msg.code.." ".. (msg.body.message and msg.body.message or msg.message).. "\n")
success = false
else
docker:append_status("done\n")
end
end
if success then
docker:clear_status()
end
luci.http.redirect(luci.dispatcher.build_url("admin/docker/images"))
end
end
s = m:section(SimpleSection)
s.template = "dockerman/apply_widget"
s.err = docker:read_status()
s.err = s.err and s.err:gsub("\n","<br />"):gsub(" "," ")
if s.err then
docker:clear_status()
end
s = m:section(Table,{{}})
s.notitle=true
s.rowcolors=false
s.template="cbi/nullsection"
o = s:option(Button, "remove")
o.inputtitle= translate("Remove")
o.template = "dockerman/cbi/inlinebutton"
o.inputstyle = "remove"
o.forcewrite = true
o.write = function(self, section)
remove_action()
end
o = s:option(Button, "forceremove")
o.inputtitle= translate("Force Remove")
o.template = "dockerman/cbi/inlinebutton"
o.inputstyle = "remove"
o.forcewrite = true
o.write = function(self, section)
remove_action(true)
end
o = s:option(Button, "save")
o.inputtitle= translate("Save")
o.template = "dockerman/cbi/inlinebutton"
o.inputstyle = "edit"
o.forcewrite = true
o.write = function (self, section)
local image_selected = {}
for k in pairs(image_list) do
if image_list[k]._selected == 1 then
image_selected[#image_selected + 1] = image_list[k].id
end
end
if next(image_selected) ~= nil then
local names, first
for _, img in ipairs(image_selected) do
names = names and (names .. "&names=".. img) or img
end
local cb = function(res, chunk)
if res.code == 200 then
if not first then
first = true
luci.http.header('Content-Disposition', 'inline; filename="images.tar"')
luci.http.header('Content-Type', 'application\/x-tar')
end
luci.ltn12.pump.all(chunk, luci.http.write)
else
if not first then
first = true
luci.http.prepare_content("text/plain")
end
luci.ltn12.pump.all(chunk, luci.http.write)
end
end
docker:write_status("Images: " .. "save" .. " " .. table.concat(image_selected, "\n") .. "...")
local msg = dk.images:get({query = {names = names}}, cb)
if msg.code ~= 200 then
docker:append_status("code:" .. msg.code.." ".. (msg.body.message and msg.body.message or msg.message).. "\n")
success = false
else
docker:clear_status()
end
end
end
o = s:option(Button, "load")
o.inputtitle= translate("Load")
o.template = "dockerman/images_load"
o.inputstyle = "add"
return m
| apache-2.0 |
greasydeal/darkstar | scripts/zones/Oldton_Movalpolos/Zone.lua | 13 | 2426 | -----------------------------------
--
-- Zone: Oldton_Movalpolos (11)
--
-----------------------------------
package.loaded["scripts/zones/Oldton_Movalpolos/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/conquest");
require("scripts/zones/Oldton_Movalpolos/TextIDs");
require("scripts/globals/missions");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
UpdateTreasureSpawnPoint(16822527);
SetRegionalConquestOverseers(zone:getRegionID())
end;
-----------------------------------
-- onConquestUpdate
-----------------------------------
function onConquestUpdate(zone, updatetype)
local players = zone:getPlayers();
for name, player in pairs(players) do
conquestUpdate(zone, player, updatetype, CONQUEST_BASE);
end
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local currentday = tonumber(os.date("%j"));
local LouverancePath=player:getVar("COP_Louverance_s_Path");
local cs = -1;
if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then
player:setPos(70.956,5.99,139.843,134);
end
if(player:getCurrentMission(COP) == THREE_PATHS and (LouverancePath == 3 or LouverancePath == 4))then
cs=0x0001;
elseif(player:getCurrentMission(COP) == DAWN and player:getVar("PromathiaStatus")==3 and player:getVar("Promathia_kill_day")~=currentday and player:getVar("COP_jabbos_story")== 0 )then
cs=0x0039;
end
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if(csid==0x0001)then
player:setVar("COP_Louverance_s_Path",5);
elseif(csid == 0x0039)then
player:setVar("COP_jabbos_story",1);
end
end;
| gpl-3.0 |
greasydeal/darkstar | scripts/zones/Temenos/npcs/Matter_Diffusion_Module.lua | 19 | 6043 | -----------------------------------
-- Area: temenos
-- NPC: Matter diffusion module
-- @pos
-----------------------------------
package.loaded["scripts/zones/Temenos/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/limbus");
require("scripts/globals/keyitems");
require("scripts/zones/Temenos/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
local count = trade:getItemCount();
local InstanceTrade=0;
if(player:hasKeyItem(COSMOCLEANSE) and player:hasKeyItem(WHITE_CARD) )then
if(count==1 and trade:hasItemQty(2127,1))then -- Central Temenos - Basement 1
InstanceTrade=128;
elseif(count==1 and trade:hasItemQty(1906,1))then -- Central Temenos - 1st Floor
InstanceTrade=64;
elseif(count==1 and trade:hasItemQty(1905,1))then -- Central Temenos - 2st Floor
InstanceTrade=32;
elseif(count==1 and trade:hasItemQty(1904,1))then -- Central Temenos - 3st Floor
InstanceTrade=16;
elseif(count==3 and trade:hasItemQty(1986,1) and trade:hasItemQty(1908,1) and trade:hasItemQty(1907,1))then --proto-ultima
InstanceTrade=8;
end
else
player:messageSpecial(CONDITION_FOR_LIMBUS_T);
print("error player don't have cosmo clean");
end
if(InstanceTrade~=0)then
player:setVar("Limbus_Trade_Item-T",InstanceTrade);
player:tradeComplete();
player:messageSpecial(CHIP_TRADE_T);
player:startEvent(0x7d00,0,0,0,InstanceTrade,0,0,0,0);
player:setVar("limbusbitmap",InstanceTrade);
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local instancelist ={};
local limbusbitmap = 0 ;
local AllowLimbusToPlayer = true ;
local currentlimbus= TryTobackOnCurrentLimbus(player);
instancelist = TEMENOS_LIST;
printf("currentlimbus: %u",currentlimbus);
if(player:hasKeyItem(COSMOCLEANSE))then
if(player:hasStatusEffect(EFFECT_BATTLEFIELD) == false) then
local LimbusTradeItem = player:getVar("Limbus_Trade_Item-T");
for nt = 1,table.getn (instancelist),2 do
-- printf("list d'instance: %u",instancelist[nt]);
if(instancelist[nt+1][1]==true and player:hasKeyItem(WHITE_CARD))then
-- print("player_have_white_card");
limbusbitmap = limbusbitmap + instancelist[nt+1][4];
-- printf("bitmapadd: %u",instancelist[nt+1][4]);
end
if(instancelist[nt+1][2]==true and player:hasKeyItem(RED_CARD))then
-- print("player_have_red_card");
limbusbitmap = limbusbitmap + instancelist[nt+1][4];
-- printf("bitmapadd: %u",instancelist[nt+1][4]);
end
if(instancelist[nt+1][3]==true and player:hasKeyItem(BLACK_CARD))then
-- print("player_have_black_card");
limbusbitmap = limbusbitmap + instancelist[nt+1][4];
-- printf("bitmapadd: %u",instancelist[nt+1][4]);
end
end
limbusbitmap= limbusbitmap + LimbusTradeItem;
----- /////////////////////////////////////////////on doit ajouter le mipmap pour l'item trade ici
else
local status = player:getStatusEffect(EFFECT_BATTLEFIELD);
local playerbcnmid = status:getPower();
-- check if the player has the key item for the current battlefield
for nt = 1,table.getn (instancelist),2 do
-- printf("list d'instance: %u",instancelist[nt]);
if(instancelist[nt] == playerbcnmid)then
if(instancelist[nt+1][1]== true and player:hasKeyItem(WHITE_CARD) == false)then
AllowLimbusToPlayer = false;
end
if(instancelist[nt+1][2]== true and player:hasKeyItem(RED_CARD) == false )then
AllowLimbusToPlayer = false;
end
if(instancelist[nt+1][3]== true and player:hasKeyItem(BLACK_CARD) == false )then
AllowLimbusToPlayer = false;
end
if(AllowLimbusToPlayer == true)then --player have the correct key item for the current battflield
limbusbitmap = instancelist[nt+1][4];
end
end
end
end
if(limbusbitmap~= 0 )then
player:startEvent(0x7d00,0,0,0,limbusbitmap,0,0,0,0);
player:setVar("limbusbitmap",limbusbitmap);
else
player:messageSpecial(CONDITION_FOR_LIMBUS_T);
print("player need a card for basic limbus");
end
elseif(currentlimbus~=0)then
for nt = 1,table.getn (instancelist),2 do
-- printf("list d'instance: %u",instancelist[nt]);
if(instancelist[nt] == currentlimbus)then
limbusbitmap = instancelist[nt+1][4];
end
end
player:startEvent(0x7d00,0,0,0,limbusbitmap,0,0,0,0);
player:setVar("limbusbitmap",limbusbitmap);
else
player:messageSpecial(CONDITION_FOR_LIMBUS_T);
print("error player don't have cosmo clean");
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
if(csid == 0x7d00)then
if(player:hasStatusEffect(EFFECT_BATTLEFIELD) == false) then
ResetPlayerLimbusVariable(player);
player:setVar("characterLimbusKey",0);
else
local status = player:getStatusEffect(EFFECT_BATTLEFIELD);
player:setVar("LimbusID",status:getPower());
player:setVar("characterLimbusKey",GetLimbusKeyFromInstance(status:getPower()));
end
player:updateEvent(2,player:getVar("limbusbitmap"),0,1,1,0);
player:setVar("limbusbitmap",0);
end
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if(csid == 0x7d00)then
end
end; | gpl-3.0 |
ibm2431/darkstar | scripts/zones/Newton_Movalpolos/IDs.lua | 11 | 1844 | -----------------------------------
-- Area: Newton_Movalpolos
-----------------------------------
require("scripts/globals/zone")
-----------------------------------
zones = zones or {}
zones[dsp.zone.NEWTON_MOVALPOLOS] =
{
text =
{
ITEM_CANNOT_BE_OBTAINED = 6382, -- You cannot obtain the <item>. Come back after sorting your inventory.
ITEM_OBTAINED = 6388, -- Obtained: <item>.
GIL_OBTAINED = 6389, -- Obtained <number> gil.
KEYITEM_OBTAINED = 6391, -- Obtained key item: <keyitem>.
CONQUEST_BASE = 7049, -- Tallying conquest results...
COME_CLOSER = 7230, -- H0000! C0mE cL0SEr! C0mE cL0SEr! CAn'T TrAdE fr0m S0 fAr AwAy!
MINING_IS_POSSIBLE_HERE = 7238, -- Mining is possible here if you have <item>.
CHEST_UNLOCKED = 7253, -- You unlock the chest!
SHOWMAN_DECLINE = 7264, -- ... Me no want that. Thing me want not here! It not being here!!!
SHOWMAN_TRIGGER = 7265, -- Hey, you there! Muscles nice. You want fight strong one? It cost you. Give me nice item.
SHOWMAN_ACCEPT = 7266, -- Fhungaaa!!! The freshyness, the flavoryness! This very nice item! Good luck, then. Try not die. One...two...four...FIIIIIIGHT!!!
HOMEPOINT_SET = 7269, -- Home point set!
},
mob =
{
MIMIC = 16826564,
BUGBEAR_MATMAN = 16826570,
},
npc =
{
DOOR_OFFSET = 16826582,
FURNACE_HATCH_OFFSET = 16826607,
TREASURE_COFFER = 16826627,
MINING =
{
16826621,
16826622,
16826623,
16826624,
16826625,
16826626,
},
},
}
return zones[dsp.zone.NEWTON_MOVALPOLOS] | gpl-3.0 |
LegionXI/darkstar | scripts/globals/items/jar_of_ground_wasabi.lua | 12 | 1589 | -----------------------------------------
-- ID: 5164
-- Item: jar_of_ground_wasabi
-- Food Effect: 5Min, All Races
-----------------------------------------
-- Strength -1
-- Dexterity -1
-- Agility -1
-- Vitality -1
-- Intelligence -1
-- Mind -1
-- Charisma -1
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,300,5164);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_STR, -1);
target:addMod(MOD_DEX, -1);
target:addMod(MOD_AGI, -1);
target:addMod(MOD_VIT, -1);
target:addMod(MOD_INT, -1);
target:addMod(MOD_MND, -1);
target:addMod(MOD_CHR, -1);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_STR, -1);
target:delMod(MOD_DEX, -1);
target:delMod(MOD_AGI, -1);
target:delMod(MOD_VIT, -1);
target:delMod(MOD_INT, -1);
target:delMod(MOD_MND, -1);
target:delMod(MOD_CHR, -1);
end;
| gpl-3.0 |
greasydeal/darkstar | scripts/zones/Aht_Urhgan_Whitegate/npcs/Saluhwa.lua | 34 | 1475 | -----------------------------------
-- Area: Aht Urhgan Whitegate
-- NPC: Saluhwa
-- Standard Merchant NPC
-----------------------------------
package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/shop");
require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,SALUHWA_SHOP_DIALOG);
stock = {0x3002,605, -- Mapple Shield (Available when AC is in the city)
0x3003,1815, -- Elm Shield (Available when AC is in the city)
0x3004,4980, -- Mahogany Shield (Available when AC is in the city)
0x3005,15600, -- Oak Shield (Available when AC is in the city)
0x3007,64791} -- Round Shield (Available when AC is in the city)
showShop(player, STATIC, stock);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
ibm2431/darkstar | scripts/zones/Inner_Horutoto_Ruins/IDs.lua | 9 | 2622 | -----------------------------------
-- Area: Inner Horutoto Ruins (192)
-----------------------------------
require("scripts/globals/zone")
-----------------------------------
zones = zones or {}
zones[dsp.zone.INNER_HORUTOTO_RUINS] =
{
text =
{
PORTAL_SEALED_BY_3_MAGIC = 8, -- The Sealed Portal is sealed by three kinds of magic.
PORTAL_NOT_OPEN_THAT_SIDE = 9, -- The Sealed Portal cannot be opened from this side.
CONQUEST_BASE = 10, -- Tallying conquest results...
ITEM_CANNOT_BE_OBTAINED = 6551, -- You cannot obtain the <item>. Come back after sorting your inventory.
ITEM_OBTAINED = 6557, -- Obtained: <item>.
GIL_OBTAINED = 6558, -- Obtained <number> gil.
KEYITEM_OBTAINED = 6560, -- Obtained key item: <keyitem>.
GEOMAGNETRON_ATTUNED = 7179, -- Your <keyitem> has been attuned to a geomagnetic fount in the corresponding locale.
NOT_BROKEN_ORB = 7234, -- The Mana Orb in this receptacle is not broken.
EXAMINED_RECEPTACLE = 7235, -- You have already examined this receptacle.
DOOR_FIRMLY_CLOSED = 7262, -- The door is firmly closed.
CHEST_UNLOCKED = 7338, -- You unlock the chest!
PLAYER_OBTAINS_ITEM = 7401, -- <name> obtains <item>!
UNABLE_TO_OBTAIN_ITEM = 7402, -- You were unable to obtain the item.
PLAYER_OBTAINS_TEMP_ITEM = 7403, -- <name> obtains the temporary item: <item>!
ALREADY_POSSESS_TEMP = 7404, -- You already possess that temporary item.
NO_COMBINATION = 7409, -- You were unable to enter a combination.
REGIME_REGISTERED = 9487, -- New training regime registered!
COMMON_SENSE_SURVIVAL = 10535, -- It appears that you have arrived at a new survival guide provided by the Adventurers' Mutual Aid Network. Common sense dictates that you should now be able to teleport here from similar tomes throughout the world.
},
mob =
{
SLENDLIX_SPINDLETHUMB_PH =
{
[17563758] = 17563785, -- -238.315 -0.002 -179.249
},
NOCUOUS_WEAPON_PH =
{
[17563798] = 17563801, -- -236.855 0.476 -51.263
[17563799] = 17563801, -- -237.426 0.5 -23.412
[17563800] = 17563801, -- -230.732 -0.025 -52.324
},
},
npc =
{
CASKET_BASE = 17563838,
PORTAL_CIRCLE_BASE = 17563861,
TREASURE_CHEST = 17563914,
},
}
return zones[dsp.zone.INNER_HORUTOTO_RUINS] | gpl-3.0 |
ibm2431/darkstar | scripts/globals/spells/aisha_ichi.lua | 12 | 1837 | -----------------------------------------
-- Spell: Aisha: Ichi
-----------------------------------------
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 effect = dsp.effect.ATTACK_DOWN
-- Base Stats
local dINT = (caster:getStat(dsp.mod.INT) - target:getStat(dsp.mod.INT))
--Duration Calculation
local params = {}
params.diff = nil
params.attribute = dsp.mod.INT
params.skillType = dsp.skill.NINJUTSU
params.bonus = 0
params.effect = nil
local resist = applyResistance(caster, target, spell, params)
--Base power is 15 and is not affected by resistaces.
local power = 15
--Calculates Resist Chance
if (resist >= 0.125) then
local duration = 120 * resist
if (duration >= 50) then
-- Erases a weaker attack down and applies the stronger one
local attackdown = target:getStatusEffect(effect)
if (attackdown ~= nil) then
if (attackdown:getPower() < power) then
target:delStatusEffect(effect)
target:addStatusEffect(effect,power,0,duration)
spell:setMsg(dsp.msg.basic.MAGIC_ENFEEB)
else
-- no effect
spell:setMsg(dsp.msg.basic.MAGIC_NO_EFFECT)
end
else
target:addStatusEffect(effect,power,0,duration)
spell:setMsg(dsp.msg.basic.MAGIC_ENFEEB)
end
else
spell:setMsg(dsp.msg.basic.MAGIC_RESIST)
end
else
spell:setMsg(dsp.msg.basic.MAGIC_RESIST_2)
end
return effect
end
| gpl-3.0 |
greasydeal/darkstar | scripts/zones/Castle_Oztroja/mobs/Tzee_Xicu_the_Manifest.lua | 27 | 1224 | -----------------------------------
-- Area: Castle Oztroja
-- NPC: Tzee Xicu the Manifest
-----------------------------------
require("scripts/globals/titles");
require("scripts/zones/Castle_Oztroja/TextIDs");
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
end;
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
-- target:showText(mob,YAGUDO_KING_ENGAGE);
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, killer)
killer:addTitle(DEITY_DEBUNKER);
-- killer:showText(mob,YAGUDO_KING_DEATH);
-- Set Tzee_Xicu_the_Manifest's Window Open Time
wait = 72 * 3600
SetServerVariable("[POP]Tzee_Xicu_the_Manifest", os.time(t) + wait); -- 3 days
-- Set Yagudo_Avatar's spawnpoint and respawn time (21-24 hours)
SetServerVariable("[PH]Tzee_Xicu_the_Manifest", 0);
Yagudo_Avatar = 17396134;
DeterMob(Yagudo_Avatar, false);
UpdateNMSpawnPoint(Yagudo_Avatar);
GetMobByID(Yagudo_Avatar):setRespawnTime(math.random((75600),(86400)));
end; | gpl-3.0 |
greasydeal/darkstar | scripts/zones/QuBia_Arena/npcs/Burning_Circle.lua | 12 | 2528 | -----------------------------------
-- Area: Qu'Bia Arena
-- NPC: Burning Circle
-- @pos -221 -24 19 206
-------------------------------------
package.loaded["scripts/zones/QuBia_Arena/TextIDs"] = nil;
-------------------------------------
require("scripts/globals/bcnm");
require("scripts/globals/missions");
require("scripts/globals/keyitems");
require("scripts/zones/QuBia_Arena/TextIDs");
-------------------------------------
-- 0: The Ruins of Fei'Yin, Darkness Rising, The Final Seal (Rank 5 Mission)
-- 1: Come Into My Parlor
-- 2: E-vase-ive Action
-- 3: Infernal Swarm
-- 4: The Heir to the Light
-- 5: Shattering Stars (Paladin)
-- 6: Shattering Stars (Dark Knight)
-- 7: Shattering Stars (Bard)
-- 8: Demolition Squad
-- 9: Die By the Sword
-- 10: Let Sleeping Dogs Die
-- 11: Brothers D'Aurphe
-- 12: Undying Promise
-- 13: Factory Rejects
-- 14: Idol Thoughts
-- 15: An Awful Autopsy
-- 16: Celery
-- 17: Mirror Images
-- 18: A Furious Finale (Dancer)
-- 19: Clash of the Comrades
-- 20: Those Who Lurk in the Shadows (III)
-- 21: Beyond Infinity
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if(TradeBCNM(player,player:getZoneID(),trade,npc))then
return;
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
-- if(player:hasKeyItem(MARK_OF_SEED) and player:getCurrentMission(ACP) == THOSE_WHO_LURK_IN_SHADOWS_II) then
--player:startEvent(0x005);
--elseif(EventTriggerBCNM(player,npc)) then
-- Temp disabled pending fixes for the BCNM mobs.
if(EventTriggerBCNM(player,npc))then
return;
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("onUpdate CSID: %u",csid);
-- printf("onUpdate RESULT: %u",option);
if (EventUpdateBCNM(player,csid,option)) then
return;
end
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("onFinish CSID: %u",csid);
-- printf("onFinish RESULT: %u",option);
if (csid == 0x005) then
player:completeMission(ACP,THOSE_WHO_LURK_IN_SHADOWS_II);
player:addMission(ACP,THOSE_WHO_LURK_IN_SHADOWS_III);
elseif (EventFinishBCNM(player,csid,option)) then
return;
end
end; | gpl-3.0 |
icyxp/kong | kong/plugins/datadog/migrations/postgres.lua | 5 | 2444 | return {
{
name = "2017-06-09-160000_datadog_schema_changes",
up = function(_, _, dao)
local plugins, err = dao.plugins:find_all { name = "datadog" }
if err then
return err
end
local default_metrics = {
request_count = {
name = "request_count",
stat_type = "counter",
sample_rate = 1,
},
latency = {
name = "latency",
stat_type = "gauge",
sample_rate = 1,
},
request_size = {
name = "request_size",
stat_type = "gauge",
sample_rate = 1,
},
status_count = {
name = "status_count",
stat_type = "counter",
sample_rate = 1,
},
response_size = {
name = "response_size",
stat_type = "timer",
},
unique_users = {
name = "unique_users",
stat_type = "set",
consumer_identifier = "consumer_id",
},
request_per_user = {
name = "request_per_user",
stat_type = "counter",
sample_rate = 1,
consumer_identifier = "consumer_id",
},
upstream_latency = {
name = "upstream_latency",
stat_type = "gauge",
sample_rate = 1,
},
}
for i = 1, #plugins do
local datadog = plugins[i]
local _, err = dao.plugins:delete(datadog)
if err then
return err
end
local tags = datadog.config.tags or {}
local new_metrics = {}
if datadog.config.metrics then
for _, metric in ipairs(datadog.config.metrics) do
local new_metric = default_metrics[metric]
if new_metric then
new_metric.tags = tags[metric]
table.insert(new_metrics, new_metric)
end
end
end
local _, err = dao.plugins:insert {
name = "datadog",
api_id = datadog.api_id,
enabled = datadog.enabled,
config = {
host = datadog.config.host,
port = datadog.config.port,
metrics = new_metrics,
prefix = "kong",
}
}
if err then
return err
end
end
end
},
down = function()
end,
}
| apache-2.0 |
Igalia/snabbswitch | lib/luajit/testsuite/test/lang/meta/newindex.lua | 6 | 1479 | do --- table 1
local t=setmetatable({}, {__newindex=function(t,k,v)
rawset(t, k, 100-v)
end})
for i=1,100 do t[i] = i end
for i=1,100 do assert(t[i] == 100-i) end
for i=1,100 do t[i] = i end
for i=1,100 do assert(t[i] == i) end
for i=1,100 do t[i] = nil end
for i=1,100 do t[i] = i end
for i=1,100 do assert(t[i] == 100-i) end
end
do --- jit gaining href
local count = 0
local t = setmetatable({ foo = nil },
{ __newindex=function() count = count + 1 end })
for j=1,2 do
for i=1,100 do t.foo = 1 end
rawset(t, "foo", 1)
end
assert(count == 100)
end
do --- jit gaining aref
local count = 0
local t = setmetatable({ nil },
{ __newindex=function() count = count + 1 end })
for j=1,2 do
for i=1,100 do t[1] = 1 end
rawset(t, 1, 1)
end
assert(count == 100)
end
do --- resize
local grandparent = {}
grandparent.__newindex = function(s,_,_) tostring(s) end
local parent = {}
parent.__newindex = parent
parent.bar = 1
setmetatable(parent, grandparent)
local child = setmetatable({}, parent)
child.foo = _
end
do --- str
local t=setmetatable({}, {__newindex=function(t,k,v)
assert(v == "foo"..k)
rawset(t, k, "bar"..k)
end})
for i=1,100 do t[i]="foo"..i end
for i=1,100 do assert(t[i] == "bar"..i) end
for i=1,100 do t[i]="baz"..i end
for i=1,100 do assert(t[i] == "baz"..i) end
local t=setmetatable({foo=1,bar=1,baz=1},{})
t.baz=nil
t.baz=2
t.baz=nil
t.baz=2
end
| apache-2.0 |
peymankhanas8487/Horror-Avatar | plugins/minecraft.lua | 624 | 2605 | local usage = {
"!mine [ip]: Searches Minecraft server on specified ip and sends info. Default port: 25565",
"!mine [ip] [port]: Searches Minecraft server on specified ip and port and sends info.",
}
local ltn12 = require "ltn12"
local function mineSearch(ip, port, receiver) --25565
local responseText = ""
local api = "https://api.syfaro.net/server/status"
local parameters = "?ip="..(URL.escape(ip) or "").."&port="..(URL.escape(port) or "").."&players=true&favicon=true"
local http = require("socket.http")
local respbody = {}
local body, code, headers, status = http.request{
url = api..parameters,
method = "GET",
redirect = true,
sink = ltn12.sink.table(respbody)
}
local body = table.concat(respbody)
if (status == nil) then return "ERROR: status = nil" end
if code ~=200 then return "ERROR: "..code..". Status: "..status end
local jsonData = json:decode(body)
responseText = responseText..ip..":"..port.." ->\n"
if (jsonData.motd ~= nil) then
local tempMotd = ""
tempMotd = jsonData.motd:gsub('%§.', '')
if (jsonData.motd ~= nil) then responseText = responseText.." Motd: "..tempMotd.."\n" end
end
if (jsonData.online ~= nil) then
responseText = responseText.." Online: "..tostring(jsonData.online).."\n"
end
if (jsonData.players ~= nil) then
if (jsonData.players.max ~= nil) then
responseText = responseText.." Max Players: "..jsonData.players.max.."\n"
end
if (jsonData.players.now ~= nil) then
responseText = responseText.." Players online: "..jsonData.players.now.."\n"
end
if (jsonData.players.sample ~= nil and jsonData.players.sample ~= false) then
responseText = responseText.." Players: "..table.concat(jsonData.players.sample, ", ").."\n"
end
end
if (jsonData.favicon ~= nil and false) then
--send_photo(receiver, jsonData.favicon) --(decode base64 and send)
end
return responseText
end
local function parseText(chat, text)
if (text == nil or text == "!mine") then
return usage
end
ip, port = string.match(text, "^!mine (.-) (.*)$")
if (ip ~= nil and port ~= nil) then
return mineSearch(ip, port, chat)
end
local ip = string.match(text, "^!mine (.*)$")
if (ip ~= nil) then
return mineSearch(ip, "25565", chat)
end
return "ERROR: no input ip?"
end
local function run(msg, matches)
local chat_id = tostring(msg.to.id)
local result = parseText(chat_id, msg.text)
return result
end
return {
description = "Searches Minecraft server and sends info",
usage = usage,
patterns = {
"^!mine (.*)$"
},
run = run
} | gpl-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.