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
TheOnePharaoh/YGOPro-Custom-Cards
script/c70649904.lua
2
2647
--ADE Garuda function c70649904.initial_effect(c) --destroy local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(70649904,0)) e1:SetCategory(CATEGORY_DESTROY) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetTarget(c70649904.destg) e1:SetOperation(c70649904.desop) c:RegisterEffect(e1) --atk local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_CANNOT_ATTACK) e2:SetCondition(c70649904.atkcon) c:RegisterEffect(e2) --destroy2 local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(70649904,1)) e3:SetType(EFFECT_TYPE_TRIGGER_O+EFFECT_TYPE_SINGLE) e3:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP) e3:SetCategory(CATEGORY_DESTROY) e3:SetCode(EVENT_TO_GRAVE) e3:SetCondition(c70649904.descon2) e3:SetTarget(c70649904.destg2) e3:SetOperation(c70649904.desop2) c:RegisterEffect(e3) end function c70649904.filter(c) return c:IsFaceup() and c:IsDestructable() end function c70649904.destg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c70649904.filter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,nil) end local g=Duel.GetMatchingGroup(c70649904.filter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0) end function c70649904.desop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectMatchingCard(tp,c70649904.filter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,nil) if g:GetCount()>0 then Duel.HintSelection(g) Duel.Destroy(g,REASON_EFFECT) end end function c70649904.filter2(c) return c:IsSetCard(0xd0a214) and not c:IsCode(70649904) and c:IsFaceup() end function c70649904.atkcon(e,tp,eg,ep,ev,re,r,rp) local tp=e:GetHandlerPlayer() return not Duel.IsExistingMatchingCard(c70649904.filter2,tp,LOCATION_MZONE,0,1,e:GetHandler()) end function c70649904.descon2(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsReason(REASON_EFFECT) and e:GetHandler():IsReason(REASON_DESTROY) end function c70649904.destg2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c70649904.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end local g=Duel.GetMatchingGroup(c70649904.filter,tp,LOCATION_MZONE,LOCATION_MZONE,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0) end function c70649904.desop2(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectMatchingCard(tp,c70649904.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil) if g:GetCount()>0 then Duel.HintSelection(g) Duel.Destroy(g,REASON_EFFECT) end end
gpl-3.0
waytim/darkstar
scripts/globals/spells/absorb-int.lua
17
1359
-------------------------------------- -- Spell: Absorb-INT -- Steals an enemy's intelligence. -------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------------- -- OnSpellCast ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) if (target:hasStatusEffect(EFFECT_INT_DOWN) or caster:hasStatusEffect(EFFECT_INT_BOOST)) then spell:setMsg(75); -- no effect else local dINT = caster:getStat(MOD_INT) - target:getStat(MOD_INT); local resist = applyResistance(caster,spell,target,dINT,37,0); if (resist <= 0.125) then spell:setMsg(85); else spell:setMsg(333); caster:addStatusEffect(EFFECT_INT_BOOST,ABSORB_SPELL_AMOUNT*resist*((100+(caster:getMod(MOD_AUGMENTS_ABSORB)))/100), ABSORB_SPELL_TICK, ABSORB_SPELL_AMOUNT*ABSORB_SPELL_TICK,FLAG_DISPELABLE); -- caster gains INT target:addStatusEffect(EFFECT_INT_DOWN,ABSORB_SPELL_AMOUNT*resist*((100+(caster:getMod(MOD_AUGMENTS_ABSORB)))/100), ABSORB_SPELL_TICK, ABSORB_SPELL_AMOUNT*ABSORB_SPELL_TICK,FLAG_ERASBLE); -- target loses INT end end return EFFECT_INT_DOWN; end;
gpl-3.0
waytim/darkstar
scripts/zones/La_Theine_Plateau/npcs/Equesobillot.lua
13
2518
----------------------------------- -- Area: La Theine Plateau -- NPC: Equesobillot -- Involved in Mission: The Rescue Drill -- @pos -287 9 284 102 ----------------------------------- package.loaded["scripts/zones/La_Theine_Plateau/TextIDs"] = nil; ----------------------------------- require("scripts/globals/missions"); require("scripts/zones/La_Theine_Plateau/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:getCurrentMission(SANDORIA) == THE_RESCUE_DRILL) then local MissionStatus = player:getVar("MissionStatus"); if (MissionStatus == 2) then player:startEvent(0x0065); elseif (MissionStatus == 3) then player:showText(npc, RESCUE_DRILL + 3); elseif (MissionStatus == 8) then if (player:getVar("theRescueDrillRandomNPC") == 2) then player:startEvent(0x0070); else player:showText(npc, RESCUE_DRILL + 21); end elseif (MissionStatus == 9) then if (player:getVar("theRescueDrillRandomNPC") == 2) then player:showText(npc, RESCUE_DRILL + 25); else player:showText(npc, RESCUE_DRILL + 26); end elseif (MissionStatus >= 10) then player:showText(npc, RESCUE_DRILL + 30); else player:showText(npc, RESCUE_DRILL); end else player:showText(npc, RESCUE_DRILL); 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 (csid == 0x0065) then player:setVar("MissionStatus",3); elseif (csid == 0x0070) then if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,16535); -- Bronze Sword else player:addItem(16535); player:messageSpecial(ITEM_OBTAINED, 16535); -- Bronze Sword player:setVar("MissionStatus",9); end end end;
gpl-3.0
waytim/darkstar
scripts/zones/Windurst_Waters/npcs/Dagoza-Beruza.lua
13
1055
----------------------------------- -- Area: Windurst Waters -- NPC: Dagoza-Beruza -- Type: Mission NPC -- @zone: 238 -- @pos -54.523 -6 229.271 -- -- Auto-Script: Requires Verification (Verfied By Brawndo) ----------------------------------- package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x0068); 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
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/globals/weaponskills/sonic_thrust.lua
4
1128
----------------------------------- -- Sonic Thrust -- Polearm weapon skill -- Skill Level: 300 -- Delivers an area attack. Damage varies with TP. -- Will stack with Sneak Attack. -- Element: None -- Modifiers: STR:30% ; DEX:30% -- 100%TP 200%TP 300%TP -- 3.00 3.25 3.50 ----------------------------------- require("scripts/globals/status"); require("scripts/globals/settings"); require("scripts/globals/weaponskills"); ----------------------------------- function OnUseWeaponSkill(player, target, wsID) local params = {}; params.numHits = 1; params.ftp100 = 3; params.ftp200 = 3.25; params.ftp300 = 3.5; params.str_wsc = 0.3; params.dex_wsc = 0.3; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0; params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0; params.canCrit = false; params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0; params.atkmulti = 1; local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, params); return tpHits, extraHits, criticalHit, damage; end
gpl-3.0
TheOnePharaoh/YGOPro-Custom-Cards
script/c99930160.lua
1
3794
--OTNN - Tail Gear Change function c99930160.initial_effect(c) c:SetUniqueOnField(1,0,99930160) --Activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e1) --Xyz SUmmon local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(99930160,0)) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetCode(EVENT_FREE_CHAIN) e2:SetRange(LOCATION_SZONE) e2:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP) e2:SetHintTiming(TIMING_DAMAGE_STEP) e2:SetCountLimit(1) e2:SetTarget(c99930160.sptg) e2:SetOperation(c99930160.spop) c:RegisterEffect(e2) --To Deck local e3=Effect.CreateEffect(c) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP) e3:SetCode(EVENT_TO_GRAVE) e3:SetCondition(c99930160.tdcon) e3:SetTarget(c99930160.tdtg) e3:SetOperation(c99930160.tdop) c:RegisterEffect(e3) end function c99930160.filter1(c,e,tp) return c:IsFaceup() and c:IsType(TYPE_XYZ) and c:IsSetCard(0x993) and Duel.IsExistingMatchingCard(c99930160.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,c,c:GetCode()) end function c99930160.filter2(c,e,tp,mc,code) return c:IsType(TYPE_XYZ) and c:IsSetCard(0x993) and not c:IsCode(code) and mc:IsCanBeXyzMaterial(c) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_XYZ,tp,false,false) end function c99930160.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and c99930160.filter1(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>-1 and Duel.IsExistingTarget(c99930160.filter1,tp,LOCATION_MZONE,0,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET) Duel.SelectTarget(tp,c99930160.filter1,tp,LOCATION_MZONE,0,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function c99930160.spop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<0 then return end local tc=Duel.GetFirstTarget() if tc:IsFacedown() or not tc:IsRelateToEffect(e) or tc:IsControler(1-tp) or tc:IsImmuneToEffect(e) then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c99930160.filter2,tp,LOCATION_EXTRA,0,1,1,nil,e,tp,tc,tc:GetCode()) local sc=g:GetFirst() if sc then local mg=tc:GetOverlayGroup() if mg:GetCount()~=0 then Duel.Overlay(sc,mg) end sc:SetMaterial(Group.FromCards(tc)) Duel.Overlay(sc,Group.FromCards(tc)) Duel.SpecialSummon(sc,SUMMON_TYPE_XYZ,tp,tp,false,false,POS_FACEUP) sc:CompleteProcedure() local ct=sc:GetOverlayCount() if not sc:IsFaceup() or not sc:IsRelateToEffect(e) and ct<0 then return end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_RANK) e1:SetValue(ct) e1:SetReset(RESET_EVENT+0x1fe0000) sc:RegisterEffect(e1) end end function c99930160.tdcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsReason(REASON_DESTROY) end function c99930160.tdfilter(c) return c:IsType(TYPE_MONSTER) and c:IsSetCard(0x993) and c:IsType(TYPE_XYZ) and c:IsAbleToDeck() end function c99930160.tdtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end local g=Duel.GetMatchingGroup(c99930160.tdfilter,tp,LOCATION_GRAVE,0,nil) Duel.SetOperationInfo(0,CATEGORY_TODECK,g,g:GetCount(),0,0) e:SetLabel(g:GetCount()) end function c99930160.tdop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local ct=e:GetLabel() local g=Duel.GetMatchingGroup(c99930160.tdfilter,tp,LOCATION_GRAVE,0,nil) if g:GetCount()>0 and Duel.SendtoDeck(g,nil,2,REASON_EFFECT)~=0 then Duel.Draw(tp,ct,REASON_EFFECT) end end
gpl-3.0
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/globals/weaponskills/bora_axe.lua
4
1490
----------------------------------- -- Bora Axe -- Axe weapon skill -- Skill level: 290 -- Delivers a single-hit ranged attack at a maximum distance of 15.7'. Chance of binding varies with TP -- Bind doesn't always break from hitting mob. -- This Weapon Skill's first hit params.ftp is duplicated for all additional hits -- Not natively available to RNG -- Aligned with the ?? Gorget. -- Element: Ice -- Modifiers: DEX 60% --http://wiki.bluegartr.com/bg/Bora_Axe -- 100%TP 200%TP 300%TP -- 1.0 1.0 1.0 ----------------------------------- require("scripts/globals/status"); require("scripts/globals/settings"); require("scripts/globals/weaponskills"); ----------------------------------- function OnUseWeaponSkill(player, target, wsID) local params = {}; params.numHits = 1; params.ftp100 = 1.0; params.ftp200 = 1.0; params.ftp300 = 1.0; params.str_wsc = 0.0; params.dex_wsc = 0.6; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0; params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0; params.canCrit = false; params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0; params.atkmulti = 3.5; local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, params); if damage > 0 and (target:hasStatusEffect(EFFECT_BIND) == false) then target:addStatusEffect(EFFECT_BIND, 1, 0, 20); end return tpHits, extraHits, criticalHit, damage; end
gpl-3.0
waytim/darkstar
scripts/zones/Port_Windurst/npcs/Panja-Nanja.lua
53
1909
----------------------------------- -- Area: Port Windurst -- NPC: Panja-Nanja -- Type: Fishing Adv. Image Support -- @pos -194.499 -3 58.692 240 ----------------------------------- package.loaded["scripts/zones/Port_Windurst/TextIDs"] = nil; ----------------------------------- require("scripts/globals/status"); require("scripts/globals/crafting"); require("scripts/zones/Port_Windurst/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local guildMember = isGuildMember(player,8); local SkillLevel = player:getSkillLevel(SKILL_FISHING); local Cost = getAdvImageSupportCost(player,SKILL_FISHING); if (guildMember == 1) then if (player:hasStatusEffect(EFFECT_FISHING_IMAGERY) == false) then player:startEvent(0x271B,Cost,SkillLevel,0,239,player:getGil(),0,0,0); -- p1 = skill level else player:startEvent(0x271B,Cost,SkillLevel,0,239,player:getGil(),38586,30,0); end else player:startEvent(0x271B); -- Standard Dialogue, incorrect 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); local Cost = getAdvImageSupportCost(player,256); if (csid == 0x271B and option == 1) then player:delGil(Cost); player:messageSpecial(FISHING_SUPPORT,0,0,0); player:addStatusEffect(EFFECT_FISHING_IMAGERY,2,0,7200); end end;
gpl-3.0
lusiankaitz/koreader-master
frontend/apps/reader/modules/readerview.lua
1
24134
local AlphaContainer = require("ui/widget/container/alphacontainer") local ReaderFlipping = require("apps/reader/modules/readerflipping") local ReaderFooter = require("apps/reader/modules/readerfooter") local ReaderDogear = require("apps/reader/modules/readerdogear") local OverlapGroup = require("ui/widget/overlapgroup") local ImageWidget = require("ui/widget/imagewidget") local UIManager = require("ui/uimanager") local Screen = require("device").screen local Geom = require("ui/geometry") local Event = require("ui/event") local DEBUG = require("dbg") local Blitbuffer = require("ffi/blitbuffer") local _ = require("gettext") local ReaderView = OverlapGroup:new{ document = nil, -- single page state state = { page = nil, pos = 0, zoom = 1.0, rotation = 0, gamma = 1.0, offset = nil, bbox = nil, }, outer_page_color = Blitbuffer.gray(DOUTER_PAGE_COLOR/15), -- hightlight with "lighten" or "underscore" or "invert" highlight = { lighten_factor = 0.2, temp_drawer = "invert", temp = {}, saved_drawer = "lighten", saved = {}, }, highlight_visible = true, -- PDF/DjVu continuous paging page_scroll = nil, page_bgcolor = Blitbuffer.gray(DBACKGROUND_COLOR/15), page_states = {}, scroll_mode = "vertical", page_gap = { width = Screen:scaleBySize(8), height = Screen:scaleBySize(8), color = Blitbuffer.gray(0.5), }, -- DjVu page rendering mode (used in djvu.c:drawPage()) render_mode = DRENDER_MODE, -- default to COLOR -- Crengine view mode view_mode = DCREREADER_VIEW_MODE, -- default to page mode hinting = true, -- visible area within current viewing page visible_area = Geom:new{x = 0, y = 0}, -- dimen for current viewing page page_area = Geom:new{}, -- dimen for area to dim dim_area = nil, -- has footer footer_visible = nil, -- has dogear dogear_visible = false, -- in flipping state flipping_visible = false, -- auto save settings after turning pages auto_save_paging_count = 0, } function ReaderView:init() -- fix recalculate from close document pageno self.state.page = nil -- fix inherited dim_area for following opened documents self:resetDimArea() self:resetLayout() end function ReaderView:resetDimArea() self.dim_area = Geom:new{w = 0, h = 0} end function ReaderView:resetLayout() self.dogear = ReaderDogear:new{ view = self, ui = self.ui, } self.footer = ReaderFooter:new{ view = self, ui = self.ui, visible = self.footer_visible, } self.flipping = ReaderFlipping:new{ view = self, ui = self.ui, } self.arrow = AlphaContainer:new{ alpha = 0.6, ImageWidget:new{ file = "resources/icons/appbar.control.expand.png", } } self[1] = self.dogear self[2] = self.footer self[3] = self.flipping end function ReaderView:paintTo(bb, x, y) DEBUG("painting", self.visible_area, "to", x, y) if self.page_scroll then self:drawPageBackground(bb, x, y) else self:drawPageSurround(bb, x, y) end -- draw page content if self.ui.document.info.has_pages then if self.page_scroll then self:drawScrollPages(bb, x, y) else self:drawSinglePage(bb, x, y) end else if self.view_mode == "page" then self:drawPageView(bb, x, y) elseif self.view_mode == "scroll" then self:drawScrollView(bb, x, y) end end -- dim last read area if self.dim_area.w ~= 0 and self.dim_area.h ~= 0 then --DEBUG("dim area", self.dim_area) if self.page_overlap_style == "dim" then bb:dimRect( self.dim_area.x, self.dim_area.y, self.dim_area.w, self.dim_area.h ) elseif self.page_overlap_style == "arrow" then self.arrow:paintTo(bb, 0, self.dim_area.h) end end -- draw saved highlight if self.highlight_visible then self:drawSavedHighlight(bb, x, y) end -- draw temporary highlight if self.highlight.temp then self:drawTempHighlight(bb, x, y) end -- paint dogear if self.dogear_visible then self.dogear:paintTo(bb, x, y) end -- paint footer if self.footer_visible then self.footer:paintTo(bb, x, y) end -- paint flipping if self.flipping_visible then self.flipping:paintTo(bb, x, y) end -- stop activity indicator self.ui:handleEvent(Event:new("StopActivityIndicator")) end --[[ Given coordinates on the screen return position in original page ]]-- function ReaderView:screenToPageTransform(pos) if self.ui.document.info.has_pages then if self.page_scroll then return self:getScrollPagePosition(pos) else return self:getSinglePagePosition(pos) end else pos.page = self.ui.document:getCurrentPage() local last_y = self.ui.document:getCurrentPos() DEBUG("document has no pages at", pos) return pos end end --[[ Given rectangle in original page return rectangle on the screen ]]-- function ReaderView:pageToScreenTransform(page, rect) if self.ui.document.info.has_pages then if self.page_scroll then return self:getScrollPageRect(page, rect) else return self:getSinglePageRect(rect) end else return rect end end --[[ Get page area on screen for a given page number --]] function ReaderView:getScreenPageArea(page) if self.ui.document.info.has_pages then local area = Geom:new{x = 0, y = 0} if self.page_scroll then for _, state in ipairs(self.page_states) do if page ~= state.page then area.y = area.y + state.visible_area.h + state.offset.y area.y = area.y + self.page_gap.height else area.x = state.offset.x area.w = state.visible_area.w area.h = state.visible_area.h return area end end else area.x = self.state.offset.x area.y = self.state.offset.y area.w = self.visible_area.w area.h = self.visible_area.h return area end else return self.dimen end end function ReaderView:drawPageBackground(bb, x, y) bb:paintRect(x, y, self.dimen.w, self.dimen.h, self.page_bgcolor) end function ReaderView:drawPageSurround(bb, x, y) if self.dimen.h > self.visible_area.h then bb:paintRect(x, y, self.dimen.w, self.state.offset.y, self.outer_page_color) bb:paintRect(x, y + self.dimen.h - self.state.offset.y - 1, self.dimen.w, self.state.offset.y + 1, self.outer_page_color) end if self.dimen.w > self.visible_area.w then bb:paintRect(x, y, self.state.offset.x, self.dimen.h, self.outer_page_color) bb:paintRect(x + self.dimen.w - self.state.offset.x - 1, y, self.state.offset.x + 1, self.dimen.h, self.outer_page_color) end end function ReaderView:drawScrollPages(bb, x, y) local pos = Geom:new{x = x , y = y} for page, state in ipairs(self.page_states) do self.ui.document:drawPage( bb, pos.x + state.offset.x, pos.y + state.offset.y, state.visible_area, state.page, state.zoom, state.rotation, state.gamma, self.render_mode) pos.y = pos.y + state.visible_area.h -- draw page gap if not the last part if page ~= #self.page_states then self:drawPageGap(bb, pos.x, pos.y) pos.y = pos.y + self.page_gap.height end end UIManager:scheduleIn(0, function() self.ui:handleEvent(Event:new("HintPage", self.hinting)) end) end function ReaderView:getCurrentPageList() local pages = {} if self.ui.document.info.has_pages then if self.page_scroll then for _, state in ipairs(self.page_states) do table.insert(pages, state.page) end else table.insert(pages, self.state.page) end end return pages end function ReaderView:getScrollPagePosition(pos) local x_s, y_s = pos.x, pos.y local x_p, y_p = nil, nil for _, state in ipairs(self.page_states) do if y_s < state.visible_area.h + state.offset.y then y_p = (state.visible_area.y + y_s - state.offset.y) / state.zoom x_p = (state.visible_area.x + x_s - state.offset.x) / state.zoom return { x = x_p, y = y_p, page = state.page, zoom = state.zoom, rotation = state.rotation, } else y_s = y_s - state.visible_area.h - self.page_gap.height end end end function ReaderView:getScrollPageRect(page, rect_p) local rect_s = Geom:new{} for _, state in ipairs(self.page_states) do local trans_p = Geom:new(rect_p):copy() trans_p:transformByScale(state.zoom, state.zoom) if page == state.page and state.visible_area:intersectWith(trans_p) then rect_s.x = rect_s.x + state.offset.x + trans_p.x - state.visible_area.x rect_s.y = rect_s.y + state.offset.y + trans_p.y - state.visible_area.y rect_s.w = trans_p.w rect_s.h = trans_p.h return rect_s end rect_s.y = rect_s.y + state.visible_area.h + self.page_gap.height end end function ReaderView:drawPageGap(bb, x, y) if self.scroll_mode == "vertical" then bb:paintRect(x, y, self.dimen.w, self.page_gap.height, self.page_gap.color) elseif self.scroll_mode == "horizontal" then bb:paintRect(x, y, self.page_gap.width, self.dimen.h, self.page_gap.color) end end function ReaderView:drawSinglePage(bb, x, y) self.ui.document:drawPage( bb, x + self.state.offset.x, y + self.state.offset.y, self.visible_area, self.state.page, self.state.zoom, self.state.rotation, self.state.gamma, self.render_mode) UIManager:scheduleIn(0, function() self.ui:handleEvent(Event:new("HintPage", self.hinting)) end) end function ReaderView:getSinglePagePosition(pos) local x_s, y_s = pos.x, pos.y return { x = (self.visible_area.x + x_s - self.state.offset.x) / self.state.zoom, y = (self.visible_area.y + y_s - self.state.offset.y) / self.state.zoom, page = self.state.page, zoom = self.state.zoom, rotation = self.state.rotation, } end function ReaderView:getSinglePageRect(rect_p) local rect_s = Geom:new{} local trans_p = Geom:new(rect_p):copy() trans_p:transformByScale(self.state.zoom, self.state.zoom) if self.visible_area:intersectWith(trans_p) then rect_s.x = self.state.offset.x + trans_p.x - self.visible_area.x rect_s.y = self.state.offset.y + trans_p.y - self.visible_area.y rect_s.w = trans_p.w rect_s.h = trans_p.h return rect_s end end function ReaderView:drawPageView(bb, x, y) self.ui.document:drawCurrentViewByPage( bb, x + self.state.offset.x, y + self.state.offset.y, self.visible_area, self.state.page) end function ReaderView:drawScrollView(bb, x, y) self.ui.document:drawCurrentViewByPos( bb, x + self.state.offset.x, y + self.state.offset.y, self.visible_area, self.state.pos) end function ReaderView:drawTempHighlight(bb, x, y) for page, boxes in pairs(self.highlight.temp) do for i = 1, #boxes do local rect = self:pageToScreenTransform(page, boxes[i]) if rect then self:drawHighlightRect(bb, x, y, rect, self.highlight.temp_drawer) end end end end function ReaderView:drawSavedHighlight(bb, x, y) if self.ui.document.info.has_pages then self:drawPageSavedHighlight(bb, x, y) else self:drawXPointerSavedHighlight(bb, x, y) end end function ReaderView:drawPageSavedHighlight(bb, x, y) local pages = self:getCurrentPageList() for _, page in pairs(pages) do local items = self.highlight.saved[page] if not items then items = {} end for i = 1, #items do local item = items[i] local pos0, pos1 = item.pos0, item.pos1 local boxes = self.ui.document:getPageBoxesFromPositions(page, pos0, pos1) if boxes then for _, box in pairs(boxes) do local rect = self:pageToScreenTransform(page, box) if rect then self:drawHighlightRect(bb, x, y, rect, item.drawer or self.highlight.saved_drawer) end end -- end for each box end -- end if boxes end -- end for each highlight end -- end for each page end function ReaderView:drawXPointerSavedHighlight(bb, x, y) for page, _ in pairs(self.highlight.saved) do local items = self.highlight.saved[page] if not items then items = {} end for j = 1, #items do local item = items[j] local pos0, pos1 = item.pos0, item.pos1 local boxes = self.ui.document:getScreenBoxesFromPositions(pos0, pos1) if boxes then for _, box in pairs(boxes) do local rect = self:pageToScreenTransform(page, box) if rect then self:drawHighlightRect(bb, x, y, rect, item.drawer or self.highlight.saved_drawer) end end -- end for each box end -- end if boxes end -- end for each highlight end -- end for all saved highlight end function ReaderView:drawHighlightRect(bb, x, y, rect, drawer) local x, y, w, h = rect.x, rect.y, rect.w, rect.h if drawer == "underscore" then self.highlight.line_width = self.highlight.line_width or 2 self.highlight.line_color = self.highlight.line_color or Blitbuffer.gray(0.33) bb:paintRect(x, y+h-1, w, self.highlight.line_width, self.highlight.line_color) elseif drawer == "lighten" then bb:lightenRect(x, y, w, h, self.highlight.lighten_factor) elseif drawer == "invert" then bb:invertRect(x, y, w, h) end end function ReaderView:getPageArea(page, zoom, rotation) if self.use_bbox then return self.ui.document:getUsedBBoxDimensions(page, zoom, rotation) else return self.ui.document:getPageDimensions(page, zoom, rotation) end end --[[ This method is supposed to be only used by ReaderPaging --]] function ReaderView:recalculate() local page_size = nil if self.ui.document.info.has_pages and self.state.page then self.page_area = self:getPageArea( self.state.page, self.state.zoom, self.state.rotation) -- reset our size self.visible_area:setSizeTo(self.dimen) if self.ui.document.configurable.writing_direction == 0 then -- starts from left top of page_area self.visible_area.x = self.page_area.x self.visible_area.y = self.page_area.y else -- start from right top of page_area self.visible_area.x = self.page_area.x + self.page_area.w - self.visible_area.w self.visible_area.y = self.page_area.y end -- and recalculate it according to page size self.visible_area:offsetWithin(self.page_area, 0, 0) -- clear dim area self.dim_area.w = 0 self.dim_area.h = 0 self.ui:handleEvent( Event:new("ViewRecalculate", self.visible_area, self.page_area)) else self.visible_area:setSizeTo(self.dimen) end self.state.offset = Geom:new{x = 0, y = 0} if self.dimen.h > self.visible_area.h then self.state.offset.y = (self.dimen.h - self.visible_area.h) / 2 end if self.dimen.w > self.visible_area.w then self.state.offset.x = (self.dimen.w - self.visible_area.w) / 2 end -- flag a repaint so self:paintTo will be called UIManager:setDirty(self.dialog, "partial") end function ReaderView:PanningUpdate(dx, dy) DEBUG("pan by", dx, dy) local old = self.visible_area:copy() self.visible_area:offsetWithin(self.page_area, dx, dy) if self.visible_area ~= old then -- flag a repaint UIManager:setDirty(self.dialog, "partial") DEBUG("on pan: page_area", self.page_area) DEBUG("on pan: visible_area", self.visible_area) self.ui:handleEvent( Event:new("ViewRecalculate", self.visible_area, self.page_area)) end return true end function ReaderView:PanningStart(x, y) DEBUG("panning start", x, y) if not self.panning_visible_area then self.panning_visible_area = self.visible_area:copy() end self.visible_area = self.panning_visible_area:copy() self.visible_area:offsetWithin(self.page_area, x, y) self.ui:handleEvent(Event:new("ViewRecalculate", self.visible_area, self.page_area)) UIManager:setDirty(self.dialog, "partial") end function ReaderView:PanningStop() self.panning_visible_area = nil end function ReaderView:SetZoomCenter(x, y) local old = self.visible_area:copy() self.visible_area:centerWithin(self.page_area, x, y) if self.visible_area ~= old then self.ui:handleEvent(Event:new("ViewRecalculate", self.visible_area, self.page_area)) UIManager:setDirty(self.dialog, "partial") end end function ReaderView:onSetScreenMode(new_mode, rotation) if new_mode == "landscape" or new_mode == "portrait" then self.screen_mode = new_mode if rotation ~= nil then Screen:setRotationMode(rotation) else Screen:setScreenMode(new_mode) end UIManager:setDirty(self.dialog, "full") self.ui:handleEvent(Event:new("SetDimensions", Screen:getSize())) self.ui:handleEvent(Event:new("InitScrollPageStates")) end self.cur_rotation_mode = Screen.cur_rotation_mode return true end function ReaderView:onSetDimensions(dimensions) self:resetLayout() self.dimen = dimensions -- recalculate view self:recalculate() end function ReaderView:onRestoreDimensions(dimensions) --DEBUG("restore dimen", dimensions) self:resetLayout() self.dimen = dimensions -- recalculate view self:recalculate() end function ReaderView:onSetFullScreen(full_screen) self.footer_visible = not full_screen self.ui:handleEvent(Event:new("SetDimensions", Screen:getSize())) end function ReaderView:onToggleScrollMode(page_scroll) self.page_scroll = page_scroll self:recalculate() self.ui:handleEvent(Event:new("InitScrollPageStates")) end function ReaderView:onReadSettings(config) local screen_mode self.render_mode = config:readSetting("render_mode") or 0 if self.ui.document.info.has_pages then screen_mode = config:readSetting("screen_mode") or G_reader_settings:readSetting("kopt_screen_mode") or "portrait" else screen_mode = config:readSetting("screen_mode") or G_reader_settings:readSetting("copt_screen_mode") or "portrait" end if screen_mode then Screen:setScreenMode(screen_mode) self:onSetScreenMode(screen_mode, config:readSetting("rotation_mode")) end self.state.gamma = config:readSetting("gamma") or DGLOBALGAMMA local full_screen = config:readSetting("kopt_full_screen") or self.document.configurable.full_screen local status_line = config:readSetting("copt_status_line") or self.document.configurable.status_line self.footer_visible = (full_screen == 0 or status_line == 1) and true or false self:resetLayout() local page_scroll = config:readSetting("kopt_page_scroll") or self.document.configurable.page_scroll self.page_scroll = page_scroll == 1 and true or false self.highlight.saved = config:readSetting("highlight") or {} self.page_overlap_style = config:readSetting("page_overlap_style") or "dim" end function ReaderView:onPageUpdate(new_page_no) self.state.page = new_page_no self:recalculate() self.highlight.temp = {} self:autoSaveSettings() end function ReaderView:onPosUpdate(new_pos) self.state.pos = new_pos self:recalculate() self.highlight.temp = {} self:autoSaveSettings() end function ReaderView:onZoomUpdate(zoom) self.state.zoom = zoom self:recalculate() self.highlight.temp = {} end function ReaderView:onBBoxUpdate(bbox) self.use_bbox = bbox and true or false end function ReaderView:onRotationUpdate(rotation) self.state.rotation = rotation self:recalculate() end function ReaderView:onGammaUpdate(gamma) self.state.gamma = gamma if self.page_scroll then self.ui:handleEvent(Event:new("UpdateScrollPageGamma", gamma)) end end function ReaderView:onFontSizeUpdate() self.ui:handleEvent(Event:new("ReZoom")) end function ReaderView:onDefectSizeUpdate() self.ui:handleEvent(Event:new("ReZoom")) end function ReaderView:onPageCrop() self.ui:handleEvent(Event:new("ReZoom")) end function ReaderView:onMarginUpdate() self.ui:handleEvent(Event:new("ReZoom")) end function ReaderView:onSetViewMode(new_mode) self.view_mode = new_mode self.ui.document:setViewMode(new_mode) self.ui:handleEvent(Event:new("ChangeViewMode")) return true end function ReaderView:onSaveSettings() self.ui.doc_settings:saveSetting("render_mode", self.render_mode) self.ui.doc_settings:saveSetting("screen_mode", self.screen_mode) self.ui.doc_settings:saveSetting("rotation_mode", self.cur_rotation_mode) self.ui.doc_settings:saveSetting("gamma", self.state.gamma) self.ui.doc_settings:saveSetting("highlight", self.highlight.saved) self.ui.doc_settings:saveSetting("page_overlap_style", self.page_overlap_style) end function ReaderView:autoSaveSettings() if DAUTO_SAVE_PAGING_COUNT then if self.auto_save_paging_count == DAUTO_SAVE_PAGING_COUNT then self.ui:saveSettings() self.auto_save_paging_count = 0 else self.auto_save_paging_count = self.auto_save_paging_count + 1 end end end function ReaderView:getRenderModeMenuTable() local view = self local function make_mode(text, mode) return { text = text, checked_func = function() return view.render_mode == mode end, callback = function() view.render_mode = mode end, } end return { text = _("DjVu render mode"), sub_item_table = { make_mode(_("COLOUR (works for both colour and b&w pages)"), 0), make_mode(_("BLACK & WHITE (for b&w pages only, much faster)"), 1), make_mode(_("COLOUR ONLY (slightly faster than COLOUR)"), 2), make_mode(_("MASK ONLY (for b&w pages only)"), 3), make_mode(_("COLOUR BACKGROUND (show only background)"), 4), make_mode(_("COLOUR FOREGROUND (show only foreground)"), 5), } } end local page_overlap_styles = { arrow = _("Arrow"), dim = _("Gray out"), } function ReaderView:genOverlapStyleMenu() local view = self local get_overlap_style = function(style) return { text = page_overlap_styles[style], checked_func = function() return view.page_overlap_style == style end, callback = function() view.page_overlap_style = style end } end return { get_overlap_style("arrow"), get_overlap_style("dim"), } end return ReaderView
agpl-3.0
waytim/darkstar
scripts/zones/Aht_Urhgan_Whitegate/npcs/Ekhu_Pesshyadha.lua
13
1836
----------------------------------- -- Area: Aht Urhgan Whitegate -- NPC: Ekhu Pesshyadha -- Type: Standard NPC -- @pos -13.043 0.999 103.423 50 ----------------------------------- package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/quests"); require("scripts/globals/keyitems"); require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local gotItAllProg = player:getVar("gotitallCS"); if (gotItAllProg == 1) then player:startEvent(0x0219); elseif (gotItAllProg == 2) then player:startEvent(0x0218); elseif (gotItAllProg == 3) then player:startEvent(0x020c); elseif (player:getQuestStatus(AHT_URHGAN,GOT_IT_ALL) == QUEST_COMPLETED) then player:startEvent(0x0213); else player:startEvent(0x0214); 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 == 0x0219) then player:setVar("gotitallCS",2); elseif (csid == 0x020c) then player:addKeyItem(VIAL_OF_LUMINOUS_WATER); player:messageSpecial(KEYITEM_OBTAINED,VIAL_OF_LUMINOUS_WATER); player:setVar("gotitallCS",4); end end;
gpl-3.0
aug2uag/ESPbootloader
init.lua
3
1093
-- Copyright (c) 2015 Sebastian Hodapp -- https://github.com/sebastianhodapp/ESPbootloader -- Improved by Simonarde Jr. -- https://github.com/simonardejr/ESPbootloader -- Change ssid and password of AP in configuration mode ssid = "ESP" ..node.chipid() psw = "espconfig" -- If GPIO0 changes during the countdown, launch config gpio.mode(3, gpio.INT) gpio.trig(3,"both",function() tmr.stop(0) dofile("run_config.lua") end) local countdown = 5 tmr.alarm(1, 5000, 1, function() if wifi.sta.getip() == nil then print("IP unavailable, waiting.") else tmr.stop(1) print("Connected, IP is "..wifi.sta.getip()) dofile("run_program.lua") end end) tmr.alarm(0,1000,1,function() print(countdown) countdown = countdown -1 if (countdown == 0) then gpio.mode(3,gpio.FLOAT) tmr.stop(0) if pcall(function () dofile("config.lc") end) then dofile("run_program.lua") else print("Enter configuration mode") dofile("run_config.lua") end end end)
mit
TheOnePharaoh/YGOPro-Custom-Cards
script/c99950081.lua
2
8234
--MSMM - Tomoe Mami function c99950081.initial_effect(c) c:EnableReviveLimit() --Spell Zone local e1=Effect.CreateEffect(c) e1:SetCode(EFFECT_SEND_REPLACE) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE+EFFECT_FLAG_UNCOPYABLE) e1:SetRange(LOCATION_MZONE) e1:SetTarget(c99950081.sztg) e1:SetOperation(c99950081.szop) c:RegisterEffect(e1) --Pay local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e2:SetCode(EVENT_PHASE+PHASE_STANDBY) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1) e2:SetCondition(c99950081.paycon) e2:SetOperation(c99950081.payop) c:RegisterEffect(e2) --ATK up local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e3:SetRange(LOCATION_MZONE) e3:SetCode(EFFECT_UPDATE_ATTACK) e3:SetValue(c99950081.value) c:RegisterEffect(e3) --Direct/Draw local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(99950081,2)) e4:SetType(EFFECT_TYPE_IGNITION) e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e4:SetCountLimit(1) e4:SetRange(LOCATION_MZONE) e4:SetCost(c99950081.dircost) e4:SetTarget(c99950081.dirtg) e4:SetOperation(c99950081.dirop) c:RegisterEffect(e4) --To hand local e5=Effect.CreateEffect(c) e5:SetDescription(aux.Stringid(99950081,3)) e5:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e5:SetType(EFFECT_TYPE_IGNITION) e5:SetRange(LOCATION_HAND) e5:SetCost(c99950081.thcost) e5:SetTarget(c99950081.thtg) e5:SetOperation(c99950081.thop) c:RegisterEffect(e5) --Cannot Special Summon local e6=Effect.CreateEffect(c) e6:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e6:SetType(EFFECT_TYPE_SINGLE) e6:SetCode(EFFECT_SPSUMMON_CONDITION) e6:SetValue(c99950081.splimit) c:RegisterEffect(e6) --Banish local e7=Effect.CreateEffect(c) e7:SetCategory(CATEGORY_REMOVE) e7:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e7:SetCode(EVENT_TO_GRAVE) e7:SetCondition(c99950081.bancon) e7:SetTarget(c99950081.bantg) e7:SetOperation(c99950081.banop) c:RegisterEffect(e7) end function c99950081.splimit(e,se,sp,st) return se:GetHandler():IsSetCard(9995) end function c99950081.sztg(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return c:GetDestination()==LOCATION_GRAVE and c:IsReason(REASON_DESTROY) end if Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 then return false end return Duel.SelectYesNo(tp,aux.Stringid(99950081,0)) end function c99950081.szop(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() Duel.MoveToField(c,tp,tp,LOCATION_SZONE,POS_FACEUP,true) --Spell local e1=Effect.CreateEffect(c) e1:SetCode(EFFECT_CHANGE_TYPE) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetReset(RESET_EVENT+0x1fc0000) e1:SetValue(TYPE_SPELL+TYPE_CONTINUOUS) c:RegisterEffect(e1) --Discard local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F) e2:SetCode(EVENT_PHASE+PHASE_STANDBY) e2:SetRange(LOCATION_SZONE) e2:SetCountLimit(1) e2:SetCondition(c99950081.discon) e2:SetTarget(c99950081.distg) e2:SetOperation(c99950081.disop) e2:SetReset(RESET_EVENT+0x1fe0000) c:RegisterEffect(e2) Duel.RaiseEvent(c,99950280,e,0,tp,0,0) end function c99950081.discon(e,tp,eg,ep,ev,re,r,rp) return Duel.GetTurnPlayer()==tp and Duel.GetFieldGroupCount(e:GetHandlerPlayer(),0,LOCATION_HAND)>0 end function c99950081.distg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetFieldGroupCount(tp,0,LOCATION_HAND)>0 end Duel.SetTargetPlayer(tp) Duel.SetOperationInfo(0,CATEGORY_TODECK,nil,0,1-tp,LOCATION_HAND) end function c99950081.disop(e,tp,eg,ep,ev,re,r,rp) local p=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER) local g=Duel.GetFieldGroup(p,0,LOCATION_HAND) if g:GetCount()>0 then Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(99950081,4)) local sg=g:Select(p,1,1,nil) Duel.ConfirmCards(tp,sg) local tc=sg:GetFirst() if tc:IsType(TYPE_MONSTER) then Duel.Remove(tc,POS_FACEUP,REASON_EFFECT+REASON_DISCARD) Duel.ShuffleHand(1-tp) else Duel.ShuffleHand(1-tp) end end end function c99950081.paycon(e,tp,eg,ep,ev,re,r,rp) return Duel.GetTurnPlayer()==tp end function c99950081.payop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLP(tp)>300 and Duel.SelectYesNo(tp,aux.Stringid(99950081,1)) then Duel.PayLPCost(tp,300) else Duel.Destroy(e:GetHandler(),REASON_EFFECT) end end function c99950081.dirfilter(c) return c:IsFaceup() and c:IsSetCard(9995) and c:IsType(TYPE_MONSTER) and not c:IsHasEffect(EFFECT_DIRECT_ATTACK) end function c99950081.dircost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(Card.IsDiscardable,tp,LOCATION_HAND,0,1,e:GetHandler()) end Duel.DiscardHand(tp,Card.IsDiscardable,1,1,REASON_COST+REASON_DISCARD) end function c99950081.dirtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c99950081.dirfilter,tp,LOCATION_MZONE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(99950081,5)) Duel.SelectTarget(tp,c99950081.dirfilter,tp,LOCATION_MZONE,0,1,1,nil) end function c99950081.dirop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_DIRECT_ATTACK) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) tc:RegisterEffect(e1) local e2=Effect.CreateEffect(e:GetHandler()) e2:SetCategory(CATEGORY_DRAW) e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e2:SetCode(EVENT_BATTLE_DAMAGE) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e2:SetCondition(c99950081.drcon) e2:SetTarget(c99950081.drtg) e2:SetOperation(c99950081.drop) e2:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) tc:RegisterEffect(e2) end end function c99950081.drcon(e,tp,eg,ep,ev,re,r,rp) return ep~=tp and Duel.GetAttackTarget()==nil end function c99950081.drtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,1) end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(1) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function c99950081.drop(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Draw(p,d,REASON_EFFECT) end function c99950081.thfilter(c) return c:GetCode()==99950000 and c:IsAbleToHand() end function c99950081.thcost(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return c:IsAbleToGraveAsCost() and c:IsDiscardable() end Duel.SendtoGrave(c,REASON_COST+REASON_DISCARD) end function c99950081.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chk==0 then return Duel.IsExistingMatchingCard(c99950081.thfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function c99950081.thop(e,tp,eg,ep,ev,re,r,rp,chk) local tg=Duel.GetFirstMatchingCard(c99950081.thfilter,tp,LOCATION_DECK,0,nil) if tg then Duel.SendtoHand(tg,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,tg) end end function c99950081.banfilter(c) return c:IsFaceup() and c:IsAbleToRemove() end function c99950081.bancon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetPreviousLocation()==LOCATION_DECK and e:GetHandler():IsReason(REASON_EFFECT) end function c99950081.bantg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and c99950081.banfilter(chkc) end if chk==0 then return Duel.IsExistingTarget(c99950081.banfilter,tp,0,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectTarget(tp,c99950081.banfilter,tp,0,LOCATION_MZONE,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,1,0,0) end function c99950081.banop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) and tc:IsFaceup() then Duel.Remove(tc,POS_FACEUP,REASON_EFFECT) end end function c99950081.atkfilter(c) return c:IsFaceup() and c:IsType(TYPE_MONSTER) end function c99950081.value(e,c) return Duel.GetMatchingGroupCount(c99950081.atkfilter,c:GetControler(),0,LOCATION_REMOVED,nil)*100 end
gpl-3.0
TheOnePharaoh/YGOPro-Custom-Cards
script/c78330013.lua
2
4093
--AB King function c78330013.initial_effect(c) Duel.EnableGlobalFlag(GLOBALFLAG_DETACH_EVENT) --xyz summon aux.AddXyzProcedure(c,aux.FilterBoolFunction(Card.IsRace,RACE_INSECT),4,2) c:EnableReviveLimit() --destroy replace local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EFFECT_DESTROY_REPLACE) e1:SetRange(LOCATION_MZONE) e1:SetTarget(c78330013.reptg) e1:SetValue(c78330013.repval) c:RegisterEffect(e1) --attack up local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(78330013,0)) e2:SetCategory(CATEGORY_ATKCHANGE) e2:SetType(EFFECT_TYPE_TRIGGER_F+EFFECT_TYPE_SINGLE) e2:SetCode(EVENT_DETACH_MATERIAL) e2:SetTarget(c78330013.atktg) e2:SetOperation(c78330013.atkop) c:RegisterEffect(e2) --special summon local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(78330013,1)) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetProperty(EFFECT_FLAG_CARD_TARGET) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetRange(LOCATION_GRAVE+LOCATION_REMOVED) e3:SetCost(c78330013.spcost) e3:SetTarget(c78330013.sptg) e3:SetOperation(c78330013.spop) c:RegisterEffect(e3) --draw local e5=Effect.CreateEffect(c) e5:SetDescription(aux.Stringid(78330013,2)) e5:SetCategory(CATEGORY_DRAW) e5:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e5:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e5:SetCode(EVENT_SPSUMMON_SUCCESS) e5:SetCondition(c78330013.drcon) e5:SetTarget(c78330013.drtg) e5:SetOperation(c78330013.drop) c:RegisterEffect(e5) end function c78330013.repfilter(c,tp) return c:IsFaceup() and c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) and c:IsRace(RACE_INSECT) end function c78330013.reptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return eg:IsExists(c78330013.repfilter,1,nil,tp) end if e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_EFFECT) and Duel.SelectYesNo(tp,aux.Stringid(78330013,1)) then e:GetHandler():RemoveOverlayCard(tp,1,1,REASON_EFFECT) local g=eg:Filter(c78330013.repfilter,nil,tp) if g:GetCount()==1 then e:SetLabelObject(g:GetFirst()) else Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESREPLACE) local cg=g:Select(tp,1,1,nil) e:SetLabelObject(cg:GetFirst()) end return true else return false end end function c78330013.repval(e,c) return c==e:GetLabelObject() end function c78330013.atktg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsRelateToEffect(e) end end function c78330013.atkop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and c:IsFaceup() then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_COPY_INHERIT) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetReset(RESET_EVENT+0x1ff0000) e1:SetValue(1000) c:RegisterEffect(e1) end end function c78330013.cfilter(c) return c:IsRace(RACE_INSECT) and c:IsAbleToRemoveAsCost() end function c78330013.spcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c78330013.cfilter,tp,LOCATION_GRAVE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,c78330013.cfilter,tp,LOCATION_GRAVE,0,1,1,nil) Duel.Remove(g,POS_FACEUP,REASON_COST) end function c78330013.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and e:GetHandler():IsCanBeSpecialSummoned(e,1,tp,false,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function c78330013.spop(e,tp,eg,ep,ev,re,r,rp) if e:GetHandler():IsRelateToEffect(e) then Duel.SpecialSummon(e:GetHandler(),1,tp,tp,false,false,POS_FACEUP) end end function c78330013.drcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetSummonType()==SUMMON_TYPE_SPECIAL end function c78330013.drtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,1) end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(1) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function c78330013.drop(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Draw(p,d,REASON_EFFECT) end
gpl-3.0
MinFu/luci
applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/exec.lua
68
2536
-- Copyright 2008 Freifunk Leipzig / Jo-Philipp Wich <jow@openwrt.org> -- Licensed to the public under the Apache License 2.0. m = Map("luci_statistics", translate("Exec Plugin Configuration"), translate( "The exec plugin starts external commands to read values " .. "from or to notify external processes when certain threshold " .. "values have been reached." )) -- collectd_exec config section s = m:section( NamedSection, "collectd_exec", "luci_statistics" ) -- collectd_exec.enable enable = s:option( Flag, "enable", translate("Enable this plugin") ) enable.default = 0 -- collectd_exec_input config section (Exec directives) exec = m:section( TypedSection, "collectd_exec_input", translate("Add command for reading values"), translate( "Here you can define external commands which will be " .. "started by collectd in order to read certain values. " .. "The values will be read from stdout." )) exec.addremove = true exec.anonymous = true -- collectd_exec_input.cmdline exec_cmdline = exec:option( Value, "cmdline", translate("Script") ) exec_cmdline.default = "/usr/bin/stat-dhcpusers" -- collectd_exec_input.cmdline exec_cmduser = exec:option( Value, "cmduser", translate("User") ) exec_cmduser.default = "nobody" exec_cmduser.rmempty = true exec_cmduser.optional = true -- collectd_exec_input.cmdline exec_cmdgroup = exec:option( Value, "cmdgroup", translate("Group") ) exec_cmdgroup.default = "nogroup" exec_cmdgroup.rmempty = true exec_cmdgroup.optional = true -- collectd_exec_notify config section (NotifyExec directives) notify = m:section( TypedSection, "collectd_exec_notify", translate("Add notification command"), translate( "Here you can define external commands which will be " .. "started by collectd when certain threshold values have " .. "been reached. The values leading to invokation will be " .. "feeded to the the called programs stdin." )) notify.addremove = true notify.anonymous = true -- collectd_notify_input.cmdline notify_cmdline = notify:option( Value, "cmdline", translate("Script") ) notify_cmdline.default = "/usr/bin/stat-dhcpusers" -- collectd_notify_input.cmdline notify_cmduser = notify:option( Value, "cmduser", translate("User") ) notify_cmduser.default = "nobody" notify_cmduser.rmempty = true notify_cmduser.optional = true -- collectd_notify_input.cmdline notify_cmdgroup = notify:option( Value, "cmdgroup", translate("Group") ) notify_cmdgroup.default = "nogroup" notify_cmdgroup.rmempty = true notify_cmdgroup.optional = true return m
apache-2.0
TheOnePharaoh/YGOPro-Custom-Cards
script/c59821095.lua
2
3021
--The Idol Master of Mystery Zefra-Zuki function c59821095.initial_effect(c) --pendulum summon aux.EnablePendulumAttribute(c) --splimit local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetRange(LOCATION_PZONE) e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_CANNOT_DISABLE) e2:SetTargetRange(1,0) e2:SetTarget(c59821095.splimit) e2:SetCondition(c59821095.splimcon) c:RegisterEffect(e2) --atk down local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD) e3:SetRange(LOCATION_PZONE) e3:SetCode(EFFECT_UPDATE_ATTACK) e3:SetTargetRange(0,LOCATION_MZONE) e3:SetValue(-200) c:RegisterEffect(e3) --special summon local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(59821095,0)) e4:SetCategory(CATEGORY_SPECIAL_SUMMON) e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e4:SetCode(EVENT_BATTLE_DESTROYING) e4:SetCondition(c59821095.condition) e4:SetTarget(c59821095.target) e4:SetOperation(c59821095.operation) c:RegisterEffect(e4) --add setcode local e5=Effect.CreateEffect(c) e5:SetType(EFFECT_TYPE_SINGLE) e5:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e5:SetCode(EFFECT_ADD_SETCODE) e5:SetValue(0xc4) c:RegisterEffect(e5) end function c59821095.splimit(e,c,sump,sumtype,sumpos,targetp) if c:IsSetCard(0xc4) or c:IsSetCard(0xa1a2) then return false end return bit.band(sumtype,SUMMON_TYPE_PENDULUM)==SUMMON_TYPE_PENDULUM end function c59821095.splimcon(e) return not e:GetHandler():IsForbidden() end function c59821095.condition(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return c:IsRelateToBattle() and c:GetBattleTarget():IsType(TYPE_MONSTER) end function c59821095.filter(c,e,tp) return (c:IsType(TYPE_MONSTER) and c:IsSetCard(0xa1a2) or c:IsSetCard(0xc4)) and not c:IsCode(59821029) and not c:IsCode(59821095) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c59821095.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_DECK) and chkc:IsControler(tp) and c59821095.filter(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingTarget(c59821095.filter,tp,LOCATION_DECK,0,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectTarget(tp,c59821095.filter,tp,LOCATION_DECK,0,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0) end function c59821095.operation(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EVENT_PHASE+PHASE_END) e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE) e1:SetRange(LOCATION_MZONE) e1:SetCountLimit(1) e1:SetOperation(c59821095.desop) e1:SetReset(RESET_EVENT+0x1fe0000) tc:RegisterEffect(e1) end end function c59821095.desop(e,tp,eg,ep,ev,re,r,rp) Duel.Destroy(e:GetHandler(),REASON_EFFECT) end
gpl-3.0
waytim/darkstar
scripts/globals/spells/cure_ii.lua
26
4497
----------------------------------------- -- Spell: Cure II -- Restores target's HP. -- Shamelessly stolen from http://members.shaw.ca/pizza_steve/cure/Cure_Calculator.html ----------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------------- -- OnSpellCast ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) local divisor = 0; local constant = 0; local basepower = 0; local power = 0; local basecure = 0; local final = 0; local minCure = 60; if (USE_OLD_CURE_FORMULA == true) then power = getCurePowerOld(caster); divisor = 1; constant = 20; if (power > 170) then divisor = 35.6666; constant = 87.62; elseif (power > 110) then divisor = 2; constant = 47.5; end else power = getCurePower(caster); if (power < 70) then divisor = 1; constant = 60; basepower = 40; elseif (power < 125) then divisor = 5.5; constant = 90; basepower = 70; elseif (power < 200) then divisor = 7.5; constant = 100; basepower = 125; elseif (power < 400) then divisor = 10; constant = 110; basepower = 200; elseif (power < 700) then divisor = 20; constant = 130; basepower = 400; else divisor = 999999; constant = 145; basepower = 0; end end if (target:getAllegiance() == caster:getAllegiance() and (target:getObjType() == TYPE_PC or target:getObjType() == TYPE_MOB)) then if (USE_OLD_CURE_FORMULA == true) then basecure = getBaseCure(power,divisor,constant); else basecure = getBaseCure(power,divisor,constant,basepower); end final = getCureFinal(caster,spell,basecure,minCure,false); if (caster:hasStatusEffect(EFFECT_AFFLATUS_SOLACE) and target:hasStatusEffect(EFFECT_STONESKIN) == false) then local solaceStoneskin = 0; local equippedBody = caster:getEquipID(SLOT_BODY); if (equippedBody == 11186) then solaceStoneskin = math.floor(final * 0.30); elseif (equippedBody == 11086) then solaceStoneskin = math.floor(final * 0.35); else solaceStoneskin = math.floor(final * 0.25); end target:addStatusEffect(EFFECT_STONESKIN,solaceStoneskin,0,25); end; final = final + (final * (target:getMod(MOD_CURE_POTENCY_RCVD)/100)); --Applying server mods.... final = final * CURE_POWER; local diff = (target:getMaxHP() - target:getHP()); if (final > diff) then final = diff; end target:addHP(final); target:wakeUp(); caster:updateEnmityFromCure(target,final); else if (target:isUndead()) then spell:setMsg(2); local dmg = calculateMagicDamage(minCure,1,caster,spell,target,HEALING_MAGIC_SKILL,MOD_MND,false)*0.5; local resist = applyResistance(caster,spell,target,caster:getStat(MOD_MND)-target:getStat(MOD_MND),HEALING_MAGIC_SKILL,1.0); dmg = dmg*resist; dmg = addBonuses(caster,spell,target,dmg); dmg = adjustForTarget(target,dmg,spell:getElement()); dmg = finalMagicAdjustments(caster,target,spell,dmg); final = dmg; target:delHP(final); target:updateEnmityFromDamage(caster,final); elseif (caster:getObjType() == TYPE_PC) then spell:setMsg(75); else -- e.g. monsters healing themselves. if (USE_OLD_CURE_FORMULA == true) then basecure = getBaseCureOld(power,divisor,constant); else basecure = getBaseCure(power,divisor,constant,basepower); end final = getCureFinal(caster,spell,basecure,minCure,false); local diff = (target:getMaxHP() - target:getHP()); if (final > diff) then final = diff; end target:addHP(final); end end return final; end;
gpl-3.0
waytim/darkstar
scripts/zones/Temenos/mobs/Goblin_Fencer.lua
28
1132
----------------------------------- -- Area: Temenos N T -- NPC: Goblin_Fencer ----------------------------------- 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) GetMobByID(16928831):updateEnmity(target); GetMobByID(16928833):updateEnmity(target); GetMobByID(16928835):updateEnmity(target); end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob, player, isKiller) if (IsMobDead(16928831)==true and IsMobDead(16928832)==true and IsMobDead(16928833)==true and IsMobDead(16928834)==true and IsMobDead(16928835)==true ) then GetNPCByID(16928768+39):setPos(-599,85,438); GetNPCByID(16928768+39):setStatus(STATUS_NORMAL); GetNPCByID(16928768+456):setStatus(STATUS_NORMAL); end end;
gpl-3.0
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/zones/Northern_San_dOria/npcs/Narcheral.lua
23
3760
----------------------------------- -- Area: Northern San d'Oria -- NPC: Narcheral -- Starts and Finishes Quest: Messenger from Beyond, Prelude of Black and White (Finish), Pieuje's Decision (Finish) -- @zone 231 -- @pos 129 -11 126 ----------------------------------- package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/titles"); require("scripts/globals/shop"); require("scripts/globals/quests"); require("scripts/zones/Northern_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if(player:getQuestStatus(SANDORIA, MESSENGER_FROM_BEYOND) == QUEST_ACCEPTED) then if(trade:hasItemQty(1096,1) and trade:getItemCount() == 1) then -- Trade Tavnazia Pass player:startEvent(0x02b2); -- Finish quest "Messenger from Beyond" end elseif(player:getQuestStatus(SANDORIA,PRELUDE_OF_BLACK_AND_WHITE) == QUEST_ACCEPTED) then if(trade:hasItemQty(1097,1) and trade:hasItemQty(12995,1) and trade:getItemCount() == 2) then -- Trade Yagudo Holy Water & Moccasins player:startEvent(0x02b3); -- Finish quest "Prelude of Black and White" end elseif(player:getQuestStatus(SANDORIA,PIEUJE_S_DECISION) == QUEST_ACCEPTED) then if(trade:hasItemQty(13842,1) and trade:getItemCount() == 1) then -- Trade Tavnazian Mask player:startEvent(0x02b4); -- Finish quest "Pieuje's Decision" end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) messengerFromBeyond = player:getQuestStatus(SANDORIA,MESSENGER_FROM_BEYOND); -- Checking levels and jobs for af quest mLvl = player:getMainLvl(); mJob = player:getMainJob(); if(messengerFromBeyond == QUEST_AVAILABLE and mJob == 3 and mLvl >= AF1_QUEST_LEVEL) then player:startEvent(0x02b1); -- Start quest "Messenger from Beyond" else player:startEvent(0x02b0); -- Standard dialog end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if(csid == 0x02b1) then player:addQuest(SANDORIA,MESSENGER_FROM_BEYOND); elseif(csid == 0x02b2) then if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,17422); else player:addItem(17422); player:messageSpecial(ITEM_OBTAINED,17422); -- Blessed Hammer player:tradeComplete(); player:addFame(SANDORIA,SAN_FAME*AF1_FAME); player:completeQuest(SANDORIA,MESSENGER_FROM_BEYOND); end elseif(csid == 0x02b3) then if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,14091); -- Healer's Duckbills else player:addItem(14091); player:messageSpecial(ITEM_OBTAINED,14091); -- Healer's Duckbills player:tradeComplete(); player:addFame(SANDORIA,SAN_FAME*AF2_FAME); player:completeQuest(SANDORIA,PRELUDE_OF_BLACK_AND_WHITE); end elseif(csid == 0x02b4) then if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,12640); -- Healer's Briault else player:addTitle(PARAGON_OF_WHITE_MAGE_EXCELLENCE); player:setVar("pieujesDecisionCS",0); player:addItem(12640); player:messageSpecial(ITEM_OBTAINED,12640); -- Healer's Briault player:tradeComplete(); player:addFame(SANDORIA,SAN_FAME*AF3_FAME); player:completeQuest(SANDORIA,PIEUJE_S_DECISION); end end end;
gpl-3.0
waytim/darkstar
scripts/globals/items/homemade_rice_ball.lua
18
1105
----------------------------------------- -- ID: 5224 -- Item: homemade_rice_ball -- Food Effect: 30Min, All Races ----------------------------------------- -- Dexterity 1 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,1800,5224); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_DEX, 1); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_DEX, 1); end;
gpl-3.0
TheOnePharaoh/YGOPro-Custom-Cards
script/c90000080.lua
2
6513
--Black Flag Duelist function c90000080.initial_effect(c) --Pendulum Summon aux.EnablePendulumAttribute(c) --Pendulum Limit local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_CANNOT_NEGATE) e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e1:SetRange(LOCATION_PZONE) e1:SetTargetRange(1,0) e1:SetTarget(c90000080.tg) c:RegisterEffect(e1) --Scale Change local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_PZONE) e2:SetCountLimit(1) e2:SetCost(c90000080.cost) e2:SetOperation(c90000080.operation) c:RegisterEffect(e2) --Special Summon local e3=Effect.CreateEffect(c) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_SPSUMMON_SUCCESS) e3:SetRange(LOCATION_PZONE) e3:SetCondition(c90000080.condition) e3:SetTarget(c90000080.target) e3:SetOperation(c90000080.operation2) c:RegisterEffect(e3) --Search local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(90000080,0)) e4:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e4:SetType(EFFECT_TYPE_IGNITION) e4:SetRange(LOCATION_HAND) e4:SetCost(c90000080.cost) e4:SetTarget(c90000080.target2) e4:SetOperation(c90000080.operation3) c:RegisterEffect(e4) --To Hand local e5=Effect.CreateEffect(c) e5:SetCategory(CATEGORY_TOHAND) e5:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e5:SetCode(EVENT_SPSUMMON_SUCCESS) e5:SetCondition(c90000080.condition2) e5:SetTarget(c90000080.target3) e5:SetOperation(c90000080.operation4) c:RegisterEffect(e5) --Control local e6=Effect.CreateEffect(c) e6:SetCategory(CATEGORY_CONTROL) e6:SetType(EFFECT_TYPE_QUICK_O) e6:SetProperty(EFFECT_FLAG_CARD_TARGET) e6:SetCode(EVENT_FREE_CHAIN) e6:SetRange(LOCATION_MZONE) e6:SetCountLimit(1) e6:SetCondition(c90000080.condition3) e6:SetTarget(c90000080.target4) e6:SetOperation(c90000080.operation5) c:RegisterEffect(e6) end function c90000080.tg(e,c,sump,sumtype,sumpos,targetp) return not c:IsRace(RACE_ZOMBIE) and bit.band(sumtype,SUMMON_TYPE_PENDULUM)==SUMMON_TYPE_PENDULUM end function c90000080.filter(c) return c:IsRace(RACE_ZOMBIE) and not c:IsPublic() end function c90000080.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c90000080.filter,tp,LOCATION_HAND,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_CONFIRM) local g=Duel.SelectMatchingCard(tp,c90000080.filter,tp,LOCATION_HAND,0,1,1,nil) Duel.ConfirmCards(1-tp,g) Duel.ShuffleHand(tp) e:SetLabel(g:GetFirst():GetLevel()) end function c90000080.operation(e,tp,eg,ep,ev,re,r,rp) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_CHANGE_LSCALE) e1:SetValue(e:GetLabel()) e1:SetReset(RESET_EVENT+0x1ff0000) e:GetHandler():RegisterEffect(e1) local e2=e1:Clone() e2:SetCode(EFFECT_CHANGE_RSCALE) e:GetHandler():RegisterEffect(e2) end function c90000080.filter2(c,tp) return c:IsControler(tp) and c:GetSummonLocation()==LOCATION_EXTRA end function c90000080.condition(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(c90000080.filter2,1,nil,1-tp) end function c90000080.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function c90000080.operation2(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not c:IsRelateToEffect(e) then return end if Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)==0 and Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 and c:IsCanBeSpecialSummoned(e,0,tp,false,false) then Duel.SendtoGrave(c,REASON_RULE) end end function c90000080.cost(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return c:IsDiscardable() end Duel.SendtoGrave(c,REASON_COST+REASON_DISCARD) end function c90000080.filter3(c) return c:IsType(TYPE_FIELD) and c:IsAbleToHand() end function c90000080.target2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c90000080.filter3,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function c90000080.operation3(e,tp,eg,ep,ev,re,r,rp,chk) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,c90000080.filter3,tp,LOCATION_DECK,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end function c90000080.condition2(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetSummonType()==SUMMON_TYPE_PENDULUM end function c90000080.filter4(c) return c:IsRace(RACE_ZOMBIE) and c:IsAbleToHand() end function c90000080.target3(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c90000080.filter4,tp,LOCATION_GRAVE,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_GRAVE) end function c90000080.operation4(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,c90000080.filter4,tp,LOCATION_GRAVE,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end function c90000080.condition3(e,tp,eg,ep,ev,re,r,rp) return tp~=Duel.GetTurnPlayer() and (Duel.GetCurrentPhase()>=PHASE_BATTLE_START and Duel.GetCurrentPhase()<=PHASE_BATTLE) end function c90000080.target4(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingTarget(Card.IsControlerCanBeChanged,tp,0,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_CONTROL) local g=Duel.SelectTarget(tp,Card.IsControlerCanBeChanged,tp,0,LOCATION_MZONE,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_CONTROL,g,1,0,0) end function c90000080.operation5(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) and Duel.GetControl(tc,tp,PHASE_BATTLE,1)~=0 then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CANNOT_SELECT_BATTLE_TARGET) e1:SetTargetRange(0,LOCATION_MZONE) e1:SetLabel(tc:GetFieldID()) e1:SetValue(c90000080.value) e1:SetReset(RESET_PHASE+PHASE_BATTLE) Duel.RegisterEffect(e1,tp) local e2=Effect.CreateEffect(e:GetHandler()) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_REFLECT_BATTLE_DAMAGE) e2:SetValue(1) e2:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_BATTLE) tc:RegisterEffect(e2) end end function c90000080.value(e,c) return e:GetLabel()~=c:GetFieldID() end
gpl-3.0
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/globals/summon.lua
2
9299
require("scripts/globals/common"); require("scripts/globals/status"); SUMMONING_MAGIC_SKILL = 38 MSG_NONE = 0; -- display nothing MSG_NO_EFFECT = 189; MSG_DAMAGE = 185; -- player uses, target takes 10 damage. DEFAULT MSG_MISS = 188; MSG_RESIST = 85; function AvatarPhysicalMove(avatar,target,skill,numberofhits,accmod,dmgmod1,dmgmodsubsequent,tpeffect,mtp100,mtp200,mtp300) returninfo = {}; --Damage = (D+fSTR) * dmgmod * PDIF -- printf("str: %f, vit: %f", avatar:getStat(MOD_STR), target:getStat(MOD_VIT)); fstr = avatarFSTR(avatar:getStat(MOD_STR), target:getStat(MOD_VIT)); lvluser = avatar:getMainLvl(); lvltarget = target:getMainLvl(); acc = avatar:getACC(); eva = target:getEVA(); local base = avatar:getWeaponDmg() + fstr; local ratio = avatar:getStat(MOD_ATT)/target:getStat(MOD_DEF); lvldiff = lvluser - lvltarget; --work out hit rate for mobs (bias towards them) hitrate = (acc*accmod) - eva; if (lvluser > lvltarget) then hitrate = hitrate + ((lvluser-lvltarget)*5); end if (lvltarget > lvluser) then hitrate = hitrate + ((lvltarget-lvluser)*3); end if (hitrate > 95) then hitrate = 95; end if (hitrate < 20) then hitrate = 20; end if(base < 1) then base = 1; end hitdamage = base * dmgmod1; subsequenthitdamage = base * dmgmodsubsequent; if(ratio<=1) then maxRatio = 1; minRatio = 1/3; elseif(ratio<1.6) then maxRatio = ((4/6) * ratio) + (2/6); minRatio = ((7/9) * ratio) - (4/9); elseif(ratio<=1.8) then maxRatio = 1.8; minRatio = 1; elseif(ratio<3.6) then maxRatio = (2.4 * ratio) - 2.52; minRatio = ((5/3) * ratio) - 2; else maxRatio = 4.2; minRatio = 4; end if(tpeffect==TP_DMG_BONUS) then hitdamage = hitdamage * avatarFTP(skill:getTP(), mtp100, mtp200, mtp300); end --Applying pDIF local double pdif = 0; -- start the hits local double hitchance = math.random(); finaldmg = 0; hitsdone = 1; hitslanded = 0; --add on native crit hit rate (guesstimated, it actually follows an exponential curve) nativecrit = (avatar:getStat(MOD_DEX) - target:getStat(MOD_AGI))*0.005; --assumes +0.5% crit rate per 1 dDEX nativecrit = nativecrit + (avatar:getMod(MOD_CRITHITRATE)/100); if(nativecrit > 0.2) then --caps! nativecrit = 0.2; elseif(nativecrit < 0.05) then nativecrit = 0.05; end local double critchance = math.random(); local double hitchance = 0; local crit = false; if critchance <= nativecrit then crit = true; else hitchance = math.random(); end if crit == true or hitchance*100 <= 95 then pdif = math.random((minRatio * 1000), (maxRatio * 1000)); pdif = pdif/1000; if crit == true then pdif = pdif + 1; if pdif > 4.2 then pdif = 4.2 end end finaldmg = finaldmg + hitdamage * pdif; hitslanded = hitslanded + 1; end while (hitsdone < numberofhits) do chance = math.random(); if ((chance*100)<=hitrate) then pdif = math.random((minRatio * 1000), (maxRatio * 1000)); pdif = pdif/1000; finaldmg = finaldmg + subsequenthitdamage * pdif; hitslanded = hitslanded + 1; end hitsdone = hitsdone + 1; end -- all hits missed if(hitslanded == 0 or finaldmg == 0) then finaldmg = 0; hitslanded = 0; skill:setMsg(MSG_MISS); end returninfo.dmg = finaldmg; returninfo.hitslanded = hitslanded; return returninfo; end; --Given the attacker's str and the mob's vit, fSTR is calculated function avatarFSTR(atk_str,def_vit) local dSTR = atk_str - def_vit; if (dSTR >= 12) then fSTR2 = ((dSTR+4)/2); elseif (dSTR >= 6) then fSTR2 = ((dSTR+6)/2); elseif (dSTR >= 1) then fSTR2 = ((dSTR+7)/2); elseif (dSTR >= -2) then fSTR2 = ((dSTR+8)/2); elseif (dSTR >= -7) then fSTR2 = ((dSTR+9)/2); elseif (dSTR >= -15) then fSTR2 = ((dSTR+10)/2); elseif (dSTR >= -21) then fSTR2 = ((dSTR+12)/2); else fSTR2 = ((dSTR+13)/2); end --Apply fSTR caps. if (fSTR2< -1) then fSTR2 = -1; elseif (fSTR2>8) then fSTR2 = 8; end return fSTR2; end; function AvatarFinalAdjustments(dmg,mob,skill,target,skilltype,skillparam,shadowbehav) -- physical attack missed, skip rest if(skilltype == MOBSKILL_PHYSICAL and dmg == 0) then return 0; end -- set message to damage -- this is for AoE because its only set once skill:setMsg(MSG_DAMAGE); --Handle shadows depending on shadow behaviour / skilltype if(shadowbehav < 5 and shadowbehav ~= MOBPARAM_IGNORE_SHADOWS) then --remove 'shadowbehav' shadows. targShadows = target:getMod(MOD_UTSUSEMI); shadowType = MOD_UTSUSEMI; if(targShadows==0)then --try blink, as utsusemi always overwrites blink this is okay targShadows = target:getMod(MOD_BLINK); shadowType = MOD_BLINK; end if(targShadows>0)then --Blink has a VERY high chance of blocking tp moves, so im assuming its 100% because its easier! if(targShadows >= shadowbehav) then --no damage, just suck the shadows skill:setMsg(31); target:setMod(shadowType,(targShadows-shadowbehav)); if(shadowType == MOD_UTSUSEMI) then --update icon effect = target:getStatusEffect(EFFECT_COPY_IMAGE); if(effect ~= nil) then if((targShadows-shadowbehav) == 0) then target:delStatusEffect(EFFECT_COPY_IMAGE); target:delStatusEffect(EFFECT_BLINK); elseif((targShadows-shadowbehav) == 1) then effect:setIcon(EFFECT_COPY_IMAGE); elseif((targShadows-shadowbehav) == 2) then effect:setIcon(EFFECT_COPY_IMAGE_2); elseif((targShadows-shadowbehav) == 3) then effect:setIcon(EFFECT_COPY_IMAGE_3); end end end return shadowbehav; else --less shadows than this move will take, remove all and factor damage down dmg = dmg * ((shadowbehav-targShadows)/shadowbehav); target:setMod(MOD_UTSUSEMI,0); target:setMod(MOD_BLINK,0); target:delStatusEffect(EFFECT_COPY_IMAGE); target:delStatusEffect(EFFECT_BLINK); end end elseif(shadowbehav == MOBPARAM_WIPE_SHADOWS) then --take em all! target:setMod(MOD_UTSUSEMI,0); target:setMod(MOD_BLINK,0); target:delStatusEffect(EFFECT_COPY_IMAGE); target:delStatusEffect(EFFECT_BLINK); end --handle Third Eye using shadowbehav as a guide teye = target:getStatusEffect(EFFECT_THIRD_EYE); if(teye ~= nil and skilltype==MOBSKILL_PHYSICAL) then --T.Eye only procs when active with PHYSICAL stuff if(shadowbehav == MOBPARAM_WIPE_SHADOWS) then --e.g. aoe moves target:delStatusEffect(EFFECT_THIRD_EYE); elseif(shadowbehav ~= MOBPARAM_IGNORE_SHADOWS) then --it can be absorbed by shadows --third eye doesnt care how many shadows, so attempt to anticipate, but reduce --chance of anticipate based on previous successful anticipates. prevAnt = teye:getPower(); if(prevAnt == 0) then --100% proc teye:setPower(1); skill:setMsg(30); return 0; end if( (math.random()*100) < (80-(prevAnt*10)) ) then --anticipated! teye:setPower(prevAnt+1); skill:setMsg(30); return 0; end target:delStatusEffect(EFFECT_THIRD_EYE); end end --TODO: Handle anything else (e.g. if you have Magic Shield and its a Magic skill, then do 0 damage. if(skilltype == MOBSKILL_PHYSICAL and target:hasStatusEffect(EFFECT_PHYSICAL_SHIELD)) then return 0; end if(skilltype == MOBSKILL_RANGED and target:hasStatusEffect(EFFECT_ARROW_SHIELD)) then return 0; end -- handle elemental resistence if(skilltype == MOBSKILL_MAGICAL and target:hasStatusEffect(EFFECT_MAGIC_SHIELD)) then return 0; end --handling phalanx dmg = dmg - target:getMod(MOD_PHALANX); if(dmg<0) then return 0; end --handle invincible if(target:hasStatusEffect(EFFECT_INVINCIBLE) and skilltype==MOBSKILL_PHYSICAL)then return 0; end --handle pd if(target:hasStatusEffect(EFFECT_PERFECT_DODGE) and skilltype==MOBSKILL_PHYSICAL)then return 0; end --handling stoneskin skin = target:getMod(MOD_STONESKIN); if(skin>0) then if(skin >= dmg) then --absorb all damage target:delMod(MOD_STONESKIN,dmg); if(target:getMod(MOD_STONESKIN)==0) then target:delStatusEffect(EFFECT_STONESKIN); end return 0; else --absorbs some damage then wear target:delMod(MOD_STONESKIN,skin); target:delStatusEffect(EFFECT_STONESKIN); return dmg - skin; end end return dmg; end; -- returns true if mob attack hit -- used to stop tp move status effects function AvatarPhysicalHit(skill, dmg) -- if message is not the default. Then there was a miss, shadow taken etc return skill:getMsg() == MSG_DAMAGE; end; function avatarFTP(tp,ftp1,ftp2,ftp3) if(tp<100) then tp=100; end if(tp>=100 and tp<200) then return ftp1 + ( ((ftp2-ftp1)/100) * (tp-100)); elseif(tp>=200 and tp<=300) then --generate a straight line between ftp2 and ftp3 and find point @ tp return ftp2 + ( ((ftp3-ftp2)/100) * (tp-200)); end return 1; --no ftp mod end; -------- -- Checks if the summoner is in a Trial Size Avatar Mini Fight (used to restrict summoning while in bcnm) -------- function avatarMiniFightCheck(caster) local result = 0; local bcnmid; if (caster:hasStatusEffect(EFFECT_BATTLEFIELD) == true) then bcnmid = caster:getStatusEffect(EFFECT_BATTLEFIELD):getPower(); if(bcnmid == 418 or bcnmid == 609 or bcnmid == 450 or bcnmid == 482 or bcnmid == 545 or bcnmid == 578) then -- Mini Avatar Fights result = 40; -- Cannot use <spell> in this area. end end return result; end;
gpl-3.0
3pehrdev/iran-telenymous
plugins/ingroup.lua
1
43783
do -- Check Member local function check_member_autorealm(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Group configuration data[tostring(msg.to.id)] = { group_type = 'Realm', settings = { set_name = string.gsub(msg.to.print_name, '_', ' '), lock_name = 'yes', lock_photo = 'no', lock_member = 'no', flood = 'yes' } } save_data(_config.moderation.data, data) local realms = 'realms' if not data[tostring(realms)] then data[tostring(realms)] = {} save_data(_config.moderation.data, data) end data[tostring(realms)][tostring(msg.to.id)] = msg.to.id save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Welcome to your new realm !') end end end local function check_member_realm_add(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Group configuration data[tostring(msg.to.id)] = { group_type = 'Realm', settings = { set_name = string.gsub(msg.to.print_name, '_', ' '), lock_name = 'yes', lock_photo = 'no', lock_member = 'no', flood = 'yes' } } save_data(_config.moderation.data, data) local realms = 'realms' if not data[tostring(realms)] then data[tostring(realms)] = {} save_data(_config.moderation.data, data) end data[tostring(realms)][tostring(msg.to.id)] = msg.to.id save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Realm has been added!') end end end function check_member_group(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Group configuration data[tostring(msg.to.id)] = { group_type = 'Group', moderators = {}, set_owner = member_id , settings = { set_name = string.gsub(msg.to.print_name, '_', ' '), lock_name = 'yes', lock_photo = 'no', lock_member = 'no', flood = 'yes', } } save_data(_config.moderation.data, data) local groups = 'groups' if not data[tostring(groups)] then data[tostring(groups)] = {} save_data(_config.moderation.data, data) end data[tostring(groups)][tostring(msg.to.id)] = msg.to.id save_data(_config.moderation.data, data) return send_large_msg(receiver, 'You promoted as the owner.') end end end local function check_member_modadd(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Group configuration data[tostring(msg.to.id)] = { group_type = 'Group', moderators = {}, set_owner = member_id , settings = { set_name = string.gsub(msg.to.print_name, '_', ' '), lock_name = 'yes', lock_photo = 'no', lock_member = 'no', flood = 'yes', } } save_data(_config.moderation.data, data) local groups = 'groups' if not data[tostring(groups)] then data[tostring(groups)] = {} save_data(_config.moderation.data, data) end data[tostring(groups)][tostring(msg.to.id)] = msg.to.id save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Group added and you have promote the owner gp ') end end end local function automodadd(msg) local data = load_data(_config.moderation.data) if msg.action.type == 'chat_created' then receiver = get_receiver(msg) chat_info(receiver, check_member_group,{receiver=receiver, data=data, msg = msg}) end end local function autorealmadd(msg) local data = load_data(_config.moderation.data) if msg.action.type == 'chat_created' then receiver = get_receiver(msg) chat_info(receiver, check_member_autorealm,{receiver=receiver, data=data, msg = msg}) end end local function check_member_realmrem(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Realm configuration removal data[tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) local realms = 'realms' if not data[tostring(realms)] then data[tostring(realms)] = nil save_data(_config.moderation.data, data) end data[tostring(realms)][tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Realm has been removed!') end end end local function check_member_modrem(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Group configuration removal data[tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) local groups = 'groups' if not data[tostring(groups)] then data[tostring(groups)] = nil save_data(_config.moderation.data, data) end data[tostring(groups)][tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Group has been removed') end end end --End Check Member local function show_group_settingsmod(msg, data, target) if not is_momod(msg) then return "For mods only!" end local data = load_data(_config.moderation.data) if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['settings']['flood_msg_max'] then NUM_MSG_MAX = tonumber(data[tostring(msg.to.id)]['settings']['flood_msg_max']) print('custom'..NUM_MSG_MAX) else NUM_MSG_MAX = 5 end end local bots_protection = "Yes" if data[tostring(msg.to.id)]['settings']['lock_bots'] then bots_protection = data[tostring(msg.to.id)]['settings']['lock_bots'] end local leave_ban = "no" if data[tostring(msg.to.id)]['settings']['leave_ban'] then leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban'] end local settings = data[tostring(target)]['settings'] local text = "Group settings🔋:\nLock group name🔮 : "..settings.lock_name☠.."\nLock group photo♨️ : "..settings.lock_photo🔱.."\nLock group member🔰 : "..settings.lock_member🌀.."\nLock group leave☔️ : "..leave_ban.."\nflood sensitivity⚡️ : "..NUM_MSG_MAX.."\nBot protection🌀 : "..bots_protection--"\nPublic: "..public end local function set_descriptionmod(msg, data, target, about) if not is_momod(msg) then return "For mods only!" end local data_cat = 'description' data[tostring(target)][data_cat] = about save_data(_config.moderation.data, data) return 'Set gp description to:\n'..about end local function get_description(msg, data) local data_cat = 'description' if not data[tostring(msg.to.id)][data_cat] then return 'No description available.' end local about = data[tostring(msg.to.id)][data_cat] local about = string.gsub(msg.to.print_name, "_", " ")..':\n\n'..about return 'About '..about end local function lock_group_arabic(msg, data, target) if not is_momod(msg) then return "For mods only!" end local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic'] if group_arabic_lock == 'yes' then return 'Arabic already locked' else data[tostring(target)]['settings']['lock_arabic'] = 'yes' save_data(_config.moderation.data, data) return 'Arabic locked' end end local function unlock_group_arabic(msg, data, target) if not is_momod(msg) then return "For mods only!" end local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic'] if group_arabic_lock == 'no' then return 'Arabic already unlocked' else data[tostring(target)]['settings']['lock_arabic'] = 'no' save_data(_config.moderation.data, data) return 'Arabic unlocked' end end local function lock_group_bots(msg, data, target) if not is_momod(msg) then return "For mods only!" end local group_bots_lock = data[tostring(target)]['settings']['lock_bots'] if group_bots_lock == 'yes' then return 'Bots protection already enabled' else data[tostring(target)]['settings']['lock_bots'] = 'yes' save_data(_config.moderation.data, data) return 'Bots protection enabled' end end local function unlock_group_bots(msg, data, target) if not is_momod(msg) then return "For mods only!" end local group_bots_lock = data[tostring(target)]['settings']['lock_bots'] if group_bots_lock == 'no' then return 'Bots protection already disabled' else data[tostring(target)]['settings']['lock_bots'] = 'no' save_data(_config.moderation.data, data) return 'Bots protection disabled' end end local function lock_group_namemod(msg, data, target) if not is_momod(msg) then return "For mods only!" end local group_name_set = data[tostring(target)]['settings']['set_name'] local group_name_lock = data[tostring(target)]['settings']['lock_name'] if group_name_lock == 'yes' then return 'Gp name already locked' else data[tostring(target)]['settings']['lock_name'] = 'yes' save_data(_config.moderation.data, data) rename_chat('chat#id'..target, group_name_set, ok_cb, false) return 'Gp name locked' end end local function unlock_group_namemod(msg, data, target) if not is_momod(msg) then return "For mods only!" end local group_name_set = data[tostring(target)]['settings']['set_name'] local group_name_lock = data[tostring(target)]['settings']['lock_name'] if group_name_lock == 'no' then return 'Gp name already unlocked' else data[tostring(target)]['settings']['lock_name'] = 'no' save_data(_config.moderation.data, data) return 'Gp name unlocked' end end local function lock_group_floodmod(msg, data, target) if not is_owner(msg) then return " sick baw Only admins can do it for now" end local group_flood_lock = data[tostring(target)]['settings']['flood'] if group_flood_lock == 'yes' then return 'Gp flood locked' else data[tostring(target)]['settings']['flood'] = 'yes' save_data(_config.moderation.data, data) return 'gp flood locked' end end local function unlock_group_floodmod(msg, data, target) if not is_owner(msg) then return "Only admins can do it for now" end local group_flood_lock = data[tostring(target)]['settings']['flood'] if group_flood_lock == 'no' then return 'Gp flood not locked' else data[tostring(target)]['settings']['flood'] = 'no' save_data(_config.moderation.data, data) return 'Gp flood unlocked' end end local function lock_group_membermod(msg, data, target) if not is_momod(msg) then return "For mods only!" end local group_member_lock = data[tostring(target)]['settings']['lock_member'] if group_member_lock == 'yes' then return 'Gp members already locked' else data[tostring(target)]['settings']['lock_member'] = 'yes' save_data(_config.moderation.data, data) end return 'Gp members locked' end local function unlock_group_membermod(msg, data, target) if not is_momod(msg) then return "For mods only!" end local group_member_lock = data[tostring(target)]['settings']['lock_member'] if group_member_lock == 'no' then return 'Gp members not locked' else data[tostring(target)]['settings']['lock_member'] = 'no' save_data(_config.moderation.data, data) return 'Gp members unlocked' end end local function set_public_membermod(msg, data, target) if not is_momod(msg) then return "For mods only!" end local group_member_lock = data[tostring(target)]['settings']['public'] if group_member_lock == 'yes' then return 'Group is already public' else data[tostring(target)]['settings']['public'] = 'yes' save_data(_config.moderation.data, data) end return 'Group is now: public' end local function unset_public_membermod(msg, data, target) if not is_momod(msg) then return "For mods only!" end local group_member_lock = data[tostring(target)]['settings']['public'] if group_member_lock == 'no' then return 'Group is not public' else data[tostring(target)]['settings']['public'] = 'no' save_data(_config.moderation.data, data) return 'Group is now: not public' end end local function lock_group_leave(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban'] if leave_ban == 'yes' then return 'Leaving users will be banned' else data[tostring(msg.to.id)]['settings']['leave_ban'] = 'yes' save_data(_config.moderation.data, data) end return 'Leaving users will be banned' end local function unlock_group_leave(msg, data, target) if not is_momod(msg) then return "For mod only!" end local leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban'] if leave_ban == 'no' then return 'Leaving users will not be banned' else data[tostring(msg.to.id)]['settings']['leave_ban'] = 'no' save_data(_config.moderation.data, data) return 'Leaving users will not be banned' end end local function unlock_group_photomod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_photo_lock = data[tostring(target)]['settings']['lock_photo'] if group_photo_lock == 'no' then return 'Gp photo is not locked' else data[tostring(target)]['settings']['lock_photo'] = 'no' save_data(_config.moderation.data, data) return 'Gp photo has been unlocked' end end local function set_rulesmod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local data_cat = 'rules' data[tostring(target)][data_cat] = rules save_data(_config.moderation.data, data) return 'Set group rules to:\n'..rules end local function modadd(msg) -- superuser and admins only (because sudo are always has privilege) if not is_admin(msg) then return "You're not admin" end local data = load_data(_config.moderation.data) if is_group(msg) then return 'Group is already added.' end receiver = get_receiver(msg) chat_info(receiver, check_member_modadd,{receiver=receiver, data=data, msg = msg}) end local function realmadd(msg) -- superuser and admins only (because sudo are always has privilege) if not is_admin(msg) then return "You're not admin" end local data = load_data(_config.moderation.data) if is_realm(msg) then return 'Realm is already added.' end receiver = get_receiver(msg) chat_info(receiver, check_member_realm_add,{receiver=receiver, data=data, msg = msg}) end -- Global functions function modrem(msg) -- superuser and admins only (because sudo are always has privilege) if not is_admin(msg) then return "You're not admin" end local data = load_data(_config.moderation.data) if not is_group(msg) then return 'Group is not added.' end receiver = get_receiver(msg) chat_info(receiver, check_member_modrem,{receiver=receiver, data=data, msg = msg}) end function realmrem(msg) -- superuser and admins only (because sudo are always has privilege) if not is_admin(msg) then return "You're not admin" end local data = load_data(_config.moderation.data) if not is_realm(msg) then return 'Realm is not added.' end receiver = get_receiver(msg) chat_info(receiver, check_member_realmrem,{receiver=receiver, data=data, msg = msg}) end local function get_rules(msg, data) local data_cat = 'rules' if not data[tostring(msg.to.id)][data_cat] then return 'No rules available.' end local rules = data[tostring(msg.to.id)][data_cat] local rules = 'Chat rules:\n'..rules return rules end local function set_group_photo(msg, success, result) local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) if success then local file = 'data/photos/chat_photo_'..msg.to.id..'.jpg' print('File downloaded to:', result) os.rename(result, file) print('File moved to:', file) chat_set_photo (receiver, file, ok_cb, false) data[tostring(msg.to.id)]['settings']['set_photo'] = file save_data(_config.moderation.data, data) data[tostring(msg.to.id)]['settings']['lock_photo'] = 'yes' save_data(_config.moderation.data, data) send_large_msg(receiver, 'Photo saved!', ok_cb, false) else print('Error downloading: '..msg.id) send_large_msg(receiver, 'Failed, please try again!', ok_cb, false) end end local function promote(receiver, member_username, member_id) local data = load_data(_config.moderation.data) local group = string.gsub(receiver, 'chat#id', '') if not data[group] then return send_large_msg(receiver, 'Gp is not added.') end if data[group]['moderators'][tostring(member_id)] then return send_large_msg(receiver, member_username..' is already a moderator.') end data[group]['moderators'][tostring(member_id)] = member_username save_data(_config.moderation.data, data) return send_large_msg(receiver, member_username..' has been promoted.') end local function promote_by_reply(extra, success, result) local msg = result local full_name = (msg.from.first_name or '')..' '..(msg.from.last_name or '') if msg.from.username then member_username = '@'.. msg.from.username else member_username = full_name end local member_id = msg.from.id if msg.to.type == 'chat' then return promote(get_receiver(msg), member_username, member_id) end end local function demote(receiver, member_username, member_id) local data = load_data(_config.moderation.data) local group = string.gsub(receiver, 'chat#id', '') if not data[group] then return send_large_msg(receiver, 'Group is not added.') end if not data[group]['moderators'][tostring(member_id)] then return send_large_msg(receiver, member_username..' is not a moderator.') end data[group]['moderators'][tostring(member_id)] = nil save_data(_config.moderation.data, data) return send_large_msg(receiver, member_username..' has been demoted.') end local function demote_by_reply(extra, success, result) local msg = result local full_name = (msg.from.first_name or '')..' '..(msg.from.last_name or '') if msg.from.username then member_username = '@'..msg.from.username else member_username = full_name end local member_id = msg.from.id if msg.to.type == 'chat' then return demote(get_receiver(msg), member_username, member_id) end end local function setowner_by_reply(extra, success, result) local msg = result local receiver = get_receiver(msg) local data = load_data(_config.moderation.data) local name_log = msg.from.print_name:gsub("_", " ") data[tostring(msg.to.id)]['set_owner'] = tostring(msg.from.id) save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] setted ["..msg.from.id.."] as owner") local text = msg.from.print_name:gsub("_", " ").." is the owner now" return send_large_msg(receiver, text) end local function promote_demote_res(extra, success, result) --vardump(result) --vardump(extra) local member_id = result.id local member_username = "@"..result.username local chat_id = extra.chat_id local mod_cmd = extra.mod_cmd local receiver = "chat#id"..chat_id if mod_cmd == 'promote' then return promote(receiver, member_username, member_id) elseif mod_cmd == 'demote' then return demote(receiver, member_username, member_id) end end local function modlist(msg) local data = load_data(_config.moderation.data) local groups = "groups" if not data[tostring(groups)][tostring(msg.to.id)] then return 'Group is not added.' end -- determine if table is empty if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way return 'No moderator in this group.' end local i = 1 local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n' for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do message = message ..i..' - '..v..' [' ..k.. '] \n' i = i + 1 end return message end local function callbackres(extra, success, result) --vardump(result) local user = result.id local name = string.gsub(result.print_name, "_", " ") local chat = 'chat#id'..extra.chatid send_large_msg(chat, user..'\n'..name) return user end local function help() local help_text = tostring(_config.help_text) return help_text end local function cleanmember(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name for k,v in pairs(result.members) do kick_user(v.id, result.id) end end local function killchat(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name for k,v in pairs(result.members) do kick_user_any(v.id, result.id) end end local function killrealm(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name for k,v in pairs(result.members) do kick_user_any(v.id, result.id) end end local function user_msgs(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 = tonumber(redis:get(um_hash) or 0) return user_info end local function kick_zero(cb_extra, success, result) local chat_id = cb_extra.chat_id local chat = "chat#id"..chat_id local ci_user local re_user for k,v in pairs(result.members) do local si = false ci_user = v.id local hash = 'chat:'..chat_id..':users' local users = redis:smembers(hash) for i = 1, #users do re_user = users[i] if tonumber(ci_user) == tonumber(re_user) then si = true end end if not si then if ci_user ~= our_id then if not is_momod2(ci_user, chat_id) then chat_del_user(chat, 'user#id'..ci_user, ok_cb, true) end end end end end local function kick_inactive(chat_id, num, receiver) local hash = 'chat:'..chat_id..':users' local users = redis:smembers(hash) -- Get user info for i = 1, #users do local user_id = users[i] local user_info = user_msgs(user_id, chat_id) local nmsg = user_info if tonumber(nmsg) < tonumber(num) then if not is_momod2(user_id, chat_id) then chat_del_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, true) end end end return chat_info(receiver, kick_zero, {chat_id = chat_id}) end local function run(msg, matches) local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) local name_log = user_print_name(msg.from) local group = msg.to.id if msg.media then if msg.media.type == 'photo' and data[tostring(msg.to.id)]['settings']['set_photo'] == 'waiting' and is_chat_msg(msg) and is_momod(msg) then load_photo(msg.id, set_group_photo, msg) end end if matches[1] == 'add' and not matches[2] then if is_realm(msg) then return 'Error: Already a realm.' end print("group "..msg.to.print_name.."("..msg.to.id..") added") return modadd(msg) end if matches[1] == 'add' and matches[2] == 'realm' then if is_group(msg) then return 'Error: Already a group.' end print("group "..msg.to.print_name.."("..msg.to.id..") added as a realm") return realmadd(msg) end if matches[1] == 'rem' and not matches[2] then print("group "..msg.to.print_name.."("..msg.to.id..") removed") return modrem(msg) end if matches[1] == 'rem' and matches[2] == 'realm' then print("group "..msg.to.print_name.."("..msg.to.id..") removed as a realm") return realmrem(msg) end if matches[1] == 'chat_created' and msg.from.id == 0 and group_type == "group" then return automodadd(msg) end if matches[1] == 'chat_created' and msg.from.id == 0 and group_type == "realm" then return autorealmadd(msg) end if msg.to.id and data[tostring(msg.to.id)] then local settings = data[tostring(msg.to.id)]['settings'] if matches[1] == 'chat_add_user' then if not msg.service then return "Are you trying to troll me?" end local group_member_lock = settings.lock_member local user = 'user#id'..msg.action.user.id local chat = 'chat#id'..msg.to.id if group_member_lock == 'yes' and not is_owner2(msg.action.user.id, msg.to.id) then chat_del_user(chat, user, ok_cb, true) elseif group_member_lock == 'yes' and tonumber(msg.from.id) == tonumber(our_id) then return nil elseif group_member_lock == 'no' then return nil end end if matches[1] == 'chat_del_user' then if not msg.service then -- return "Are you trying to troll me?" end local user = 'user#id'..msg.action.user.id local chat = 'chat#id'..msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted user "..user) end if matches[1] == 'chat_delete_photo' then if not msg.service then return "Are you trying to troll me?" end local group_photo_lock = settings.lock_photo if group_photo_lock == 'yes' then local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:incr(picturehash) --- local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id local picprotectionredis = redis:get(picturehash) if picprotectionredis then if tonumber(picprotectionredis) == 4 and not is_owner(msg) then kick_user(msg.from.id, msg.to.id) end if tonumber(picprotectionredis) == 8 and not is_owner(msg) then ban_user(msg.from.id, msg.to.id) local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:set(picturehash, 0) end end savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to deleted picture but failed ") chat_set_photo(receiver, settings.set_photo, ok_cb, false) elseif group_photo_lock == 'no' then return nil end end if matches[1] == 'chat_change_photo' and msg.from.id ~= 0 then if not msg.service then return "Are you trying to troll me?" end local group_photo_lock = settings.lock_photo if group_photo_lock == 'yes' then local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:incr(picturehash) --- local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id local picprotectionredis = redis:get(picturehash) if picprotectionredis then if tonumber(picprotectionredis) == 4 and not is_owner(msg) then kick_user(msg.from.id, msg.to.id) end if tonumber(picprotectionredis) == 8 and not is_owner(msg) then ban_user(msg.from.id, msg.to.id) local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:set(picturehash, 0) end end savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change picture but failed ") chat_set_photo(receiver, settings.set_photo, ok_cb, false) elseif group_photo_lock == 'no' then return nil end end if matches[1] == 'chat_rename' then if not msg.service then return "Are you trying to troll me?" end local group_name_set = settings.set_name local group_name_lock = settings.lock_name local to_rename = 'chat#id'..msg.to.id if group_name_lock == 'yes' then if group_name_set ~= tostring(msg.to.print_name) then local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id redis:incr(namehash) local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id local nameprotectionredis = redis:get(namehash) if nameprotectionredis then if tonumber(nameprotectionredis) == 4 and not is_owner(msg) then kick_user(msg.from.id, msg.to.id) end if tonumber(nameprotectionredis) == 8 and not is_owner(msg) then ban_user(msg.from.id, msg.to.id) local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id redis:set(namehash, 0) end end savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change name but failed ") rename_chat(to_rename, group_name_set, ok_cb, false) end elseif group_name_lock == 'no' then return nil end end if matches[1] == 'setname' and is_momod(msg) then local new_name = string.gsub(matches[2], '_', ' ') data[tostring(msg.to.id)]['settings']['set_name'] = new_name save_data(_config.moderation.data, data) local group_name_set = data[tostring(msg.to.id)]['settings']['set_name'] local to_rename = 'chat#id'..msg.to.id rename_chat(to_rename, group_name_set, ok_cb, false) savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]") end if matches[1] == 'setphoto' and is_momod(msg) then data[tostring(msg.to.id)]['settings']['set_photo'] = 'waiting' save_data(_config.moderation.data, data) return ' send me new group photo' end if matches[1] == 'promote' and not matches[2] then if not is_owner(msg) then return "Only the owner can prmote new moderators" end if type(msg.reply_id)~="nil" then msgr = get_message(msg.reply_id, promote_by_reply, false) end end if matches[1] == 'promote' and matches[2] then if not is_momod(msg) then return end if not is_owner(msg) then return "Only owner,admins and sudo can promote" end local member = matches[2] savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted @".. member) local cbres_extra = { chat_id = msg.to.id, mod_cmd = 'promote', from_id = msg.from.id } local username = matches[2] local username = string.gsub(matches[2], '@', '') return res_user(username, promote_demote_res, cbres_extra) end if matches[1] == 'demote' and not matches[2] then if not is_owner(msg) then return "Only the owner can dem mod" end if type(msg.reply_id)~="nil" then msgr = get_message(msg.reply_id, demote_by_reply, false) end end if matches[1] == 'demote' and matches[2] then if not is_momod(msg) then return end if not is_owner(msg) then return "Only owner,admins and sudo can demote" end if string.gsub(matches[2], "@", "") == msg.from.username and not is_owner(msg) then return "You can't dem yourself" end local member = matches[2] savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted @".. member) local cbres_extra = { chat_id = msg.to.id, mod_cmd = 'demote', from_id = msg.from.id } local username = matches[2] local username = string.gsub(matches[2], '@', '') return res_user(username, promote_demote_res, cbres_extra) end if matches[1] == 'modlist' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested gp modlist") return modlist(msg) end if matches[1] == 'about' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested gp description") return get_description(msg, data) end if matches[1] == 'rules' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested gp rules") return get_rules(msg, data) end if matches[1] == 'set' then if matches[2] == 'rules' then rules = matches[3] local target = msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed gp rules to ["..matches[3].."]") return set_rulesmod(msg, data, target) end if matches[2] == 'about' then local data = load_data(_config.moderation.data) local target = msg.to.id local about = matches[3] savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed gp description to ["..matches[3].."]") return set_descriptionmod(msg, data, target, about) end end if matches[1] == 'lock' then local target = msg.to.id if matches[2] == 'name' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked name ") return lock_group_namemod(msg, data, target) end if matches[2] == 'member' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked member ") return lock_group_membermod(msg, data, target) end if matches[2] == 'flood' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked flood ") return lock_group_floodmod(msg, data, target) end if matches[2] == 'arabic' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked arabic ") return lock_group_arabic(msg, data, target) end if matches[2] == 'bots' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked bots ") return lock_group_bots(msg, data, target) end if matches[2] == 'leave' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked leaving ") return lock_group_leave(msg, data, target) end end if matches[1] == 'unlock' then local target = msg.to.id if matches[2] == 'name' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked name ") return unlock_group_namemod(msg, data, target) end if matches[2] == 'member' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked member ") return unlock_group_membermod(msg, data, target) end if matches[2] == 'photo' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked photo ") return unlock_group_photomod(msg, data, target) end if matches[2] == 'flood' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked flood ") return unlock_group_floodmod(msg, data, target) end if matches[2] == 'arabic' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked arabic ") return unlock_group_arabic(msg, data, target) end if matches[2] == 'bots' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked bots ") return unlock_group_bots(msg, data, target) end if matches[2] == 'leave' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked leaving ") return unlock_group_leave(msg, data, target) end end if matches[1] == 'settings' then local target = msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group settings ") return show_group_settingsmod(msg, data, target) end --[[if matches[1] == 'public' then local target = msg.to.id if matches[2] == 'yes' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: public") return set_public_membermod(msg, data, target) end if matches[2] == 'no' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: not public") return unset_public_membermod(msg, data, target) end end]] if matches[1] == 'newlink' and not is_realm(msg) then if not is_momod(msg) then return "For mod only!" end local function callback (extra , success, result) local receiver = 'chat#'..msg.to.id if success == 0 then return send_large_msg(receiver, '*Error: Invite link failed* \nReason: Not creator.') end send_large_msg(receiver, "Create a new link") data[tostring(msg.to.id)]['settings']['set_link'] = result save_data(_config.moderation.data, data) end local receiver = 'chat#'..msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] revoked group link ") return export_chat_link(receiver, callback, true) end if matches[1] == 'link' then if not is_momod(msg) then return "For mod only!" end local group_link = data[tostring(msg.to.id)]['settings']['set_link'] if not group_link then return "Created a link first!" end savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group link ["..group_link.."]") return "Group link for ["..group_name.."]:\n"..group_link end if matches[1] == 'setowner' and matches[2] then if not is_owner(msg) then return "For owner only!" end data[tostring(msg.to.id)]['set_owner'] = matches[2] save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] set ["..matches[2].."] new owner") local text = matches[2].." is new owner" return text end if matches[1] == 'setowner' and not matches[2] then if not is_owner(msg) then return "only owner!" end if type(msg.reply_id)~="nil" then msgr = get_message(msg.reply_id, setowner_by_reply, false) end end if matches[1] == 'owner' then local group_owner = data[tostring(msg.to.id)]['set_owner'] if not group_owner then return "no owner,ask admins in support groups to set owner for your group" end savelog(msg.to.id, name_log.." ["..msg.from.id.."] used /owner") return "Group owner is ["..group_owner..']' end if matches[1] == 'setgpowner' then local receiver = "chat#id"..matches[2] if not is_admin(msg) then return "For admins only!" end data[tostring(matches[2])]['set_owner'] = matches[3] save_data(_config.moderation.data, data) local text = matches[3].." is new owner!" send_large_msg(receiver, text) return end if matches[1] == 'setflood' then if not is_momod(msg) then return "For mod only" end if tonumber(matches[2]) < 5 or tonumber(matches[2]) > 20 then return "Wrong number,range flood is [5-20]" end local flood_max = matches[2] data[tostring(msg.to.id)]['settings']['flood_msg_max'] = flood_max save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] set flood to ["..matches[2].."]") return 'Gp flood has been set to '..matches[2] end if matches[1] == 'clean' then if not is_owner(msg) then return "Only owner can clean" end if matches[2] == 'member' then if not is_owner(msg) then return " sick baw Only admins can clean members" end local receiver = get_receiver(msg) chat_info(receiver, cleanmember, {receiver=receiver}) end if matches[2] == 'modlist' then if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way return 'No mod in this group.' end local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n' for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do data[tostring(msg.to.id)]['moderators'][tostring(k)] = nil save_data(_config.moderation.data, data) end savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned modlist") end if matches[2] == 'rules' then local data_cat = 'rules' data[tostring(msg.to.id)][data_cat] = nil save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned rules") end if matches[2] == 'about' then local data_cat = 'description' data[tostring(msg.to.id)][data_cat] = nil save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned about") end end if matches[1] == 'kill' and matches[2] == 'chat' then if not is_admin(msg) then return nil end if not is_realm(msg) then local receiver = get_receiver(msg) return modrem(msg), print("Closing Group..."), chat_info(receiver, killchat, {receiver=receiver}) else return 'This is already realm' end end if matches[1] == 'kill' and matches[2] == 'realm' then if not is_admin(msg) then return nil end if not is_group(msg) then local receiver = get_receiver(msg) return realmrem(msg), print("Closing Realm..."), chat_info(receiver, killrealm, {receiver=receiver}) else return 'This is a group' end end if matches[1] == 'help' then if not is_momod(msg) or is_realm(msg) then return end savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help") return help() end if matches[1] == 'res' and is_momod(msg) then local cbres_extra = { chatid = msg.to.id } local username = matches[2] local username = username:gsub("@","") savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /res "..username) return res_user(username, callbackres, cbres_extra) end if matches[1] == 'kickinactive' then --send_large_msg('chat#id'..msg.to.id, 'I\'m in matches[1]') if not is_momod(msg) then return 'Only a moderator can kick inactive users' end local num = 1 if matches[2] then num = matches[2] end local chat_id = msg.to.id local receiver = get_receiver(msg) return kick_inactive(chat_id, num, receiver) end end end return { patterns = { "^[!#/](add)$", "^[#!/](add) (r)$", "^[#!/](rem)$", "^[!#/](rem) (realm)$", "^[#!/](rules)$", "^[!#/](about)$", "^[!#/](sname) (.*)$", "^[#!/](sphoto)$", "^[#!/](prom) (.*)$", "^[!#/](prom)", "^[!#/](help)$", "^[!#/](clean) (.*)$", "^[!#/](kill) (chat)$", "^[!#/](kill) (realm)$", "^[!#/](dem) (.*)$", "^[!#/](dem)", "^[!#/](set) ([^%s]+) (.*)$", "^[!#/](lock) (.*)$", "^[!#/](set) (ow) (%d+)$", "^[!#/](set) (ow)", "^[!#/](owner)$", "^[!#/](res) (.*)$", "^[!#/](setgpowner) (%d+) (%d+)$",-- (group id) (owner id) "^[!#/](unlock) (.*)$", "^[!#/](sflood) (%d+)$", "^[!#/](settings)$", -- "^[!/](public) (.*)$", "^[!#/](mlist)$", "^[!#/](newlink)$", "^[!#/](link)$", "^[!#/](kickinactive)$", "^[!#/](kickinactive) (%d+)$", "%[(photo)%]", "^!!tgservice (.+)$", }, run = run } end
gpl-2.0
EShamaev/ardupilot
libraries/AP_Scripting/applets/Aerobatics/FixedWing/plane_aerobatics.lua
1
96881
--[[ trajectory tracking aerobatic control See README.md for usage Written by Matthew Hampsey, Andy Palmer and Andrew Tridgell, with controller assistance from Paul Riseborough, testing by Henry Wurzburg ]]-- -- setup param block for aerobatics, reserving 30 params beginning with AERO_ local PARAM_TABLE_KEY = 70 local PARAM_TABLE_PREFIX = 'AEROM_' assert(param:add_table(PARAM_TABLE_KEY, "AEROM_", 30), 'could not add param table') -- add a parameter and bind it to a variable function bind_add_param(name, idx, default_value) assert(param:add_param(PARAM_TABLE_KEY, idx, name, default_value), string.format('could not add param %s', name)) return Parameter(PARAM_TABLE_PREFIX .. name) end AEROM_ANG_ACCEL = bind_add_param('ANG_ACCEL', 1, 6000) AEROM_ANG_TC = bind_add_param('ANG_TC', 2, 0.1) AEROM_KE_ANG = bind_add_param('KE_ANG', 3, 0) THR_PIT_FF = bind_add_param('THR_PIT_FF', 4, 80) SPD_P = bind_add_param('SPD_P', 5, 5) SPD_I = bind_add_param('SPD_I', 6, 25) ERR_CORR_TC = bind_add_param('ERR_COR_TC', 7, 3) ROLL_CORR_TC = bind_add_param('ROL_COR_TC', 8, 0.25) -- removed 9 and 10 TIME_CORR_P = bind_add_param('TIME_COR_P', 11, 1.0) ERR_CORR_P = bind_add_param('ERR_COR_P', 12, 2.0) ERR_CORR_D = bind_add_param('ERR_COR_D', 13, 2.8) AEROM_ENTRY_RATE = bind_add_param('ENTRY_RATE', 14, 60) AEROM_THR_LKAHD = bind_add_param('THR_LKAHD', 15, 1) AEROM_DEBUG = bind_add_param('DEBUG', 16, 0) AEROM_THR_MIN = bind_add_param('THR_MIN', 17, 0) AEROM_THR_BOOST = bind_add_param('THR_BOOST', 18, 50) AEROM_YAW_ACCEL = bind_add_param('YAW_ACCEL', 19, 1500) AEROM_LKAHD = bind_add_param('LKAHD', 20, 0.5) -- cope with old param values if AEROM_ANG_ACCEL:get() < 100 and AEROM_ANG_ACCEL:get() > 0 then AEROM_ANG_ACCEL:set_and_save(3000) end if AEROM_ANG_TC:get() > 1.0 then AEROM_ANG_TC:set_and_save(0.2) end ACRO_ROLL_RATE = Parameter("ACRO_ROLL_RATE") ARSPD_FBW_MIN = Parameter("ARSPD_FBW_MIN") SCALING_SPEED = Parameter("SCALING_SPEED") local GRAVITY_MSS = 9.80665 --[[ Aerobatic tricks on a switch support - allows for tricks to be initiated outside AUTO mode --]] -- 2nd param table for tricks on a switch local PARAM_TABLE_KEY2 = 71 local PARAM_TABLE_PREFIX2 = "TRIK" assert(param:add_table(PARAM_TABLE_KEY2, PARAM_TABLE_PREFIX2, 63), 'could not add param table2') -- add a parameter and bind it to a variable in table2 function bind_add_param2(name, idx, default_value) assert(param:add_param(PARAM_TABLE_KEY2, idx, name, default_value), string.format('could not add param %s', name)) return Parameter(PARAM_TABLE_PREFIX2 .. name) end local TRIK_ENABLE = bind_add_param2("_ENABLE", 1, 0) local TRICKS = nil local TRIK_SEL_FN = nil local TRIK_ACT_FN = nil local TRIK_COUNT = nil local function TrickDef(id, arg1, arg2, arg3, arg4) local self = {} self.id = id self.args = {arg1, arg2, arg3, arg4} return self end -- constrain a value between limits function constrain(v, vmin, vmax) if v < vmin then v = vmin end if v > vmax then v = vmax end return v end function sq(x) return x*x end if TRIK_ENABLE:get() > 0 then TRIK_SEL_FN = bind_add_param2("_SEL_FN", 2, 301) TRIK_ACT_FN = bind_add_param2("_ACT_FN", 3, 300) TRIK_COUNT = bind_add_param2("_COUNT", 4, 3) TRICKS = {} -- setup parameters for tricks local count = math.floor(constrain(TRIK_COUNT:get(),1,11)) for i = 1, count do local k = 5*i local prefix = string.format("%u", i) TRICKS[i] = TrickDef(bind_add_param2(prefix .. "_ID", k+0, i), bind_add_param2(prefix .. "_ARG1", k+1, 30), bind_add_param2(prefix .. "_ARG2", k+2, 0), bind_add_param2(prefix .. "_ARG3", k+3, 0), bind_add_param2(prefix .. "_ARG4", k+4, 0)) end gcs:send_text(0, string.format("Enabled %u aerobatic tricks", TRIK_COUNT:get())) end local NAV_TAKEOFF = 22 local NAV_WAYPOINT = 16 local NAV_SCRIPT_TIME = 42702 local MODE_AUTO = 10 local LOOP_RATE = 20 local DO_JUMP = 177 local k_throttle = 70 local NAME_FLOAT_RATE = 2 local TRIM_ARSPD_CM = Parameter("TRIM_ARSPD_CM") local last_id = 0 local current_task = nil local last_named_float_t = 0 local path_var = {} function wrap_360(angle) local res = math.fmod(angle, 360.0) if res < 0 then res = res + 360.0 end return res end function wrap_180(angle) local res = wrap_360(angle) if res > 180 then res = res - 360 end return res end function wrap_pi(angle) local angle_deg = math.deg(angle) local angle_wrapped = wrap_180(angle_deg) return math.rad(angle_wrapped) end function wrap_2pi(angle) local angle_deg = math.deg(angle) local angle_wrapped = wrap_360(angle_deg) return math.rad(angle_wrapped) end --[[ calculate an alpha for a first order low pass filter --]] function calc_lowpass_alpha(dt, time_constant) local rc = time_constant/(math.pi*2) return dt/(dt+rc) end -- a PI controller implemented as a Lua object local function PI_controller(kP,kI,iMax,min,max) -- the new instance. You can put public variables inside this self -- declaration if you want to local self = {} -- private fields as locals local _kP = kP or 0.0 local _kI = kI or 0.0 local _kD = kD or 0.0 local _iMax = iMax local _min = min local _max = max local _last_t = nil local _I = 0 local _P = 0 local _total = 0 local _counter = 0 local _target = 0 local _current = 0 -- update the controller. function self.update(target, current) local now = millis():tofloat() * 0.001 if not _last_t then _last_t = now end local dt = now - _last_t _last_t = now local err = target - current _counter = _counter + 1 local P = _kP * err if ((_total < _max and _total > _min) or (_total >= _max and err < 0) or (_total <= _min and err > 0)) then _I = _I + _kI * err * dt end if _iMax then _I = constrain(_I, -_iMax, iMax) end local I = _I local ret = P + I _target = target _current = current _P = P _total = ret return ret end -- reset integrator to an initial value function self.reset(integrator) _I = integrator end function self.set_I(I) _kI = I end function self.set_P(P) _kP = P end function self.set_Imax(Imax) _iMax = Imax end -- log the controller internals function self.log(name, add_total) -- allow for an external addition to total logger.write(name,'Targ,Curr,P,I,Total,Add','ffffff',_target,_current,_P,_I,_total,add_total) end -- return the instance return self end local function speed_controller(kP_param,kI_param, kFF_pitch_param, Imax, min, max) local self = {} local kFF_pitch = kFF_pitch_param local PI = PI_controller(kP_param:get(), kI_param:get(), Imax, min, max) function self.update(target, anticipated_pitch_rad) local current_speed = ahrs:get_velocity_NED():length() local throttle = PI.update(target, current_speed) local FF = math.sin(anticipated_pitch_rad)*kFF_pitch:get() PI.log("AESP", FF) return throttle + FF end function self.reset() PI.reset(0) local temp_throttle = self.update(ahrs:get_velocity_NED():length(), 0) local current_throttle = SRV_Channels:get_output_scaled(k_throttle) PI.reset(current_throttle-temp_throttle) end return self end local speed_PI = speed_controller(SPD_P, SPD_I, THR_PIT_FF, 100.0, 0.0, 100.0) function sgn(x) local eps = 0.000001 if (x > eps) then return 1.0 elseif x < eps then return -1.0 else return 0.0 end end function get_wp_location(i) local m = mission:get_item(i) local loc = Location() loc:lat(m:x()) loc:lng(m:y()) loc:relative_alt(true) loc:terrain_alt(false) loc:origin_alt(false) loc:alt(math.floor(m:z()*100)) return loc end function resolve_jump(i) local m = mission:get_item(i) while m:command() == DO_JUMP do i = math.floor(m:param1()) m = mission:get_item(i) end return i end --[[ Wrapper to construct a Vector3f{x, y, z} from (x, y, z) --]] function makeVector3f(x, y, z) local vec = Vector3f() vec:x(x) vec:y(y) vec:z(z) return vec end --[[ get quaternion rotation between vector1 and vector2 with thanks to https://stackoverflow.com/questions/1171849/finding-quaternion-representing-the-rotation-from-one-vector-to-another --]] function vectors_to_quat_rotation(vector1, vector2) local v1 = vector1:copy() local v2 = vector2:copy() v1:normalize() v2:normalize() local dot = v1:dot(v2) local a = v1:cross(v2) local w = 1.0 + dot local q = Quaternion() q:q1(w) q:q2(a:x()) q:q3(a:y()) q:q4(a:z()) q:normalize() return q end --[[ get path rate from two tangents and delta time --]] function tangents_to_rate(t1, t2, dt) local q_delta = vectors_to_quat_rotation(t1, t2) local rate_rads = Vector3f() q_delta:to_axis_angle(rate_rads) rate_rads = rate_rads:scale(1.0/dt) return rate_rads end --[[ trajectory building blocks. We have two types of building blocks, roll blocks and path blocks. These are combined to give composite paths --]] --[[ all roll components inherit from RollComponent --]] function RollComponent() local self = {} self.name = nil function self.get_roll(t) return 0 end return self end --[[ roll component that goes through a fixed total angle at a fixed roll rate --]] function roll_angle(_angle) local self = RollComponent() self.name = "roll_angle" local angle = _angle function self.get_roll(t) return angle * t end return self end --[[ roll component that banks to _angle over AEROM_ENTRY_RATE degrees/s, then holds that angle, then banks back to zero at AEROM_ENTRY_RATE degrees/s --]] function roll_angle_entry_exit(_angle) local self = RollComponent() self.name = "roll_angle_entry_exit" local angle = _angle local entry_s = math.abs(angle) / AEROM_ENTRY_RATE:get() function self.get_roll(t, time_s) local entry_t = entry_s / time_s if entry_t > 0.5 then entry_t = 0.5 end if t <= 0 then return 0 end if t < entry_t then return angle * t / entry_t end if t < 1.0 - entry_t then return angle end if angle == 0 or t >= 1.0 then return 0 end return (1.0 - ((t - (1.0 - entry_t)) / entry_t)) * angle end return self end --[[ roll component that banks to _angle over AEROM_ENTRY_RATE degrees/s, then holds that angle --]] function roll_angle_entry(_angle) local self = RollComponent() self.name = "roll_angle_entry" local angle = _angle local entry_s = math.abs(angle) / AEROM_ENTRY_RATE:get() function self.get_roll(t, time_s) local entry_t = entry_s / time_s if entry_t > 0.5 then entry_t = 0.5 end if t < entry_t then return angle * t / entry_t end return angle end return self end --[[ roll component that holds angle until the end of the subpath, then rolls back to 0 at the AEROM_ENTRY_RATE --]] function roll_angle_exit(_angle) local self = {} self.name = "roll_angle_exit" local angle = _angle local entry_s = math.abs(angle) / AEROM_ENTRY_RATE:get() function self.get_roll(t, time_s) local entry_t = entry_s / time_s if t < 1.0 - entry_t then return 0 end if angle == 0 then return 0 end return ((t - (1.0 - entry_t)) / entry_t) * angle end return self end --[[ all path components inherit from PathComponent --]] function PathComponent() local self = {} self.name = nil function self.get_pos(t) return makeVector3f(0, 0, 0) end function self.get_length() return 0 end function self.get_final_orientation() return Quaternion() end function self.get_roll_correction(t) return 0 end function self.get_throttle_boost(t) return self.thr_boost or false end return self end --[[ rotate a vector by a quaternion --]] function quat_earth_to_body(quat, v) local v = v:copy() quat:earth_to_body(v) return v end --[[ rotate a vector by a inverse quaternion --]] function quat_body_to_earth(quat, v) local v = v:copy() quat:inverse():earth_to_body(v) return v end --[[ copy a quaternion --]] function quat_copy(q) return q:inverse():inverse() end --[[ path component that does a straight horizontal line --]] function path_straight(_distance) local self = PathComponent() self.name = "path_straight" local distance = _distance function self.get_pos(t) return makeVector3f(distance*t, 0, 0) end function self.get_length() return distance end return self end --[[ path component that does a vertical arc over a given angle --]] function path_vertical_arc(_radius, _angle) local self = PathComponent() self.name = "path_vertical_arc" local radius = _radius local angle = _angle function self.get_pos(t) local t2ang = wrap_2pi(t * math.rad(angle)) return makeVector3f(math.abs(radius)*math.sin(t2ang), 0, -radius*(1.0 - math.cos(t2ang))) end function self.get_length() return math.abs(radius) * 2 * math.pi * math.abs(angle) / 360.0 end function self.get_final_orientation() local q = Quaternion() q:from_axis_angle(makeVector3f(0,1,0), sgn(radius)*math.rad(wrap_180(angle))) q:normalize() return q end return self end --[[ integrate a function, assuming fn takes a time t from 0 to 1 --]] function integrate_length(fn) local total = 0.0 local p = fn(0) for i = 1, 100 do local t = i*0.01 local p2 = fn(t) local dv = p2 - p total = total + dv:length() p = p2 end return total end --[[ path component that does a horizontal arc over a given angle --]] function path_horizontal_arc(_radius, _angle, _height_gain) local self = PathComponent() self.name = "path_horizontal_arc" local radius = _radius local angle = _angle local height_gain = _height_gain if height_gain == nil then height_gain = 0 end function self.get_pos(t) local t2ang = t * math.rad(angle) return makeVector3f(math.abs(radius)*math.sin(t2ang), radius*(1.0 - math.cos(t2ang)), -height_gain*t) end function self.get_length() local circumference = 2 * math.pi * math.abs(radius) local full_circle_height_gain = height_gain * 360.0 / math.abs(angle) local helix_length = math.sqrt(full_circle_height_gain*full_circle_height_gain + circumference*circumference) return helix_length * math.abs(angle) / 360.0 end function self.get_final_orientation() local q = Quaternion() q:from_axis_angle(makeVector3f(0,0,1), sgn(radius)*math.rad(angle)) return q end --[[ roll correction for the rotation caused by height gain --]] function self.get_roll_correction(t) if height_gain == 0 then return 0 end local gamma=math.atan(height_gain*(angle/360)/(2*math.pi*radius)) return -t*360*math.sin(gamma) end return self end --[[ path component that does a cylinder for a barrel roll --]] function path_cylinder(_radius, _length, _num_spirals) local self = PathComponent() self.name = "path_cylinder" local radius = _radius local length = _length local num_spirals = _num_spirals local gamma = math.atan((length/num_spirals)/(2*math.pi*radius)) local qrot = Quaternion() qrot:from_axis_angle(makeVector3f(0,0,1), (0.5*math.pi)-gamma) function self.get_pos(t) local t2ang = t * num_spirals * math.pi * 2 local v = makeVector3f(length*t, math.abs(radius)*math.sin(t2ang+math.pi), -radius*(1.0 - math.cos(t2ang))) return quat_earth_to_body(qrot, v) end function self.get_length() local circumference = 2 * math.pi * math.abs(radius) local length_per_spiral = length / num_spirals local helix_length = math.sqrt(length_per_spiral*length_per_spiral + circumference*circumference) return helix_length * num_spirals end --[[ roll correction for the rotation caused by the path --]] function self.get_roll_correction(t) return t*360*math.sin(gamma)*num_spirals end return self end --[[ a Path has the methods of both RollComponent and PathComponent allowing for a complete description of a subpath --]] function Path(_path_component, _roll_component) local self = {} self.name = string.format("%s|%s", _path_component.name, _roll_component.name) local path_component = _path_component local roll_component = _roll_component function self.get_roll(t, time_s) return wrap_180(roll_component.get_roll(t, time_s)) end function self.get_roll_correction(t) return path_component.get_roll_correction(t) end function self.get_pos(t) return path_component.get_pos(t) end function self.get_speed(t) return nil end function self.get_length() return path_component.get_length() end function self.get_final_orientation() return path_component.get_final_orientation() end function self.get_throttle_boost(t) return self.thr_boost or false end return self end --[[ componse multiple sub-paths together to create a full trajectory --]] function path_composer(_name, _subpaths) local self = {} self.name = _name local subpaths = _subpaths local lengths = {} local proportions = {} local start_time = {} local end_time = {} local start_orientation = {} local start_pos = {} local start_angle = {} local start_roll_correction = {} local end_speed = {} local start_speed = {} local total_length = 0 local num_sub_paths = #subpaths local last_subpath_t = { -1, 0, 0 } local orientation = Quaternion() local pos = makeVector3f(0,0,0) local angle = 0 local roll_correction = 0 local speed = target_groundspeed() local highest_i = 0 local cache_i = -1 local cache_sp = nil local message = nil -- return the subpath with index i. Used to cope with two ways of calling path_composer function self.subpath(i) if i == cache_i then return cache_sp end cache_i = i local sp = subpaths[i] if sp.name then -- we are being called with a list of Path objects cache_sp = sp message = nil else -- we are being called with a list function/argument tuples local args = subpaths[i][2] cache_sp = subpaths[i][1](args[1], args[2], args[3], args[4], start_pos[i], start_orientation[i]) message = subpaths[i].message end return cache_sp end for i = 1, num_sub_paths do -- accumulate orientation, position and angle start_orientation[i] = quat_copy(orientation) start_pos[i] = pos:copy() start_angle[i] = angle start_roll_correction[i] = roll_correction local sp = self.subpath(i) lengths[i] = sp.get_length() total_length = total_length + lengths[i] local spos = quat_earth_to_body(orientation, sp.get_pos(1.0)) pos = pos + spos orientation = sp.get_final_orientation() * orientation orientation:normalize() angle = angle + sp.get_roll(1.0, lengths[i]/speed) roll_correction = roll_correction + sp.get_roll_correction(1.0) start_speed[i] = speed end_speed[i] = sp.get_speed(1.0) if end_speed[i] == nil then end_speed[i] = target_groundspeed() end speed = end_speed[i] if sp.roll_ref ~= nil then local q = Quaternion() q:from_axis_angle(makeVector3f(1,0,0), math.rad(sp.roll_ref)) orientation = orientation * q orientation:normalize() end end -- get our final orientation, including roll local final_orientation = quat_copy(orientation) local q = Quaternion() q:from_axis_angle(makeVector3f(1,0,0), math.rad(wrap_180(angle))) final_orientation = q * final_orientation -- work out the proportion of the total time we will spend in each sub path local total_time = 0 for i = 1, num_sub_paths do proportions[i] = lengths[i] / total_length start_time[i] = total_time end_time[i] = total_time + proportions[i] total_time = total_time + proportions[i] end function self.get_subpath_t(t) if last_subpath_t[1] == t then -- use cached value return last_subpath_t[2], last_subpath_t[3] end local i = 1 while t >= end_time[i] and i < num_sub_paths do i = i + 1 end local subpath_t = (t - start_time[i]) / proportions[i] last_subpath_t = { t, subpath_t, i } local sp = self.subpath(i) if i > highest_i and t < 1.0 and t > 0 then highest_i = i if message ~= nil then gcs:send_text(0, message) end if AEROM_DEBUG:get() > 0 then gcs:send_text(0, string.format("starting %s[%d] %s", self.name, i, sp.name)) end end return subpath_t, i end -- return position at time t function self.get_pos(t) local subpath_t, i = self.get_subpath_t(t) local sp = self.subpath(i) return quat_earth_to_body(start_orientation[i], sp.get_pos(subpath_t)) + start_pos[i] end -- return angle for the composed path at time t function self.get_roll(t, time_s) local subpath_t, i = self.get_subpath_t(t) local speed = self.get_speed(t) if speed == nil then speed = target_groundspeed() end local sp = self.subpath(i) angle = sp.get_roll(subpath_t, lengths[i]/speed) return angle + start_angle[i] end function self.get_roll_correction(t) local subpath_t, i = self.get_subpath_t(t) local sp = self.subpath(i) return sp.get_roll_correction(subpath_t) + start_roll_correction[i] end -- return speed for the composed path at time t function self.get_speed(t) local subpath_t, i = self.get_subpath_t(t) return start_speed[i] + subpath_t * (end_speed[i] - start_speed[i]) end function self.get_length() return total_length end function self.get_final_orientation() return final_orientation end function self.get_throttle_boost(t) local subpath_t, i = self.get_subpath_t(t) local sp = self.subpath(i) return sp.get_throttle_boost(t) end return self end --[[ make a list of Path() objects from a list of PathComponent, RollComponent pairs --]] function make_paths(name, paths) local p = {} for i = 1, #paths do if paths[i][2] == nil then p[i] = paths[i][1] else p[i] = Path(paths[i][1], paths[i][2]) end if paths[i].roll_ref then p[i].roll_ref = paths[i].roll_ref end p[i].thr_boost = paths[i].thr_boost end return path_composer(name, p) end --[[ composed trajectories, does as individual aerobatic maneuvers --]] function climbing_circle(radius, height, bank_angle, arg4) return make_paths("climbing_circle", { { path_horizontal_arc(radius, 360, height), roll_angle_entry_exit(bank_angle) }, }) end function half_climbing_circle(radius, height, bank_angle, arg4) return make_paths("half_climbing_circle", { { path_horizontal_arc(radius, 180, height), roll_angle_entry_exit(bank_angle) }, }) end function partial_circle(radius, bank_angle, angle) return make_paths("partial_circle", { { path_horizontal_arc(radius, angle, 0), roll_angle_entry_exit(bank_angle) }, }) end function loop(radius, bank_angle, num_loops, arg4) if not num_loops or num_loops <= 0 then num_loops = 1 end return make_paths("loop", { { path_vertical_arc(radius, 360*num_loops), roll_angle_entry_exit(bank_angle) }, }) end function straight_roll(length, num_rolls, arg3, arg4) return make_paths("straight_roll", { { path_straight(length), roll_angle(num_rolls*360) }, }) end --[[ fly straight until we are distance meters from the composite path origin in the maneuver frame along the X axis. If we are already past that position then return immediately --]] function straight_align(distance, arg2, arg3, arg4, start_pos, start_orientation) local d2 = distance - start_pos:x() local v = quat_earth_to_body(start_orientation, makeVector3f(d2, 0, 0)) local len = math.max(v:x(),0.01) return make_paths("straight_align", { { path_straight(len), roll_angle(0) }, }) end function immelmann_turn(r, arg2, arg3, arg4) local rabs = math.abs(r) return make_paths("immelmann_turn", { { path_vertical_arc(r, 180), roll_angle(0) }, { path_straight(rabs/2), roll_angle(180) }, }) end -- immelmann with max roll rate function immelmann_turn_fast(r, arg2, arg3, arg4) local rabs = math.abs(r) local roll_time = 180.0 / ACRO_ROLL_RATE:get() local roll_dist = target_groundspeed() * roll_time return make_paths("immelmann_turn_fast", { { path_vertical_arc(r, 180), roll_angle(0) }, { path_straight(roll_dist), roll_angle(180) }, }) end function humpty_bump(r, h, arg3, arg4) assert(h >= 2*r) local rabs = math.abs(r) return make_paths("humpty_bump", { { path_vertical_arc(r, 90), roll_angle(0) }, { path_straight((h-2*rabs)/3), roll_angle(0) }, { path_straight((h-2*rabs)/3), roll_angle(180) }, { path_straight((h-2*rabs)/3), roll_angle(0) }, { path_vertical_arc(-r, 180), roll_angle(0) }, { path_straight(h-2*rabs), roll_angle(0) }, { path_vertical_arc(-r, 90), roll_angle(0) }, { path_straight(2*rabs), roll_angle(0) }, }) end function crossbox_humpty(r, h, arg3, arg4) assert(h >= 2*r) local rabs = math.abs(r) return make_paths("crossbox_humpty", { { path_vertical_arc(r, 90), roll_angle(0) }, { path_straight((h-2*rabs)/3), roll_angle(0) }, { path_straight((h-2*rabs)/3), roll_angle(90), roll_ref=90 }, { path_straight((h-2*rabs)/3), roll_angle(0) }, { path_vertical_arc(-r, 180), roll_angle(0) }, { path_straight((h-2*rabs)/3), roll_angle(0) }, { path_straight((h-2*rabs)/3), roll_angle(90), roll_ref=-90 }, { path_straight((h-2*rabs)/3), roll_angle(0) }, { path_vertical_arc(r, 90), roll_angle(0), roll_ref=180 }, }) end function laydown_humpty(r, h, arg3, arg4) assert(h >= 2*r) local rabs = math.abs(r) return make_paths("laydown_humpty", { { path_vertical_arc(r, 45), roll_angle(0) }, { path_straight((h-2*rabs)/3), roll_angle(0) }, { path_straight((h-2*rabs)/3), roll_angle(-90), roll_ref=90 }, { path_straight((h-2*rabs)/3), roll_angle(0) }, { path_vertical_arc(r, 180), roll_angle(0) }, { path_straight((h-2*rabs)/3), roll_angle(0) }, { path_straight((h-2*rabs)/3), roll_angle(90), roll_ref=-90 }, { path_straight((h-2*rabs)/3), roll_angle(0) }, { path_vertical_arc(-r, 45), roll_angle(0), roll_ref=180}, }) end function split_s(r, arg2, arg3, arg4) local rabs = math.abs(r) return make_paths("split_s", { { path_straight(rabs/2), roll_angle(180) }, { path_vertical_arc(-r, 180), roll_angle(0) }, }) end function upline_45(r, height_gain, arg3, arg4) --local h = (height_gain - 2*r*(1.0-math.cos(math.rad(45))))/math.sin(math.rad(45)) local h = (height_gain - (2 * r) + (2 * r * math.cos(math.rad(45)))) / math.cos(math.rad(45)) assert(h >= 0) return make_paths("upline_45", { { path_vertical_arc(r, 45), roll_angle(0) }, { path_straight(h), roll_angle(0) }, { path_vertical_arc(-r, 45), roll_angle(0) }, }) end function upline_20(r, height_gain, arg3, arg4) local h = (height_gain - 2*r*(1.0-math.cos(math.rad(20))))/math.sin(math.rad(20)) assert(h >= 0) return make_paths("upline_45", { { path_vertical_arc(r, 20), roll_angle(0) }, { path_straight(h), roll_angle(0) }, { path_vertical_arc(-r, 20), roll_angle(0) }, }) end function downline_45(r, height_loss, arg3, arg4) local h = (height_loss - 2*r*(1.0-math.cos(math.rad(45))))/math.sin(math.rad(45)) assert(h >= 0) return make_paths("downline_45", { { path_vertical_arc(-r, 45), roll_angle(0) }, { path_straight(h), roll_angle(0) }, { path_vertical_arc(r, 45), roll_angle(0) }, }) end function rolling_circle(radius, num_rolls, arg3, arg4) return make_paths("rolling_circle", { { path_horizontal_arc(radius, 360), roll_angle(360*num_rolls), thr_boost=true }, }) end function cylinder(radius, length, num_spirals, arg4) return make_paths("cylinder", { { path_cylinder(radius, length, num_spirals), roll_angle(0), thr_boost=true }, }) end function barrel_roll(radius, length, num_spirals, arg4) local gamma_deg = math.deg(math.atan((length/num_spirals)/(2*math.pi*radius))) local speed = target_groundspeed() local bank = math.deg(math.atan((speed*speed) / (radius * GRAVITY_MSS))) return make_paths("barrel_roll", { { path_horizontal_arc(-radius, 90-gamma_deg, 0), roll_angle_entry_exit(-bank) }, { path_cylinder(radius, length, num_spirals), roll_angle(0) }, { path_horizontal_arc(radius, 90-gamma_deg, 0), roll_angle_entry_exit(bank) }, }) end function straight_flight(length, bank_angle, arg3, arg4) return make_paths("straight_flight", { { path_straight(length), roll_angle_entry_exit(bank_angle) }, }) end function straight_hold(length, bank_angle, arg3, arg4) return make_paths("straight_hold", { { path_straight(length), roll_angle_entry(bank_angle) }, }) end function scale_figure_eight(r, bank_angle, arg3, arg4) local rabs = math.abs(r) return make_paths("scale_figure_eight", { { path_straight(rabs), roll_angle(0) }, { path_horizontal_arc(r, 90), roll_angle_entry_exit(bank_angle) }, { path_horizontal_arc(-r, 360), roll_angle_entry_exit(-bank_angle) }, { path_horizontal_arc(r, 270), roll_angle_entry_exit(bank_angle) }, { path_straight(3*rabs), roll_angle(0) }, }) end function figure_eight(r, bank_angle, arg3, arg4) local rabs = math.abs(r) return make_paths("figure_eight", { { path_straight(rabs*math.sqrt(2)), roll_angle(0) }, { path_horizontal_arc(r, 225), roll_angle_entry_exit(bank_angle) }, { path_straight(2*rabs), roll_angle(0) }, { path_horizontal_arc(-r, 270), roll_angle_entry_exit(-bank_angle) }, { path_straight(2*rabs), roll_angle(0) }, { path_horizontal_arc(r, 45), roll_angle_entry_exit(bank_angle) }, }) end --[[ stall turn is not really correct, as we don't fully stall. Needs to be reworked --]] function stall_turn(radius, height, direction, min_speed) local h = height - radius assert(h >= 0) return make_paths("stall_turn", { { path_vertical_arc(radius, 90), roll_angle(0) }, { path_straight(h), roll_angle(0), min_speed }, { path_horizontal_arc(5*direction, 180), roll_angle(0), min_speed }, { path_straight(h), roll_angle(0) }, { path_vertical_arc(radius, 90), roll_angle(0) }, }) end function half_cuban_eight(r, arg2, arg3, arg4) local rabs = math.abs(r) return make_paths("half_cuban_eight", { { path_straight(2*rabs*math.sqrt(2)), roll_angle(0) }, { path_vertical_arc(r, 225), roll_angle(0) }, { path_straight(2*rabs/3), roll_angle(0) }, { path_straight(2*rabs/3), roll_angle(180) }, { path_straight(2*rabs/3), roll_angle(0) }, { path_vertical_arc(-r, 45), roll_angle(0) }, }) end function cuban_eight(r, arg2, arg3, arg4) local rabs = math.abs(r) return make_paths("cuban_eight", { { path_straight(rabs*math.sqrt(2)), roll_angle(0) }, { path_vertical_arc(r, 225), roll_angle(0) }, { path_straight(2*rabs/3), roll_angle(0) }, { path_straight(2*rabs/3), roll_angle(180) }, { path_straight(2*rabs/3), roll_angle(0) }, { path_vertical_arc(-r, 270), roll_angle(0) }, { path_straight(2*rabs/3), roll_angle(0) }, { path_straight(2*rabs/3), roll_angle(180) }, { path_straight(2*rabs/3), roll_angle(0) }, { path_vertical_arc(r, 45), roll_angle(0) }, }) end function half_reverse_cuban_eight(r, arg2, arg3, arg4) local rabs = math.abs(r) return make_paths("half_reverse_cuban_eight", { { path_vertical_arc(r, 45), roll_angle(0) }, { path_straight(2*rabs/3), roll_angle(0) }, { path_straight(2*rabs/3), roll_angle(180) }, { path_straight(2*rabs/3), roll_angle(0) }, { path_vertical_arc(-r, 225), roll_angle(0) }, }) end function horizontal_rectangle(total_length, total_width, r, bank_angle) local l = total_length - 2*r local w = total_width - 2*r return make_paths("horizontal_rectangle", { { path_straight(0.5*l), roll_angle(0) }, { path_horizontal_arc(r, 90), roll_angle_entry_exit(bank_angle)}, { path_straight(w), roll_angle(0) }, { path_horizontal_arc(r, 90), roll_angle_entry_exit(bank_angle) }, { path_straight(l), roll_angle(0) }, { path_horizontal_arc(r, 90), roll_angle_entry_exit(bank_angle) }, { path_straight(w), roll_angle(0) }, { path_horizontal_arc(r, 90), roll_angle_entry_exit(bank_angle) }, { path_straight(0.5*l), roll_angle(0) }, }) end function vertical_aerobatic_box(total_length, total_width, r, bank_angle) local l = total_length - 2*r local w = total_width - 2*r return make_paths("vertical_aerobatic_box", { { path_straight(0.5*l), roll_angle_entry(bank_angle) }, { path_vertical_arc(r, 90), roll_angle(0) }, { path_straight(w), roll_angle(0) }, { path_vertical_arc(r, 90), roll_angle(0) }, { path_straight(l), roll_angle(0) }, { path_vertical_arc(r, 90), roll_angle(0) }, { path_straight(w), roll_angle(0) }, { path_vertical_arc(r, 90), roll_angle(0) }, { path_straight(0.5*l), roll_angle_exit(-bank_angle) }, }) end function multi_point_roll(length, N, arg3, arg4) local paths = {} local len_roll = length * (N-1) / (N*4-1) local len_hold = length / (N*4-1) local ang = 360 / N for i = 1, N do paths[#paths+1] = { path_straight(len_roll), roll_angle(ang) } paths[#paths+1] = { path_straight(len_hold), roll_angle(0) } end return make_paths("multi_point_roll", paths) end function two_point_roll(length, arg2, arg3, arg4) return multi_point_roll(length, 2) end function four_point_roll(length, arg2, arg3, arg4) return multi_point_roll(length, 4) end function eight_point_roll(length, arg2, arg3, arg4) return multi_point_roll(length, 8) end function procedure_turn(radius, bank_angle, step_out, arg4) local rabs = math.abs(radius) return make_paths("procedure_turn", { { path_straight(rabs), roll_angle(0) }, { path_horizontal_arc(radius, 90), roll_angle_entry_exit(bank_angle) }, { path_straight(step_out), roll_angle(0) }, { path_horizontal_arc(-radius, 270), roll_angle_entry_exit(-bank_angle) }, { path_straight(4*rabs), roll_angle(0) }, }) end function derry_turn(radius, bank_angle, arg3, arg4) return make_paths("derry_turn", { { path_horizontal_arc(radius, 90), roll_angle_entry_exit(bank_angle) }, { path_horizontal_arc(-radius, 90), roll_angle_entry_exit(-bank_angle) }, }) end function p23_1(radius, height, width, arg4) -- top hat return make_paths("p23_1", { { path_vertical_arc(radius, 90), roll_angle(0) }, { path_straight((height-2*radius)*2/9), roll_angle(0) }, { path_straight((height-2*radius)*2/9), roll_angle(90) }, { path_straight((height-2*radius)/9), roll_angle(0) }, { path_straight((height-2*radius)*2/9), roll_angle(90) }, { path_straight((height-2*radius)*2/9), roll_angle(0) }, { path_vertical_arc(-radius, 90), roll_angle(0) }, { path_straight((width-2*radius)/3), roll_angle(0) }, { path_straight((width-2*radius)/3), roll_angle(180) }, { path_straight((width-2*radius)/3), roll_angle(0) }, { path_vertical_arc(-radius, 90), roll_angle(0) }, { path_straight((height-2*radius)*2/9), roll_angle(0) }, { path_straight((height-2*radius)*2/9), roll_angle(90) }, { path_straight((height-2*radius)/9), roll_angle(0) }, { path_straight((height-2*radius)*2/9), roll_angle(90) }, { path_straight((height-2*radius)*2/9), roll_angle(0) }, { path_vertical_arc(radius, 90), roll_angle(0) }, }) end function p23_2(radius, height, arg3, arg4) -- half square return make_paths("p23_2", { { path_vertical_arc(-radius, 90), roll_angle(0) }, { path_straight((height-2*radius)/3), roll_angle(0) }, { path_straight((height-2*radius)/3), roll_angle(180) }, { path_straight((height-2*radius)/3), roll_angle(0) }, { path_vertical_arc(-radius, 90), roll_angle(0) }, }) end function p23_3(radius, height, arg3, arg4) -- humpty return make_paths("p23_3", { { path_vertical_arc(radius, 90), roll_angle(0) }, { path_straight((height-2*radius)/8), roll_angle(0) }, { path_straight((height-2*radius)*6/8), roll_angle(360) }, { path_straight((height-2*radius)/8), roll_angle(0) }, { path_vertical_arc(radius, 180), roll_angle(0) }, { path_straight((height-2*radius)/3), roll_angle(0) }, { path_straight((height-2*radius)/3), roll_angle(180) }, { path_straight((height-2*radius)/3), roll_angle(0) }, { path_vertical_arc(radius, 90), roll_angle(0) }, }) end function p23_4(radius, height, arg3, arg4) -- on corner local l = ((height - (2 * radius)) * math.sin(math.rad(45))) return make_paths("p23_4", { { path_vertical_arc(-radius, 45), roll_angle(0) }, { path_straight(l/3), roll_angle(0) }, { path_straight(l/3), roll_angle(180) }, { path_straight(l/3), roll_angle(0) }, { path_vertical_arc(-radius, 90), roll_angle(0) }, { path_straight(l/3), roll_angle(0) }, { path_straight(l/3), roll_angle(180) }, { path_straight(l/3), roll_angle(0) }, { path_vertical_arc(-radius, 45), roll_angle(0) }, }) end function p23_5(radius, height_gain, arg3, arg4) -- 45 up - should be 1 1/2 snaps.... --local l = (height_gain - 2*radius*(1.0-math.cos(math.rad(45))))/math.sin(math.rad(45)) local l = (height_gain - (2 * radius) + (2 * radius * math.cos(math.rad(45)))) / math.cos(math.rad(45)) return make_paths("p23_5", { { path_vertical_arc(-radius, 45), roll_angle(0) }, { path_straight(l/3), roll_angle(0) }, { path_straight(l/3), roll_angle(540) }, { path_straight(l/3), roll_angle(0) }, { path_vertical_arc(radius, 45), roll_angle(0) }, }) end function p23_6(radius, height_gain, arg3, arg4) -- 3 sided local l = (height_gain - 2*radius) / ((2*math.sin(math.rad(45))) + 1) return make_paths("p23_6", { { path_vertical_arc(-radius, 45), roll_angle(0) }, { path_straight(l), roll_angle(0) }, { path_vertical_arc(-radius, 45), roll_angle(0) }, { path_straight(l), roll_angle(0) }, { path_vertical_arc(-radius, 45), roll_angle(0) }, { path_straight(l), roll_angle(0) }, { path_vertical_arc(-radius, 45), roll_angle(0) }, }) end function p23_7(length, arg2, arg3, arg4) -- roll combination return make_paths("p23_7", { { path_straight(length*5/22), roll_angle(180) }, { path_straight(length*1/22), roll_angle(0) }, { path_straight(length*5/22), roll_angle(180) }, { path_straight(length*5/22), roll_angle(-180) }, { path_straight(length*1/22), roll_angle(0) }, { path_straight(length*5/22), roll_angle(-180) }, }) end function p23_8(radius, height, arg3, arg4) -- immelmann return make_paths("p23_8", { { path_vertical_arc(-radius, 180), roll_angle(0) }, { path_straight(radius/2), roll_angle(180) }, }) end function p23_9(radius, height, num_turns, arg4) -- spin (currently a vert down 1/2 roll) return make_paths("p23_9", { { path_vertical_arc(radius, 90), roll_angle(0) }, { path_straight(height-2*radius), roll_angle(180) }, { path_vertical_arc(-radius, 90), roll_angle(0) }, }) end function p23_10(radius, height, arg3, arg4) -- humpty return make_paths("p23_10", { { path_vertical_arc(radius, 90), roll_angle(0) }, { path_straight((height-2*radius)/3), roll_angle(0) }, { path_straight((height-2*radius)/3), roll_angle(180) }, { path_straight((height-2*radius)/3), roll_angle(0) }, { path_vertical_arc(-radius, 180), roll_angle(0) }, { path_straight((height-2*radius)/3), roll_angle(0) }, { path_straight((height-2*radius)/3), roll_angle(180) }, { path_straight((height-2*radius)/3), roll_angle(0) }, { path_vertical_arc(-radius, 90), roll_angle(0) }, }) end function p23_11(radius, height, arg3, arg4) -- laydown loop local rabs = math.abs(radius) local vert_length = height - (2 * rabs) local angle_length = ((2 * rabs) - (2 * (rabs - (rabs * (math.cos(math.rad(45))))))) / math.sin(math.rad(45)) return make_paths("p23_11", { { path_vertical_arc(-radius, 45), roll_angle(0) }, { path_straight(angle_length*2/6), roll_angle(0) }, { path_straight(angle_length*1/6), roll_angle(180) }, { path_straight(angle_length*1/6), roll_angle(-180) }, { path_straight(angle_length*2/6), roll_angle(0) }, { path_vertical_arc(radius, 315), roll_angle(0) }, { path_straight(vert_length*2/9), roll_angle(0) }, { path_straight(vert_length*2/9), roll_angle(90) }, { path_straight(vert_length*1/9), roll_angle(0) }, { path_straight(vert_length*2/9), roll_angle(90) }, { path_straight(vert_length*2/9), roll_angle(0) }, { path_vertical_arc(radius, 90), roll_angle(0) }, }) end function p23_12(radius, height, arg3, arg4) -- 1/2 square return make_paths("p23_12", { { path_vertical_arc(-radius, 90), roll_angle(0) }, { path_straight((height-2*radius)/3), roll_angle(0) }, { path_straight((height-2*radius)/3), roll_angle(180) }, { path_straight((height-2*radius)/3), roll_angle(0) }, { path_vertical_arc(-radius, 90), roll_angle(0) }, }) end function p23_13(radius, height, arg3, arg4) -- stall turn return make_paths("p23_13", { { path_vertical_arc(radius, 90), roll_angle(0) }, { path_straight((height-2*radius)/3), roll_angle(0) }, { path_straight((height-2*radius)/3), roll_angle(90) }, { path_straight((height-2*radius)/3), roll_angle(0) }, { path_vertical_arc(-radius, 90), roll_angle(0) }, { path_straight((height-2*radius)/3), roll_angle(0) }, { path_straight((height-2*radius)/3), roll_angle(90) }, { path_straight((height-2*radius)/3), roll_angle(0) }, { path_vertical_arc(-radius, 90), roll_angle(0) }, }) end function p23_13a(radius, height, arg3, arg4) -- stall turn PLACE HOLDER assert(height >= 2*radius) local rabs = math.abs(radius) return make_paths("P23_13a", { { path_vertical_arc(radius, 90), roll_angle(0) }, { path_straight((height-2*rabs)/3), roll_angle(0) }, { path_straight((height-2*rabs)/3), roll_angle(90), roll_ref=90 }, { path_straight((height-2*rabs)/3), roll_angle(0) }, { path_vertical_arc(-radius, 180), roll_angle(0) }, { path_straight((height-2*rabs)/3), roll_angle(0) }, { path_straight((height-2*rabs)/3), roll_angle(90), roll_ref=-90 }, { path_straight((height-2*rabs)/3), roll_angle(0) }, { path_vertical_arc(radius, 90), roll_angle(0), roll_ref=180 }, }) end function p23_14(r, h, arg3, arg4) -- fighter turn assert(h >= 2*r) local rabs = math.abs(r) local angle_length = (h - ((0.2929 * rabs)) / (math.sin(math.rad(45)))) - rabs return make_paths("fighter_turn", { { path_vertical_arc(r, 45), roll_angle(0) }, { path_straight((angle_length)/3), roll_angle(0) }, { path_straight((angle_length)/3), roll_angle(-90), roll_ref=90 }, { path_straight((angle_length)/3), roll_angle(0) }, { path_vertical_arc(r, 180), roll_angle(0) }, { path_straight((angle_length)/3), roll_angle(0) }, { path_straight((angle_length)/3), roll_angle(90), roll_ref=-90 }, { path_straight((angle_length)/3), roll_angle(0) }, { path_vertical_arc(-r, 45), roll_angle(0), roll_ref=180 }, }) end function p23_15(radius, height, arg3, arg4) -- triangle local h1 = radius * math.sin(math.rad(45)) local h2 = (2 * radius) - (radius * math.cos(math.rad(45))) local h3 = height - (2 * radius) local side = h3 / math.cos(math.rad(45)) --local base = (h3 + (2 * (radius - radius * math.cos(math.rad(45))))) - (2 * radius) local base = (2 * (h3 + radius)) - 2 * radius return make_paths("p23_15", { { path_straight(base * 1/5), roll_angle(180) }, { path_straight(base * 2/5), roll_angle(0) }, { path_vertical_arc(radius, 135) , roll_angle(0) }, { path_straight(side*2/9), roll_angle(0) }, { path_straight(side*2/9), roll_angle(90) }, { path_straight(side*1/9), roll_angle(0) }, { path_straight(side*2/9), roll_angle(90) }, { path_straight(side*2/9), roll_angle(0) }, { path_vertical_arc(radius, 90), roll_angle(0) }, { path_straight(side*2/9), roll_angle(0) }, { path_straight(side*2/9), roll_angle(90) }, { path_straight(side*1/9), roll_angle(0) }, { path_straight(side*2/9), roll_angle(90) }, { path_straight(side*2/9), roll_angle(0) }, { path_vertical_arc(radius, 135), roll_angle(0) }, { path_straight(base * 2/5), roll_angle(0) }, { path_straight(base * 1/5), roll_angle(180) }, { path_straight(base * 2/5), roll_angle(0) }, }) end function p23_16(radius, height, arg3, arg4) -- sharks tooth local angle_length = (height - 2 * (radius - (radius * math.cos(math.rad(45))))) / math.cos(math.rad(45)) local vert_length = height - (2 * radius) return make_paths("p23_16", { { path_vertical_arc(radius, 90), roll_angle(0) }, { path_straight((vert_length)/3), roll_angle(0) }, { path_straight((vert_length)/3), roll_angle(180) }, { path_straight((vert_length)/3), roll_angle(0) }, { path_vertical_arc(radius, 135), roll_angle(0) }, { path_straight(angle_length*2/9), roll_angle(0) }, { path_straight(angle_length*2/9), roll_angle(90) }, { path_straight(angle_length*1/9), roll_angle(0) }, { path_straight(angle_length*2/9), roll_angle(90) }, { path_straight(angle_length*2/9), roll_angle(0) }, { path_vertical_arc(-radius, 45), roll_angle(0), roll_ref=180 }, }) end function p23_17(radius, arg2, arg3, arg4) -- loop return make_paths("p23_17", { { path_vertical_arc(radius, 135), roll_angle(0) }, { path_vertical_arc(radius, 90), roll_angle(180) }, { path_vertical_arc(radius, 135), roll_angle(0), roll_ref=180 }, }) end function half_roll(arg1, arg2, arg3, arg4) -- half roll for testing inverted manouvers return make_paths("half_roll", { { path_straight(40), roll_angle(180) }, { path_straight(10), roll_angle(0) }, }) end function fai_f3a_box_l_r() return path_composer("f3a_box_l_r", { -- positioned for a flight line 150m out. Flight line 520m total length. -- Script start point is ON CENTER, with the model heading DOWNWIND! { straight_roll, { 150, 0 } }, { half_reverse_cuban_eight, { 95 } }, { straight_align, { 0, 0 } }, { vertical_aerobatic_box, { 540, 190, 45, 0 }, message="Starting Box Demo"}, { vertical_aerobatic_box, { 540, 190, 45, 0 } }, { vertical_aerobatic_box, { 540, 190, 45, 0 } }, { vertical_aerobatic_box, { 540, 190, 45, 0 } }, { straight_roll, { 50, 0 } } }) end --[[ NZ clubman schedule --]] function nz_clubman() -- positioned for a flight line 100m out -- Script start point is ON CENTER, with the model heading DOWNWIND! return path_composer("nz_clubman_l_r", { --[[ { straight_roll, { 20, 0 } }, { procedure_turn, { 20, 45, 60 } }, { straight_roll, { 150, 0 } }, { half_reverse_cuban_eight, { 40 } }, { straight_roll, { 150, 0 } }, --]] { straight_roll, { 150, 0 } }, { half_reverse_cuban_eight, { 90 } }, { straight_align, { 0, 0 } }, { cuban_eight, { 90 }, message="Cuban Eight"}, { straight_align, { -100, 0 } }, { half_reverse_cuban_eight, { 90 } }, { straight_align, { 40, 0 } }, { half_reverse_cuban_eight, { 90 }, message="Half Rev Cuban"}, { straight_align, { -180, 0 } }, { half_reverse_cuban_eight, { 90 } }, { straight_align, { -120, 0 } }, { two_point_roll, { 240 }, message="Two Point Roll"}, { straight_align, { 150, 0 } }, { half_reverse_cuban_eight, { 90 } }, { straight_align, { 106, 0 } }, { upline_45, { 40, 180 }, message="45 Upline"}, { straight_align, { -180, 0 } }, -- missing the stall turn { split_s, { 90, 90 } }, { straight_align, { -120, 0 } }, { straight_roll, { 240, 1 }, message="Slow Roll"}, { straight_align, { 150, 0 } }, { half_cuban_eight, { 90 } }, { straight_align, { 0, 0 } }, { loop, { 90, 0, 2 }, message="Two Loops"}, { straight_align, { -180, 0 } }, { immelmann_turn, { 90, 90 } }, { straight_align, { -106, 0 } }, { downline_45, { 40, 180 }, message="45 Downline"}, { straight_align, { 150, 0 } }, { half_cuban_eight, { 90 } }, { straight_roll, { 100, 0 } }, }) end --[[ F3A p23, preliminary schedule 2023 --]] function f3a_p23_l_r() return path_composer("f3a_p23_l_r", { -- positioned for a flight line 150m out. Flight line 520m total length. -- Script start point is ON CENTER, with the model heading DOWNWIND! { straight_roll, { 160, 0 } }, { half_reverse_cuban_eight, { 80 } }, { straight_align, { 140, 0 } }, { p23_1, { 40, 200, 200 }, message="Top Hat"}, { straight_align, { -220, 0 } }, { p23_2, { 40, 200 }, message="Half Square Loop"}, { straight_align, { 0, 0 } }, { p23_3, { 40, 200 }, message="Humpty"}, { straight_align, { 160, 0 } }, { p23_4, { 40, 200 }, message="Half Square on Corner"}, { straight_align, { 116, 0 } }, { p23_5, { 40, 200 }, message="45 Up"}, -- snap roll { straight_align, { -185, 0 } }, { p23_6, { 40, 200 }, message="Half Eight Sided Loop"}, { straight_align, { -100, 0 } }, { p23_7, { 200 }, message="Roll Combination"}, { straight_align, { 160, 0 } }, { p23_8, { 100 }, message="Immelmann Turn"}, { straight_align, { 40, 0 } }, { p23_9, { 40, 200 }, message="Should be a Spin"}, -- spin { straight_align, { -140, 0 } }, { p23_10, { 40, 200 }, message="Humpty"}, { straight_align, { -91, 0 } }, { p23_11, { 50, 200 }, message="Laydown Loop"}, { straight_align, { 220, 0 } }, { p23_12, { 40, 200 }, message="Half Square Loop"}, { straight_align, { 40, 0 } }, { p23_13a, { 40, 200 }, message="Stall Turn"}, -- stall turn { straight_roll, { 100, 0 } }, { p23_14, { 40, 180 }, message="Fighter Turn"}, { straight_align, { -24, 0 } }, { p23_15, { 40, 200 }, message="Triangle"}, { straight_align, { 220, 0 } }, { p23_16, { 40, 160 }, message="Sharks Tooth"}, { straight_align, { 0, 0 } }, { p23_17, { 100 }, message="Loop"}, { straight_roll, { 100, 0 } }, }) end --[[ F4C Scale Schedule Example --]] function f4c_example_l_r() -- positioned for a flight line nominally 150m out (some manouvers start 30m out) -- Script start point is ON CENTER @ 150m, with the model heading DOWNWIND ie flying Right to Left! return path_composer("f4c_example", { { straight_roll, { 320, 0 } }, { half_climbing_circle, { -70, 0, -60 } }, -- come in close for the first two manouvers --{ straight_roll, { 10, 0 } }, { straight_align, { 280, 0 } }, { scale_figure_eight, { -140, -30 }, message="Scale Figure Eight"}, { straight_roll, { 80, 0 } }, { immelmann_turn, { 90 } }, { straight_align, { 0, 0 } }, --{ straight_roll, { 340, 0 } }, { climbing_circle, { 140, -205, 30 }, message="Descending 360"}, { straight_roll, { 40, 0 } }, { upline_20, { 80, 25 } }, -- Climb up 25m to base height { straight_roll, { 50, 0 } }, { half_climbing_circle, { 70, 0, 60 } }, -- Go back out to 150m { straight_align, { 0, 0 } }, { loop, { 90, 0, 1 }, message="Loop"}, { straight_align, { -50, 0 } }, { half_reverse_cuban_eight, { 90 } }, { straight_align, { 0, 0 } }, { immelmann_turn, { 90 }, message="Immelmann Turn"}, { straight_align, { -140, 0 } }, { split_s, { 90 } }, { straight_align, { 0, 0 } }, { half_cuban_eight, { 90 }, message="Half Cuban Eight"}, { straight_align, { -180, 0 } }, { half_climbing_circle, { 70, 0, 60 } }, --{ straight_roll, { 115, 0 } }, { straight_align, { -90, 0 } }, { derry_turn, { 90, 60 }, message="Derry Turn"}, { straight_roll, { 200, 0 } }, { half_climbing_circle, { -90, 0, -60 } }, { straight_align, { 0, 0 } }, { climbing_circle, { -140, 0, -30 }, message="Gear Demo"}, { straight_roll, { 250, 0 } }, { half_climbing_circle, { -100, 0, -60 } }, { straight_align, { -185, 0 } }, { barrel_roll, { 90, 240, 1 }, message="Barrel Roll"}, { straight_roll, { 60, 0 } }, { half_reverse_cuban_eight, { 90 }}, { straight_roll, { 60, 0 } }, }) end --[[ simple air show --]] function air_show1() return path_composer("AirShow", { { loop, { 25, 0, 1 }, message="Loop"}, { straight_align, { 80, 0 } }, { half_reverse_cuban_eight, { 25 }, message="HalfReverseCubanEight" }, { straight_align, { 80 } }, { scale_figure_eight, { -40, -45 }, message="ScaleFigureEight" }, { immelmann_turn, { 30 }, message="Immelmann" }, { straight_align, { -40, 0 } }, { straight_roll, { 80, 2 }, message="Roll" }, { straight_align, { 120, 0 } }, { split_s, { 30 }, message="Split-S"}, { straight_align, { 0 } }, { rolling_circle, { -50, 3}, message="RollingCircle" }, { straight_align, { -50, 0 } }, { humpty_bump, { 20, 60 }, message="HumptyBump" }, { straight_align, { 80, 0 } }, { half_cuban_eight, { 25 }, message="HalfCubanEight" }, { straight_align, { 75, 0 } }, { upline_45, { 30, 50 }, message="Upline45", }, { downline_45, { 30, 50 }, message="Downline45" }, { half_reverse_cuban_eight, { 25 }, message="HalfReverseCubanEight" }, { straight_align, { 0 } }, }) end function air_show3() return path_composer("AirShow3", { { air_show1, {}, message="AirShowPt1" }, { air_show1, {}, message="AirShowPt2" }, { air_show1, {}, message="AirShowPt3" }, }) end function test_all_paths() return path_composer("test_all_paths", { { figure_eight, { 100, 45 } }, { straight_roll, { 20, 0 } }, { loop, { 30, 0, 1 } }, { straight_roll, { 20, 0 } }, { horizontal_rectangle, { 100, 100, 20, 45 } }, { straight_roll, { 20, 0 } }, { climbing_circle, { 100, 20, 45 } }, { straight_roll, { 20, 0 } }, { vertical_aerobatic_box, { 100, 100, 20, 0 } }, { straight_roll, { 20, 0 } }, { rolling_circle, { 100, 2, 0, 0 } }, { straight_roll, { 20, 0 } }, { half_cuban_eight, { 30, } }, { straight_roll, { 20, 0 } }, { half_reverse_cuban_eight, { 30, } }, { straight_roll, { 20, 0 } }, { cuban_eight, { 30, } }, { straight_roll, { 20, 0 } }, { humpty_bump, { 30, 100 } }, { straight_flight, { 100, 45 } }, { scale_figure_eight, { 100, 45 } }, { straight_roll, { 20, 0 } }, { immelmann_turn, { 30, 60 } }, { straight_roll, { 20, 0 } }, { split_s, { 30, 60 } }, { straight_roll, { 20, 0 } }, { upline_45, { 20, 50 } }, { straight_roll, { 20, 0 } }, { downline_45, { 20, 50 } }, { straight_roll, { 20, 0 } }, { procedure_turn, { 40, 45, 20 } }, { straight_roll, { 20, 0 } }, { two_point_roll, { 100 } }, { straight_roll, { 20, 0 } }, { derry_turn, { 40, 60 } }, { straight_roll, { 20, 0 } }, { half_climbing_circle, { -65, 0, -60 } }, { straight_roll, { 20, 0 } }, --[[ { p23_1, { 20, 150, 150 } }, { straight_roll, { 20, 0 } }, { p23_2, { 20, 150 } }, { straight_roll, { 20, 0 } }, { p23_3, { 20, 150 } }, { straight_roll, { 20, 0 } }, { p23_4, { 20, 150 } }, { straight_roll, { 20, 0 } }, { p23_5, { 20, 150 } }, { straight_roll, { 20, 0 } }, { p23_6, { 20, 150 } }, -- now inverted :-) { straight_roll, { 20, 0 } }, --]] }) end --------------------------------------------------- --[[ target speed is taken as max of target airspeed and current 3D velocity at the start of the maneuver --]] function target_groundspeed() return math.max(ahrs:get_EAS2TAS()*TRIM_ARSPD_CM:get()*0.01, ahrs:get_velocity_NED():length()) end --[[ get ground course from AHRS --]] function get_ground_course_deg() local vned = ahrs:get_velocity_NED() return wrap_180(math.deg(math.atan(vned:y(), vned:x()))) end --args: -- path_f: path function returning position -- t: normalised [0, 1] time -- arg1, arg2: arguments for path function -- orientation: maneuver frame orientation --returns: requested position, angle and speed in maneuver frame function rotate_path(path_f, t, orientation, offset) local t = constrain(t, 0, 1) local point = path_f.get_pos(t) local angle = path_f.get_roll(t) local roll_correction = path_f.get_roll_correction(t) local speed = path_f.get_speed(t) local thr_boost = path_f.get_throttle_boost(t) local point = quat_earth_to_body(orientation, point) return point+offset, math.rad(angle+roll_correction), speed, thr_boost end --Given vec1, vec2, returns an (rotation axis, angle) tuple that rotates vec1 to be parallel to vec2 --If vec1 and vec2 are already parallel, returns a zero vector and zero angle --Note that the rotation will not be unique. function vectors_to_rotation(vector1, vector2) local axis = vector1:cross(vector2) if axis:length() < 0.00001 then local vec = Vector3f() vec:x(1) return vec, 0 end axis:normalize() local angle = vector1:angle(vector2) return axis, angle end --returns Quaternion function vectors_to_rotation_w_roll(vector1, vector2, roll) local axis, angle = vectors_to_rotation(vector1, vector2) local vector_rotation = Quaternion() vector_rotation:from_axis_angle(axis, angle) local roll_rotation = Quaternion() roll_rotation:from_euler(roll, 0, 0) local total_rot = vector_rotation*roll_rotation return to_axis_and_angle(total_rot) end --Given vec1, vec2, returns an angular velocity tuple that rotates vec1 to be parallel to vec2 --If vec1 and vec2 are already parallel, returns a zero vector and zero angle function vectors_to_angular_rate(vector1, vector2, time_constant) local axis, angle = vectors_to_rotation(vector1, vector2) local angular_velocity = angle/time_constant return axis:scale(angular_velocity) end function vectors_to_angular_rate_w_roll(vector1, vector2, time_constant, roll) local axis, angle = vectors_to_rotation_w_roll(vector1, vector2, roll) local angular_velocity = angle/time_constant return axis:scale(angular_velocity) end -- convert a quaternion to axis angle form function to_axis_and_angle(quat) local axis_angle = Vector3f() quat:to_axis_angle(axis_angle) local angle = axis_angle:length() if angle < 0.00001 then return makeVector3f(1.0, 0.0, 0.0), 0.0 end return axis_angle:scale(1.0/angle), angle end --projects x onto the othogonal subspace of span(unit_v) function ortho_proj(x, unit_v) local temp_x = unit_v:cross(x) return unit_v:cross(temp_x) end -- log a pose from position and quaternion attitude function log_pose(logname, pos, quat) logger.write(logname, 'px,py,pz,q1,q2,q3,q4,r,p,y','ffffffffff', pos:x(), pos:y(), pos:z(), quat:q1(), quat:q2(), quat:q3(), quat:q4(), math.deg(quat:get_euler_roll()), math.deg(quat:get_euler_pitch()), math.deg(quat:get_euler_yaw())) end --[[ check if a number is Nan. --]] function isNaN(value) -- NaN is lua is not equal to itself return value ~= value end function Vec3IsNaN(v) return isNaN(v:x()) or isNaN(v:y()) or isNaN(v:z()) end function qIsNaN(q) return isNaN(q:q1()) or isNaN(q:q2()) or isNaN(q:q3()) or isNaN(q:q4()) end --[[ return the body y projection down, this is the c.y element of the equivalent rotation matrix --]] function quat_projection_ground_plane(q) local q1q2 = q:q1() * q:q2() local q3q4 = q:q3() * q:q4() return 2.0 * (q3q4 + q1q2) end path_var.count = 0 function do_path() local now = millis():tofloat() * 0.001 local ahrs_pos_NED = ahrs:get_relative_position_NED_origin() local ahrs_pos = ahrs:get_position() local ahrs_gyro = ahrs:get_gyro() local ahrs_velned = ahrs:get_velocity_NED() local ahrs_airspeed = ahrs:airspeed_estimate() --[[ ahrs_quat is the quaterion which when used with quat_earth_to_body() rotates a vector from earth to body frame. It needs to be the inverse of ahrs:get_quaternion() --]] local ahrs_quat = ahrs:get_quaternion():inverse() path_var.count = path_var.count + 1 local target_dt = 1.0/LOOP_RATE local path = current_task.fn if not current_task.started then local initial_yaw_deg = current_task.initial_yaw_deg current_task.started = true local speed = target_groundspeed() path_var.target_speed = speed path_var.length = path.get_length() path_var.total_rate_rads_ef = makeVector3f(0.0, 0.0, 0.0) --assuming constant velocity path_var.total_time = path_var.length/speed path_var.last_pos = path.get_pos(0) --position at t0 --deliberately only want yaw component, because the maneuver should be performed relative to the earth, not relative to the initial orientation path_var.initial_ori = Quaternion() path_var.initial_ori:from_euler(0, 0, math.rad(initial_yaw_deg)) path_var.initial_ori = path_var.initial_ori path_var.initial_ori:normalize() path_var.initial_ef_pos = ahrs_pos_NED:copy() path_var.start_pos = ahrs_pos:copy() path_var.path_int = path_var.start_pos:copy() speed_PI.reset() path_var.accumulated_orientation_rel_ef = path_var.initial_ori path_var.time_correction = 0.0 path_var.filtered_angular_velocity = Vector3f() path_var.last_time = now - 1.0/LOOP_RATE path_var.sideslip_angle_rad = { 0.0, 0.0 } path_var.ff_yaw_rate_rads = 0.0 path_var.last_q_change_t = 1.0 / LOOP_RATE path_var.last_ang_rate_dps = ahrs_gyro:scale(math.deg(1)) path_var.path_t = 0.0 path_var.pos = path_var.initial_ef_pos:copy() path_var.roll = 0.0 path_var.speed = nil -- get initial tangent local p1, r1, s1 = rotate_path(path, path_var.path_t + 0.1/(path_var.total_time*LOOP_RATE), path_var.initial_ori, path_var.initial_ef_pos) path_var.tangent = p1 - path_var.pos return true end local vel_length = ahrs_velned:length() local actual_dt = now - path_var.last_time if actual_dt < 0.25 / LOOP_RATE then -- the update has been executed too soon return true end path_var.last_time = now local local_n_dt = actual_dt/path_var.total_time if path_var.path_t + local_n_dt > 1.0 then -- all done return false end -- airspeed, assume we don't go below min local airspeed_constrained = math.max(ARSPD_FBW_MIN:get(), ahrs_airspeed) --[[ calculate positions and angles at previous, current and next time steps --]] local p0 = path_var.pos:copy() local r0 = path_var.roll local s0 = path_var.speed local p1, r1, s1 = rotate_path(path, path_var.path_t + local_n_dt, path_var.initial_ori, path_var.initial_ef_pos) local current_measured_pos_ef = ahrs_pos_NED:copy() --[[ get tangents to the path --]] local tangent1_ef = path_var.tangent:copy() local tangent2_ef = p1 - p0 local tv_unit = tangent2_ef:copy() if tv_unit:length() < 0.00001 then gcs:send_text(0, string.format("path not advancing %f", tv_unit:length())) end tv_unit:normalize() --[[ use actual vehicle velocity to calculate how far along the path we have progressed --]] local v = ahrs_velned:copy() local path_dist = v:dot(tv_unit)*actual_dt if path_dist < 0 then gcs:send_text(0, string.format("aborting %.2f at %d tv=(%.2f,%.2f,%.2f) vx=%.2f adt=%.2f", path_dist, path_var.count, tangent2_ef:x(), tangent2_ef:y(), tangent2_ef:z(), v:x(), actual_dt)) return false end local path_t_delta = constrain(path_dist/path_var.length, 0.2*local_n_dt, 4*local_n_dt) --[[ recalculate the current path position and angle based on actual delta time --]] local p1, r1, s1, thr_boost = rotate_path(path, constrain(path_var.path_t + path_t_delta, 0, 1), path_var.initial_ori, path_var.initial_ef_pos) local last_path_t = path_var.path_t path_var.path_t = path_var.path_t + path_t_delta -- tangents needs to be recalculated tangent2_ef = p1 - p0 tv_unit = tangent2_ef:copy() tv_unit:normalize() -- error in position versus current point on the path local pos_error_ef = current_measured_pos_ef - p1 --[[ calculate a time correction. We first get the projection of the position error onto the track. This tells us how far we are ahead or behind on the track --]] local path_dist_err_m = tv_unit:dot(pos_error_ef) -- normalize against the total path length local path_err_t = path_dist_err_m / path_var.length -- don't allow the path to go backwards in time, or faster than twice the actual rate path_err_t = constrain(path_err_t, -0.9*path_t_delta, 2*path_t_delta) -- correct time to bring us back into sync path_var.path_t = path_var.path_t + TIME_CORR_P:get() * path_err_t -- get the path again with the corrected time p1, r1, s1 = rotate_path(path, constrain(path_var.path_t, 0, 1), path_var.initial_ori, path_var.initial_ef_pos) -- recalculate the tangent to match the amount we advanced the path time tangent2_ef = p1 - p0 -- get the real world time corresponding to the quaternion change local q_change_t = (path_var.path_t - last_path_t) * path_var.total_time -- low pass filter the demanded roll angle r1 = path_var.roll + wrap_pi(r1 - path_var.roll) local alpha = calc_lowpass_alpha(q_change_t, AEROM_ANG_TC:get()) r1 = (1.0 - alpha) * path_var.roll + alpha * r1 r1 = wrap_pi(r1) path_var.tangent = tangent2_ef:copy() path_var.pos = p1:copy() path_var.roll = r1 path_var.speed = s1 --[[ calculation of error correction, calculating acceleration needed to bring us back on the path, and body rates in pitch and yaw to achieve those accelerations --]] -- component of pos_err perpendicular to the current path tangent local B = ortho_proj(pos_error_ef, tv_unit) -- derivative of pos_err perpendicular to the current path tangent, assuming tangent is constant local B_dot = ortho_proj(v, tv_unit) -- gains for error correction. local acc_err_ef = B:scale(ERR_CORR_P:get()) + B_dot:scale(ERR_CORR_D:get()) local acc_err_bf = quat_earth_to_body(ahrs_quat, acc_err_ef) local TAS = constrain(ahrs:get_EAS2TAS()*airspeed_constrained, 3, 100) local corr_rate_bf_y_rads = -acc_err_bf:z()/TAS local corr_rate_bf_z_rads = acc_err_bf:y()/TAS local cor_ang_vel_bf_rads = makeVector3f(0.0, corr_rate_bf_y_rads, corr_rate_bf_z_rads) if Vec3IsNaN(cor_ang_vel_bf_rads) then cor_ang_vel_bf_rads = makeVector3f(0,0,0) end local cor_ang_vel_bf_dps = cor_ang_vel_bf_rads:scale(math.deg(1)) if path_var.count < 2 then cor_ang_vel_bf_dps = Vector3f() end --[[ work out body frame path rate, this is based on two adjacent tangents on the path --]] local path_rate_ef_rads = tangents_to_rate(tangent1_ef, tangent2_ef, actual_dt) if Vec3IsNaN(path_rate_ef_rads) then gcs:send_text(0,string.format("path_rate_ef_rads: NaN")) path_rate_ef_rads = makeVector3f(0,0,0) end local path_rate_ef_dps = path_rate_ef_rads:scale(math.deg(1)) if path_var.count < 3 then -- cope with small initial misalignment path_rate_ef_dps:z(0) end local path_rate_bf_dps = quat_earth_to_body(ahrs_quat, path_rate_ef_dps) -- set the path roll rate path_rate_bf_dps:x(math.deg(wrap_pi(r1 - r0)/actual_dt)) --[[ calculate body frame roll rate to achieved the desired roll angle relative to the maneuver path --]] local zero_roll_angle_delta = Quaternion() zero_roll_angle_delta:from_angular_velocity(path_rate_ef_rads, actual_dt) path_var.accumulated_orientation_rel_ef = zero_roll_angle_delta*path_var.accumulated_orientation_rel_ef path_var.accumulated_orientation_rel_ef:normalize() local mf_axis = quat_earth_to_body(path_var.accumulated_orientation_rel_ef, makeVector3f(1, 0, 0)) local orientation_rel_mf_with_roll_angle = Quaternion() orientation_rel_mf_with_roll_angle:from_axis_angle(mf_axis, r1) orientation_rel_ef_with_roll_angle = orientation_rel_mf_with_roll_angle*path_var.accumulated_orientation_rel_ef --[[ calculate the error correction for the roll versus the desired roll --]] local roll_error = orientation_rel_ef_with_roll_angle * ahrs_quat roll_error:normalize() local err_axis_ef, err_angle_rad = to_axis_and_angle(roll_error) local time_const_roll = ROLL_CORR_TC:get() local err_angle_rate_ef_rads = err_axis_ef:scale(err_angle_rad/time_const_roll) local err_angle_rate_bf_dps = quat_earth_to_body(ahrs_quat,err_angle_rate_ef_rads):scale(math.deg(1)) -- zero any non-roll components err_angle_rate_bf_dps:y(0) err_angle_rate_bf_dps:z(0) --[[ implement lookahead for path rates --]] if AEROM_LKAHD:get() > 0 then local lookahead = AEROM_LKAHD:get() local lookahead_vt = lookahead / path_var.total_time p2 = rotate_path(path, constrain(path_var.path_t+lookahead_vt, 0, 1), path_var.initial_ori, path_var.initial_ef_pos) local tangent3_ef = p2 - p1 local lk_ef_rads = tangents_to_rate(tangent2_ef, tangent3_ef, 0.5*(lookahead+(1.0/LOOP_RATE))) -- scale for airspeed lk_ef_rads = lk_ef_rads:scale(sq(vel_length/path_var.target_speed)) local lookahead_bf_rads = quat_earth_to_body(ahrs_quat, lk_ef_rads) local lookahead_bf_dps = lookahead_bf_rads:scale(math.deg(1)) logger.write('AELK','Py,Ly,Pz,Lz', 'ffff', path_rate_bf_dps:y(), lookahead_bf_dps:y(), path_rate_bf_dps:z(), lookahead_bf_dps:z()) path_rate_bf_dps:y(lookahead_bf_dps:y()) path_rate_bf_dps:z(lookahead_bf_dps:z()) end --[[ calculate an additional yaw rate to get us to the right angle of sideslip for knifeedge --]] local g_force = (path_rate_ef_rads:cross(v)):scale(1.0/GRAVITY_MSS) local specific_force_g_ef = g_force - makeVector3f(0,0,-1) local specific_force_g_bf = quat_earth_to_body(orientation_rel_ef_with_roll_angle, specific_force_g_ef) local airspeed_scaling = SCALING_SPEED:get()/airspeed_constrained local sideslip_rad = specific_force_g_bf:y() * (airspeed_scaling*airspeed_scaling) * math.rad(AEROM_KE_ANG:get()) local ff_yaw_rate_rads1 = -(sideslip_rad - path_var.sideslip_angle_rad[2]) / q_change_t local ff_yaw_rate_rads2 = -(path_var.sideslip_angle_rad[2] - path_var.sideslip_angle_rad[1]) / path_var.last_q_change_t local ff_yaw_rate_rads = 0.5 * (ff_yaw_rate_rads1 + ff_yaw_rate_rads2) if path_var.count <= 4 then -- prevent an initialisation issue ff_yaw_rate_rads = 0.0 end ff_yaw_rate_rads = 0.8 * path_var.ff_yaw_rate_rads + 0.2 * ff_yaw_rate_rads path_var.ff_yaw_rate_rads = ff_yaw_rate_rads path_var.sideslip_angle_rad[1] = path_var.sideslip_angle_rad[2] path_var.sideslip_angle_rad[2] = sideslip_rad path_var.last_q_change_t = q_change_t local sideslip_rate_bf_dps = makeVector3f(0, 0, ff_yaw_rate_rads):scale(math.deg(1)) --[[ total angular rate is sum of path rate, correction rate and roll correction rate --]] local tot_ang_vel_bf_dps = path_rate_bf_dps + cor_ang_vel_bf_dps + err_angle_rate_bf_dps + sideslip_rate_bf_dps --[[ apply angular accel limit --]] local ang_rate_diff_dps = tot_ang_vel_bf_dps - path_var.last_ang_rate_dps local max_delta_dps = AEROM_ANG_ACCEL:get() * actual_dt local max_delta_yaw_dps = max_delta_dps if AEROM_YAW_ACCEL:get() > 0 and (AEROM_YAW_ACCEL:get() < AEROM_ANG_ACCEL:get() or AEROM_ANG_ACCEL:get() <= 0) then max_delta_yaw_dps = AEROM_YAW_ACCEL:get() * actual_dt end if max_delta_dps > 0 then ang_rate_diff_dps:x(constrain(ang_rate_diff_dps:x(), -max_delta_dps, max_delta_dps)) ang_rate_diff_dps:y(constrain(ang_rate_diff_dps:y(), -max_delta_dps, max_delta_dps)) end if max_delta_yaw_dps > 0 then ang_rate_diff_dps:z(constrain(ang_rate_diff_dps:z(), -max_delta_yaw_dps, max_delta_yaw_dps)) end tot_ang_vel_bf_dps = path_var.last_ang_rate_dps + ang_rate_diff_dps path_var.last_ang_rate_dps = tot_ang_vel_bf_dps --[[ log POSM is pose-measured, POST is pose-track, POSB is pose-track without the roll --]] log_pose('POSM', current_measured_pos_ef, ahrs_quat:inverse()) log_pose('POST', p1, orientation_rel_ef_with_roll_angle) logger.write('AETM', 'T,Terr,QCt,Adt','ffff', path_var.path_t, path_err_t, q_change_t, actual_dt) logger.write('AERT','Cx,Cy,Cz,Px,Py,Pz,Ex,Tx,Ty,Tz,Perr,Aerr,Yff,SS', 'ffffffffffffff', cor_ang_vel_bf_dps:x(), cor_ang_vel_bf_dps:y(), cor_ang_vel_bf_dps:z(), path_rate_bf_dps:x(), path_rate_bf_dps:y(), path_rate_bf_dps:z(), err_angle_rate_bf_dps:x(), tot_ang_vel_bf_dps:x(), tot_ang_vel_bf_dps:y(), tot_ang_vel_bf_dps:z(), pos_error_ef:length(), wrap_180(math.deg(err_angle_rad)), math.deg(ff_yaw_rate_rads), math.deg(sideslip_rad)) --log_pose('POSB', p1, path_var.accumulated_orientation_rel_ef) --[[ run the throttle based speed controller --]] if s1 == nil then s1 = path_var.target_speed end --[[ get the anticipated pitch at the throttle lookahead time we use the maximum of the current path pitch and the anticipated pitch --]] local qchange = Quaternion() qchange:from_angular_velocity(path_rate_ef_rads, AEROM_THR_LKAHD:get()) local qnew = qchange * orientation_rel_ef_with_roll_angle local anticipated_pitch_rad = math.max(qnew:get_euler_pitch(), orientation_rel_ef_with_roll_angle:get_euler_pitch()) local throttle = speed_PI.update(s1, anticipated_pitch_rad) local thr_min = AEROM_THR_MIN:get() if thr_boost then thr_min = math.max(thr_min, AEROM_THR_BOOST:get()) end throttle = constrain(throttle, thr_min, 100.0) if isNaN(throttle) or Vec3IsNaN(tot_ang_vel_bf_dps) then gcs:send_text(0,string.format("Path NaN - aborting")) return false end vehicle:set_target_throttle_rate_rpy(throttle, tot_ang_vel_bf_dps:x(), tot_ang_vel_bf_dps:y(), tot_ang_vel_bf_dps:z()) if now - last_named_float_t > 1.0 / NAME_FLOAT_RATE then last_named_float_t = now gcs:send_named_float("PERR", pos_error_ef:length()) end return true end --[[ an object defining a path --]] function PathFunction(fn, name) local self = {} self.fn = fn self.name = name return self end local command_table = {} command_table[1] = PathFunction(figure_eight, "Figure Eight") command_table[2] = PathFunction(loop, "Loop") command_table[3] = PathFunction(horizontal_rectangle, "Horizontal Rectangle") command_table[4] = PathFunction(climbing_circle, "Climbing Circle") command_table[5] = PathFunction(vertical_aerobatic_box, "Vertical Box") command_table[6] = PathFunction(immelmann_turn_fast, "Immelmann Fast") command_table[7] = PathFunction(straight_roll, "Axial Roll") command_table[8] = PathFunction(rolling_circle, "Rolling Circle") command_table[9] = PathFunction(half_cuban_eight, "Half Cuban Eight") command_table[10]= PathFunction(half_reverse_cuban_eight, "Half Reverse Cuban Eight") command_table[11]= PathFunction(cuban_eight, "Cuban Eight") command_table[12]= PathFunction(humpty_bump, "Humpty Bump") command_table[13]= PathFunction(straight_flight, "Straight Flight") command_table[14]= PathFunction(scale_figure_eight, "Scale Figure Eight") command_table[15]= PathFunction(immelmann_turn, "Immelmann Turn") command_table[16]= PathFunction(split_s, "Split-S") command_table[17]= PathFunction(upline_45, "Upline-45") command_table[18]= PathFunction(downline_45, "Downline-45") command_table[19]= PathFunction(stall_turn, "Stall Turn") command_table[20]= PathFunction(procedure_turn, "Procedure Turn") command_table[21]= PathFunction(derry_turn, "Derry Turn") command_table[22]= PathFunction(two_point_roll, "Two Point Roll") command_table[23]= PathFunction(half_climbing_circle, "Half Climbing Circle") command_table[24]= PathFunction(crossbox_humpty, "Crossbox Humpty") command_table[25]= PathFunction(laydown_humpty, "Laydown Humpty") command_table[26] = PathFunction(barrel_roll, "Barrel Roll") command_table[27]= PathFunction(straight_flight, "Straight Hold") command_table[28] = PathFunction(partial_circle, "Partial Circle") command_table[29]= PathFunction(four_point_roll, "Four Point Roll") command_table[30]= PathFunction(eight_point_roll, "Eight Point Roll") command_table[31]= PathFunction(multi_point_roll, "Multi Point Roll") command_table[200] = PathFunction(test_all_paths, "Test Suite") command_table[201] = PathFunction(nz_clubman, "NZ Clubman") command_table[202] = PathFunction(f3a_p23_l_r, "FAI F3A P23 L to R") command_table[203] = PathFunction(f4c_example_l_r, "FAI F4C Example L to R") command_table[204] = PathFunction(air_show1, "AirShow") command_table[205] = PathFunction(fai_f3a_box_l_r, "FAI F3A Aerobatic Box Demonstration") command_table[206] = PathFunction(air_show3, "AirShow3") --[[ a table of function available in loadable tricks --]] local load_table = {} load_table["loop"] = loop load_table["horizontal_rectangle"] = horizontal_rectangle load_table["climbing_circle"] = climbing_circle load_table["vertical_aerobatic_box"] = vertical_aerobatic_box load_table["immelmann_turn_fast"] = immelmann_turn_fast load_table["straight_roll"] = straight_roll load_table["rolling_circle"] = rolling_circle load_table["half_cuban_eight"] = half_cuban_eight load_table["half_reverse_cuban_eight"] = half_reverse_cuban_eight load_table["cuban_eight"] = cuban_eight load_table["humpty_bump"] = humpty_bump load_table["straight_flight"] = straight_flight load_table["scale_figure_eight"] = scale_figure_eight load_table["immelmann_turn"] = immelmann_turn load_table["split_s"] = split_s load_table["upline_45"] = upline_45 load_table["downline_45"] = downline_45 load_table["stall_turn"] = stall_turn load_table["procedure_turn"] = procedure_turn load_table["derry_turn"] = derry_turn load_table["two_point_roll"] = two_point_roll load_table["half_climbing_circle"] = half_climbing_circle load_table["crossbox_humpty"] = crossbox_humpty load_table["laydown_humpty"] = laydown_humpty load_table["straight_align"] = straight_align load_table["figure_eight"] = figure_eight load_table["barrel_roll"] = barrel_roll load_table["straight_hold"] = straight_hold load_table["partial_circle"] = partial_circle load_table["multi_point_roll"] = multi_point_roll load_table["p23_1a"] = p23_1a load_table["p23_1"] = p23_1 load_table["p23_13a"] = p23_13a load_table["p23_14"] = p23_14 load_table["p23_15"] = p23_15 load_table["p23_16"] = p23_16 load_table["p23_17"] = p23_17 --[[ load a trick description from a text file --]] function load_trick(id) if command_table[id] ~= nil then -- already have it return end -- look in 3 possible locations for the trick, coping with SITL and real boards local trickdirs = { "APM/scripts/", "scripts/", "./" } local file = nil local fname = string.format("trick%u.txt", id) for i = 1, #trickdirs do file = io.open(trickdirs[i] .. fname, "r") if file then break end end if file == nil then gcs:send_text(0,string.format("Failed to open %s", fname)) return end local name = string.format("Trick%u", id) local paths = {} local message = nil while true do local line = file:read() if not line then break end local _, _, cmd, arg1, arg2, arg3, arg4 = string.find(line, "^([%w_:]+)%s*([-.%d]*)%s*([-.%d]*)%s*([-.%d]*)%s*([-.%d]*)") if cmd == "" or cmd == nil or string.sub(cmd,1,1) == "#" then -- ignore comments elseif cmd == "name:" then _, _, name = string.find(line, "^name:%s*([%w_]+)$") elseif cmd == "message:" then _, _, message = string.find(line, "^message:%s*(.+)$") elseif cmd ~= nil then arg1 = tonumber(arg1) or 0 arg2 = tonumber(arg2) or 0 arg3 = tonumber(arg3) or 0 arg4 = tonumber(arg4) or 0 local f = load_table[cmd] if f == nil then gcs:send_text(0,string.format("Unknown command '%s' in %s", cmd, fname)) else paths[#paths+1] = { f, { arg1, arg2, arg3, arg4 }} if message ~= nil then paths[#paths].message = message message = nil end end end end local pc = path_composer(name, paths) gcs:send_text(0, string.format("Loaded trick%u '%s'", id, name)) command_table[id] = PathFunction(pc, name) end function PathTask(fn, name, id, initial_yaw_deg, arg1, arg2, arg3, arg4) self = {} if type(fn) == "table" then self.fn = fn else self.fn = fn(arg1, arg2, arg3, arg4) end self.name = name self.id = id self.initial_yaw_deg = initial_yaw_deg self.started = false return self end -- see if an auto mission item needs to be run function check_auto_mission() id, cmd, arg1, arg2, arg3, arg4 = vehicle:nav_script_time() if not id then return end if id ~= last_id then -- we've started a new command current_task = nil last_id = id local initial_yaw_deg = get_ground_course_deg() load_trick(cmd) gcs:send_text(0, string.format("Starting %s!", command_table[cmd].name )) -- work out yaw between previous WP and next WP local cnum = mission:get_current_nav_index() -- find previous nav waypoint local loc_prev = get_wp_location(cnum-1) local loc_next = get_wp_location(cnum+1) local i= cnum-1 while get_wp_location(i):lat() == 0 and get_wp_location(i):lng() == 0 do i = i-1 loc_prev = get_wp_location(i) end -- find next nav waypoint i = cnum+1 while get_wp_location(i):lat() == 0 and get_wp_location(i):lng() == 0 do i = i+1 loc_next = get_wp_location(resolve_jump(i)) end local wp_yaw_deg = math.deg(loc_prev:get_bearing(loc_next)) if math.abs(wrap_180(initial_yaw_deg - wp_yaw_deg)) > 90 then gcs:send_text(0, string.format("Doing turnaround!")) wp_yaw_deg = wrap_180(wp_yaw_deg + 180) end initial_yaw_deg = wp_yaw_deg current_task = PathTask(command_table[cmd].fn, command_table[cmd].name, id, initial_yaw_deg, arg1, arg2, arg3, arg4) end end local last_trick_action_state = 0 local trick_sel_chan = nil local last_trick_selection = nil --[[ get selected trick. Trick numbers are 1 .. TRIK_COUNT. A value of 0 is invalid --]] function get_trick_selection() if trick_sel_chan == nil then trick_sel_chan = rc:find_channel_for_option(TRIK_SEL_FN:get()) if trick_sel_chan == nil then return 0 end end -- get trick selection based on selection channel input and number of tricks local i = math.floor(TRIK_COUNT:get() * constrain(0.5*(trick_sel_chan:norm_input_ignore_trim()+1),0,0.999)+1) if TRICKS[i] == nil then return 0 end return i end --[[ check for running a trick --]] function check_trick() local selection = get_trick_selection() local action = rc:get_aux_cached(TRIK_ACT_FN:get()) if action == 0 and current_task ~= nil then gcs:send_text(0,string.format("Trick aborted")) current_task = nil last_trick_selection = nil -- use invalid mode to disable script control vehicle:nav_scripting_enable(255) return end if selection == 0 then return end if action == 1 and selection ~= last_trick_selection then local id = TRICKS[selection].id:get() load_trick(id) if command_table[id] ~= nil then local cmd = command_table[id] gcs:send_text(0, string.format("Trick %u selected (%s)", selection, cmd.name)) last_trick_selection = selection return end end if current_task ~= nil then -- let the task finish return end if action ~= last_trick_action_state then last_trick_selection = selection last_trick_action_state = action if selection == 0 then gcs:send_text(0, string.format("No trick selected")) return end local id = TRICKS[selection].id:get() load_trick(id) if command_table[id] == nil then gcs:send_text(0, string.format("Invalid trick ID %u", id)) return end local cmd = command_table[id] if action == 1 then gcs:send_text(0, string.format("Trick %u selected (%s)", selection, cmd.name)) end if action == 2 then last_trick_selection = nil local current_mode = vehicle:get_mode() if not vehicle:nav_scripting_enable(current_mode) then gcs:send_text(0, string.format("Tricks not available in mode")) return end gcs:send_text(0, string.format("Trick %u started (%s)", selection, cmd.name)) local initial_yaw_deg = get_ground_course_deg() current_task = PathTask(cmd.fn, cmd.name, nil, initial_yaw_deg, TRICKS[selection].args[1]:get(), TRICKS[selection].args[2]:get(), TRICKS[selection].args[3]:get(), TRICKS[selection].args[4]:get()) end end end function update() if vehicle:get_mode() == MODE_AUTO then check_auto_mission() elseif TRICKS ~= nil then check_trick() end if current_task ~= nil then if not do_path() then gcs:send_text(0, string.format("Finishing %s!", current_task.name)) if current_task.id ~= nil then vehicle:nav_script_time_done(current_task.id) else -- use invalid mode to disable script control vehicle:nav_scripting_enable(255) end current_task = nil end end return update, 1000.0/LOOP_RATE end return update()
gpl-3.0
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/zones/Bastok_Mines/npcs/Phara.lua
4
2463
----------------------------------- -- Area: Bastok Mines -- NPC: Phara -- Starts and Finishes Quest: The doorman (start) -- Involved in Quest: The Talekeeper's Truth -- @zone 234 -- @pos 75 0 -80 ----------------------------------- package.loaded["scripts/zones/Bastok_Mines/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/quests"); require("scripts/zones/Bastok_Mines/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) theDoorman = player:getQuestStatus(BASTOK,THE_DOORMAN); theTalekeeperTruth = player:getQuestStatus(BASTOK,THE_TALEKEEPER_S_TRUTH); if(theDoorman == QUEST_AVAILABLE and player:getMainJob() == 1 and player:getMainLvl() >= 40) then player:startEvent(0x0097); -- Start Quests "The doorman" elseif(player:hasKeyItem(SWORD_GRIP_MATERIAL)) then player:startEvent(0x0098); -- Need to wait 1 vanadiel day elseif(player:getVar("theDoormanCS") == 2 and VanadielDayOfTheYear() ~= player:getVar("theDoorman_time")) then player:startEvent(0x0099); -- The doorman notification, go to naji elseif(theDoorman == QUEST_COMPLETED and theTalekeeperTruth == QUEST_AVAILABLE) then player:startEvent(0x009a); -- New standard dialog else player:startEvent(0x0096); -- Standard dialog end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); if(csid == 0x0097) then player:addQuest(BASTOK,THE_DOORMAN); player:setVar("theDoormanCS",1); elseif(csid == 0x0098) then player:setVar("theDoorman_time",VanadielDayOfTheYear()); player:setVar("theDoormanCS",2); player:delKeyItem(SWORD_GRIP_MATERIAL); elseif(csid == 0x0099) then player:addKeyItem(YASINS_SWORD); player:messageSpecial(KEYITEM_OBTAINED,YASINS_SWORD); player:setVar("theDoormanCS",3); player:setVar("theDoorman_time",0); elseif(csid == 0x009a) then player:setVar("theTalekeeperTruthCS",1); end end;
gpl-3.0
wanmaple/MWFrameworkForCocosLua
frameworks/cocos2d-x/cocos/scripting/lua-bindings/auto/api/SkeletonRenderer.lua
10
2646
-------------------------------- -- @module SkeletonRenderer -- @extend Node,BlendProtocol -- @parent_module sp -------------------------------- -- -- @function [parent=#SkeletonRenderer] setTimeScale -- @param self -- @param #float scale -------------------------------- -- -- @function [parent=#SkeletonRenderer] isOpacityModifyRGB -- @param self -- @return bool#bool ret (return value: bool) -------------------------------- -- -- @function [parent=#SkeletonRenderer] setDebugSlotsEnabled -- @param self -- @param #bool enabled -------------------------------- -- -- @function [parent=#SkeletonRenderer] getDebugSlotsEnabled -- @param self -- @return bool#bool ret (return value: bool) -------------------------------- -- -- @function [parent=#SkeletonRenderer] setBonesToSetupPose -- @param self -------------------------------- -- -- @function [parent=#SkeletonRenderer] setSlotsToSetupPose -- @param self -------------------------------- -- -- @function [parent=#SkeletonRenderer] setSkin -- @param self -- @param #string skinName -- @return bool#bool ret (return value: bool) -------------------------------- -- -- @function [parent=#SkeletonRenderer] setToSetupPose -- @param self -------------------------------- -- -- @function [parent=#SkeletonRenderer] setOpacityModifyRGB -- @param self -- @param #bool value -------------------------------- -- -- @function [parent=#SkeletonRenderer] setDebugBonesEnabled -- @param self -- @param #bool enabled -------------------------------- -- -- @function [parent=#SkeletonRenderer] getSkeleton -- @param self -- @return spSkeleton#spSkeleton ret (return value: spSkeleton) -------------------------------- -- -- @function [parent=#SkeletonRenderer] getDebugBonesEnabled -- @param self -- @return bool#bool ret (return value: bool) -------------------------------- -- -- @function [parent=#SkeletonRenderer] getTimeScale -- @param self -- @return float#float ret (return value: float) -------------------------------- -- @overload self, string, string, float -- @overload self, string, spAtlas, float -- @function [parent=#SkeletonRenderer] createWithFile -- @param self -- @param #string skeletonDataFile -- @param #spAtlas atlas -- @param #float scale -- @return SkeletonRenderer#SkeletonRenderer ret (return value: sp.SkeletonRenderer) -------------------------------- -- -- @function [parent=#SkeletonRenderer] getBoundingBox -- @param self -- @return rect_table#rect_table ret (return value: rect_table) return nil
apache-2.0
waytim/darkstar
scripts/zones/Norg/npcs/Vuliaie.lua
13
1305
----------------------------------- -- Area: Norg -- NPC: Vuliaie -- Type: Tenshodo Merchant -- @pos -24.259 0.891 -19.556 252 ----------------------------------- package.loaded["scripts/zones/Norg/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/shop"); require("scripts/globals/keyitems"); require("scripts/zones/Norg/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:hasKeyItem(TENSHODO_MEMBERS_CARD)) then if (player:sendGuild(60424,9,23,7)) then player:showText(npc, VULIAIE_SHOP_DIALOG); end else -- player:startEvent(0x0096); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
gpl-3.0
GregSatre/nn
HingeEmbeddingCriterion.lua
50
1290
local HingeEmbeddingCriterion, parent = torch.class('nn.HingeEmbeddingCriterion', 'nn.Criterion') function HingeEmbeddingCriterion:__init(margin) parent.__init(self) self.margin = margin or 1 self.sizeAverage = true end function HingeEmbeddingCriterion:updateOutput(input,y) self.buffer = self.buffer or input.new() if not torch.isTensor(y) then self.ty = self.ty or input.new():resize(1) self.ty[1]=y y=self.ty end self.buffer:resizeAs(input):copy(input) self.buffer[torch.eq(y, -1)] = 0 self.output = self.buffer:sum() self.buffer:fill(self.margin):add(-1, input) self.buffer:cmax(0) self.buffer[torch.eq(y, 1)] = 0 self.output = self.output + self.buffer:sum() if (self.sizeAverage == nil or self.sizeAverage == true) then self.output = self.output / input:nElement() end return self.output end function HingeEmbeddingCriterion:updateGradInput(input, y) if not torch.isTensor(y) then self.ty[1]=y; y=self.ty end self.gradInput:resizeAs(input):copy(y) self.gradInput[torch.cmul(torch.eq(y, -1), torch.gt(input, self.margin))] = 0 if (self.sizeAverage == nil or self.sizeAverage == true) then self.gradInput:mul(1 / input:nElement()) end return self.gradInput end
bsd-3-clause
tomyun/Gearsystem
platforms/ios/dependencies/SDL-2.0.4-9174/premake/projects/testresample.lua
7
1029
-- Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely. -- -- Meta-build system using premake created and maintained by -- Benjamin Henning <b.henning@digipen.edu> --[[ testresample.lua This file defines the testresample test project. It depends on the SDL2main and SDL2 projects. It will not build on iOS or Cygwin. ]] SDL_project "testresample" SDL_kind "ConsoleApp" SDL_notos "ios|cygwin" SDL_language "C" SDL_sourcedir "../test" SDL_projectLocation "tests" -- a list of items to copy from the sourcedir to the destination SDL_copy { "sample.wav" } SDL_projectDependencies { "SDL2main", "SDL2" } SDL_files { "/testresample.*" }
gpl-3.0
Paziko54/BolScripts
MrArticunoLaucher.lua
23
3851
--[[ _____ _____ __ .__ / \_______ / _ \________/ |_|__| ____ __ __ ____ ____ / \ / \_ __ \ / /_\ \_ __ \ __\ |/ ___\| | \/ \ / _ \ / Y \ | \/ / | \ | \/| | | \ \___| | / | ( <_> ) \____|__ /__| \____|__ /__| |__| |__|\___ >____/|___| /\____/ \/ \/ \/ \/ Mechanics Series Laucher ]] require 'mrLib' _G.ScriptLoaded = false _G.LibsChecked = false local ScriptLink = { SOW = { filename = "SOW.lua", host = "raw.github.com" , versionLink = "/Hellsing/BoL/master/common/SOW.lua" , isLib = true , forceUpdate = false }, VPrediction = { filename = "VPrediction.lua", host = "raw.github.com" , versionLink = "/Hellsing/BoL/master/common/VPrediction.lua" , isLib = true , forceUpdate = false }, Prodiction = { filename = "Prodiction.lua", host = "bitbucket.org" , versionLink = "/Klokje/public-klokjes-bol-scripts/raw/ec830facccefb3b52212dba5696c08697c3c2854/Test/Prodiction/Prodiction.lua" , isLib = true , forceUpdate = false }, Tristana = { filename = "TristanaMechanics.lua", host = "raw.github.com" , versionLink = "/gmlyra/BolScripts/master/TristanaMechanics.lua" , isLib = false , forceUpdate = true }, Elise = { filename = "EliseMechanics.lua", host = "raw.github.com" , versionLink = "/gmlyra/BolScripts/master/EliseMechanics.lua" , isLib = false , forceUpdate = true }, Lucian = { filename = "LucianMechanics.lua", host = "raw.github.com" , versionLink = "/gmlyra/BolScripts/master/LucianMechanics.lua" , isLib = false , forceUpdate = true }, Jinx = { filename = "JinxMechanics.lua", host = "raw.github.com" , versionLink = "/gmlyra/BolScripts/master/JinxMechanics.lua" , isLib = false , forceUpdate = true }, Gragas = { filename = "GragasMechanics.lua", host = "raw.github.com" , versionLink = "/gmlyra/BolScripts/master/GragasMechanics.lua" , isLib = false , forceUpdate = true }, Viktor = { filename = "ViktorMechanics.lua", host = "raw.github.com" , versionLink = "/gmlyra/BolScripts/master/ViktorMechanics.lua" , isLib = false , forceUpdate = true }, Chogath = { filename = "ChogathMechanics.lua", host = "raw.github.com" , versionLink = "/gmlyra/BolScripts/master/ChogathMechanics.lua" , isLib = false , forceUpdate = true }, Kayle = { filename = "KayleMechanics.lua", host = "raw.github.com" , versionLink = "/gmlyra/BolScripts/master/KayleMechanics.lua" , isLib = false , forceUpdate = true }, Karthus = { filename = "KarthusMechanics.lua", host = "raw.github.com" , versionLink = "/gmlyra/BolScripts/master/KarthusMechanics.lua" , isLib = false , forceUpdate = true }, } function OnLoad() if file_exists(LIB_PATH.."mrLib.lua") then require 'mrLib' else print('You must have mrLib.lua to use this laucher') return end checkLibs() if not _G.ScriptLoaded then if not ScriptLink[myHero.charName].forceUpdate then if not file_exists(SCRIPT_PATH..ScriptLink[myHero.charName].filename) then loadFromWeb(SCRIPT_PATH..ScriptLink[myHero.charName].filename, ScriptLink[myHero.charName].host, ScriptLink[myHero.charName].versionLink, true) else loadfile(SCRIPT_PATH..ScriptLink[myHero.charName].filename)() end else loadFromWeb(SCRIPT_PATH..ScriptLink[myHero.charName].filename, ScriptLink[myHero.charName].host, ScriptLink[myHero.charName].versionLink, false) end end end function checkLibs() for i,v in ipairs(ScriptLink) do if ScriptLink[v].isLib then if not file_exists(LIB_PATH..ScriptLink[v].filename) or ScriptLink[v].forceUpdate then downloadLib(ScriptLink[v].filename, ScriptLink[v].host, ScriptLink[v].versionLink) end end end end local io = require "io" function file_exists(file) local f = io.open(file, "rb") if f then f:close() end return f ~= nil end -- End of Laucher --
gpl-2.0
waytim/darkstar
scripts/zones/Cloister_of_Gales/bcnms/sugar-coated_directive.lua
30
1808
---------------------------------------- -- Area: Cloister of Gales -- BCNM: Sugar Coated Directive (ASA-4) ---------------------------------------- package.loaded["scripts/zones/Cloister_of_Gales/TextIDs"] = nil; ---------------------------------------- require("scripts/globals/keyitems"); require("scripts/globals/quests"); require("scripts/zones/Cloister_of_Gales/TextIDs"); ---------------------------------------- -- After registering the BCNM via bcnmRegister(bcnmid) function onBcnmRegister(player,instance) end; -- Physically entering the BCNM via bcnmEnter(bcnmid) function onBcnmEnter(player,instance) end; -- Leaving the BCNM by every mean possible, given by the LeaveCode -- 1=Select Exit on circle -- 2=Winning the BC -- 3=Disconnected or warped out -- 4=Losing the BC -- via bcnmLeave(1) or bcnmLeave(2). LeaveCodes 3 and 4 are called -- from the core when a player disconnects or the time limit is up, etc function onBcnmLeave(player,instance,leavecode) -- print("leave code "..leavecode); if (leavecode == 2) then -- play end CS. Need time and battle id for record keeping + storage if (player:hasCompletedMission(ASA,SUGAR_COATED_DIRECTIVE)) then player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,4,1); else player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,4,0); end elseif (leavecode == 4) then player:startEvent(0x7d02); end end; function onEventUpdate(player,csid,option) -- print("bc update csid "..csid.." and option "..option); end; function onEventFinish(player,csid,option) -- print("bc finish csid "..csid.." and option "..option); if (csid == 0x7d01) then player:addExp(400); player:setVar("ASA4_Emerald","1"); end end;
gpl-3.0
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/zones/Castle_Oztroja/npcs/_47b.lua
2
1231
----------------------------------- -- Area: Castle Oztroja -- NPC: Handle -- Open trap door or brass door -- @pos 20 0 -13 151 ----------------------------------- require("scripts/globals/missions"); ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) X = player:getXPos(); Z = player:getZPos(); if(X < 21.6 and X > 18 and Z > -15.6 and Z < -12.4) then if(VanadielDayOfTheYear() % 2 == 0) then GetNPCByID(17396151):openDoor(); else GetNPCByID(17396152):openDoor(); if(player:getCurrentMission(WINDURST) == TO_EACH_HIS_OWN_RIGHT and player:getVar("MissionStatus") == 3) then player:startEvent(0x002B); end end else player:messageSpecial(0); 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(csid == 0x002B) then player:setVar("MissionStatus",4); end end;
gpl-3.0
internetisalie/lua-for-idea
testdata/non-test-system-files/lua5.1-tests/files.lua
7
8815
print('testing i/o') assert(io.input(io.stdin) == io.stdin) assert(io.output(io.stdout) == io.stdout) assert(type(io.input()) == "userdata" and io.type(io.output()) == "file") assert(io.type(8) == nil) local a = {}; setmetatable(a, {}) assert(io.type(a) == nil) local a,b,c = io.open('xuxu_nao_existe') assert(not a and type(b) == "string" and type(c) == "number") a,b,c = io.open('/a/b/c/d', 'w') assert(not a and type(b) == "string" and type(c) == "number") local file = os.tmpname() local otherfile = os.tmpname() assert(os.setlocale('C', 'all')) io.input(io.stdin); io.output(io.stdout); os.remove(file) assert(loadfile(file) == nil) assert(io.open(file) == nil) io.output(file) assert(io.output() ~= io.stdout) assert(io.output():seek() == 0) assert(io.write("alo alo")) assert(io.output():seek() == string.len("alo alo")) assert(io.output():seek("cur", -3) == string.len("alo alo")-3) assert(io.write("joao")) assert(io.output():seek("end") == string.len("alo joao")) assert(io.output():seek("set") == 0) assert(io.write('"álo"', "{a}\n", "second line\n", "third line \n")) assert(io.write('çfourth_line')) io.output(io.stdout) collectgarbage() -- file should be closed by GC assert(io.input() == io.stdin and rawequal(io.output(), io.stdout)) print('+') -- test GC for files collectgarbage() for i=1,120 do for i=1,5 do io.input(file) assert(io.open(file, 'r')) io.lines(file) end collectgarbage() end assert(os.rename(file, otherfile)) assert(os.rename(file, otherfile) == nil) io.output(io.open(otherfile, "a")) assert(io.write("\n\n\t\t 3450\n")); io.close() -- test line generators assert(os.rename(otherfile, file)) io.output(otherfile) local f = io.lines(file) while f() do end; assert(not pcall(f)) -- read lines after EOF assert(not pcall(f)) -- read lines after EOF -- copy from file to otherfile for l in io.lines(file) do io.write(l, "\n") end io.close() -- copy from otherfile back to file local f = assert(io.open(otherfile)) assert(io.type(f) == "file") io.output(file) assert(io.output():read() == nil) for l in f:lines() do io.write(l, "\n") end assert(f:close()); io.close() assert(not pcall(io.close, f)) -- error trying to close again assert(tostring(f) == "file (closed)") assert(io.type(f) == "closed file") io.input(file) f = io.open(otherfile):lines() for l in io.lines() do assert(l == f()) end assert(os.remove(otherfile)) io.input(file) do -- test error returns local a,b,c = io.input():write("xuxu") assert(not a and type(b) == "string" and type(c) == "number") end assert(io.read(0) == "") -- not eof assert(io.read(5, '*l') == '"álo"') assert(io.read(0) == "") assert(io.read() == "second line") local x = io.input():seek() assert(io.read() == "third line ") assert(io.input():seek("set", x)) assert(io.read('*l') == "third line ") assert(io.read(1) == "ç") assert(io.read(string.len"fourth_line") == "fourth_line") assert(io.input():seek("cur", -string.len"fourth_line")) assert(io.read() == "fourth_line") assert(io.read() == "") -- empty line assert(io.read('*n') == 3450) assert(io.read(1) == '\n') assert(io.read(0) == nil) -- end of file assert(io.read(1) == nil) -- end of file assert(({io.read(1)})[2] == nil) assert(io.read() == nil) -- end of file assert(({io.read()})[2] == nil) assert(io.read('*n') == nil) -- end of file assert(({io.read('*n')})[2] == nil) assert(io.read('*a') == '') -- end of file (OK for `*a') assert(io.read('*a') == '') -- end of file (OK for `*a') collectgarbage() print('+') io.close(io.input()) assert(not pcall(io.read)) assert(os.remove(file)) local t = '0123456789' for i=1,12 do t = t..t; end assert(string.len(t) == 10*2^12) io.output(file) io.write("alo\n") io.close() assert(not pcall(io.write)) local f = io.open(file, "a") io.output(f) collectgarbage() assert(io.write(' ' .. t .. ' ')) assert(io.write(';', 'end of file\n')) f:flush(); io.flush() f:close() print('+') io.input(file) assert(io.read() == "alo") assert(io.read(1) == ' ') assert(io.read(string.len(t)) == t) assert(io.read(1) == ' ') assert(io.read(0)) assert(io.read('*a') == ';end of file\n') assert(io.read(0) == nil) assert(io.close(io.input())) assert(os.remove(file)) print('+') local x1 = "string\n\n\\com \"\"''coisas [[estranhas]] ]]'" io.output(file) assert(io.write(string.format("x2 = %q\n-- comment without ending EOS", x1))) io.close() assert(loadfile(file))() assert(x1 == x2) print('+') assert(os.remove(file)) assert(os.remove(file) == nil) assert(os.remove(otherfile) == nil) io.output(file) assert(io.write("qualquer coisa\n")) assert(io.write("mais qualquer coisa")) io.close() io.output(assert(io.open(otherfile, 'wb'))) assert(io.write("outra coisa\0\1\3\0\0\0\0\255\0")) io.close() local filehandle = assert(io.open(file, 'r')) local otherfilehandle = assert(io.open(otherfile, 'rb')) assert(filehandle ~= otherfilehandle) assert(type(filehandle) == "userdata") assert(filehandle:read('*l') == "qualquer coisa") io.input(otherfilehandle) assert(io.read(string.len"outra coisa") == "outra coisa") assert(filehandle:read('*l') == "mais qualquer coisa") filehandle:close(); assert(type(filehandle) == "userdata") io.input(otherfilehandle) assert(io.read(4) == "\0\1\3\0") assert(io.read(3) == "\0\0\0") assert(io.read(0) == "") -- 255 is not eof assert(io.read(1) == "\255") assert(io.read('*a') == "\0") assert(not io.read(0)) assert(otherfilehandle == io.input()) otherfilehandle:close() assert(os.remove(file)) assert(os.remove(otherfile)) collectgarbage() io.output(file) io.write[[ 123.4 -56e-2 not a number second line third line and the rest of the file ]] io.close() io.input(file) local _,a,b,c,d,e,h,__ = io.read(1, '*n', '*n', '*l', '*l', '*l', '*a', 10) assert(io.close(io.input())) assert(_ == ' ' and __ == nil) assert(type(a) == 'number' and a==123.4 and b==-56e-2) assert(d=='second line' and e=='third line') assert(h==[[ and the rest of the file ]]) assert(os.remove(file)) collectgarbage() -- testing buffers do local f = assert(io.open(file, "w")) local fr = assert(io.open(file, "r")) assert(f:setvbuf("full", 2000)) f:write("x") assert(fr:read("*all") == "") -- full buffer; output not written yet f:close() fr:seek("set") assert(fr:read("*all") == "x") -- `close' flushes it f = assert(io.open(file), "w") assert(f:setvbuf("no")) f:write("x") fr:seek("set") assert(fr:read("*all") == "x") -- no buffer; output is ready f:close() f = assert(io.open(file, "a")) assert(f:setvbuf("line")) f:write("x") fr:seek("set", 1) assert(fr:read("*all") == "") -- line buffer; no output without `\n' f:write("a\n") fr:seek("set", 1) assert(fr:read("*all") == "xa\n") -- now we have a whole line f:close(); fr:close() end -- testing large files (> BUFSIZ) io.output(file) for i=1,5001 do io.write('0123456789123') end io.write('\n12346') io.close() io.input(file) local x = io.read('*a') io.input():seek('set', 0) local y = io.read(30001)..io.read(1005)..io.read(0)..io.read(1)..io.read(100003) assert(x == y and string.len(x) == 5001*13 + 6) io.input():seek('set', 0) y = io.read() -- huge line assert(x == y..'\n'..io.read()) assert(io.read() == nil) io.close(io.input()) assert(os.remove(file)) x = nil; y = nil x, y = pcall(io.popen, "ls") if x then assert(y:read("*a")) assert(y:close()) else (Message or print)('\a\n >>> popen not available<<<\n\a') end print'+' local t = os.time() T = os.date("*t", t) loadstring(os.date([[assert(T.year==%Y and T.month==%m and T.day==%d and T.hour==%H and T.min==%M and T.sec==%S and T.wday==%w+1 and T.yday==%j and type(T.isdst) == 'boolean')]], t))() assert(os.time(T) == t) T = os.date("!*t", t) loadstring(os.date([[!assert(T.year==%Y and T.month==%m and T.day==%d and T.hour==%H and T.min==%M and T.sec==%S and T.wday==%w+1 and T.yday==%j and type(T.isdst) == 'boolean')]], t))() do local T = os.date("*t") local t = os.time(T) assert(type(T.isdst) == 'boolean') T.isdst = nil local t1 = os.time(T) assert(t == t1) -- if isdst is absent uses correct default end t = os.time(T) T.year = T.year-1; local t1 = os.time(T) -- allow for leap years assert(math.abs(os.difftime(t,t1)/(24*3600) - 365) < 2) t = os.time() t1 = os.time(os.date("*t")) assert(os.difftime(t1,t) <= 2) local t1 = os.time{year=2000, month=10, day=1, hour=23, min=12, sec=17} local t2 = os.time{year=2000, month=10, day=1, hour=23, min=10, sec=19} assert(os.difftime(t1,t2) == 60*2-2) io.output(io.stdout) local d = os.date('%d') local m = os.date('%m') local a = os.date('%Y') local ds = os.date('%w') + 1 local h = os.date('%H') local min = os.date('%M') local s = os.date('%S') io.write(string.format('test done on %2.2d/%2.2d/%d', d, m, a)) io.write(string.format(', at %2.2d:%2.2d:%2.2d\n', h, min, s)) io.write(string.format('%s\n', _VERSION))
apache-2.0
waytim/darkstar
scripts/zones/Southern_San_dOria/npcs/Emoussine.lua
27
2406
----------------------------------- -- Area: Southern San d'Oria -- NPC: Emoussine -- Type: Chocobo Renter -- @pos -11 1 -100 ----------------------------------- package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/zones/Southern_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if (FlyerForRegine == 1) then count = trade:getItemCount(); MagicFlyer = trade:hasItemQty(532,1); if (MagicFlyer == true and count == 1) then player:messageSpecial(FLYER_REFUSED); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local level = player:getMainLvl(); local gil = player:getGil(); if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then local price = getChocoboPrice(player); player:setLocalVar("chocoboPriceOffer",price); if (level >= 20) then level = 0; end player:startEvent(0x0258,price,gil,level); else player:startEvent(0x025B); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish Action ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); local price = player:getLocalVar("chocoboPriceOffer"); if (csid == 0x0258 and option == 0) then if (player:delGil(price)) then updateChocoboPrice(player, price); if (player:getMainLvl() >= 20) then local duration = 1800 + (player:getMod(MOD_CHOCOBO_RIDING_TIME) * 60) player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,duration,true); else player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); end player:setPos(-126,-62,274,0x65,0x64); end end end;
gpl-3.0
waytim/darkstar
scripts/zones/West_Sarutabaruta/npcs/Twinkle_Tree.lua
13
2325
----------------------------------- -- Area: West Sarutabaruta -- NPC: Twinkle Tree -- Involved in Quest: To Catch a Falling Star -- Note: EventID for Twinkle Tree is unknown. Quest funtions but the full event is not played. -- @pos 156.003 -40.753 333.742 115 ----------------------------------- package.loaded["scripts/zones/West_Sarutabaruta/TextIDs"] = nil; ----------------------------------- require("scripts/globals/quests"); require("scripts/globals/settings"); require("scripts/globals/titles"); require("scripts/globals/status"); require("scripts/zones/West_Sarutabaruta/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) starstatus = player:getQuestStatus(WINDURST,TO_CATCH_A_FALLIHG_STAR); if (starstatus == 1 and VanadielHour() <= 3) then if (trade:getGil() == 0 and trade:hasItemQty(868,1) == true and trade:getItemCount() == 1 and player:getVar("QuestCatchAFallingStar_prog") == 0) then if (player:getFreeSlotsCount() == 0) then player:messageSpecial(7336); player:messageSpecial(7338); player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,546); else player:tradeComplete(trade); player:messageSpecial(7336); player:messageSpecial(7338); player:addItem(546,1); player:messageSpecial(ITEM_OBTAINED,546); player:setVar("QuestCatchAFallingStar_prog",1); end end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (VanadielHour() <= 3 and player:getVar("QuestCatchAFallingStar_prog") == 0) then player:messageSpecial(7336); player:messageSpecial(7338); else player:messageSpecial(7339); 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
Fir3element/tfs12
data/npc/scripts/The Oracle.lua
21
3593
local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local vocation = {} local town = {} local destination = {} 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 local function greetCallback(cid) local player = Player(cid) local level = player:getLevel() if level < 8 then npcHandler:say("CHILD! COME BACK WHEN YOU HAVE GROWN UP!", cid) return false elseif level > 9 then npcHandler:say(player:getName() .. ", I CAN'T LET YOU LEAVE - YOU ARE TOO STRONG ALREADY! YOU CAN ONLY LEAVE WITH LEVEL 9 OR LOWER.", cid) return false elseif player:getVocation():getId() > 0 then npcHandler:say("YOU ALREADY HAVE A VOCATION!", cid) return false end return true end local function creatureSayCallback(cid, type, msg) if not npcHandler:isFocused(cid) then return false end if msgcontains(msg, "yes") and npcHandler.topic[cid] == 0 then npcHandler:say("IN WHICH TOWN DO YOU WANT TO LIVE: {RHYVES}?", cid) npcHandler.topic[cid] = 1 elseif npcHandler.topic[cid] == 1 then if msgcontains(msg, "rhyves") then town[cid] = 2 destination[cid] = Position(159, 387, 6) npcHandler:say("IN RHYVES! AND WHAT PROFESSION HAVE YOU CHOSEN: {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid) npcHandler.topic[cid] = 2 else npcHandler:say("IN WHICH TOWN DO YOU WANT TO LIVE: {RHYVES}?", cid) end elseif npcHandler.topic[cid] == 2 then if msgcontains(msg, "sorcerer") then npcHandler:say("A SORCERER! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", cid) npcHandler.topic[cid] = 3 vocation[cid] = 1 elseif msgcontains(msg, "druid") then npcHandler:say("A DRUID! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", cid) npcHandler.topic[cid] = 3 vocation[cid] = 2 elseif msgcontains(msg, "paladin") then npcHandler:say("A PALADIN! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", cid) npcHandler.topic[cid] = 3 vocation[cid] = 3 elseif msgcontains(msg, "knight") then npcHandler:say("A KNIGHT! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", cid) npcHandler.topic[cid] = 3 vocation[cid] = 4 else npcHandler:say("{KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid) end elseif npcHandler.topic[cid] == 3 then if msgcontains(msg, "yes") then local player = Player(cid) npcHandler:say("SO BE IT!", cid) player:setVocation(Vocation(vocation[cid])) player:setTown(Town(town[cid])) local destination = destination[cid] npcHandler:releaseFocus(cid) player:teleportTo(destination) player:getPosition():sendMagicEffect(CONST_ME_TELEPORT) destination:sendMagicEffect(CONST_ME_TELEPORT) else npcHandler:say("THEN WHAT? {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid) npcHandler.topic[cid] = 2 end end return true end local function onAddFocus(cid) town[cid] = 0 vocation[cid] = 0 destination[cid] = 0 end local function onReleaseFocus(cid) town[cid] = nil vocation[cid] = nil destination[cid] = nil end npcHandler:setCallback(CALLBACK_ONADDFOCUS, onAddFocus) npcHandler:setCallback(CALLBACK_ONRELEASEFOCUS, onReleaseFocus) npcHandler:setCallback(CALLBACK_GREET, greetCallback) npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
gpl-2.0
waytim/darkstar
scripts/globals/weaponskills/heavy_swing.lua
11
1335
----------------------------------- -- Heavy Swing -- Staff weapon skill -- Skill Level: 5 -- Deacription:Delivers a single-hit attack. Damage varies with TP. -- Will stack with Sneak Attack. -- Aligned with the Thunder Gorget. -- Aligned with the Thunder Belt. -- Element: None -- Modifiers: STR:30% -- 100%TP 200%TP 300%TP -- 1.00 1.25 2.25 ----------------------------------- require("scripts/globals/status"); require("scripts/globals/settings"); require("scripts/globals/weaponskills"); ----------------------------------- function onUseWeaponSkill(player, target, wsID, tp, primary) local params = {}; params.numHits = 1; params.ftp100 = 1; params.ftp200 = 1.25; params.ftp300 = 2.25; params.str_wsc = 0.3; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0; params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0; params.canCrit = false; params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0; params.atkmulti = 1; if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then params.str_wsc = 1.0; end local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, params, tp, primary); return tpHits, extraHits, criticalHit, damage; end
gpl-3.0
testprooject/magma
plugins/anti_spam.lua
4
3665
kicktable = {} do local TIME_CHECK = 2 -- seconds local data = load_data(_config.moderation.data) -- Save stats, ban user local function pre_process(msg) -- Ignore service msg if msg.service then return msg end if msg.from.id == our_id then return msg end --Load moderation data local data = load_data(_config.moderation.data) if data[tostring(msg.to.id)] then --Check if flood is one or off if data[tostring(msg.to.id)]['settings']['flood'] == 'no' then return msg end end -- Save user on Redis if msg.from.type == 'user' then local hash = 'user:'..msg.from.id print('Saving user', hash) if msg.from.print_name then redis:hset(hash, 'print_name', msg.from.print_name) end if msg.from.first_name then redis:hset(hash, 'first_name', msg.from.first_name) end if msg.from.last_name then redis:hset(hash, 'last_name', msg.from.last_name) end end -- Save stats on Redis if msg.to.type == 'chat' then -- User is on chat local hash = 'chat:'..msg.to.id..':users' redis:sadd(hash, msg.from.id) end -- Total user msgs local hash = 'msgs:'..msg.from.id..':'..msg.to.id redis:incr(hash) -- Check flood if msg.from.type == 'user' then local hash = 'user:'..msg.from.id..':msgs' local msgs = tonumber(redis:get(hash) or 0) local data = load_data(_config.moderation.data) local NUM_MSG_MAX = 5 if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['settings']['flood_msg_max'] then NUM_MSG_MAX = tonumber(data[tostring(msg.to.id)]['settings']['flood_msg_max'])--Obtain group flood sensitivity end end local max_msg = NUM_MSG_MAX * 1 if msgs > max_msg then local user = msg.from.id -- Ignore mods,owner and admins if is_momod(msg) then return msg end local chat = msg.to.id local user = msg.from.id -- Return end if user was kicked before if kicktable[user] == true then return end kick_user(user, chat) local name = user_print_name(msg.from) --save it to log file savelog(msg.to.id, name.." ["..msg.from.id.."] spammed and kicked ! ") -- incr it on redis local gbanspam = 'gban:spam'..msg.from.id redis:incr(gbanspam) local gbanspam = 'gban:spam'..msg.from.id local gbanspamonredis = redis:get(gbanspam) --Check if user has spammed is group more than 4 times if gbanspamonredis then if tonumber(gbanspamonredis) == 4 and not is_owner(msg) then --Global ban that user banall_user(msg.from.id) local gbanspam = 'gban:spam'..msg.from.id --reset the counter redis:set(gbanspam, 0) local username = " " if msg.from.username ~= nil then username = msg.from.username end local name = user_print_name(msg.from) --Send this to that chat send_large_msg("chat#id"..msg.to.id, "User [ "..name.." ]"..msg.from.id.." Globally banned (spamming)") local log_group = 1 --set log group caht id --send it to log group send_large_msg("chat#id"..log_group, "User [ "..name.." ] ( @"..username.." )"..msg.from.id.." Globally banned from ( "..msg.to.print_name.." ) [ "..msg.to.id.." ] (spamming)") end end kicktable[user] = true msg = nil end redis:setex(hash, TIME_CHECK, msgs+1) end return msg end local function cron() --clear that table on the top of the plugins kicktable = {} end return { patterns = {}, cron = cron, pre_process = pre_process } end
gpl-2.0
TienHP/Aquaria
files/scripts/maps/_unused/node_prologue.lua
6
1881
-- Copyright (C) 2007, 2010 - Bit-Blot -- -- This file is part of Aquaria. -- -- Aquaria 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. if not v then v = {} end if not AQUARIA_VERSION then dofile("scripts/entities/entityinclude.lua") end v.n = 0 v.n1 = 0 v.n2 = 0 v.n3 = 0 function init(me) v.n = getNaija() node_setCursorActivation(me, true) v.n1 = getNode("N1") -- monsters v.n2 = getNode("N2") v.n3 = getNode("N3") end function update(me, dt) end function activate(me) entity_idle(v.n) shakeCamera(0,0.001) fade(1,0) setCameraLerpDelay(0.0001) cam_toNode(v.n1) overrideZoom(0.7) overrideZoom(1, 12) fade(0, 4) watch(4) watch(4) fade(1, 4) watch(4) cam_toNode(v.n2) watch(2) shakeCamera(2, 200) fade(0, 0.1) watch(0.1) fade(1, 0.1) watch(0.1) fade(0, 0.1) watch(0.1) fade(1, 0.1) watch(0.1) watch(0.5) fade(0, 0.1) watch(0.1) watch(1) fade(1, 0.2) watch(0.2) cam_toNode(v.n3) fade(0, 0.1) watch(0.1) fade(1, 0.1) watch(0.1) fade(0, 0.1) watch(0.1) fade(1, 0.1) watch(0.1) watch(0.5) fade(0, 0.1) watch(0.1) watch(1) fade(1, 0.2) watch(0.2) setCameraLerpDelay(0) fade(0,1) cam_toEntity(v.n) shakeCamera(0,0.001) overrideZoom(0) end
gpl-2.0
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/zones/Port_Bastok/npcs/Corann.lua
6
1984
----------------------------------- -- Area: Port Bastok -- NPC: Corann -- Start & Finishes Quest: The Quadav's Curse ----------------------------------- package.loaded["scripts/zones/Port_Bastok/TextIDs"] = nil; ----------------------------------- require("scripts/globals/quests"); require("scripts/globals/settings"); require("scripts/zones/Port_Bastok/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) TheQuadav = player:getQuestStatus(BASTOK,THE_QUADAV_S_CURSE); if (TheQuadav == QUEST_ACCEPTED) then count = trade:getItemCount(); QuadavBack = trade:hasItemQty(596,1); if (count == 1 and QuadavBack == true) then player:startEvent(0x0051); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) TheQuadav = player:getQuestStatus(BASTOK,THE_QUADAV_S_CURSE); OutOfOneShell = player:getQuestStatus(BASTOK,OUT_OF_ONE_S_SHELL); if (OutOfOneShell == QUEST_COMPLETED) then player:startEvent(0x0058); elseif (TheQuadav == QUEST_COMPLETED) then player:startEvent(0x0057); elseif (TheQuadav == QUEST_AVAILABLE) then player:startEvent(0x0050); else player:startEvent(0x0026); 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 == 0x0050) then player:addQuest(BASTOK,THE_QUADAV_S_CURSE); elseif (csid == 0x0051) then player:tradeComplete(); player:completeQuest(BASTOK,THE_QUADAV_S_CURSE); player:addFame(BASTOK,BAS_FAME*120); player:addItem(12832); player:messageSpecial(ITEM_OBTAINED,12832); end end;
gpl-3.0
TheOnePharaoh/YGOPro-Custom-Cards
script/c20162004.lua
2
3742
--Lizardfolk - Spearman function c20162004.initial_effect(c) --synchro custom local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_SYNCHRO_MATERIAL_CUSTOM) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e1:SetTarget(c20162004.syntg) e1:SetValue(1) e1:SetOperation(c20162004.synop) c:RegisterEffect(e1) --search local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(20162004,0)) e2:SetCategory(CATEGORY_DRAW) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F) e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_DELAY) e2:SetRange(LOCATION_MZONE) e2:SetCode(EVENT_TO_DECK) e2:SetCondition(c20162004.condition) e2:SetTarget(c20162004.target) e2:SetOperation(c20162004.operation) c:RegisterEffect(e2) --todeck local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(20162004,1)) e3:SetCategory(CATEGORY_TODECK) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_BE_MATERIAL) e3:SetCondition(c20162004.tdcon) e3:SetTarget(c20162004.tdtg) e3:SetOperation(c20162004.tdop) c:RegisterEffect(e3) end function c20162004.synfilter1(c,syncard,tuner,f) return c:IsFaceup() and c:IsNotTuner() and c:IsCanBeSynchroMaterial(syncard,tuner) and (f==nil or f(c)) end function c20162004.synfilter2(c,syncard,tuner,f) return c:IsSetCard(0xab90) and c:IsNotTuner() and c:IsCanBeSynchroMaterial(syncard,tuner) and (f==nil or f(c)) end function c20162004.syntg(e,syncard,f,minc,maxc) local c=e:GetHandler() local lv=syncard:GetLevel()-c:GetLevel() if lv<=0 then return false end local g=Duel.GetMatchingGroup(c20162004.synfilter1,syncard:GetControler(),LOCATION_MZONE,LOCATION_MZONE,c,syncard,c,f) if syncard:IsRace(RACE_REPTILE) then local exg=Duel.GetMatchingGroup(c20162004.synfilter2,syncard:GetControler(),LOCATION_HAND,0,c,syncard,c,f) g:Merge(exg) end return g:CheckWithSumEqual(Card.GetSynchroLevel,lv,minc,maxc,syncard) end function c20162004.synop(e,tp,eg,ep,ev,re,r,rp,syncard,f,minc,maxc) local c=e:GetHandler() local lv=syncard:GetLevel()-c:GetLevel() local g=Duel.GetMatchingGroup(c20162004.synfilter1,syncard:GetControler(),LOCATION_MZONE,LOCATION_MZONE,c,syncard,c,f) if syncard:IsRace(RACE_REPTILE) then local exg=Duel.GetMatchingGroup(c20162004.synfilter2,syncard:GetControler(),LOCATION_HAND,0,c,syncard,c,f) g:Merge(exg) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SMATERIAL) local sg=g:SelectWithSumEqual(tp,Card.GetSynchroLevel,lv,minc,maxc,syncard) Duel.SetSynchroMaterial(sg) end function c20162004.cfilter(c,tp) return c:IsControler(tp) and c:GetPreviousControler()==tp and (c:IsPreviousLocation(LOCATION_HAND) or (c:IsPreviousLocation(LOCATION_ONFIELD) and c:IsPreviousPosition(POS_FACEUP))) and c:IsRace(RACE_REPTILE) end function c20162004.condition(e,tp,eg,ep,ev,re,r,rp) return bit.band(r,REASON_COST+REASON_EFFECT)~=0 and eg:IsExists(c20162004.cfilter,1,nil,tp) end function c20162004.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,1) end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(1) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function c20162004.operation(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Draw(p,d,REASON_EFFECT) end function c20162004.tdcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsLocation(LOCATION_GRAVE) and r==REASON_SYNCHRO end function c20162004.tdtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_TODECK,e:GetHandler(),1,0,0) end function c20162004.tdop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) then Duel.SendtoDeck(c,nil,1,REASON_EFFECT) end end
gpl-3.0
waytim/darkstar
scripts/zones/Windurst_Waters/npcs/Leepe-Hoppe.lua
13
9408
----------------------------------- -- Area: Windurst Waters -- NPC: Leepe-Hoppe -- Involved in Mission 1-3, Mission 7-2 -- @pos 13 -9 -197 238 ----------------------------------- package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/missions"); require("scripts/globals/keyitems"); require("scripts/zones/Windurst_Waters/TextIDs"); ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local moonlitPath = player:getQuestStatus(WINDURST,THE_MOONLIT_PATH) local realday = tonumber(os.date("%j")); -- %M for next minute, %j for next day local MissionStatus = player:getVar("MissionStatus"); -- Check if we are on Windurst Mission 1-3 and haven't already delivered both offerings. if (player:getCurrentMission(WINDURST) == THE_PRICE_OF_PEACE and MissionStatus < 3) then if (player:hasKeyItem(FOOD_OFFERINGS) == false and player:hasKeyItem(DRINK_OFFERINGS) == false) then player:startEvent(140); elseif (MissionStatus >= 1) then player:startEvent(142); -- Keep displaying the instructions end -- Check if we are on Windurst Mission 7-2 elseif (player:getCurrentMission(WINDURST) == AWAKENING_OF_THE_GODS and player:getVar("MissionStatus") == 0) then player:startEvent(734); elseif (player:getCurrentMission(WINDURST) == AWAKENING_OF_THE_GODS and player:getVar("MissionStatus") == 1) then player:startEvent(735); elseif (player:getCurrentMission(WINDURST) == AWAKENING_OF_THE_GODS and player:getVar("MissionStatus") == 2) then player:startEvent(739); elseif (player:getCurrentMission(WINDURST) == AWAKENING_OF_THE_GODS and player:getVar("MissionStatus") == 5 and player:hasKeyItem(BOOK_OF_THE_GODS)) then player:startEvent(742); --------------------------- elseif (player:getQuestStatus(WINDURST,FOOD_FOR_THOUGHT) == QUEST_ACCEPTED) then player:startEvent(311); -- The Moonlit Path and Other Fenrir Stuff! elseif (moonlitPath == QUEST_AVAILABLE and player:getFameLevel(WINDURST) >= 6 and player:getFameLevel(SANDORIA) >= 6 and player:getFameLevel(BASTOK) >= 6 and player:getFameLevel(NORG) >= 4) then -- Fenrir flag event player:startEvent(842,0,1125); elseif (moonlitPath == QUEST_ACCEPTED) then if (player:hasKeyItem(MOON_BAUBLE)) then -- Default text after acquiring moon bauble and before fighting Fenrir player:startEvent(845,0,1125,334); elseif (player:hasKeyItem(WHISPER_OF_THE_MOON)) then -- First turn-in player:startEvent(846,0,13399,1208,1125,0,18165,13572); elseif (player:hasKeyItem(WHISPER_OF_FLAMES) and player:hasKeyItem(WHISPER_OF_TREMORS) and player:hasKeyItem(WHISPER_OF_TIDES) and player:hasKeyItem(WHISPER_OF_GALES) and player:hasKeyItem(WHISPER_OF_FROST) and player:hasKeyItem(WHISPER_OF_STORMS)) then -- Collected the whispers player:startEvent(844,0,1125,334); else -- Talked to after flag without the whispers player:startEvent(843,0,1125); end elseif (moonlitPath == QUEST_COMPLETED) then if (player:hasKeyItem(MOON_BAUBLE)) then -- Default text after acquiring moon bauble and before fighting Fenrir player:startEvent(845,0,1125,334); elseif (player:hasKeyItem(WHISPER_OF_THE_MOON)) then -- Repeat turn-in local availRewards = 0 if (player:hasItem(18165)) then availRewards = availRewards + 1; end -- Fenrir's Stone if (player:hasItem(13572)) then availRewards = availRewards + 2; end -- Fenrir's Cape if (player:hasItem(13138)) then availRewards = availRewards + 4; end -- Fenrir's Torque if (player:hasItem(13399)) then availRewards = availRewards + 8; end -- Fenrir's Earring if (player:hasItem(1208)) then availRewards = availRewards + 16; end -- Ancient's Key if (player:hasSpell(297)) then availRewards = availRewards + 64; end -- Pact player:startEvent(850,0,13399,1208,1125,availRewards,18165,13572); elseif (realday ~= player:getVar("MoonlitPath_date")) then --24 hours have passed, flag a new fight player:startEvent(848,0,1125,334); else player:startEvent(847,0,1125); -- Yes, this will indefinitely replace his standard dialogue! end else player:startEvent(345); -- 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); local reward = 0 if (csid == 140) then player:setVar("MissionStatus",1); player:setVar("ohbiru_dohbiru_talk",0); player:addKeyItem(FOOD_OFFERINGS); player:messageSpecial(KEYITEM_OBTAINED,FOOD_OFFERINGS); player:addKeyItem(DRINK_OFFERINGS); player:messageSpecial(KEYITEM_OBTAINED,DRINK_OFFERINGS); -- Moonlit Path and Other Fenrir Stuff elseif (csid == 842 and option == 2) then player:addQuest(WINDURST,THE_MOONLIT_PATH); elseif (csid == 844) then player:addKeyItem(MOON_BAUBLE); player:messageSpecial(KEYITEM_OBTAINED,MOON_BAUBLE); player:delKeyItem(WHISPER_OF_FLAMES); player:delKeyItem(WHISPER_OF_TREMORS); player:delKeyItem(WHISPER_OF_TIDES); player:delKeyItem(WHISPER_OF_GALES); player:delKeyItem(WHISPER_OF_FROST); player:delKeyItem(WHISPER_OF_STORMS); player:delQuest(OUTLANDS,TRIAL_BY_FIRE); player:delQuest(BASTOK,TRIAL_BY_EARTH); player:delQuest(OUTLANDS,TRIAL_BY_WATER); player:delQuest(OUTLANDS,TRIAL_BY_WIND); player:delQuest(SANDORIA,TRIAL_BY_ICE); player:delQuest(OTHER_AREAS,TRIAL_BY_LIGHTNING); elseif (csid == 846) then -- Turn-in event player:addTitle(HEIR_OF_THE_NEW_MOON); player:delKeyItem(WHISPER_OF_THE_MOON); player:setVar("MoonlitPath_date", os.date("%j")); -- %M for next minute, %j for next day player:addFame(WINDURST,30); player:completeQuest(WINDURST,THE_MOONLIT_PATH); if (option == 1) then reward = 18165; -- Fenrir's Stone elseif (option == 2) then reward = 13572; -- Fenrir's Cape elseif (option == 3) then reward = 13138; -- Fenrir's Torque elseif (option == 4) then reward = 13399; -- Fenrir's Earring elseif (option == 5) then reward = 1208; -- Ancient's Key elseif (option == 6) then player:addGil(GIL_RATE*10000); player:messageSpecial(GIL_OBTAINED,GIL_RATE*10000); -- Gil elseif (option == 7) then player:addSpell(297) -- Pact end if (player:getFreeSlotsCount() == 0 and reward ~= 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,reward); elseif (reward ~= 0) then player:addItem(reward); player:messageSpecial(ITEM_OBTAINED,reward); end if (player:getNation() == WINDURST and player:getRank() == 10 and player:getQuestStatus(WINDURST,THE_PROMISE) == QUEST_COMPLETED) then player:addKeyItem(DARK_MANA_ORB); player:messageSpecial(KEYITEM_OBTAINED,DARK_MANA_ORB); end elseif (csid == 850) then -- Repeat turn-in event player:addTitle(HEIR_OF_THE_NEW_MOON); player:delKeyItem(WHISPER_OF_THE_MOON); player:setVar("MoonlitPath_date", os.date("%j")); -- %M for next minute, %j for next day player:addFame(WINDURST,30); if (option == 1) then reward = 18165; -- Fenrir's Stone elseif (option == 2) then reward = 13572; -- Fenrir's Cape elseif (option == 3) then reward = 13138; -- Fenrir's Torque elseif (option == 4) then reward = 13399; -- Fenrir's Earring elseif (option == 5) then reward = 1208; -- Ancient's Key elseif (option == 6) then player:addGil(GIL_RATE*10000); player:messageSpecial(GIL_OBTAINED,GIL_RATE*15000); -- Gil elseif (option == 7) then player:addSpell(297) -- Pact end if (player:getFreeSlotsCount() == 0 and reward ~= 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,reward); elseif (reward ~= 0) then player:addItem(reward); player:messageSpecial(ITEM_OBTAINED,reward); end if (player:getNation() == WINDURST and player:getRank() == 10 and player:getQuestStatus(WINDURST,THE_PROMISE) == QUEST_COMPLETED) then player:addKeyItem(DARK_MANA_ORB); player:messageSpecial(KEYITEM_OBTAINED,DARK_MANA_ORB); end elseif (csid == 848) then player:addKeyItem(MOON_BAUBLE); player:messageSpecial(KEYITEM_OBTAINED,MOON_BAUBLE); elseif (csid == 734) then player:setVar("MissionStatus",1); elseif (csid == 742) then finishMissionTimeline(player,3,csid,option); end end;
gpl-3.0
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/globals/items/emerald_quiche.lua
3
1284
----------------------------------------- -- ID: 5171 -- Item: emerald_quiche -- Food Effect: 60Min, All Races ----------------------------------------- -- Magic 15 -- Agility 1 -- Ranged ACC % 7 -- Ranged ACC Cap 20 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,3600,5171); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_MP, 15); target:addMod(MOD_AGI, 1); target:addMod(MOD_FOOD_RACCP, 7); target:addMod(MOD_FOOD_RACC_CAP, 20); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_MP, 15); target:delMod(MOD_AGI, 1); target:delMod(MOD_FOOD_RACCP, 7); target:delMod(MOD_FOOD_RACC_CAP, 20); end;
gpl-3.0
waytim/darkstar
scripts/zones/Caedarva_Mire/npcs/qm1.lua
30
1329
----------------------------------- -- Area: Caedarva Mire -- NPC: ??? (Spawn Verdelet(ZNM T2)) -- @pos 417 -19 -69 79 ----------------------------------- package.loaded["scripts/zones/Caedarva_Mire/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Caedarva_Mire/TextIDs"); require("scripts/globals/status"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) local mobID = 17101202; if (trade:hasItemQty(2599,1) and trade:getItemCount() == 1) then -- Trade Mint Drop if (GetMobAction(mobID) == ACTION_NONE) then player:tradeComplete(); SpawnMob(mobID):updateClaim(player); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:messageSpecial(NOTHING_HAPPENS); 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
waytim/darkstar
scripts/zones/Lower_Jeuno/npcs/Chululu.lua
25
5445
----------------------------------- -- Area: Lower Jeuno -- NPC: Chululu -- Starts and Finishes Quests: Collect Tarut Cards, Rubbish Day -- Optional Cutscene at end of Quest: Searching for the Right Words -- @pos -13 -6 -42 245 ----------------------------------- package.loaded["scripts/zones/Lower_Jeuno/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/titles"); require("scripts/globals/keyitems"); require("scripts/globals/shop"); require("scripts/globals/quests"); require("scripts/zones/Lower_Jeuno/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if (player:getQuestStatus(JEUNO,COLLECT_TARUT_CARDS) == QUEST_ACCEPTED) then if (trade:hasItemQty(558,1) == true and trade:hasItemQty(559,1) == true and trade:hasItemQty(561,1) == true and trade:hasItemQty(562,1) == true and trade:getItemCount() == 4) then player:startEvent(0x00c8); -- Finish quest "Collect Tarut Cards" end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local CollectTarutCards = player:getQuestStatus(JEUNO,COLLECT_TARUT_CARDS); local RubbishDay = player:getQuestStatus(JEUNO,RUBBISH_DAY); local SearchingForTheRightWords = player:getQuestStatus(JEUNO,SEARCHING_FOR_THE_RIGHT_WORDS); if (player:getFameLevel(JEUNO) >= 3 and CollectTarutCards == QUEST_AVAILABLE) then player:startEvent(0x001C); -- Start quest "Collect Tarut Cards" with option elseif (CollectTarutCards == QUEST_ACCEPTED) then player:startEvent(0x001B); -- During quest "Collect Tarut Cards" elseif (CollectTarutCards == QUEST_COMPLETED and RubbishDay == QUEST_AVAILABLE and player:getVar("RubbishDay_day") ~= VanadielDayOfTheYear()) then -- prog = player:getVar("RubbishDay_prog"); -- if (prog <= 2) then -- player:startEvent(0x00c7); -- Required to get compatibility 3x on 3 diff game days before quest is kicked off -- elseif (prog == 3) then player:startEvent(0x00c6); -- Start quest "Rubbish Day" with option -- end elseif (CollectTarutCards == QUEST_COMPLETED and RubbishDay == QUEST_AVAILABLE) then player:startEvent(0x0039); -- Standard dialog between 2 quests elseif (RubbishDay == QUEST_ACCEPTED and player:getVar("RubbishDayVar") == 0) then player:startEvent(0x0031); -- During quest "Rubbish Day" elseif (RubbishDay == QUEST_ACCEPTED and player:getVar("RubbishDayVar") == 1) then player:startEvent(0x00c5); -- Finish quest "Rubbish Day" elseif (SearchingForTheRightWords == QUEST_COMPLETED) then if (player:getVar("SearchingForRightWords_postcs") < -1) then player:startEvent(0x0038); else player:startEvent(0x0057); -- final state, after all quests complete end elseif (RubbishDay == QUEST_COMPLETED) then player:startEvent(0x0057); -- New standard dialog else player:startEvent(0x001A); -- Standard dialog end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x001C and option == 0) then local rand = math.random(1,4); local card = 0; if (rand == 1) then card = 559; -- Tarut: Death elseif (rand == 2) then card = 562; -- Tarut: Hermit elseif (rand == 3) then card = 561; -- Tarut: King else card = 558; -- Tarut: Fool end if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,card); else player:addQuest(JEUNO,COLLECT_TARUT_CARDS); player:addItem(card,5); player:messageSpecial(ITEM_OBTAINED,card); end elseif (csid == 0x00c8) then player:addTitle(CARD_COLLECTOR); player:addFame(JEUNO, 30); player:tradeComplete(); player:completeQuest(JEUNO,COLLECT_TARUT_CARDS); elseif (csid == 0x00c7 and option == 0) then player:setVar("RubbishDay_prog", player:getVar("RubbishDay_prog") + 1); player:setVar("RubbishDay_day", VanadielDayOfTheYear()); -- new vanadiel day elseif (csid == 0x00c6 and option == 0) then player:addQuest(JEUNO,RUBBISH_DAY); player:addKeyItem(MAGIC_TRASH); player:messageSpecial(KEYITEM_OBTAINED,MAGIC_TRASH); player:setVar("RubbishDay_prog",0); player:setVar("RubbishDay_day",0); elseif (csid == 0x00c5) then if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,13083); else player:addGil(GIL_RATE*6000); player:messageSpecial(GIL_OBTAINED,GIL_RATE*6000); player:addItem(13083); player:messageSpecial(ITEM_OBTAINED,13083); player:setVar("RubbishDayVar",0); player:addFame(JEUNO, 30); player:completeQuest(JEUNO,RUBBISH_DAY); end end end;
gpl-3.0
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/globals/items/jar_of_ground_wasabi.lua
3
1463
----------------------------------------- -- 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) 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
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/zones/West_Ronfaure/npcs/Chatarre.lua
16
1039
----------------------------------- -- Area: West Ronfaure -- NPC: Cerite -- Type: Standard NPC -- @zone: 100 -- @pos: -263.577 -72.999 425.885 -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/West_Ronfaure/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) -- player:startEvent(136); 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
waytim/darkstar
scripts/zones/Bastok_Markets/npcs/Hortense.lua
16
1909
----------------------------------- -- Area: Bastok Markets -- NPC: Hortense -- Standard Merchant NPC -- -- Updated Aug-09-2013 by Zerahn, based on bgwiki and gamerescape ----------------------------------- require("scripts/globals/shop"); package.loaded["scripts/zones/Bastok_Markets/TextIDs"] = nil; require("scripts/zones/Bastok_Markets/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc,HORTENSE_SHOP_DIALOG); stock = { 0x1370, 64,3, --Scroll of Foe Requiem 0x1371, 441,3, --Scroll of Foe Requiem II 0x1372, 3960,3, --Scroll of Foe Requiem III 0x1373, 6912,3, --Scroll of Foe Requiem IV 0x1376, 47196,3, --Scroll of Foe Requiem VII 0x137A, 37,3, --Scroll of Army's Paeon 0x137B, 321,3, --Scroll of Army's Paeon II 0x137C, 3240,3, --Scroll of Army's Paeon III 0x137D, 5940,3, --Scroll of Army's Paeon IV 0x137F, 48944,3, --Scroll of Army's Paeon VI 0x138A, 21,3, --Scroll of Valor Minuet 0x138B, 1101,3, --Scroll of Valor Minuet II 0x138C, 5544,3, --Scroll of Valor Minuet III 0x138E, 53820,3 --Scroll of Valor Minuet V } showNationShop(player, BASTOK, 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
TheOnePharaoh/YGOPro-Custom-Cards
script/c55438801.lua
2
6098
--T.M. Master El Vain function c55438801.initial_effect(c) c:EnableReviveLimit() --special summon condition local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e1:SetCode(EFFECT_SPSUMMON_CONDITION) c:RegisterEffect(e1) --special summon local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetCode(EFFECT_SPSUMMON_PROC) e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e2:SetRange(LOCATION_HAND+LOCATION_GRAVE) e2:SetCondition(c55438801.spcon) e2:SetOperation(c55438801.spop) c:RegisterEffect(e2) --code local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e3:SetCode(EFFECT_CHANGE_CODE) e3:SetRange(LOCATION_MZONE+LOCATION_GRAVE) e3:SetValue(55438799) c:RegisterEffect(e3) --destroy local e4=Effect.CreateEffect(c) e4:SetCategory(CATEGORY_DESTROY) e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e4:SetCode(EVENT_SPSUMMON_SUCCESS) e4:SetTarget(c55438801.destg) e4:SetOperation(c55438801.desop) c:RegisterEffect(e4) --special summon2 local e5=Effect.CreateEffect(c) e5:SetDescription(aux.Stringid(55438801,0)) e5:SetCategory(CATEGORY_SPECIAL_SUMMON) e5:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e5:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP) e5:SetCode(EVENT_DESTROYED) e5:SetCondition(c55438801.condition) e5:SetTarget(c55438801.target) e5:SetOperation(c55438801.operation) c:RegisterEffect(e5) --atk down local e6=Effect.CreateEffect(c) e6:SetDescription(aux.Stringid(55438801,1)) e6:SetCategory(CATEGORY_ATKCHANGE) e6:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e6:SetCode(EVENT_REMOVE) e6:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e6:SetCountLimit(1,55438801) e6:SetTarget(c55438801.atkctg) e6:SetOperation(c55438801.atkcop) c:RegisterEffect(e6) end function c55438801.spfilter(c) return c:IsSetCard(0xd70) and c:IsType(TYPE_MONSTER) and c:IsAbleToRemoveAsCost() end function c55438801.spcon(e,c) if c==nil then return true end local tp=c:GetControler() local sum=0 for i=0,4 do local tc=Duel.GetFieldCard(tp,LOCATION_MZONE,i) if tc and tc:IsFaceup() and tc:IsAttribute(ATTRIBUTE_LIGHT) then if tc:IsType(TYPE_XYZ) then sum=sum+tc:GetRank() else sum=sum+tc:GetLevel() end end end if sum>12 then return false end local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) if ft<-2 then return false end if c:IsHasEffect(55438812) then if ft>0 then return Duel.IsExistingMatchingCard(c55438801.spfilter,tp,LOCATION_MZONE+LOCATION_GRAVE+LOCATION_HAND,0,3,c) else local ct=-ft+1 return Duel.IsExistingMatchingCard(c55438801.spfilter,tp,LOCATION_MZONE,0,ct,nil) and Duel.IsExistingMatchingCard(c55438801.spfilter,tp,LOCATION_MZONE+LOCATION_GRAVE+LOCATION_HAND,0,3,c) end else return ft>0 and Duel.IsExistingMatchingCard(c55438801.spfilter,tp,LOCATION_GRAVE+LOCATION_HAND,0,3,c) end end function c55438801.spop(e,tp,eg,ep,ev,re,r,rp,c) local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) local g=nil Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) if c:IsHasEffect(55438812) then if ft>0 then g=Duel.SelectMatchingCard(tp,c55438801.spfilter,tp,LOCATION_MZONE+LOCATION_GRAVE+LOCATION_HAND,0,3,3,c) else local sg=Duel.GetMatchingGroup(c55438801.spfilter,tp,LOCATION_MZONE+LOCATION_GRAVE+LOCATION_HAND,0,c) local ct=-ft+1 g=sg:FilterSelect(tp,Card.IsLocation,ct,ct,nil,LOCATION_MZONE) if ct<3 then sg:Sub(g) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g2=sg:Select(tp,3-ct,3-ct,nil) g:Merge(g2) end end else g=Duel.SelectMatchingCard(tp,c55438801.spfilter,tp,LOCATION_GRAVE+LOCATION_HAND,0,3,3,c) end Duel.Remove(g,POS_FACEUP,REASON_COST) end function c55438801.desfilter(c) return (c:IsFacedown() or not c:IsSetCard(0xd70)) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsDestructable() end function c55438801.destg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c55438801.desfilter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,nil) end local g=Duel.GetMatchingGroup(c55438801.desfilter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0) end function c55438801.desop(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(c55438801.desfilter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil) if g:GetCount()>0 then Duel.Destroy(g,REASON_EFFECT) end end function c55438801.condition(e,tp,eg,ep,ev,re,r,rp) return rp~=tp and e:GetHandler():GetPreviousControler()==tp end function c55438801.filter(c,e,tp) return c:IsType(TYPE_MONSTER) and c:IsSetCard(0xd70) and c:IsLevelBelow(10) and not c:IsCode(55438801) and c:IsCanBeSpecialSummoned(e,0,tp,true,false) end function c55438801.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c55438801.filter,tp,LOCATION_REMOVED,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_REMOVED) end function c55438801.operation(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c55438801.filter,tp,LOCATION_REMOVED,0,1,1,nil,e,tp) if g:GetCount()>0 then Duel.SpecialSummon(g,0,tp,tp,true,false,POS_FACEUP) end end function c55438801.atkctg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(Card.IsFaceup,tp,0,LOCATION_MZONE,1,nil) end end function c55438801.atkcop(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(Card.IsFaceup,tp,0,LOCATION_MZONE,nil) if g:GetCount()>0 then local d=Duel.TossDice(tp,1)*100 local sc=g:GetFirst() while sc do local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) e1:SetValue(-d) sc:RegisterEffect(e1) local e2=e1:Clone() e2:SetCode(EFFECT_UPDATE_DEFENSE) sc:RegisterEffect(e2) sc=g:GetNext() end end end
gpl-3.0
waytim/darkstar
scripts/globals/effects/str_down.lua
34
1111
----------------------------------- -- -- EFFECT_STR_DOWN -- ----------------------------------- require("scripts/globals/status"); ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) if ((target:getStat(MOD_STR) - effect:getPower()) < 0) then effect:setPower(target:getStat(MOD_STR)); end target:addMod(MOD_STR,-effect:getPower()); end; ----------------------------------- -- onEffectTick Action ----------------------------------- function onEffectTick(target,effect) -- the effect restore strengh of 1 every 3 ticks. local downSTR_effect_size = effect:getPower() if (downSTR_effect_size > 0) then effect:setPower(downSTR_effect_size - 1) target:delMod(MOD_STR,-1); end end; ----------------------------------- -- onEffectLose Action ----------------------------------- function onEffectLose(target,effect) local downSTR_effect_size = effect:getPower() if (downSTR_effect_size > 0) then target:delMod(MOD_STR,-downSTR_effect_size); end end;
gpl-3.0
forcecore/OpenRA
mods/d2k/maps/ordos-04/ordos04.lua
5
5410
Base = { Harkonnen = { HRefinery, SHeavyFactory, SLightFactory, HGunTurret1, HGunTurret2, HGunTurret3, HGunTurret4, HGunTurret5, SBarracks, HPower1, HPower2, HPower3, HPower4 }, Smugglers = { SOutpost, SHeavyFactory, SLightFactory, SGunTurret1, SGunTurret2, SGunTurret3, SGunTurret4, SBarracks, SPower1, SPower2, SPower3 } } HarkonnenLightInfantryRushers = { easy = { "light_inf", "light_inf", "light_inf", "light_inf", "light_inf", "light_inf", "light_inf" }, normal = { "light_inf", "light_inf", "light_inf", "light_inf", "light_inf", "light_inf", "light_inf", "light_inf" }, hard = { "light_inf", "light_inf", "light_inf", "light_inf", "light_inf", "light_inf", "light_inf", "light_inf", "light_inf" } } HarkonnenAttackDelay = { easy = DateTime.Minutes(3) + DateTime.Seconds(30), normal = DateTime.Minutes(2) + DateTime.Seconds(30), hard = DateTime.Minutes(1) + DateTime.Seconds(30) } InitialReinforcements = { Harkonnen = { "combat_tank_h", "combat_tank_h", "trike", "quad" }, Smugglers = { "light_inf", "light_inf", "light_inf", "light_inf", "trooper", "trooper", "trooper" } } LightInfantryRushersPaths = { { HarkonnenEntry1.Location, HarkonnenRally1.Location }, { HarkonnenEntry2.Location, HarkonnenRally2.Location }, { HarkonnenEntry3.Location, HarkonnenRally3.Location } } InitialReinforcementsPaths = { Harkonnen = { HarkonnenEntry4.Location, HarkonnenRally4.Location }, Smugglers = { SmugglerEntry.Location, SmugglerRally.Location } } OrdosReinforcements = { "light_inf", "light_inf", "light_inf", "light_inf" } OrdosPath = { OrdosEntry.Location, OrdosRally.Location } SendHarkonnen = function(path) Trigger.AfterDelay(HarkonnenAttackDelay[Difficulty], function() if player.IsObjectiveCompleted(KillHarkonnen) then return end local units = Reinforcements.ReinforceWithTransport(harkonnen, "carryall.reinforce", HarkonnenLightInfantryRushers[Difficulty], path, { path[1] })[2] Utils.Do(units, function(unit) unit.AttackMove(HarkonnenAttackLocation) IdleHunt(unit) end) end) end Hunt = function(house) Trigger.OnAllKilledOrCaptured(Base[house.Name], function() Utils.Do(house.GetGroundAttackers(), IdleHunt) end) end CheckHarvester = function(house) if DateTime.GameTime % DateTime.Seconds(30) and HarvesterKilled[house.Name] then local units = house.GetActorsByType("harvester") if #units > 0 then HarvesterKilled[house.Name] = false ProtectHarvester(units[1], house) end end end Tick = function() if player.HasNoRequiredUnits() then harkonnen.MarkCompletedObjective(KillOrdosH) smuggler.MarkCompletedObjective(KillOrdosS) smuggler.MarkCompletedObjective(DefendOutpost) end if harkonnen.HasNoRequiredUnits() and not player.IsObjectiveCompleted(KillHarkonnen) then Media.DisplayMessage("The Harkonnen have been annihilated!", "Mentat") player.MarkCompletedObjective(KillHarkonnen) end CheckHarvester(harkonnen) CheckHarvester(smuggler) if SOutpost.IsDead then player.MarkFailedObjective(CaptureOutpost) end if SOutpost.Owner == player then player.MarkCompletedObjective(CaptureOutpost) smuggler.MarkFailedObjective(DefendOutpost) end end WorldLoaded = function() harkonnen = Player.GetPlayer("Harkonnen") smuggler = Player.GetPlayer("Smugglers") player = Player.GetPlayer("Ordos") Difficulty = Map.LobbyOption("difficulty") InitObjectives() Camera.Position = OConyard.CenterPosition HarkonnenAttackLocation = OConyard.Location Hunt(harkonnen) Hunt(smuggler) SendHarkonnen(LightInfantryRushersPaths[1]) SendHarkonnen(LightInfantryRushersPaths[2]) SendHarkonnen(LightInfantryRushersPaths[3]) ActivateAI() Actor.Create("upgrade.barracks", true, { Owner = harkonnen }) Actor.Create("upgrade.light", true, { Owner = harkonnen }) Actor.Create("upgrade.barracks", true, { Owner = smuggler }) Actor.Create("upgrade.light", true, { Owner = smuggler }) Trigger.AfterDelay(HarkonnenAttackDelay[Difficulty] - DateTime.Seconds(5), function() Media.PlaySpeechNotification(player, "Reinforce") Reinforcements.Reinforce(player, OrdosReinforcements, OrdosPath) end) Trigger.AfterDelay(HarkonnenAttackDelay[Difficulty], function() Media.DisplayMessage("WARNING: Large force approaching!", "Mentat") end) end InitObjectives = function() Trigger.OnObjectiveAdded(player, function(p, id) Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective") end) KillOrdosH = harkonnen.AddPrimaryObjective("Kill all Ordos units.") KillOrdosS = smuggler.AddSecondaryObjective("Kill all Ordos units.") DefendOutpost = smuggler.AddPrimaryObjective("Don't let the outpost to be captured or destroyed.") CaptureOutpost = player.AddPrimaryObjective("Capture the Smuggler Outpost.") KillHarkonnen = player.AddSecondaryObjective("Destroy the Harkonnen.") Trigger.OnObjectiveCompleted(player, function(p, id) Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed") end) Trigger.OnObjectiveFailed(player, function(p, id) Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed") end) Trigger.OnPlayerLost(player, function() Trigger.AfterDelay(DateTime.Seconds(1), function() Media.PlaySpeechNotification(player, "Lose") end) end) Trigger.OnPlayerWon(player, function() Trigger.AfterDelay(DateTime.Seconds(1), function() Media.PlaySpeechNotification(player, "Win") end) end) end
gpl-3.0
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/zones/Port_Bastok/npcs/Ominous_Cloud.lua
2
5263
----------------------------------- -- Area: Port Bastok -- NPC: Ominous Cloud -- Type: Traveling Merchant NPC -- @zone: 236 -- @pos: 146.962 7.499 -63.316 -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/Port_Bastok/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Port_Bastok/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) local wijinruit = trade:getItemQty(951) local uchitake = (trade:getItemQty(1161) / 99) local tsurara = (trade:getItemQty(1164) / 99) local kawahori = (trade:getItemQty(1167) / 99) local makibishi = (trade:getItemQty(1170) / 99) local hiraishin = (trade:getItemQty(1173) / 99) local mizu = (trade:getItemQty(1176) / 99) local shihei = (trade:getItemQty(1179) / 99) local jusatsu = (trade:getItemQty(1182) / 99) local kaginawa = (trade:getItemQty(1185) / 99) local sairui = (trade:getItemQty(1188) / 99) local kodoku = (trade:getItemQty(1191) / 99) local shinobi = (trade:getItemQty(1194) / 99) local sanjaku = (trade:getItemQty(2553) / 99) local soushi = (trade:getItemQty(2555) / 99) local kabenro = (trade:getItemQty(2642) / 99) local jinko = (trade:getItemQty(2643) / 99) local mokujin = (trade:getItemQty(2970) / 99) local inoshi = (trade:getItemQty(2971) / 99) local shikan = (trade:getItemQty(2972) / 99) local chono = (trade:getItemQty(2973) / 99) local tools = (uchitake + tsurara + kawahori + makibishi + hiraishin + mizu + shihei + jusatsu + kaginawa + sairui + kodoku + shinobi + sanjaku + soushi + kabenro + jinko + mokujin + inoshi + shikan + chono) if(((tools * 99) + wijinruit) == trade:getItemCount()) then if((tools == math.floor(tools)) and (tools == wijinruit) and (player:getFreeSlotsCount() >= wijinruit)) then player:tradeComplete(); if(uchitake > 0) then player:addItem(5308,uchitake); player:messageSpecial(ITEM_OBTAINED,5308); end if(tsurara > 0) then player:addItem(5309,tsurara); player:messageSpecial(ITEM_OBTAINED,5309); end if(kawahori > 0) then player:addItem(5310,kawahori); player:messageSpecial(ITEM_OBTAINED,5310); end if(makibishi > 0) then player:addItem(5311,makibishi); player:messageSpecial(ITEM_OBTAINED,5311); end if(hiraishin > 0) then player:addItem(5312,hiraishin); player:messageSpecial(ITEM_OBTAINED,5312); end if(mizu > 0) then player:addItem(5313,mizu); player:messageSpecial(ITEM_OBTAINED,5313); end if(shihei > 0) then player:addItem(5314,shihei); player:messageSpecial(ITEM_OBTAINED,5314); end if(jusatsu > 0) then player:addItem(5315,jusatsu); player:messageSpecial(ITEM_OBTAINED,5315); end if(kaginawa > 0) then player:addItem(5316,kaginawa); player:messageSpecial(ITEM_OBTAINED,5316); end if(sairui > 0) then player:addItem(5317,sairui); player:messageSpecial(ITEM_OBTAINED,5317); end if(kodoku > 0) then player:addItem(5318,kodoku); player:messageSpecial(ITEM_OBTAINED,5318); end if(shinobi > 0) then player:addItem(5319,shinobi); player:messageSpecial(ITEM_OBTAINED,5319); end if(sanjaku > 0) then player:addItem(5417,sanjaku); player:messageSpecial(ITEM_OBTAINED,5417); end if(soushi > 0) then player:addItem(5734,soushi); player:messageSpecial(ITEM_OBTAINED,5734); end if(kabenro > 0) then player:addItem(5863,kabenro); player:messageSpecial(ITEM_OBTAINED,5863); end if(jinko > 0) then player:addItem(5864,jinko); player:messageSpecial(ITEM_OBTAINED,5864); end if(mokujin > 0) then player:addItem(5866,mokujin); player:messageSpecial(ITEM_OBTAINED,5866); end if(inoshi > 0) then player:addItem(5867,inoshi); player:messageSpecial(ITEM_OBTAINED,5867); end if(shikan > 0) then player:addItem(5868,shikan); player:messageSpecial(ITEM_OBTAINED,5868); end if(chono > 0) then player:addItem(5869,chono); player:messageSpecial(ITEM_OBTAINED,5869); end end end -- 951 Wijinruit -- 1161 Uchitake 5308 -- 1164 Tsurara 5309 -- 1167 Kawahori-ogi 5310 -- 1170 Makibishi 5311 -- 1173 Hiraishin 5312 -- 1176 Mizu-deppo 5313 -- 1179 Shihei 5314 -- 1182 Jusatsu 5315 -- 1185 Kaginawa 5316 -- 1188 Sairui-ran 5317 -- 1191 Kodoku 5318 -- 1194 Shinobi-tabi 5319 -- 2553 Sanjaku-tengui 5417 -- 2555 Soshi 5734 -- 2642 Kabenro 5863 -- 2643 Jinko 5864 -- 2970 Mokujin 5866 -- 2971 Inoshishinofuda 5867 -- 2972 Shikanofuda 5868 -- 2973 Chonofuda 5869 end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x0159); 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
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/zones/Windurst_Waters/npcs/Yuli_Yaam.lua
6
1755
----------------------------------- -- Area: Windurst Waters -- NPC: Yuli Yaam -- Involved In Quest: Wondering Minstrel -- Working 100% -- @zone = 238 -- @pos = -61 -4 23 ----------------------------------- package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil; ----------------------------------- require("scripts/globals/quests"); require("scripts/globals/settings"); require("scripts/globals/titles"); require("scripts/globals/keyitems"); require("scripts/zones/Windurst_Waters/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) wonderingstatus = player:getQuestStatus(WINDURST,WONDERING_MINSTREL); fame = player:getFameLevel(WINDURST) if (wonderingstatus <= 1 and fame >= 5) then player:startEvent(0x027d); -- WONDERING_MINSTREL: Quest Available / Quest Accepted elseif (wonderingstatus == QUEST_COMPLETED and player:needToZone()) then player:startEvent(0x0281); -- WONDERING_MINSTREL: Quest After else rand = math.random(2); if (rand == 1) then player:startEvent(0x0264); -- Standard Conversation 1 else player:startEvent(0x0265); -- Standard Conversation 2 end end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
TheOnePharaoh/YGOPro-Custom-Cards
script/c83581508.lua
1
5954
--Beast of Wild - Majesty Lion function c83581508.initial_effect(c) c:SetUniqueOnField(1,0,83581508,LOCATION_MZONE) --spsummon condition local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e1:SetCode(EFFECT_SPSUMMON_CONDITION) c:RegisterEffect(e1) --special summon rule local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetCode(EFFECT_SPSUMMON_PROC) e2:SetProperty(EFFECT_FLAG_UNCOPYABLE) e2:SetRange(LOCATION_EXTRA+LOCATION_GRAVE) e2:SetCondition(c83581508.sprcon) e2:SetOperation(c83581508.sprop) e2:SetValue(SUMMON_TYPE_SPECIAL+300) c:RegisterEffect(e2) --destroy local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(83581508,0)) e3:SetCategory(CATEGORY_DESTROY) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetProperty(EFFECT_FLAG_CARD_TARGET) e3:SetCountLimit(1) e3:SetRange(LOCATION_MZONE) e3:SetTarget(c83581508.destg) e3:SetOperation(c83581508.desop) c:RegisterEffect(e3) --remove local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(83581508,1)) e4:SetCategory(CATEGORY_REMOVE) e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e4:SetCode(EVENT_BATTLED) e4:SetCondition(c83581508.rmcon) e4:SetTarget(c83581508.rmtg) e4:SetOperation(c83581508.rmop) c:RegisterEffect(e4) --activate limit local e5=Effect.CreateEffect(c) e5:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD) e5:SetCode(EVENT_CHAINING) e5:SetRange(LOCATION_MZONE) e5:SetOperation(c83581508.aclimit1) c:RegisterEffect(e5) local e6=Effect.CreateEffect(c) e6:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD) e6:SetCode(EVENT_CHAIN_NEGATED) e6:SetRange(LOCATION_MZONE) e6:SetOperation(c83581508.aclimit2) c:RegisterEffect(e6) local e7=Effect.CreateEffect(c) e7:SetType(EFFECT_TYPE_FIELD) e7:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e7:SetCode(EFFECT_CANNOT_ACTIVATE) e7:SetRange(LOCATION_MZONE) e7:SetTargetRange(1,0) e7:SetCondition(c83581508.econ1) e7:SetValue(c83581508.elimit) c:RegisterEffect(e7) local e8=e5:Clone() e8:SetOperation(c83581508.aclimit3) c:RegisterEffect(e8) local e9=e6:Clone() e9:SetOperation(c83581508.aclimit4) c:RegisterEffect(e9) local e10=e7:Clone() e10:SetCondition(c83581508.econ2) e10:SetTargetRange(0,1) c:RegisterEffect(e10) end function c83581508.ddfilter(c) return (c:GetSequence()==6 or c:GetSequence()==7) or c:IsLocation(LOCATION_MZONE) end function c83581508.spfilter1(c,tp) return c:GetLevel()==7 and c:IsFusionSetCard(0x12c) and c:IsDestructable() and c:IsCanBeFusionMaterial() and Duel.IsExistingMatchingCard(c83581508.spfilter2,tp,LOCATION_MZONE,0,1,c) end function c83581508.spfilter2(c) return c:IsType(TYPE_PENDULUM) and c:IsFusionSetCard(0x12c) and c83581508.ddfilter(c) and c:IsDestructable() and c:IsCanBeFusionMaterial() end function c83581508.sprcon(e,c) if c==nil then return true end local tp=c:GetControler() return Duel.GetLocationCount(tp,LOCATION_MZONE)>-2 and Duel.IsExistingMatchingCard(c83581508.spfilter1,tp,LOCATION_MZONE,0,1,nil,tp) end function c83581508.sprop(e,tp,eg,ep,ev,re,r,rp,c) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g1=Duel.SelectMatchingCard(tp,c83581508.spfilter1,tp,LOCATION_MZONE,0,1,1,nil,tp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g2=Duel.SelectMatchingCard(tp,c83581508.spfilter2,tp,LOCATION_ONFIELD,0,1,1,g1:GetFirst()) g1:Merge(g2) c:SetMaterial(g1) Duel.Destroy(g1,REASON_EFFECT) end function c83581508.desfilter(c) return c:IsFaceup() and c:IsSetCard(0x12c) or c:IsSetCard(0x12e) end function c83581508.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return false end if chk==0 then return Duel.IsExistingTarget(c83581508.desfilter,tp,LOCATION_ONFIELD,0,1,e:GetHandler()) and Duel.IsExistingTarget(aux.TRUE,tp,0,LOCATION_ONFIELD,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g1=Duel.SelectTarget(tp,c83581508.desfilter,tp,LOCATION_ONFIELD,0,1,1,e:GetHandler()) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g2=Duel.SelectTarget(tp,aux.TRUE,tp,0,LOCATION_ONFIELD,1,1,nil) g1:Merge(g2) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g1,2,0,0) end function c83581508.desop(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS) local tg=g:Filter(Card.IsRelateToEffect,nil,e) if tg:GetCount()>0 then Duel.Destroy(tg,REASON_EFFECT) end end function c83581508.rmcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local bc=c:GetBattleTarget() e:SetLabelObject(bc) return bc and bc:IsStatus(STATUS_BATTLE_DESTROYED) and c:IsStatus(STATUS_OPPO_BATTLE) end function c83581508.rmtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_REMOVE,e:GetLabelObject(),1,0,0) end function c83581508.rmop(e,tp,eg,ep,ev,re,r,rp) local bc=e:GetLabelObject() if bc:IsRelateToBattle() and bc:IsAbleToRemove() then Duel.Remove(bc,POS_FACEUP,REASON_EFFECT) end end function c83581508.aclimit1(e,tp,eg,ep,ev,re,r,rp) if ep~=tp or not re:IsActiveType(TYPE_MONSTER) then return end e:GetHandler():RegisterFlagEffect(83581508,RESET_EVENT+0x3ff0000+RESET_PHASE+PHASE_END,0,1) end function c83581508.aclimit2(e,tp,eg,ep,ev,re,r,rp) if ep~=tp or not re:IsHasType(EFFECT_TYPE_ACTIVATE) then return end e:GetHandler():ResetFlagEffect(83581508) end function c83581508.econ1(e) return e:GetHandler():GetFlagEffect(83581508)~=0 end function c83581508.aclimit3(e,tp,eg,ep,ev,re,r,rp) if ep==tp or not re:IsActiveType(TYPE_MONSTER) then return end e:GetHandler():RegisterFlagEffect(83581508+1,RESET_EVENT+0x3ff0000+RESET_PHASE+PHASE_END,0,1) end function c83581508.aclimit4(e,tp,eg,ep,ev,re,r,rp) if ep==tp or not re:IsHasType(EFFECT_TYPE_ACTIVATE) then return end e:GetHandler():ResetFlagEffect(83581508+1) end function c83581508.econ2(e) return e:GetHandler():GetFlagEffect(83581508+1)~=0 end function c83581508.elimit(e,re,tp) return re:IsActiveType(TYPE_MONSTER) and not re:GetHandler():IsImmuneToEffect(e) end
gpl-3.0
niegenug/wesnoth
data/ai/micro_ais/cas/ca_return_guardian.lua
26
1081
local AH = wesnoth.require "ai/lua/ai_helper.lua" local function get_guardian(cfg) local filter = cfg.filter or { id = cfg.id } local guardian = AH.get_units_with_moves { side = wesnoth.current.side, { "and", filter } }[1] return guardian end local ca_return_guardian = {} function ca_return_guardian:evaluation(ai, cfg) local guardian = get_guardian(cfg) if guardian then if (guardian.x == cfg.return_x) and (guardian.y == cfg.return_y) then return cfg.ca_score - 20 else return cfg.ca_score end end return 0 end function ca_return_guardian:execution(ai, cfg) local guardian = get_guardian(cfg) -- In case the return hex is occupied: local x, y = cfg.return_x, cfg.return_y if (guardian.x ~= x) or (guardian.y ~= y) then x, y = wesnoth.find_vacant_tile(x, y, guardian) end local nh = AH.next_hop(guardian, x, y) if (not nh) then nh = { guardian.x, guardian.y } end AH.movefull_stopunit(ai, guardian, nh) end return ca_return_guardian
gpl-2.0
AntonioModer/character-physics-demo
integrators/verlet.lua
2
1609
--[[ Copyright (c) 2012 Roland Yonaba Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --]] -- Integration -- p(t+dt) = p(t) + dt*v(t)+ 0.5*dt*dt*a(t) -- v(t+dt) = v(t) + (a(t) + a(t+dt))*0.5*dt -- i.e v(t+dt) = v(t) + (a(t))*dt, as a(t) is constant function Verlet(agent, dt, g, damping, vmax) agent.sumForces = agent.sumForces + (g * agent.mass) agent.acc = agent.sumForces * agent.massInv agent.pos = agent.pos + agent.vel * dt + agent.acc * (dt * dt * 0.5) agent.vel = (agent.vel + agent.acc * dt) * (1 - damping * dt) agent.vel:clamp(vmax) agent.sumForces:clear() end return Verlet
mit
TheOnePharaoh/YGOPro-Custom-Cards
script/c32887065.lua
2
3252
--Enchanter of the Divine Light function c32887065.initial_effect(c) --special summon local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_SPSUMMON_PROC) e1:SetProperty(EFFECT_FLAG_UNCOPYABLE) e1:SetRange(LOCATION_HAND) e1:SetCondition(c32887065.spcon) e1:SetOperation(c32887065.spop) c:RegisterEffect(e1) --search local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(32887065,0)) e2:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_SUMMON_SUCCESS) e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e2:SetTarget(c32887065.thtg) e2:SetOperation(c32887065.thop) c:RegisterEffect(e2) local e3=e2:Clone() e3:SetCode(EVENT_SPSUMMON_SUCCESS) c:RegisterEffect(e3) --atkup local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(32887065,1)) e4:SetCategory(CATEGORY_ATKCHANGE) e4:SetType(EFFECT_TYPE_QUICK_O) e4:SetCode(EVENT_PRE_DAMAGE_CALCULATE) e4:SetRange(LOCATION_HAND+LOCATION_MZONE) e4:SetCondition(c32887065.atkcon) e4:SetCost(c32887065.atkcost) e4:SetOperation(c32887065.atkop) c:RegisterEffect(e4) end function c32887065.spcon(e,c) if c==nil then return true end local tp=c:GetControler() return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(aux.TRUE,tp,LOCATION_HAND,0,1,c) end function c32887065.spop(e,tp,eg,ep,ev,re,r,rp,c) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DISCARD) local g=Duel.SelectMatchingCard(tp,aux.TRUE,tp,LOCATION_HAND,0,1,1,c) Duel.SendtoGrave(g,REASON_COST+REASON_DISCARD) end function c32887065.filter(c) return c:IsType(TYPE_CONTINUOUS) and c:IsSetCard(0x1e21) and c:IsAbleToHand() end function c32887065.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c32887065.filter,tp,LOCATION_DECK+LOCATION_GRAVE,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK+LOCATION_GRAVE) end function c32887065.thop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,c32887065.filter,tp,LOCATION_DECK+LOCATION_GRAVE,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end function c32887065.confilter(c) return c:IsRace(RACE_WARRIOR) or c:IsRace(RACE_SPELLCASTER) end function c32887065.atkcon(e,tp,eg,ep,ev,re,r,rp) local c=Duel.GetAttackTarget() if not c then return false end if c:IsControler(1-tp) then c=Duel.GetAttacker() end e:SetLabelObject(c) return c and c~=e:GetHandler() and c32887065.confilter(c) and c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsRelateToBattle() end function c32887065.atkcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToGraveAsCost() end Duel.SendtoGrave(e:GetHandler(),REASON_COST) end function c32887065.atkop(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetLabelObject() if c:IsFaceup() and c:IsRelateToBattle() then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_DAMAGE_CAL) e1:SetValue(1500) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetCode(EFFECT_UPDATE_DEFENSE) c:RegisterEffect(e2) end end
gpl-3.0
TheOnePharaoh/YGOPro-Custom-Cards
script/c22769922.lua
2
3525
--Glorious Victory function c22769922.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetCondition(c22769922.condition) e1:SetCost(c22769922.cost) e1:SetOperation(c22769922.activate) c:RegisterEffect(e1) --special summon local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(22769922,0)) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_GRAVE) e2:SetCountLimit(1,22769922) e2:SetCondition(aux.exccon) e2:SetCost(c22769922.spcost) e2:SetTarget(c22769922.sptg) e2:SetOperation(c22769922.spop) c:RegisterEffect(e2) end function c22769922.confilter(c,tp) return c:GetSummonPlayer()==1-tp and c:IsPreviousLocation(LOCATION_EXTRA) end function c22769922.condition(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(c22769922.confilter,1,nil,tp) end function c22769922.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.CheckLPCost(tp,2000) else Duel.PayLPCost(tp,2000) end end function c22769922.activate(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CANNOT_ACTIVATE) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetTargetRange(0,1) e1:SetValue(c22769922.aclimit) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetCode(EFFECT_DISABLE) e2:SetTargetRange(0,LOCATION_ONFIELD) e2:SetTarget(c22769922.disable) e2:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e2,tp) end function c22769922.aclimit(e,re,tp) return re:GetHandler():IsOnField() and e:GetHandler()~=re:GetHandler() end function c22769922.disable(e,c) return c~=e:GetHandler() and (not c:IsType(TYPE_MONSTER) or (c:IsType(TYPE_EFFECT) or bit.band(c:GetOriginalType(),TYPE_EFFECT)==TYPE_EFFECT)) end function c22769922.spcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST) end function c22769922.spfilter(c,e,tp) return c:IsSetCard(0xaa12) and c:GetLevel()==10 and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c22769922.setfilter(c,tp) return c:IsType(TYPE_TRAP+TYPE_COUNTER) and c:IsSSetable(true) end function c22769922.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c22769922.spfilter(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingTarget(c22769922.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectTarget(tp,c22769922.spfilter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0) end function c22769922.spop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then if Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)~=0 and Duel.IsExistingTarget(c22769922.setfilter,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,nil,tp) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SET) local g=Duel.SelectTarget(tp,c22769922.setfilter,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,1,nil,tp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) and (tc:IsType(TYPE_TRAP+TYPE_COUNTER) or Duel.GetLocationCount(tp,LOCATION_SZONE)>0) then Duel.SSet(tp,tc) Duel.ConfirmCards(1-tp,tc) end end end end
gpl-3.0
waytim/darkstar
scripts/globals/spells/battlefield_elegy.lua
23
1594
----------------------------------------- -- Spell: Battlefield Elegy ----------------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------------- -- OnSpellCast ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) local duration = 120; local power = 256; local pCHR = caster:getStat(MOD_CHR); local mCHR = target:getStat(MOD_CHR); local dCHR = (pCHR - mCHR); local resm = applyResistanceEffect(caster,spell,target,dCHR,SINGING_SKILL,0,EFFECT_ELEGY); if (resm < 0.5) then spell:setMsg(85); -- resist message else local iBoost = caster:getMod(MOD_ELEGY_EFFECT) + caster:getMod(MOD_ALL_SONGS_EFFECT); power = power + iBoost*10; if (caster:hasStatusEffect(EFFECT_SOUL_VOICE)) then power = power * 2; elseif (caster:hasStatusEffect(EFFECT_MARCATO)) then power = power * 1.5; end caster:delStatusEffect(EFFECT_MARCATO); duration = duration * ((iBoost * 0.1) + (caster:getMod(MOD_SONG_DURATION_BONUS)/100) + 1); if (caster:hasStatusEffect(EFFECT_TROUBADOUR)) then duration = duration * 2; end -- Try to overwrite weaker elegy if (target:addStatusEffect(EFFECT_ELEGY,power,0,duration)) then spell:setMsg(237); else spell:setMsg(75); -- no effect end end return EFFECT_ELEGY; end;
gpl-3.0
waytim/darkstar
scripts/zones/North_Gustaberg/TextIDs.lua
15
1306
-- Variable TextID Description text -- General Texts ITEM_CANNOT_BE_OBTAINED_TWICE = 6559; -- You cannot obtain the item <item>. ITEM_CANNOT_BE_OBTAINED = 6560; -- You cannot obtain the item <item>. Come back after sorting your inventory. FULL_INVENTORY_AFTER_TRADE = 6564; -- You cannot obtain the #. Try trading again after sorting your inventory. ITEM_OBTAINED = 6565; -- Obtained: <item>. GIL_OBTAINED = 6566; -- Obtained <number> gil. KEYITEM_OBTAINED = 6568; -- Obtained key item: <keyitem>. ITEMS_OBTAINED = 6571; -- You obtain FISHING_MESSAGE_OFFSET = 7226; -- You can't fish here. -- Conquest CONQUEST = 7472; -- You've earned conquest points! -- Quests SHINING_OBJECT_SLIPS_AWAY = 7429; -- The shining object slips through your fingers and is washed further down the stream. -- Other Dialog NOTHING_HAPPENS = 300; -- Nothing happens... NOTHING_OUT_OF_ORDINARY = 6579; -- There is nothing out of the ordinary here. REACH_WATER_FROM_HERE = 7436; -- You can reach the water from here. -- conquest Base CONQUEST_BASE = 0; --chocobo digging DIG_THROW_AWAY = 7239; -- You dig up$, but your inventory is full. You regretfully throw the # away. FIND_NOTHING = 7241; -- You dig and you dig, but find nothing.
gpl-3.0
waytim/darkstar
scripts/zones/Rabao/npcs/Leodarion.lua
17
3707
----------------------------------- -- Area: Rabao -- NPC: Leodarion -- Involved in Quest: 20 in Pirate Years, I'll Take the Big Box, True Will -- @pos -50 8 40 247 ----------------------------------- package.loaded["scripts/zones/Rabao/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/shop"); require("scripts/globals/quests"); require("scripts/zones/Rabao/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if (player:getQuestStatus(OUTLANDS,I_LL_TAKE_THE_BIG_BOX) == QUEST_ACCEPTED and player:getVar("illTakeTheBigBoxCS") == 2) then if (trade:hasItemQty(17098,1) and trade:getItemCount() == 1) then -- Trade Oak Pole player:startEvent(0x005c); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:getQuestStatus(OUTLANDS,I_LL_TAKE_THE_BIG_BOX) == QUEST_ACCEPTED) then illTakeTheBigBoxCS = player:getVar("illTakeTheBigBoxCS"); if (illTakeTheBigBoxCS == 1) then player:startEvent(0x005a); elseif (illTakeTheBigBoxCS == 2) then player:startEvent(0x005b); elseif (illTakeTheBigBoxCS == 3 and VanadielDayOfTheYear() == player:getVar("illTakeTheBigBox_Timer")) then player:startEvent(0x005d); elseif (illTakeTheBigBoxCS == 3) then player:startEvent(0x005e); elseif (illTakeTheBigBoxCS == 4) then player:startEvent(0x005f); end elseif (player:getQuestStatus(OUTLANDS,TRUE_WILL) == QUEST_ACCEPTED) then trueWillCS = player:getVar("trueWillCS"); if (trueWillCS == 1) then player:startEvent(0x0061); elseif (trueWillCS == 2 and player:hasKeyItem(LARGE_TRICK_BOX) == false) then player:startEvent(0x0062); elseif (player:hasKeyItem(LARGE_TRICK_BOX)) then player:startEvent(0x0063); end else player:startEvent(0x0059); 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 == 0x005a) then player:setVar("illTakeTheBigBoxCS",2); elseif (csid == 0x005c) then player:tradeComplete(); player:setVar("illTakeTheBigBox_Timer",VanadielDayOfTheYear()); player:setVar("illTakeTheBigBoxCS",3); elseif (csid == 0x005e) then player:setVar("illTakeTheBigBox_Timer",0); player:setVar("illTakeTheBigBoxCS",4); player:addKeyItem(SEANCE_STAFF); player:messageSpecial(KEYITEM_OBTAINED,SEANCE_STAFF); elseif (csid == 0x0061) then player:delKeyItem(OLD_TRICK_BOX); player:setVar("trueWillCS",2); elseif (csid == 0x0063) then if (player:getFreeSlotsCount() < 1) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,13782); else player:delKeyItem(LARGE_TRICK_BOX); player:addItem(13782); player:messageSpecial(ITEM_OBTAINED,13782); -- Ninja Chainmail player:setVar("trueWillCS",0); player:addFame(OUTLANDS,30); player:completeQuest(OUTLANDS,TRUE_WILL); end end end;
gpl-3.0
TheOnePharaoh/YGOPro-Custom-Cards
script/c11275.lua
2
1452
function c11275.initial_effect(c) --Special Summon local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(11275,1)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_DRAW) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e1:SetCode(EVENT_DESTROYED) e1:SetCondition(c11275.spcon2) e1:SetTarget(c11275.sptg2) e1:SetOperation(c11275.spop2) c:RegisterEffect(e1) end function c11275.spcon2(e,tp,eg,ep,ev,re,r,rp) return bit.band(r,REASON_EFFECT+REASON_BATTLE)~=0 and e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD) end function c11275.spfilter(c,e,tp) return c:IsSetCard(0x2BF2) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c11275.sptg2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c11275.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp) and Duel.IsPlayerCanDraw(tp,1) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function c11275.spop2(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c11275.spfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp) if g:GetCount()>0 then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) Duel.BreakEffect() Duel.Draw(tp,1,REASON_EFFECT) end end
gpl-3.0
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/globals/items/rolanberry_(874_ce).lua
3
1096
----------------------------------------- -- ID: 4530 -- Item: rolanberry_874_ce) -- Food Effect: 5Min, All Races ----------------------------------------- -- Agility -3 -- Intelligence 1 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,300,4530); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_AGI, -3); target:addMod(MOD_INT, 1); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_AGI, -3); target:delMod(MOD_INT, 1); end;
gpl-3.0
waytim/darkstar
scripts/globals/items/earth_wand.lua
41
1075
----------------------------------------- -- ID: 17076 -- Item: Earth Wand -- Additional Effect: Earth 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(6,20); local params = {}; params.bonusmab = 0; params.includemab = false; dmg = addBonusesAbility(player, ELE_EARTH, target, dmg, params); dmg = dmg * applyResistanceAddEffect(player,target,ELE_EARTH,0); dmg = adjustForTarget(target,dmg,ELE_EARTH); dmg = finalMagicNonSpellAdjustments(player,target,ELE_EARTH,dmg); local message = MSGBASIC_ADD_EFFECT_DMG; if (dmg < 0) then message = MSGBASIC_ADD_EFFECT_HEAL; end return SUBEFFECT_EARTH_DAMAGE,message,dmg; end end;
gpl-3.0
X-Raym/REAPER-ReaScripts
Items Properties/X-Raym_Add all items on selected track into item selection.lua
1
1554
--[[ * ReaScript Name: Add all items on selected track into item selection * About: Add all items on selected track into item selection * Instructions: Select tracks. Use it. * Author: X-Raym * Author URI: https://www.extremraym.com * Repository: GitHub > X-Raym > REAPER-ReaScripts * Repository URI: https://github.com/X-Raym/REAPER-ReaScripts * Licence: GPL v3 * Forum Thread: ReaScript: Select all items on selected tracks * Forum Thread URI: http://forum.cockos.com/showthread.php?p=1489411 * Version: 1.0 * Version Date: 2015-02-27 * REAPER: 5.0 pre 11 --]] --[[ * Changelog: * v1.1 (2015-03-05) + Rename * v1.0 (2015-02-27) + Initial Release --]] function selected_items_on_tracks() reaper.Undo_BeginBlock() -- Begining of the undo block. Leave it at the top of your main function. -- LOOP TRHOUGH SELECTED TRACKS selected_tracks_count = reaper.CountSelectedTracks(0) for i = 0, selected_tracks_count-1 do -- GET THE TRACK track_sel = reaper.GetSelectedTrack(0, i) -- Get selected track i item_num = reaper.CountTrackMediaItems(track_sel) -- ACTIONS for j = 0, item_num-1 do item = reaper.GetTrackMediaItem(track_sel, j) reaper.SetMediaItemSelected(item, 1) end end -- ENDLOOP through selected tracks reaper.Undo_EndBlock("Select all items on selected tracks", 0) -- End of the undo block. Leave it at the bottom of your main function. end selected_items_on_tracks() -- Execute your main function reaper.UpdateArrange() -- Update the arrangement (often needed)
gpl-3.0
TheOnePharaoh/YGOPro-Custom-Cards
script/c924363413.lua
2
3667
--Inscriber Yamimoji function c924363413.initial_effect(c) --pendulum summon aux.EnablePendulumAttribute(c) --Rune Summon c:EnableReviveLimit() local r1=Effect.CreateEffect(c) r1:SetType(EFFECT_TYPE_FIELD) r1:SetCode(EFFECT_SPSUMMON_PROC) r1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE) r1:SetRange(LOCATION_HAND+LOCATION_EXTRA) r1:SetCondition(c924363413.runcon) r1:SetOperation(c924363413.runop) r1:SetValue(0x4f000000) c:RegisterEffect(r1) --tohand local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(924363413,0)) e1:SetCategory(CATEGORY_TOHAND) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_PZONE) e1:SetCountLimit(1,924363413+EFFECT_COUNT_CODE_OATH) e1:SetCost(c924363413.thcost) e1:SetTarget(c924363413.thtg) e1:SetOperation(c924363413.thop) c:RegisterEffect(e1) --remove local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(612115,0)) e2:SetCategory(CATEGORY_REMOVE) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetCode(EVENT_SPSUMMON_SUCCESS) e2:SetTarget(c924363413.rmtg) e2:SetOperation(c924363413.rmop) c:RegisterEffect(e2) end function c924363413.matfilter1(c) return c:IsFaceup() and c:IsType(TYPE_MONSTER) and c:IsRace(RACE_SPELLCASTER) end function c924363413.matfilter2(c) return c:IsFaceup() and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsSetCard(0xff0) end function c924363413.runfilter1(c) return c924363413.matfilter1(c) and Duel.IsExistingMatchingCard(c924363413.matfilter2,c:GetControler(),LOCATION_ONFIELD,0,2,c) end function c924363413.runcon(e,c) if c==nil then return true end return Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)>-1 and Duel.IsExistingMatchingCard(c924363413.runfilter1,c:GetControler(),LOCATION_MZONE,0,1,nil) end function c924363413.runop(e,tp,eg,ep,ev,re,r,rp,c) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Group.CreateGroup() local g1=Duel.SelectMatchingCard(tp,c924363413.runfilter1,c:GetControler(),LOCATION_MZONE,0,1,1,nil,c) g:Merge(g1) local g2=Duel.SelectMatchingCard(tp,c924363413.matfilter2,c:GetControler(),LOCATION_ONFIELD,0,1,1,g1:GetFirst(),c) g:Merge(g2) c:SetMaterial(g) Duel.SendtoGrave(g,REASON_MATERIAL+0x100000000) end function c924363413.thcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsDestructable() end Duel.Destroy(e:GetHandler(),REASON_COST) end function c924363413.thfilter(c) return c:IsSetCard(0xff0) and c:IsType(TYPE_PENDULUM) and c:IsAbleToHand() and c:GetCode()~=924363413 end function c924363413.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c924363413.thfilter,tp,LOCATION_EXTRA,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_EXTRA) end function c924363413.thop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,c924363413.thfilter,tp,LOCATION_EXTRA,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end function c924363413.rmtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(1-tp) and chkc:IsAbleToRemove() end if chk==0 then return Duel.IsExistingTarget(Card.IsAbleToRemove,tp,0,LOCATION_GRAVE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectTarget(tp,Card.IsAbleToRemove,tp,0,LOCATION_GRAVE,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,g:GetCount(),0,0) end function c924363413.rmop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc and tc:IsRelateToEffect(e) then Duel.Remove(tc,POS_FACEUP,REASON_EFFECT) end end
gpl-3.0
TheOnePharaoh/YGOPro-Custom-Cards
script/c12310740.lua
2
1423
--Bonfire Enkindling --lua script by SGJin function c12310740.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_DRAW+CATEGORY_HANDES) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,12310740+EFFECT_COUNT_CODE_OATH) e1:SetCost(c12310740.cost) e1:SetTarget(c12310740.target) e1:SetOperation(c12310740.activate) c:RegisterEffect(e1) end function c12310740.cfilter(c) return (c:IsCode(12310712) or c:IsCode(12310730)) and not c:IsPublic() end function c12310740.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c12310740.cfilter,tp,LOCATION_HAND,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_CONFIRM) local g=Duel.SelectMatchingCard(tp,c12310740.cfilter,tp,LOCATION_HAND,0,1,1,nil) Duel.ConfirmCards(1-tp,g) Duel.ShuffleHand(tp) end function c12310740.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,2) end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(2) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,2) Duel.SetOperationInfo(0,CATEGORY_HANDES,nil,0,tp,1) end function c12310740.activate(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) if Duel.Draw(p,d,REASON_EFFECT)==2 then Duel.BreakEffect() Duel.DiscardHand(tp,aux.TRUE,1,1,REASON_EFFECT+REASON_DISCARD) end end
gpl-3.0
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/globals/items/cheval_salmon.lua
2
1149
----------------------------------------- -- ID: 4379 -- Item: cheval_salmon -- Food Effect: 5Min, Mithra only ----------------------------------------- -- Dexterity 2 -- Mind 4 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:getRace() ~= 7) then result = 247; elseif (target:hasStatusEffect(EFFECT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,300,4379); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_DEX, 2); target:addMod(MOD_MND, 4); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_DEX, 2); target:delMod(MOD_MND, 4); end;
gpl-3.0
nicholaides/mongrel2
examples/bbs/engine.lua
96
1958
local print = print local pcall = pcall local coroutine = coroutine local ui = require 'ui' local db = require 'db' module 'engine' local STATE = {} function run(conn, engine) while true do -- Get a message from the Mongrel2 server local good, request = pcall(conn.recv_json, conn) if good then local msg_type = request.data.type if msg_type == 'disconnect' then -- The client has disconnected print("disconnect", request.conn_id) STATE[request.conn_id] = nil elseif msg_type == 'msg' then -- The client has sent data local eng = STATE[request.conn_id] -- If the client hasn't sent data before, create a new engine. if not eng then eng = coroutine.create(engine) STATE[request.conn_id] = eng -- Initialize the engine with the client's connection coroutine.resume(eng, conn) end -- Pass the data on to the engine local good, error = coroutine.resume(eng, request) print("status", coroutine.status(eng)) -- If the engine is done, stop tracking the client if coroutine.status(eng) == "dead" then STATE[request.conn_id] = nil if not good then -- There was an error print("ERROR", error) ui.exit(conn, request, 'error') local status, error = db.reconnect() if error then print("FAILED RECONNECT", error) end end end else print("invalid message.") end print("eng", STATE[request.conn_id]) end end end
bsd-3-clause
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/zones/Aht_Urhgan_Whitegate/npcs/Ratihb.lua
2
3120
----------------------------------- -- Area: Aht Urhgan Whitegate -- NPC: Ratihb -- Standard Info NPC -- @pos 75.225 -6.000 -137.203 50 ----------------------------------- require("scripts/globals/keyitems"); require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/titles"); require("scripts/globals/quests"); require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local LuckOfTheDraw = player:getQuestStatus(AHT_URHGAN,LUCK_OF_THE_DRAW); local EquipedforAllOccasions = player:getQuestStatus(AHT_URHGAN,EQUIPED_FOR_ALL_OCCASIONS); if(LuckOfTheDraw == QUEST_AVAILABLE and player:getMainLvl() >= ADVANCED_JOB_LEVEL) then -- corsair job quest player:startEvent(0x0223); player:setVar("LuckOfTheDraw",1); player:addQuest(AHT_URHGAN,LUCK_OF_THE_DRAW); elseif(player:getQuestStatus(AHT_URHGAN,LUCK_OF_THE_DRAW) == QUEST_COMPLETED and player:getVar("LuckOfTheDraw") ==5) then -- Ending CS for Corsair Optional player:startEvent(0x0228); player:setVar("LuckOfTheDraw",6); elseif(player:getVar("EquipedforAllOccasions") ==4 and player:getVar("LuckOfTheDraw") ==6) then --Af1 Final CS player:startEvent(0x0304); player:setVar("EquipedforAllOccasions",5); player:setVar("LuckOfTheDraw",0); elseif(player:getQuestStatus(AHT_URHGAN,NAVIGATING_THE_UNFRIENDLY_SEAS) == QUEST_COMPLETED and player:getMainJob() == JOB_COR and mLvl >= AF1_QUEST_LEVEL)then player:startEvent(0x031D); elseif(player:getQuestStatus(AHT_URHGAN,LUCK_OF_THE_DRAW) == QUEST_COMPLETED and player:getQuestStatus(AHT_URHGAN,EQUIPED_FOR_ALL_OCCASIONS) == QUEST_COMPLETED) then player:setVar("EquipedforAllOccasions",0); else player:startEvent(0x025B); -- standard dialog end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); if(csid == 0x0304) then local AFgun = 18702; if(player:getFreeSlotsCount() >= 1) then player:addItem(AFgun) -- Receive Af1 Trump Gun player:messageSpecial(ITEM_OBTAINED,AFgun); player:completeQuest(AHT_URHGAN,EQUIPED_FOR_ALL_OCCASIONS); player:setVar("EquipedforAllOccasions",0); else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,AFgun); end elseif(csid == 0x031D) then player:setVar("AgainstAllOdds",1); -- Set For Corsair BCNM player:setVar("AgainstAllOddsSideQuests",1); -- Set For Corsair Side Quests player:addQuest(AHT_URHGAN,AGAINST_ALL_ODDS); -- Start of af 3 not completed yet player:addKeyItem(LIFE_FLOAT); -- BCNM KEY ITEM TO ENTER BCNM player:messageSpecial(KEYITEM_OBTAINED, LIFE_FLOAT); end end;
gpl-3.0
waytim/darkstar
scripts/globals/abilities/scholars_roll.lua
19
2280
----------------------------------- -- Ability: Scholar's Roll -- Enhances Conserve MP effect for party members within area of effect -- Optimal Job: Scholar -- Lucky Number: 2 -- Unlucky Number: 6 -- Level: 64 -- -- Data unknown ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/ability"); ----------------------------------- -- onAbilityCheck ----------------------------------- function onAbilityCheck(player,target,ability) local effectID = EFFECT_SCHOLARS_ROLL ability:setRange(ability:getRange() + player:getMod(MOD_ROLL_RANGE)); if (player:hasStatusEffect(effectID)) then return MSGBASIC_ROLL_ALREADY_ACTIVE,0; elseif atMaxCorsairBusts(player) then return MSGBASIC_CANNOT_PERFORM,0; else return 0,0; end end; ----------------------------------- -- onUseAbility ----------------------------------- function onUseAbility(caster,target,ability,action) if (caster:getID() == target:getID()) then corsairSetup(caster, ability, action, EFFECT_SCHOLARS_ROLL, JOBS.SCH); end local total = caster:getLocalVar("corsairRollTotal") return applyRoll(caster,target,ability,action,total) end; function applyRoll(caster,target,ability,action,total) local duration = 300 + caster:getMerit(MERIT_WINNING_STREAK) local effectpowers = {2, 9, 3, 4, 5, 2, 6, 6, 7, 9, 14, 4}; --mostly random guesses local effectpower = effectpowers[total]; if (caster:getLocalVar("corsairRollBonus") == 1 and total < 12) then effectpower = effectpower + 4 end if (caster:getMainJob() == JOBS.COR and caster:getMainLvl() < target:getMainLvl()) then effectpower = effectpower * (caster:getMainLvl() / target:getMainLvl()); elseif (caster:getSubJob() == JOBS.COR and caster:getSubLvl() < target:getMainLvl()) then effectpower = effectpower * (caster:getSubLvl() / target:getMainLvl()); end if (target:addCorsairRoll(caster:getMainJob(), caster:getMerit(MERIT_BUST_DURATION), EFFECT_SCHOLARS_ROLL, effectpower, 0, duration, caster:getID(), total, MOD_CONSERVE_MP) == false) then ability:setMsg(422); elseif total > 11 then ability:setMsg(426); end return total; end
gpl-3.0
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/globals/weaponskills/fell_cleave.lua
4
1210
----------------------------------- -- Fell Cleave -- Great Axe weapon skill -- Skill Level: 300 -- Delivers an area attack. Radius varies with TP. -- Aligned with the Breeze Gorget, Thunder Gorget & Soil Gorget. -- Aligned with the Breeze Belt, Thunder Belt & Soil Belt. -- Element: None -- Modifiers: STR: 60% -- 100%TP 200%TP 300%TP -- 2.00 2.00 2.00 ----------------------------------- require("scripts/globals/status"); require("scripts/globals/settings"); require("scripts/globals/weaponskills"); ----------------------------------- function OnUseWeaponSkill(player, target, wsID) local params = {}; params.numHits = 1; params.ftp100 = 2.0; params.ftp200 = 2.0; params.ftp300 = 2.0; params.str_wsc = 0.6; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0; params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0; params.canCrit = false; params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0; params.atkmulti = 1; local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, params); return tpHits, extraHits, criticalHit, damage; end
gpl-3.0
TheOnePharaoh/YGOPro-Custom-Cards
script/c99199050.lua
1
1943
--The Future Gear Master Sword function c99199050.initial_effect(c) c:SetSPSummonOnce(99199050) --special summon local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_GRAVE) e1:SetCost(c99199050.spcost) e1:SetTarget(c99199050.sptg) e1:SetOperation(c99199050.spop) c:RegisterEffect(e1) --atk/lv up local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(99199050,0)) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1) e2:SetOperation(c99199050.operation) c:RegisterEffect(e2) --add setcode local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e3:SetCode(EFFECT_ADD_SETCODE) e3:SetValue(0xff16) c:RegisterEffect(e3) end function c99199050.costfilter(c) return c:IsFaceup() and c:IsType(TYPE_PENDULUM) and c:IsAttribute(ATTRIBUTE_LIGHT) end function c99199050.spcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.CheckReleaseGroup(tp,c99199050.costfilter,1,nil) end local g=Duel.SelectReleaseGroup(tp,c99199050.costfilter,1,1,nil) Duel.Release(g,REASON_COST) end function c99199050.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function c99199050.spop(e,tp,eg,ep,ev,re,r,rp) if e:GetHandler():IsRelateToEffect(e) then Duel.SpecialSummon(e:GetHandler(),0,tp,tp,false,false,POS_FACEUP) end end function c99199050.operation(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsFaceup() and c:IsRelateToEffect(e) then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_LEVEL) e1:SetReset(RESET_EVENT+0x1ff0000+RESET_PHASE+PHASE_END) e1:SetValue(-2) c:RegisterEffect(e1) end end
gpl-3.0
waytim/darkstar
scripts/zones/Yuhtunga_Jungle/npcs/Mupia_RK.lua
13
3325
----------------------------------- -- Area: Yuhtunga Jungle -- NPC: Mupia, R.K. -- Border Conquest Guards -- @pos -241.334 -1 478.602 123 ----------------------------------- package.loaded["scripts/zones/Yuhtunga_Jungle/TextIDs"] = nil; ----------------------------------- require("scripts/globals/conquest"); require("scripts/zones/Yuhtunga_Jungle/TextIDs"); local guardnation = SANDORIA; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno local guardtype = 4; -- 1: city, 2: foreign, 3: outpost, 4: border local region = ELSHIMOLOWLANDS; local csid = 0x7ffa; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) tradeConquestGuard(player,npc,trade,guardnation,guardtype); end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:hasKeyItem(getSupplyKey(region)) and player:getNation() == guardnation) then if (supplyRunFresh(player) == 1) then player:startEvent(csid,16,0,0,0,1,0,0,255); -- you have brought us supplies ! else player:showText(npc, CONQUEST - 1); -- "Hmm... These supplies you have brought us are too old to be of any use." player:delKeyItem(getSupplyKey(region)); player:messageSpecial(KEYITEM_OBTAINED + 1, getSupplyKey(region)); player:setVar("supplyQuest_region",0); end else local arg1 = getArg1(guardnation, player) - 1; if (arg1 >= 1792) then -- foreign, non-allied player:startEvent(csid,1808,0,0,0,0,player:getRank(),0,0); else -- citizen or allied player:startEvent(csid,arg1,0,0x3F0000,0,0,getArg6(player),0,0); end end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("OPTION: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("OPTION: %u",option); if (option == 1) then local duration = (player:getRank() + getNationRank(player:getNation()) + 3) * 3600; player:delStatusEffect(EFFECT_SIGIL); player:delStatusEffect(EFFECT_SANCTION); player:delStatusEffect(EFFECT_SIGNET); player:addStatusEffect(EFFECT_SIGNET,0,0,duration); -- Grant Signet elseif (option == 2) then player:delKeyItem(getSupplyKey(region)); player:addCP(supplyReward[region + 1]) player:messageSpecial(CONQUEST); -- "You've earned conquest points!" if (hasOutpost(player, region+5) == 0) then local supply_quests = 2^(region+5); player:addNationTeleport(guardnation,supply_quests); player:setVar("supplyQuest_region",0); end elseif (option == 4) then if (player:delGil(giltosetHP(guardnation,player))) then player:setHomePoint(); player:messageSpecial(CONQUEST + 94); -- "Your home point has been set." else player:messageSpecial(CONQUEST + 95); -- "You do not have enough gil to set your home point here." end end end;
gpl-3.0
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/globals/weaponskills/stringing_pummel.lua
2
1348
----------------------------------- -- Stringing Pummel -- Hand-to-Hand weapon skill -- Skill Level: NA -- Delivers an sixfold attack. Chance of critical varies with TP. -- Kenkonken:Aftermath effect varies with TP. -- In order to obtain Stringing Pummel, the quest Unlocking a Myth must be completed. -- Aligned with the Shadow Gorget, Soil Gorget & Flame Gorget. -- Aligned with the Shadow Belt, Soil Belt & Flame Belt. -- Element: None -- Modifiers: STR:32% ; VIT:32% -- 100%TP 200%TP 300%TP -- 0.75 0.75 0.75 ----------------------------------- require("scripts/globals/status"); require("scripts/globals/settings"); require("scripts/globals/weaponskills"); ----------------------------------- function OnUseWeaponSkill(player, target, wsID) local params = {}; params.numHits = 6; params.ftp100 = 0.75; params.ftp200 = 0.75; params.ftp300 = 0.75; params.str_wsc = 0.32; params.dex_wsc = 0.0; params.vit_wsc = 0.32; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0; params.crit100 = 0.2; params.crit200 = 0.3; params.crit300 = 0.45; params.canCrit = false; params.acc100 = 0.8; params.acc200= 0.9; params.acc300= 1; params.atkmulti = 1; local damage, tpHits, extraHits = doPhysicalWeaponskill(player, target, params); return tpHits, extraHits, damage; end
gpl-3.0
waytim/darkstar
scripts/zones/Bastok_Markets/npcs/Zaira.lua
17
1868
----------------------------------- -- Area: Batok Markets -- NPC: Zaira -- Standard Merchant NPC -- -- Updated Aug-09-2013 by Zerahn, based on bgwiki and gamerescape ----------------------------------- require("scripts/globals/shop"); package.loaded["scripts/zones/Bastok_Markets/TextIDs"] = nil; require("scripts/zones/Bastok_Markets/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc,ZAIRA_SHOP_DIALOG); stock = { 0x12FE, 111,1, --Scroll of Blind 0x12E6, 360,2, --Scroll of Bio 0x12DC, 82,2, --Scroll of Poison 0x12FD, 2250,2, --Scroll of Sleep 0x129F, 61,3, --Scroll of Stone 0x12A9, 140,3, --Scroll of Water 0x129A, 324,3, --Scroll of Aero 0x1290, 837,3, --Scroll of Fire 0x1295, 1584,3, --Scroll of Blizzard 0x12A4, 3261,3, --Scroll of Thunder 0x12EF, 1363,3, --Scroll of Shock 0x12EE, 1827,3, --Scroll of Rasp 0x12ED, 2250,3, --Scroll of Choke 0x12EC, 3688,3, --Scroll of Frost 0x12EB, 4644,3, --Scroll of Burn 0x12F0, 6366,3, --Scroll of Drown } showNationShop(player, BASTOK, 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
TheOnePharaoh/YGOPro-Custom-Cards
script/c11111121.lua
2
5295
--Vocaloid Namine Ritsu Mdl - Gl103 function c11111121.initial_effect(c) c:EnableReviveLimit() --pendulum summon aux.EnablePendulumAttribute(c) --Activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e1) --search local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(11111121,0)) e2:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1,11111121) e2:SetCost(c11111121.th2cost) e2:SetTarget(c11111121.th2target) e2:SetOperation(c11111121.th2operation) c:RegisterEffect(e2) --to pzone local e3=Effect.CreateEffect(c) e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e3:SetCategory(CATEGORY_DESTROY) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_DESTROYED) e3:SetCondition(c11111121.con) e3:SetOperation(c11111121.op) c:RegisterEffect(e3) --place pcard local e4=Effect.CreateEffect(c) e4:SetType(EFFECT_TYPE_IGNITION) e4:SetRange(LOCATION_PZONE) e4:SetCountLimit(1) e4:SetCondition(c11111121.pencon) e4:SetCost(c11111121.pencost) e4:SetTarget(c11111121.pentg) e4:SetOperation(c11111121.penop) c:RegisterEffect(e4) --actlimit local e5=Effect.CreateEffect(c) e5:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e5:SetCode(EVENT_ATTACK_ANNOUNCE) e5:SetRange(LOCATION_PZONE) e5:SetCondition(c11111121.actcon) e5:SetOperation(c11111121.actop) c:RegisterEffect(e5) local e6=e5:Clone() e6:SetCode(EVENT_BE_BATTLE_TARGET) c:RegisterEffect(e6) end function c11111121.actcon(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetAttacker() if tc:IsControler(1-tp) then tc=Duel.GetAttackTarget() end return tc and tc:IsControler(tp) and tc:IsSetCard(0x0dac401) and tc:IsSetCard(0x0dac402) and tc:IsSetCard(0x0dac403) and tc:IsSetCard(0x0dac404) and tc:IsSetCard(0x0dac405) end function c11111121.actop(e,tp,eg,ep,ev,re,r,rp) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetCode(EFFECT_CANNOT_ACTIVATE) e1:SetTargetRange(0,1) e1:SetValue(c11111121.aclimit) e1:SetReset(RESET_PHASE+PHASE_DAMAGE) Duel.RegisterEffect(e1,tp) end function c11111121.aclimit(e,re,tp) return re:IsActiveType(TYPE_SPELL+TYPE_TRAP) and re:IsHasType(EFFECT_TYPE_ACTIVATE) end function c11111121.th2cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c11111121.costfilter,tp,LOCATION_HAND,0,1,nil) end Duel.DiscardHand(tp,c11111121.costfilter,1,1,REASON_COST+REASON_DISCARD) end function c11111121.filter(c) return c:IsSetCard(0x0dac406) and c:IsAbleToHand() end function c11111121.th2target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c11111121.filter,tp,LOCATION_DECK+LOCATION_GRAVE,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK+LOCATION_GRAVE) end function c11111121.th2operation(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,c11111121.filter,tp,LOCATION_DECK+LOCATION_GRAVE,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end function c11111121.penfilter1(c) return c:IsDestructable() and c:GetSequence()==6 end function c11111121.penfilter2(c) return c:IsDestructable() and c:GetSequence()==7 end function c11111121.con(e,tp,eg,ep,ev,re,r,rp) local p1=Duel.GetFieldCard(tp,LOCATION_SZONE,6) local p2=Duel.GetFieldCard(tp,LOCATION_SZONE,7) if not p1 and not p2 then return false end return (e:GetHandler():IsReason(REASON_EFFECT) or e:GetHandler():IsReason(REASON_BATTLE)) and (p1 and p1:IsDestructable()) or (p2 and p2:IsDestructable()) and e:GetHandler():GetPreviousLocation()==LOCATION_MZONE end function c11111121.op(e,tp,eg,ep,ev,re,r,rp) local p1=Duel.GetFieldCard(tp,LOCATION_SZONE,6) local p2=Duel.GetFieldCard(tp,LOCATION_SZONE,7) local g1=nil local g2=nil if p1 then g1=Duel.GetMatchingGroup(c11111121.penfilter1,tp,LOCATION_SZONE,0,nil) end if p2 then g2=Duel.GetMatchingGroup(c11111121.penfilter2,tp,LOCATION_SZONE,0,nil) if g1 then g1:Merge(g2) else g1=g2 end end if g1 and Duel.Destroy(g1,REASON_EFFECT)~=0 then local c=e:GetHandler() Duel.MoveToField(c,tp,tp,LOCATION_SZONE,POS_FACEUP,true) end end function c11111121.pencost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.CheckLPCost(tp,800) end Duel.PayLPCost(tp,800) end function c11111121.penfilter4(c) return c:IsType(TYPE_MONSTER) and c:IsRace(RACE_MACHINE) and c:IsType(TYPE_PENDULUM) end function c11111121.pencon(e,tp,eg,ep,ev,re,r,rp) local seq=e:GetHandler():GetSequence() return Duel.GetFieldCard(tp,LOCATION_SZONE,13-seq)==nil end function c11111121.pentg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c11111121.penfilter4,tp,LOCATION_EXTRA+LOCATION_HAND,0,1,nil) end end function c11111121.penop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOFIELD) local g=Duel.SelectMatchingCard(tp,c11111121.penfilter4,tp,LOCATION_EXTRA+LOCATION_HAND,0,1,1,nil) if g:GetCount()>0 then local tc=g:GetFirst() Duel.MoveToField(tc,tp,tp,LOCATION_SZONE,POS_FACEUP,true) end end
gpl-3.0
TheOnePharaoh/YGOPro-Custom-Cards
script/c11111116.lua
2
3281
--Vocaloid Mayu Mdl - Hz101 function c11111116.initial_effect(c) c:EnableReviveLimit() --pendulum summon aux.EnablePendulumAttribute(c) --atkup local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e2:SetRange(LOCATION_MZONE) e2:SetCode(EFFECT_UPDATE_ATTACK) e2:SetValue(c11111116.atkval) c:RegisterEffect(e2) --to pzone local e3=Effect.CreateEffect(c) e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e3:SetCategory(CATEGORY_DESTROY) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_DESTROYED) e3:SetCondition(c11111116.con) e3:SetOperation(c11111116.op) c:RegisterEffect(e3) --atk local e4=Effect.CreateEffect(c) e4:SetType(EFFECT_TYPE_FIELD) e4:SetCode(EFFECT_UPDATE_ATTACK) e4:SetRange(LOCATION_PZONE) e4:SetTargetRange(LOCATION_MZONE,0) e4:SetTarget(c11111116.encfilter) e4:SetValue(200) c:RegisterEffect(e4) --to grave local e5=Effect.CreateEffect(c) e5:SetDescription(aux.Stringid(11111116,1)) e5:SetCategory(CATEGORY_TOGRAVE) e5:SetType(EFFECT_TYPE_IGNITION) e5:SetCountLimit(1) e5:SetRange(LOCATION_PZONE) e5:SetTarget(c11111116.sgtg) e5:SetOperation(c11111116.sgop) c:RegisterEffect(e5) end function c11111116.atkfilter(c) return c:IsFaceup() and c:IsRace(RACE_MACHINE) end function c11111116.atkval(e,c) return Duel.GetMatchingGroupCount(c11111116.atkfilter,c:GetControler(),LOCATION_MZONE,LOCATION_MZONE,c)*300 end function c11111116.penfilter1(c) return c:IsDestructable() and c:GetSequence()==6 end function c11111116.penfilter2(c) return c:IsDestructable() and c:GetSequence()==7 end function c11111116.con(e,tp,eg,ep,ev,re,r,rp) local p1=Duel.GetFieldCard(tp,LOCATION_SZONE,6) local p2=Duel.GetFieldCard(tp,LOCATION_SZONE,7) if not p1 and not p2 then return false end return (e:GetHandler():IsReason(REASON_EFFECT) or e:GetHandler():IsReason(REASON_BATTLE)) and (p1 and p1:IsDestructable()) or (p2 and p2:IsDestructable()) and e:GetHandler():GetPreviousLocation()==LOCATION_MZONE end function c11111116.op(e,tp,eg,ep,ev,re,r,rp) local p1=Duel.GetFieldCard(tp,LOCATION_SZONE,6) local p2=Duel.GetFieldCard(tp,LOCATION_SZONE,7) local g1=nil local g2=nil if p1 then g1=Duel.GetMatchingGroup(c11111116.penfilter1,tp,LOCATION_SZONE,0,nil) end if p2 then g2=Duel.GetMatchingGroup(c11111116.penfilter2,tp,LOCATION_SZONE,0,nil) if g1 then g1:Merge(g2) else g1=g2 end end if g1 and Duel.Destroy(g1,REASON_EFFECT)~=0 then local c=e:GetHandler() Duel.MoveToField(c,tp,tp,LOCATION_SZONE,POS_FACEUP,true) end end function c11111116.encfilter(e,c) return c:IsRace(RACE_MACHINE) end function c11111116.sgfilter(c) return c:IsSetCard(0x0dac405) and c:IsAbleToGrave() end function c11111116.sgtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) local c=e:GetHandler() if chk==0 then return Duel.IsExistingMatchingCard(c11111116.sgfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_DECK) end function c11111116.sgop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,c11111116.sgfilter,tp,LOCATION_DECK,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoGrave(g,REASON_EFFECT) end end
gpl-3.0
pouya-joker/c16-bot
plugins/quran.lua
11
1413
-- Umbrella Quran Project -- http://umbrella.shayan-soft.ir -- https://telegram.me/umbrellateam -- Programmer : Engineer Shayan Ahmadi -- https://telegram.me/shayansoft do umbrella = "http://umbrella.shayan-soft.ir/quran/" -- database -- get sound of sura local function read_sura(chat_id, target) local readq = http.request(umbrella.."Sura"..target..".mp3") local url = umbrella.."Sura"..target..".mp3" local file = download_to_file(url) local cb_extra = {file_path=file} return send_document("chat#id"..chat_id, file, rmtmp_cb, cb_extra) end -- get text of sura local function view_sura(chat_id, target) local viewq = http.request(umbrella.."quran ("..target..").txt") return viewq end -- run script local function run(msg, matches) local chat_id = msg.to.id if matches[1] == "read" then local target = matches[2] return read_sura(chat_id, target) elseif matches[1] == "sura" then local target = matches[2] return view_sura(chat_id, target) elseif matches [1] == "quran" then local qlist = http.request(umbrella.."list.txt") -- list of suras return qlist end end -- other help and commands return { description = "Umbrella Quran Project", usage = { "!sura (num) : view arabic sura", "!read (num) : send sound of sura", "!quran : sura list of quran", }, patterns = { "^[!/](sura) (.+)$", "^[!/](read) (.+)$", "^[!/](quran)$", }, run = run, } end
gpl-2.0
mehrpouya81/gamerspm
plugins/rss.lua
700
5434
local function get_base_redis(id, option, extra) local ex = '' if option ~= nil then ex = ex .. ':' .. option if extra ~= nil then ex = ex .. ':' .. extra end end return 'rss:' .. id .. ex end local function prot_url(url) local url, h = string.gsub(url, "http://", "") local url, hs = string.gsub(url, "https://", "") local protocol = "http" if hs == 1 then protocol = "https" end return url, protocol end local function get_rss(url, prot) local res, code = nil, 0 if prot == "http" then res, code = http.request(url) elseif prot == "https" then res, code = https.request(url) end if code ~= 200 then return nil, "Error while doing the petition to " .. url end local parsed = feedparser.parse(res) if parsed == nil then return nil, "Error decoding the RSS.\nAre you sure that " .. url .. " it's a RSS?" end return parsed, nil end local function get_new_entries(last, nentries) local entries = {} for k,v in pairs(nentries) do if v.id == last then return entries else table.insert(entries, v) end end return entries end local function print_subs(id) local uhash = get_base_redis(id) local subs = redis:smembers(uhash) local text = id .. ' are subscribed to:\n---------\n' for k,v in pairs(subs) do text = text .. k .. ") " .. v .. '\n' end return text end local function subscribe(id, url) local baseurl, protocol = prot_url(url) local prothash = get_base_redis(baseurl, "protocol") local lasthash = get_base_redis(baseurl, "last_entry") local lhash = get_base_redis(baseurl, "subs") local uhash = get_base_redis(id) if redis:sismember(uhash, baseurl) then return "You are already subscribed to " .. url end local parsed, err = get_rss(url, protocol) if err ~= nil then return err end local last_entry = "" if #parsed.entries > 0 then last_entry = parsed.entries[1].id end local name = parsed.feed.title redis:set(prothash, protocol) redis:set(lasthash, last_entry) redis:sadd(lhash, id) redis:sadd(uhash, baseurl) return "You had been subscribed to " .. name end local function unsubscribe(id, n) if #n > 3 then return "I don't think that you have that many subscriptions." end n = tonumber(n) local uhash = get_base_redis(id) local subs = redis:smembers(uhash) if n < 1 or n > #subs then return "Subscription id out of range!" end local sub = subs[n] local lhash = get_base_redis(sub, "subs") redis:srem(uhash, sub) redis:srem(lhash, id) local left = redis:smembers(lhash) if #left < 1 then -- no one subscribed, remove it local prothash = get_base_redis(sub, "protocol") local lasthash = get_base_redis(sub, "last_entry") redis:del(prothash) redis:del(lasthash) end return "You had been unsubscribed from " .. sub end local function cron() -- sync every 15 mins? local keys = redis:keys(get_base_redis("*", "subs")) for k,v in pairs(keys) do local base = string.match(v, "rss:(.+):subs") -- Get the URL base local prot = redis:get(get_base_redis(base, "protocol")) local last = redis:get(get_base_redis(base, "last_entry")) local url = prot .. "://" .. base local parsed, err = get_rss(url, prot) if err ~= nil then return end local newentr = get_new_entries(last, parsed.entries) local subscribers = {} local text = '' -- Send only one message with all updates for k2, v2 in pairs(newentr) do local title = v2.title or 'No title' local link = v2.link or v2.id or 'No Link' text = text .. "[rss](" .. link .. ") - " .. title .. '\n' end if text ~= '' then local newlast = newentr[1].id redis:set(get_base_redis(base, "last_entry"), newlast) for k2, receiver in pairs(redis:smembers(v)) do send_msg(receiver, text, ok_cb, false) end end end end local function run(msg, matches) local id = "user#id" .. msg.from.id if is_chat_msg(msg) then id = "chat#id" .. msg.to.id end if matches[1] == "!rss"then return print_subs(id) end if matches[1] == "sync" then if not is_sudo(msg) then return "Only sudo users can sync the RSS." end cron() end if matches[1] == "subscribe" or matches[1] == "sub" then return subscribe(id, matches[2]) end if matches[1] == "unsubscribe" or matches[1] == "uns" then return unsubscribe(id, matches[2]) end end return { description = "Manage User/Chat RSS subscriptions. If you are in a chat group, the RSS subscriptions will be of that chat. If you are in an one-to-one talk with the bot, the RSS subscriptions will be yours.", usage = { "!rss: Get your rss (or chat rss) subscriptions", "!rss subscribe (url): Subscribe to that url", "!rss unsubscribe (id): Unsubscribe of that id", "!rss sync: Download now the updates and send it. Only sudo users can use this option." }, patterns = { "^!rss$", "^!rss (subscribe) (https?://[%w-_%.%?%.:/%+=&]+)$", "^!rss (sub) (https?://[%w-_%.%?%.:/%+=&]+)$", "^!rss (unsubscribe) (%d+)$", "^!rss (uns) (%d+)$", "^!rss (sync)$" }, run = run, cron = cron }
gpl-2.0
behnam98/SmartRobot
plugins/rss.lua
700
5434
local function get_base_redis(id, option, extra) local ex = '' if option ~= nil then ex = ex .. ':' .. option if extra ~= nil then ex = ex .. ':' .. extra end end return 'rss:' .. id .. ex end local function prot_url(url) local url, h = string.gsub(url, "http://", "") local url, hs = string.gsub(url, "https://", "") local protocol = "http" if hs == 1 then protocol = "https" end return url, protocol end local function get_rss(url, prot) local res, code = nil, 0 if prot == "http" then res, code = http.request(url) elseif prot == "https" then res, code = https.request(url) end if code ~= 200 then return nil, "Error while doing the petition to " .. url end local parsed = feedparser.parse(res) if parsed == nil then return nil, "Error decoding the RSS.\nAre you sure that " .. url .. " it's a RSS?" end return parsed, nil end local function get_new_entries(last, nentries) local entries = {} for k,v in pairs(nentries) do if v.id == last then return entries else table.insert(entries, v) end end return entries end local function print_subs(id) local uhash = get_base_redis(id) local subs = redis:smembers(uhash) local text = id .. ' are subscribed to:\n---------\n' for k,v in pairs(subs) do text = text .. k .. ") " .. v .. '\n' end return text end local function subscribe(id, url) local baseurl, protocol = prot_url(url) local prothash = get_base_redis(baseurl, "protocol") local lasthash = get_base_redis(baseurl, "last_entry") local lhash = get_base_redis(baseurl, "subs") local uhash = get_base_redis(id) if redis:sismember(uhash, baseurl) then return "You are already subscribed to " .. url end local parsed, err = get_rss(url, protocol) if err ~= nil then return err end local last_entry = "" if #parsed.entries > 0 then last_entry = parsed.entries[1].id end local name = parsed.feed.title redis:set(prothash, protocol) redis:set(lasthash, last_entry) redis:sadd(lhash, id) redis:sadd(uhash, baseurl) return "You had been subscribed to " .. name end local function unsubscribe(id, n) if #n > 3 then return "I don't think that you have that many subscriptions." end n = tonumber(n) local uhash = get_base_redis(id) local subs = redis:smembers(uhash) if n < 1 or n > #subs then return "Subscription id out of range!" end local sub = subs[n] local lhash = get_base_redis(sub, "subs") redis:srem(uhash, sub) redis:srem(lhash, id) local left = redis:smembers(lhash) if #left < 1 then -- no one subscribed, remove it local prothash = get_base_redis(sub, "protocol") local lasthash = get_base_redis(sub, "last_entry") redis:del(prothash) redis:del(lasthash) end return "You had been unsubscribed from " .. sub end local function cron() -- sync every 15 mins? local keys = redis:keys(get_base_redis("*", "subs")) for k,v in pairs(keys) do local base = string.match(v, "rss:(.+):subs") -- Get the URL base local prot = redis:get(get_base_redis(base, "protocol")) local last = redis:get(get_base_redis(base, "last_entry")) local url = prot .. "://" .. base local parsed, err = get_rss(url, prot) if err ~= nil then return end local newentr = get_new_entries(last, parsed.entries) local subscribers = {} local text = '' -- Send only one message with all updates for k2, v2 in pairs(newentr) do local title = v2.title or 'No title' local link = v2.link or v2.id or 'No Link' text = text .. "[rss](" .. link .. ") - " .. title .. '\n' end if text ~= '' then local newlast = newentr[1].id redis:set(get_base_redis(base, "last_entry"), newlast) for k2, receiver in pairs(redis:smembers(v)) do send_msg(receiver, text, ok_cb, false) end end end end local function run(msg, matches) local id = "user#id" .. msg.from.id if is_chat_msg(msg) then id = "chat#id" .. msg.to.id end if matches[1] == "!rss"then return print_subs(id) end if matches[1] == "sync" then if not is_sudo(msg) then return "Only sudo users can sync the RSS." end cron() end if matches[1] == "subscribe" or matches[1] == "sub" then return subscribe(id, matches[2]) end if matches[1] == "unsubscribe" or matches[1] == "uns" then return unsubscribe(id, matches[2]) end end return { description = "Manage User/Chat RSS subscriptions. If you are in a chat group, the RSS subscriptions will be of that chat. If you are in an one-to-one talk with the bot, the RSS subscriptions will be yours.", usage = { "!rss: Get your rss (or chat rss) subscriptions", "!rss subscribe (url): Subscribe to that url", "!rss unsubscribe (id): Unsubscribe of that id", "!rss sync: Download now the updates and send it. Only sudo users can use this option." }, patterns = { "^!rss$", "^!rss (subscribe) (https?://[%w-_%.%?%.:/%+=&]+)$", "^!rss (sub) (https?://[%w-_%.%?%.:/%+=&]+)$", "^!rss (unsubscribe) (%d+)$", "^!rss (uns) (%d+)$", "^!rss (sync)$" }, run = run, cron = cron }
gpl-2.0
waytim/darkstar
scripts/zones/Sealions_Den/mobs/Tenzen.lua
23
1173
----------------------------------- -- Area: Sealion den -- NPC: Tenzen ----------------------------------- ----------------------------------- -- onMobSpawn ----------------------------------- function onMobSpawn(mob) end; ----------------------------------- -- onMobEngaged ----------------------------------- function onMobEngaged(mob,target) switch (mob:getID()) : caseof { [16908310] = function (x) GetMobByID(16908311):updateEnmity(target); GetMobByID(16908312):updateEnmity(target); GetMobByID(16908313):updateEnmity(target); end, [16908314] = function (x) GetMobByID(16908315):updateEnmity(target); GetMobByID(16908316):updateEnmity(target); GetMobByID(16908317):updateEnmity(target); end, [16908318] = function (x) GetMobByID(16908319):updateEnmity(target); GetMobByID(16908320):updateEnmity(target); GetMobByID(16908321):updateEnmity(target); end, } end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob, player, isKiller) end;
gpl-3.0
pvvx/EspLua
lua_examples/email/send_email_smtp.lua
82
4640
--- -- Working Example: https://www.youtube.com/watch?v=CcRbFIJ8aeU -- @description a basic SMTP email example. You must use an account which can provide unencrypted authenticated access. -- This example was tested with an AOL and Time Warner email accounts. GMail does not offer unecrypted authenticated access. -- To obtain your email's SMTP server and port simply Google it e.g. [my email domain] SMTP settings -- For example for timewarner you'll get to this page http://www.timewarnercable.com/en/support/faqs/faqs-internet/e-mailacco/incoming-outgoing-server-addresses.html -- To Learn more about SMTP email visit: -- SMTP Commands Reference - http://www.samlogic.net/articles/smtp-commands-reference.htm -- See "SMTP transport example" in this page http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol -- @author Miguel require("base64") -- The email and password from the account you want to send emails from local MY_EMAIL = "esp8266@domain.com" local EMAIL_PASSWORD = "123456" -- The SMTP server and port of your email provider. -- If you don't know it google [my email provider] SMTP settings local SMTP_SERVER = "smtp.server.com" local SMTP_PORT = "587" -- The account you want to send email to local mail_to = "to_email@domain.com" -- Your access point's SSID and password local SSID = "ssid" local SSID_PASSWORD = "password" -- configure ESP as a station wifi.setmode(wifi.STATION) wifi.sta.config(SSID,SSID_PASSWORD) wifi.sta.autoconnect(1) -- These are global variables. Don't change their values -- they will be changed in the functions below local email_subject = "" local email_body = "" local count = 0 local smtp_socket = nil -- will be used as socket to email server -- The display() function will be used to print the SMTP server's response function display(sck,response) print(response) end -- The do_next() function is used to send the SMTP commands to the SMTP server in the required sequence. -- I was going to use socket callbacks but the code would not run callbacks after the first 3. function do_next() if(count == 0)then count = count+1 local IP_ADDRESS = wifi.sta.getip() smtp_socket:send("HELO "..IP_ADDRESS.."\r\n") elseif(count==1) then count = count+1 smtp_socket:send("AUTH LOGIN\r\n") elseif(count == 2) then count = count + 1 smtp_socket:send(base64.enc(MY_EMAIL).."\r\n") elseif(count == 3) then count = count + 1 smtp_socket:send(base64.enc(EMAIL_PASSWORD).."\r\n") elseif(count==4) then count = count+1 smtp_socket:send("MAIL FROM:<" .. MY_EMAIL .. ">\r\n") elseif(count==5) then count = count+1 smtp_socket:send("RCPT TO:<" .. mail_to ..">\r\n") elseif(count==6) then count = count+1 smtp_socket:send("DATA\r\n") elseif(count==7) then count = count+1 local message = string.gsub( "From: \"".. MY_EMAIL .."\"<"..MY_EMAIL..">\r\n" .. "To: \"".. mail_to .. "\"<".. mail_to..">\r\n".. "Subject: ".. email_subject .. "\r\n\r\n" .. email_body,"\r\n.\r\n","") smtp_socket:send(message.."\r\n.\r\n") elseif(count==8) then count = count+1 tmr.stop(0) smtp_socket:send("QUIT\r\n") else smtp_socket:close() end end -- The connectted() function is executed when the SMTP socket is connected to the SMTP server. -- This function will create a timer to call the do_next function which will send the SMTP commands -- in sequence, one by one, every 5000 seconds. -- You can change the time to be smaller if that works for you, I used 5000ms just because. function connected(sck) tmr.alarm(0,5000,1,do_next) end -- @name send_email -- @description Will initiated a socket connection to the SMTP server and trigger the connected() function -- @param subject The email's subject -- @param body The email's body function send_email(subject,body) count = 0 email_subject = subject email_body = body smtp_socket = net.createConnection(net.TCP,0) smtp_socket:on("connection",connected) smtp_socket:on("receive",display) smtp_socket:connect(SMTP_PORT,SMTP_SERVER) end -- Send an email send_email( "ESP8266", [[Hi, How are your IoT projects coming along? Best Wishes, ESP8266]])
mit
TheOnePharaoh/YGOPro-Custom-Cards
script/c100000840.lua
2
1791
--Created and coded by Rising Phoenix function c100000840.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOHAND) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCost(c100000840.cost) e1:SetTarget(c100000840.target) e1:SetOperation(c100000840.activate) c:RegisterEffect(e1) end function c100000840.cfilter(c) return c:IsSetCard(0x10B) and c:IsAbleToDeckAsCost() and not c:IsCode(100000840) end function c100000840.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c100000840.cfilter,tp,LOCATION_HAND+LOCATION_GRAVE+LOCATION_ONFIELD,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) local g=Duel.SelectMatchingCard(tp,c100000840.cfilter,tp,LOCATION_HAND+LOCATION_GRAVE+LOCATION_ONFIELD,0,1,1,nil) Duel.SendtoDeck(g,nil,2,REASON_COST) end function c100000840.filter(c) return c:IsSetCard(0x10B) and c:IsAbleToHand() and c:IsType(TYPE_MONSTER) end function c100000840.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE+LOCATION_DECK) and c100000840.filter(chkc) end if chk==0 then return Duel.IsExistingTarget(c100000840.filter,tp,LOCATION_GRAVE+LOCATION_DECK,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectTarget(tp,c100000840.filter,tp,LOCATION_GRAVE+LOCATION_DECK,0,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0) end function c100000840.activate(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then end Duel.SendtoHand(tc,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,tc) if c:IsRelateToEffect(e) then end c:CancelToGrave() Duel.SendtoDeck(c,nil,2,REASON_EFFECT) end
gpl-3.0
TheOnePharaoh/YGOPro-Custom-Cards
script/c99980100.lua
2
1228
--HN - Noire function c99980100.initial_effect(c) --To Hand local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e1:SetCode(EVENT_SUMMON_SUCCESS) e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e1:SetTarget(c99980100.thtg) e1:SetOperation(c99980100.thop) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetCode(EVENT_SPSUMMON_SUCCESS) c:RegisterEffect(e2) --Lvl 4 Xyz local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetCode(EFFECT_XYZ_LEVEL) e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e3:SetRange(LOCATION_MZONE) e3:SetValue(4) c:RegisterEffect(e3) end function c99980100.thfilter(c) return c:IsCode(99980140) and c:IsAbleToHand() end function c99980100.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chk==0 then return Duel.IsExistingMatchingCard(c99980100.thfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function c99980100.thop(e,tp,eg,ep,ev,re,r,rp,chk) local tg=Duel.GetFirstMatchingCard(c99980100.thfilter,tp,LOCATION_DECK,0,nil) if tg then Duel.SendtoHand(tg,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,tg) end end
gpl-3.0
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/zones/Mhaura/npcs/Pikini-Mikini.lua
6
1390
----------------------------------- -- Area: Mhaura -- NPC: Pikini-Mikini -- Standard Merchant NPC -- @pos -48 -4 30 249 ----------------------------------- package.loaded["scripts/zones/Mhaura/TextIDs"] = nil; ----------------------------------- require("scripts/globals/shop"); require("scripts/zones/Mhaura/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc,PIKINIMIKINI_SHOP_DIALOG); stock = {0x1036,2335, --Eye Drops 0x1034,284, --Antidote 0x1037,720, --Echo Drops 0x1010,819, --Potion 0x119d,10, --Distilled Water 0x395,1821, --Parchment 0x43f3,9, --Lugworm 0x3fd,450, --Hatchet 0x1118,108, --Meat Jerky 0x14b3,133, --Salsa 0x0b33,9000} --Mhaura Waystone 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
waytim/darkstar
scripts/globals/abilities/pets/healing_breath.lua
25
1487
--------------------------------------------------- -- Healing Breath I --------------------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/monstertpmoves"); --------------------------------------------------- function onAbilityCheck(player, target, ability) return 0,0; end; function onUseAbility(pet, target, skill, action) -- TODO: -- Healing Breath I and II should have lower multipliers. They'll need to be corrected if the multipliers are ever found. Don't want to over-correct right now. ---------- Deep Breathing ---------- -- 0 for none -- 50 for first merit -- 5 for each merit after the first -- TODO: 5 per merit for augmented AF2 (10663 *w/ augment*) local master = pet:getMaster() local deep = 0; if (pet:hasStatusEffect(EFFECT_MAGIC_ATK_BOOST) == true) then deep = 50 + (master:getMerit(MERIT_DEEP_BREATHING)-1)*5; pet:delStatusEffect(EFFECT_MAGIC_ATK_BOOST); end local gear = master:getMod(MOD_WYVERN_BREATH); -- Master gear that enhances breath local tp = math.floor(pet:getTP()/200)/1.165; -- HP only increases for every 20% TP pet:setTP(0) local base = math.floor(((45+tp+gear+deep)/256)*(pet:getMaxHP())+42); if (target:getHP()+base > target:getMaxHP()) then base = target:getMaxHP() - target:getHP(); --cap it end skill:setMsg(MSGBASIC_USES_RECOVERS_HP); target:addHP(base); return base; end
gpl-3.0
TheOnePharaoh/YGOPro-Custom-Cards
script/c99960000.lua
1
5399
--BRS - Black ★ Rock Shooter function c99960000.initial_effect(c) --Xyz Summon aux.AddXyzProcedure(c,nil,4,2) c:EnableReviveLimit() --Attach local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e1:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_CARD_TARGET) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetRange(LOCATION_MZONE) e1:SetCondition(c99960000.attachcon) e1:SetTarget(c99960000.attachtg) e1:SetOperation(c99960000.attachop) c:RegisterEffect(e1) --Special Summon 1 BRS local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(99960000,0)) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetCountLimit(1) e2:SetRange(LOCATION_MZONE) e2:SetCost(c99960000.spcost) e2:SetTarget(c99960000.sptg) e2:SetOperation(c99960000.spop) c:RegisterEffect(e2) --Destroy + Damage local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(99960000,1)) e3:SetCategory(CATEGORY_DESTROY+CATEGORY_DAMAGE) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetProperty(EFFECT_FLAG_CARD_TARGET) e3:SetCountLimit(1) e3:SetRange(LOCATION_MZONE) e3:SetCost(c99960000.descost) e3:SetTarget(c99960000.destg) e3:SetOperation(c99960000.desop) c:RegisterEffect(e3) --ATK Up local e4=Effect.CreateEffect(c) e4:SetType(EFFECT_TYPE_SINGLE) e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e4:SetRange(LOCATION_MZONE) e4:SetCode(EFFECT_UPDATE_ATTACK) e4:SetValue(c99960000.value) c:RegisterEffect(e4) --Detached local e5=Effect.CreateEffect(c) e5:SetCategory(CATEGORY_TODECK) e5:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e5:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e5:SetCode(EVENT_TO_GRAVE) e5:SetCondition(c99960000.detcon) e5:SetTarget(c99960000.dettg) e5:SetOperation(c99960000.detop) c:RegisterEffect(e5) end function c99960000.attachcon(e,tp,eg,ep,ev,re,r,rp) return re and re:GetHandler():IsSetCard(0x996) and not (e:GetHandler():IsPreviousLocation(LOCATION_EXTRA) and e:GetHandler():GetSummonType()==SUMMON_TYPE_XYZ and re:GetHandler()==e:GetHandler()) end function c99960000.attachfilter(c) return not c:IsHasEffect(EFFECT_NECRO_VALLEY) end function c99960000.attachtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and c99960000.attachfilter(chkc) end if chk==0 then return Duel.IsExistingTarget(c99960000.attachfilter,tp,LOCATION_GRAVE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL) Duel.SelectTarget(tp,c99960000.attachfilter,tp,LOCATION_GRAVE,0,1,1,nil) end function c99960000.attachop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() if c:IsFaceup() and c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) then Duel.Overlay(c,Group.FromCards(tc)) end end function c99960000.spcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.CheckLPCost(tp,700) end Duel.PayLPCost(tp,700) end function c99960000.spfilter(c,e,tp) return c:IsSetCard(0x996) and c:IsType(TYPE_XYZ) and c:GetRank()==4 and not c:IsCode(99960000) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c99960000.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c99960000.spfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function c99960000.spop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c99960000.spfilter,tp,LOCATION_EXTRA,0,1,1,nil,e,tp) if g:GetCount()>0 then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end end function c99960000.descost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_COST) end e:GetHandler():RemoveOverlayCard(tp,1,1,REASON_COST) end function c99960000.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1-tp) and chkc:IsFaceup() end if chk==0 then return Duel.IsExistingTarget(Card.IsFaceup,tp,0,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectTarget(tp,Card.IsFaceup,tp,0,LOCATION_MZONE,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0) end function c99960000.desop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() local dmg=0 if tc:IsRelateToEffect(e) and tc:IsControler(1-tp) and Duel.Destroy(tc,REASON_EFFECT)~=0 then if tc:IsType(TYPE_XYZ) then dmg=tc:GetRank() else dmg=tc:GetLevel() end Duel.Damage(1-tp,dmg*200,REASON_EFFECT) end end function c99960000.value(e,c) return Duel.GetMatchingGroupCount(Card.IsType,c:GetControler(),0,LOCATION_GRAVE,nil,TYPE_MONSTER)*100 end function c99960000.detcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return c:IsReason(REASON_COST) and re:IsHasType(0x7e0) and re:IsActiveType(TYPE_MONSTER) and bit.band(c:GetPreviousLocation(),LOCATION_OVERLAY)~=0 end function c99960000.dettg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_TODECK,e:GetHandler(),1,0,0) end function c99960000.detop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) then Duel.SendtoDeck(c,nil,0,REASON_EFFECT) end end
gpl-3.0
waytim/darkstar
scripts/zones/Qulun_Dome/npcs/Magicite.lua
13
1659
----------------------------------- -- Area: Qulun Dome -- NPC: Magicite -- Involved in Mission: Magicite -- @pos 11 25 -81 148 ----------------------------------- package.loaded["scripts/zones/Qulun_Dome/TextIDs"] = nil; ----------------------------------- require("scripts/globals/keyitems"); require("scripts/zones/Qulun_Dome/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:getCurrentMission(player:getNation()) == 13 and player:hasKeyItem(MAGICITE_AURASTONE) == false) then if (player:getVar("MissionStatus") < 4) then player:startEvent(0x0000,1); -- play Lion part of the CS (this is first magicite) else player:startEvent(0x0000); -- don't play Lion part of the CS end else player:messageSpecial(THE_MAGICITE_GLOWS_OMINOUSLY); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x0000) then player:setVar("MissionStatus",4); player:addKeyItem(MAGICITE_AURASTONE); player:messageSpecial(KEYITEM_OBTAINED,MAGICITE_AURASTONE); end end;
gpl-3.0
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/zones/The_Eldieme_Necropolis/npcs/_5fl.lua
2
2329
----------------------------------- -- Area: The Eldieme Necropolis -- NPC: East Plate -- @zone 195 -- @pos 231 -34 20 -- 17576324 ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local state0 = 8; local state1 = 9; if (npc:getAnimation() == 8) then state0 = 9; state1 = 8; end -- Gates -- Shiva's Gate GetNPCByID(17576304):setAnimation(state0); GetNPCByID(17576305):setAnimation(state0); GetNPCByID(17576306):setAnimation(state0); GetNPCByID(17576307):setAnimation(state0); GetNPCByID(17576308):setAnimation(state0); -- Odin's Gate GetNPCByID(17576309):setAnimation(state1); GetNPCByID(17576310):setAnimation(state1); GetNPCByID(17576311):setAnimation(state1); GetNPCByID(17576312):setAnimation(state1); GetNPCByID(17576313):setAnimation(state1); -- Leviathan's Gate GetNPCByID(17576314):setAnimation(state0); GetNPCByID(17576315):setAnimation(state0); GetNPCByID(17576316):setAnimation(state0); GetNPCByID(17576317):setAnimation(state0); GetNPCByID(17576318):setAnimation(state0); -- Titan's Gate GetNPCByID(17576319):setAnimation(state1); GetNPCByID(17576320):setAnimation(state1); GetNPCByID(17576321):setAnimation(state1); GetNPCByID(17576322):setAnimation(state1); GetNPCByID(17576323):setAnimation(state1); -- Plates -- East Plate GetNPCByID(17576324):setAnimation(state0); GetNPCByID(17576325):setAnimation(state0); -- North Plate GetNPCByID(17576326):setAnimation(state0); GetNPCByID(17576327):setAnimation(state0); -- West Plate GetNPCByID(17576328):setAnimation(state0); GetNPCByID(17576329):setAnimation(state0); -- South Plate GetNPCByID(17576330):setAnimation(state0); GetNPCByID(17576331):setAnimation(state0); return 0; end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
TheOnePharaoh/YGOPro-Custom-Cards
script/c83581521.lua
1
5530
--Beast of Wild - Tree Summoner function c83581521.initial_effect(c) c:SetSPSummonOnce(83581521) --pendulum summon aux.EnablePendulumAttribute(c) --splimit local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetRange(LOCATION_PZONE) e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_CANNOT_DISABLE) e1:SetTargetRange(1,0) e1:SetTarget(c83581521.splimit) e1:SetCondition(c83581521.splimcon) c:RegisterEffect(e1) --atkmod local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetCode(EFFECT_UPDATE_ATTACK) e2:SetRange(LOCATION_PZONE) e2:SetTargetRange(LOCATION_MZONE,0) e2:SetTarget(c83581521.atktg) e2:SetValue(400) c:RegisterEffect(e2) --draw1 local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(83581521,0)) e3:SetCategory(CATEGORY_DRAW) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e3:SetCountLimit(1,83581521) e3:SetRange(LOCATION_MZONE) e3:SetCost(c83581521.drcost1) e3:SetTarget(c83581521.drtg1) e3:SetOperation(c83581521.drop1) c:RegisterEffect(e3) --draw2 local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(83581521,1)) e4:SetCategory(CATEGORY_DRAW) e4:SetType(EFFECT_TYPE_IGNITION) e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e4:SetCountLimit(1,83581521) e4:SetRange(LOCATION_MZONE) e4:SetCost(c83581521.drcost2) e4:SetTarget(c83581521.drtg2) e4:SetOperation(c83581521.drop2) c:RegisterEffect(e4) --tohand local e5=Effect.CreateEffect(c) e5:SetDescription(aux.Stringid(83581521,2)) e5:SetCategory(CATEGORY_SPECIAL_SUMMON) e5:SetType(EFFECT_TYPE_TRIGGER_O+EFFECT_TYPE_SINGLE) e5:SetProperty(EFFECT_FLAG_DAMAGE_STEP) e5:SetCode(EVENT_DESTROYED) e5:SetCondition(c83581521.spcon) e5:SetTarget(c83581521.sptg) e5:SetOperation(c83581521.spop) c:RegisterEffect(e5) end function c83581521.splimit(e,c,sump,sumtype,sumpos,targetp) if c:IsSetCard(0x12c) then return false end return bit.band(sumtype,SUMMON_TYPE_PENDULUM)==SUMMON_TYPE_PENDULUM end function c83581521.splimcon(e) return not e:GetHandler():IsForbidden() end function c83581521.atktg(e,c) return bit.band(c:GetSummonType(),SUMMON_TYPE_SPECIAL)~=0 and c:GetSummonLocation()==LOCATION_HAND or c:GetSummonLocation()==LOCATION_EXTRA end function c83581521.costfilter(c) return c:IsSetCard(0x12c) and c:IsDestructable() end function c83581521.drcost1(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c83581521.costfilter,tp,LOCATION_ONFIELD,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectMatchingCard(tp,c83581521.costfilter,tp,LOCATION_ONFIELD,0,1,1,nil) Duel.Destroy(g,REASON_COST) end function c83581521.drtg1(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,1) end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(1) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function c83581521.drop1(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Draw(p,d,REASON_EFFECT) end function c83581521.drcost2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c83581521.costfilter,tp,LOCATION_ONFIELD,0,2,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectMatchingCard(tp,c83581521.costfilter,tp,LOCATION_ONFIELD,0,2,2,nil) Duel.Destroy(g,REASON_COST) end function c83581521.drtg2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,2) end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(2) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,2) end function c83581521.drop2(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Draw(p,d,REASON_EFFECT) end function c83581521.spcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsReason(REASON_EFFECT) and e:GetHandler():IsReason(REASON_DESTROY) end function c83581521.spfilter(c,e,tp,satk) local atk=c:GetAttack() return atk>=0 and (not satk or atk==satk) and c:IsSetCard(0x12c) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c83581521.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) if ft<=0 then return false end if ft==1 or Duel.IsPlayerAffectedByEffect(tp,59822133) then return Duel.IsExistingMatchingCard(c83581521.spfilter,tp,LOCATION_HAND+LOCATION_DECK+LOCATION_GRAVE,0,1,e:GetHandler(),e,tp,3000) else local g=Duel.GetMatchingGroup(c83581521.spfilter,tp,LOCATION_HAND+LOCATION_DECK+LOCATION_GRAVE,0,e:GetHandler(),e,tp) return g:CheckWithSumEqual(Card.GetAttack,3000,1,2) end end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND+LOCATION_DECK+LOCATION_GRAVE) end function c83581521.spop(e,tp,eg,ep,ev,re,r,rp) local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) if ft<=0 then return end if ft==1 or Duel.IsPlayerAffectedByEffect(tp,59822133) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c83581521.spfilter,tp,LOCATION_HAND+LOCATION_DECK+LOCATION_GRAVE,0,1,1,nil,e,tp,3000) if g:GetCount()>0 then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end else local g=Duel.GetMatchingGroup(c83581521.spfilter,tp,LOCATION_HAND+LOCATION_DECK+LOCATION_GRAVE,0,nil,e,tp) if g:CheckWithSumEqual(Card.GetAttack,3000,1,2) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local sg=g:SelectWithSumEqual(tp,Card.GetAttack,3000,1,2) Duel.SpecialSummon(sg,0,tp,tp,false,false,POS_FACEUP) end end end
gpl-3.0
waytim/darkstar
scripts/zones/Eastern_Adoulin/Zone.lua
16
1192
----------------------------------- -- -- Zone: Eastern Adoulin -- ----------------------------------- require("scripts/globals/settings"); package.loaded["scripts/zones/Eastern_Adoulin/TextIDs"] = nil; require("scripts/zones/Eastern_Adoulin/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) cs = -1; if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then player:setPos(-155,0,-19,250); end return cs; end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/zones/Sealions_Den/npcs/Sueleen.lua
2
1873
----------------------------------- -- Area: Sealion's Den -- NPC: Sueleen -- @pos 612 132 774 32 ----------------------------------- package.loaded["scripts/zones/Sealions_Den/TextIDs"] = nil; ----------------------------------- require("scripts/globals/missions"); require("scripts/zones/Sealions_Den/TextIDs"); require("scripts/globals/keyitems"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) --player:startEvent(0x000c); if(player:getCurrentMission(COP) == FLAMES_IN_THE_DARKNESS and player:getVar("PromathiaStatus") == 1)then player:startEvent(0x0010); elseif(player:getCurrentMission(COP) == CALM_BEFORE_THE_STORM and player:hasKeyItem(LETTERS_FROM_ULMIA_AND_PRISHE)== true )then player:startEvent(0x0011); else player:startEvent(0x0014); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("onUpdate CSID: %u",csid); --printf("onUpdate RESULT: %u",option); end; ----------------------------------- -- onEventFinish Action ----------------------------------- function onEventFinish(player,csid,option) --printf("onFinish CSID: %u",csid); --printf("onFinish RESULT: %u",option); if(csid == 0x000c and option == 1) then toPalaceEntrance(player) elseif(csid == 0x0010)then player:setVar("PromathiaStatus",2); elseif(csid == 0x0011)then player:completeMission(COP,CALM_BEFORE_THE_STORM); player:addMission(COP,THE_WARRIOR_S_PATH); player:setVar("PromathiaStatus",0); player:setVar("COP_Dalham_KILL",0); player:setVar("COP_Boggelmann_KILL",0); player:setVar("Cryptonberry_Executor_KILL",0); end end;
gpl-3.0
TheOnePharaoh/YGOPro-Custom-Cards
script/c99960340.lua
1
3102
--BRS - Counter Star function c99960340.initial_effect(c) --Negate Attack local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_DESTROY) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_ATTACK_ANNOUNCE) e1:SetCondition(c99960340.negcon1) e1:SetTarget(c99960340.negtg1) e1:SetOperation(c99960340.negop1) c:RegisterEffect(e1) --Negate Effect local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_NEGATE+CATEGORY_DESTROY) e2:SetType(EFFECT_TYPE_ACTIVATE) e2:SetCode(EVENT_CHAINING) e2:SetCondition(c99960340.negcon2) e2:SetTarget(c99960340.negtg2) e2:SetOperation(c99960340.negop2) c:RegisterEffect(e2) --Set local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e3:SetCode(EVENT_TO_GRAVE) e3:SetCondition(c99960340.setcon) e3:SetTarget(c99960340.settg) e3:SetOperation(c99960340.setop) c:RegisterEffect(e3) end function c99960340.cfilter(c) return c:IsFaceup() and c:IsType(TYPE_MONSTER) and c:IsSetCard(0x996) end function c99960340.negcon1(e,tp,eg,ep,ev,re,r,rp) return tp~=Duel.GetTurnPlayer() and Duel.IsExistingMatchingCard(c99960340.cfilter,tp,LOCATION_MZONE,0,1,nil) end function c99960340.negtg1(e,tp,eg,ep,ev,re,r,rp,chk,chkc) local tg=Duel.GetAttacker() if chkc then return chkc==tg end if chk==0 then return tg:IsOnField() and tg:IsCanBeEffectTarget(e) end Duel.SetTargetCard(tg) Duel.SetOperationInfo(0,CATEGORY_DESTROY,tg,1,0,0) end function c99960340.negop1(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) and tc:IsFaceup() and tc:IsAttackable() then if Duel.NegateAttack(tc) then Duel.Destroy(tc,REASON_EFFECT) end end end function c99960340.negcon2(e,tp,eg,ep,ev,re,r,rp) return Duel.IsExistingMatchingCard(c99960340.cfilter,tp,LOCATION_MZONE,0,1,nil) and rp~=tp and (re:IsActiveType(TYPE_MONSTER) or re:IsHasType(EFFECT_TYPE_ACTIVATE)) and Duel.IsChainNegatable(ev) end function c99960340.negtg2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0) if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then Duel.SetOperationInfo(0,CATEGORY_DESTROY,eg,1,0,0) end end function c99960340.negop2(e,tp,eg,ep,ev,re,r,rp) Duel.NegateActivation(ev) if re:GetHandler():IsRelateToEffect(re) then Duel.Destroy(eg,REASON_EFFECT) end end function c99960340.setcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return c:IsReason(REASON_COST) and re:IsHasType(0x7e0) and re:IsActiveType(TYPE_MONSTER) and c:IsPreviousLocation(LOCATION_OVERLAY) and re:GetHandler():IsSetCard(0x996) end function c99960340.settg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsSSetable() end Duel.SetOperationInfo(0,CATEGORY_LEAVE_GRAVE,e:GetHandler(),1,0,0) end function c99960340.setop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and c:IsSSetable() then Duel.SSet(tp,c) Duel.ConfirmCards(1-tp,c) end end
gpl-3.0
pedrohenriquerls/cocos2d_ruby_binding
frameworks/cocos2d-x/cocos/scripting/lua-bindings/auto/api/ComController.lua
10
1153
-------------------------------- -- @module ComController -- @extend Component,InputDelegate -- @parent_module ccs -------------------------------- -- -- @function [parent=#ComController] create -- @param self -- @return ComController#ComController ret (return value: ccs.ComController) -------------------------------- -- -- @function [parent=#ComController] createInstance -- @param self -- @return Ref#Ref ret (return value: cc.Ref) -------------------------------- -- -- @function [parent=#ComController] setEnabled -- @param self -- @param #bool b -------------------------------- -- -- @function [parent=#ComController] isEnabled -- @param self -- @return bool#bool ret (return value: bool) -------------------------------- -- -- @function [parent=#ComController] update -- @param self -- @param #float delta -------------------------------- -- -- @function [parent=#ComController] init -- @param self -- @return bool#bool ret (return value: bool) -------------------------------- -- js ctor -- @function [parent=#ComController] ComController -- @param self return nil
mit
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/globals/weaponskills/victory_smite.lua
4
1530
----------------------------------- -- Victory Smite -- Hand-to-Hand Weapon Skill -- Skill Level: N/A -- Description: Delivers a fourfold attack. Chance of params.critical hit varies with TP. -- Must have Verethragna (85)/(90)/(95)/(99)/(99-2) or Revenant Fists +1/+2/+3 equipped. -- Aligned with the Light Gorget, Breeze Gorget & Thunder Gorget. -- Aligned with the Light Belt, Breeze Belt & Thunder Belt. -- Element: None -- Skillchain Properties: Light, Fragmentation -- Modifiers: STR:60% -- Damage Multipliers by TP: -- 100%TP 200%TP 300%TP -- 2.25 2.25 2.25 -- params.critical Chance added with TP: -- 100%TP 200%TP 300%TP -- 10% 25% 45% -- ----------------------------------- require("scripts/globals/status"); require("scripts/globals/settings"); require("scripts/globals/weaponskills"); ----------------------------------- function OnUseWeaponSkill(player, target, wsID) local params = {}; params.numHits = 4; params.ftp100 = 2.25; params.ftp200 = 2.25; params.ftp300 = 2.25; params.str_wsc = 0.6; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0; params.crit100 = 0.1; params.crit200 = 0.25; params.crit300 = 0.45; params.canCrit = true; params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0; params.atkmulti = 1; local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, params); return tpHits, extraHits, criticalHit, damage; end
gpl-3.0
DevPGSV/telegram-bot
plugins/wiki.lua
5
4363
-- http://git.io/vUA4M local socket = require "socket" local JSON = require "cjson" local wikiusage = { "!wiki [text]: Read extract from default Wikipedia (EN)", "!wiki(lang) [text]: Read extract from 'lang' Wikipedia. Example: !wikies hola", "!wiki search [text]: Search articles on default Wikipedia (EN)", "!wiki(lang) search [text]: Search articles on 'lang' Wikipedia. Example: !wikies search hola", } local Wikipedia = { -- http://meta.wikimedia.org/wiki/List_of_Wikipedias wiki_server = "http://%s.wikipedia.org", wiki_path = "/w/api.php", wiki_load_params = { action = "query", prop = "extracts", format = "json", exchars = 300, exsectionformat = "plain", explaintext = "", redirects = "" }, wiki_search_params = { action = "query", list = "search", srlimit = 20, format = "json", }, default_lang = "en", } function Wikipedia:getWikiServer(lang) return string.format(self.wiki_server, lang or self.default_lang) end --[[ -- return decoded JSON table from Wikipedia --]] function Wikipedia:loadPage(text, lang, intro, plain, is_search) local request, sink = {}, {} local query = "" local parsed if is_search then for k,v in pairs(self.wiki_search_params) do query = query .. k .. '=' .. v .. '&' end parsed = URL.parse(self:getWikiServer(lang)) parsed.path = self.wiki_path parsed.query = query .. "srsearch=" .. URL.escape(text) else self.wiki_load_params.explaintext = plain and "" or nil for k,v in pairs(self.wiki_load_params) do query = query .. k .. '=' .. v .. '&' end parsed = URL.parse(self:getWikiServer(lang)) parsed.path = self.wiki_path parsed.query = query .. "titles=" .. URL.escape(text) end -- HTTP request request['url'] = URL.build(parsed) print(request['url']) request['method'] = 'GET' request['sink'] = ltn12.sink.table(sink) local httpRequest = parsed.scheme == 'http' and http.request or https.request local code, headers, status = socket.skip(1, httpRequest(request)) if not headers or not sink then return nil end local content = table.concat(sink) if content ~= "" then local ok, result = pcall(JSON.decode, content) if ok and result then return result else return nil end else return nil end end -- extract intro passage in wiki page function Wikipedia:wikintro(text, lang) local result = self:loadPage(text, lang, true, true) if result and result.query then local query = result.query if query and query.normalized then text = query.normalized[1].to or text end local page = query.pages[next(query.pages)] if page and page.extract then return text..": "..page.extract else local text = "Extract not found for "..text text = text..'\n'..table.concat(wikiusage, '\n') return text end else return "Sorry an error happened" end end -- search for term in wiki function Wikipedia:wikisearch(text, lang) local result = self:loadPage(text, lang, true, true, true) if result and result.query then local titles = "" for i,item in pairs(result.query.search) do titles = titles .. "\n" .. item["title"] end titles = titles ~= "" and titles or "No results found" return titles else return "Sorry, an error occurred" end end local function run(msg, matches) -- TODO: Remember language (i18 on future version) -- TODO: Support for non Wikipedias but Mediawikis local search, term, lang if matches[1] == "search" then search = true term = matches[2] lang = nil elseif matches[2] == "search" then search = true term = matches[3] lang = matches[1] else term = matches[2] lang = matches[1] end if not term then term = lang lang = nil end if term == "" then local text = "Usage:\n" text = text..table.concat(wikiusage, '\n') return text end local result if search then result = Wikipedia:wikisearch(term, lang) else -- TODO: Show the link result = Wikipedia:wikintro(term, lang) end return result end return { description = "Searches Wikipedia and send results", usage = wikiusage, patterns = { "^![Ww]iki(%w+) (search) (.+)$", "^![Ww]iki (search) ?(.*)$", "^![Ww]iki(%w+) (.+)$", "^![Ww]iki ?(.*)$" }, run = run }
gpl-2.0
ffxinfinity/ffxinfinity
FFXI Server-Development/Build Files/scripts/zones/Dynamis-Buburimu/Zone.lua
2
1071
----------------------------------- -- -- Zone: Dynamis-Buburimu -- ----------------------------------- require("scripts/globals/settings"); package.loaded["scripts/zones/Dynamis-Buburimu/TextIDs"] = nil; require("scripts/zones/Dynamis-Buburimu/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) cs = -1; return cs; end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
X-Raym/REAPER-ReaScripts
FX/X-Raym_Toggle selected tracks FX except those with (ON) and (OFF) suffixes.lua
1
1945
--[[ * ReaScript Name: Toggle selected tracks FX except those with (ON) and (OFF) suffixes * Author: X-Raym * Author URI: http:--extremraym.com * Source: GitHub > X-Raym > EEL Scripts for Cockos REAPER * Source URI: https:--github.com/X-Raym/REAPER-EEL-Scripts * Licence: GPL v3 * Forum Thread: EEL script: Toggle FX by suffix * Forum Thread URI: https:--forum.cockos.com/showthread.php?t=154742 * Version: 1.1 * Version Date: 2019-05-07 * Required: Reaper 4.60 ]] -- Heavily based on the great Toggle FX by suffix by HeDa -- http:--forum.cockos.com/showthread.php?p=1472339 function ToggleTrackFX( tracki ) trackifxcount = reaper.TrackFX_GetCount(tracki); -- count number of FX instances on the track for k = 0, trackifxcount - 1 do -- loop for all FX instances on each track retval, fx_name = reaper.TrackFX_GetFXName(tracki, k, ''); -- get the name of the FX instance if not (fx_name:find(" %(ON%)") or fx_name:find(" %(OFF%)") ) then -- if the name doesn't have the suffix... if reaper.TrackFX_GetEnabled(tracki, k) then -- FX is enabled. reaper.TrackFX_SetEnabled(tracki, k, 0); -- set FX to bypass else -- if not... reaper.TrackFX_SetEnabled(tracki, k, 1); --set FX to enabled end end end end function ToggleFXbySuffix() NumberTracks = reaper.CountSelectedTracks(0); for i = 0, NumberTracks - 1 do -- loop for all tracks tracki = reaper.GetSelectedTrack(0, i); -- which track ToggleTrackFX( tracki ); end mster_track = reaper.GetMasterTrack( 0 ); if reaper.IsTrackSelected(mster_track) then ToggleTrackFX(mster_track); end end reaper.Undo_BeginBlock() ToggleFXbySuffix() -- Run Run run !!!! reaper.Undo_EndBlock("Toggle FX by suffix", 0)
gpl-3.0
TheOnePharaoh/YGOPro-Custom-Cards
script/c22769935.lua
1
4628
--Urgent Pre-Preparation function c22769935.initial_effect(c) --Activate(summon) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_SUMMON) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetCondition(c22769935.condition1) e1:SetTarget(c22769935.target) e1:SetOperation(c22769935.activate) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetCode(EVENT_FLIP_SUMMON) c:RegisterEffect(e2) local e3=e1:Clone() e3:SetCode(EVENT_SPSUMMON) c:RegisterEffect(e3) --Activate(effect) local e4=Effect.CreateEffect(c) e4:SetType(EFFECT_TYPE_ACTIVATE) e4:SetCode(EVENT_CHAINING) e4:SetProperty(EFFECT_FLAG_CARD_TARGET) e4:SetCondition(c22769935.condition2) e4:SetTarget(c22769935.target) e4:SetOperation(c22769935.activate) c:RegisterEffect(e4) --Activate(attack) local e5=Effect.CreateEffect(c) e5:SetType(EFFECT_TYPE_ACTIVATE) e5:SetCode(EVENT_ATTACK_ANNOUNCE) e5:SetProperty(EFFECT_FLAG_CARD_TARGET) e5:SetCondition(c22769935.condition3) e5:SetTarget(c22769935.target) e5:SetOperation(c22769935.activate) c:RegisterEffect(e5) --Activate(spsummon) local e6=Effect.CreateEffect(c) e6:SetType(EFFECT_TYPE_ACTIVATE) e6:SetCode(EVENT_BATTLE_DESTROYED) e6:SetProperty(EFFECT_FLAG_CARD_TARGET) e6:SetCondition(c22769935.condition4) e6:SetTarget(c22769935.target) e6:SetOperation(c22769935.activate) c:RegisterEffect(e6) --destroy local e7=Effect.CreateEffect(c) e7:SetCategory(CATEGORY_DESTROY) e7:SetDescription(aux.Stringid(22769935,0)) e7:SetType(EFFECT_TYPE_QUICK_O) e7:SetRange(LOCATION_GRAVE) e7:SetProperty(EFFECT_FLAG_CARD_TARGET) e7:SetCode(EVENT_FREE_CHAIN) e7:SetHintTiming(0,0x1e0) e7:SetCountLimit(1,22769935) e7:SetCondition(aux.exccon) e7:SetCost(c22769935.descost) e7:SetTarget(c22769935.destg) e7:SetOperation(c22769935.desop) c:RegisterEffect(e7) end function c22769935.cfilter(c,tp) return c:IsRace(RACE_MACHINE) and c:IsReason(REASON_BATTLE) and c:IsLocation(LOCATION_GRAVE) and c:GetPreviousControler()==tp end function c22769935.condition1(e,tp,eg,ep,ev,re,r,rp) return Duel.GetCurrentChain()==0 end function c22769935.condition2(e,tp,eg,ep,ev,re,r,rp) return not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) and Duel.IsChainNegatable(ev) end function c22769935.condition3(e,tp,eg,ep,ev,re,r,rp) return tp~=Duel.GetTurnPlayer() end function c22769935.condition4(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(c22769935.cfilter,1,nil,tp) end function c22769935.copyfilter(c) return c:IsType(TYPE_COUNTER) and not c:IsCode(56981417) and c:CheckActivateEffect(true,true,false)~=nil end function c22769935.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then local te=e:GetLabelObject() local tg=te:GetTarget() return tg and tg(e,tp,eg,ep,ev,re,r,rp,0,chkc) end if chk==0 then return Duel.IsExistingTarget(c22769935.copyfilter,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,nil) end e:SetProperty(EFFECT_FLAG_CARD_TARGET) e:SetCategory(0) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET) local g=Duel.SelectTarget(tp,c22769935.copyfilter,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,1,nil) local te=g:GetFirst():CheckActivateEffect(true,true,false) Duel.ClearTargetCard() e:SetCategory(te:GetCategory()) e:SetProperty(te:GetProperty()) e:SetLabel(te:GetLabel()) e:SetLabelObject(te:GetLabelObject()) local tg=te:GetTarget() if tg then tg(e,tp,eg,ep,ev,re,r,rp,1) end te:SetLabel(e:GetLabel()) te:SetLabelObject(e:GetLabelObject()) e:SetLabelObject(te) end function c22769935.activate(e,tp,eg,ep,ev,re,r,rp) local te=e:GetLabelObject() if te:GetHandler():IsRelateToEffect(e) then e:SetLabel(te:GetLabel()) e:SetLabelObject(te:GetLabelObject()) local op=te:GetOperation() if op then op(e,tp,eg,ep,ev,re,r,rp) end te:SetLabel(e:GetLabel()) te:SetLabelObject(e:GetLabelObject()) end end function c22769935.descost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST) end function c22769935.desfilter(c) return c:IsFaceup() end function c22769935.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1-tp) and c22769935.desfilter(chkc) end if chk==0 then return Duel.IsExistingTarget(c22769935.desfilter,tp,0,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectTarget(tp,c22769935.desfilter,tp,0,LOCATION_MZONE,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0) end function c22769935.desop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsFaceup() and tc:IsRelateToEffect(e) then Duel.Destroy(tc,REASON_EFFECT) end end
gpl-3.0
waytim/darkstar
scripts/zones/Bastok_Markets/npcs/Nbu_Latteh.lua
26
3365
----------------------------------- -- Area: Bastok Markets -- NPC: Nbu Latteh -- Starts & Finishes Quest: Mom, The Adventurer? -- Starts Quest: The Signpost Marks the Spot ----------------------------------- package.loaded["scripts/zones/Bastok_Markets/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/titles"); require("scripts/globals/quests"); require("scripts/zones/Bastok_Markets/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local pFame = player:getFameLevel(BASTOK); local MomTheAdventurer = player:getQuestStatus(BASTOK,MOM_THE_ADVENTURER) local questStatus = player:getVar("MomTheAdventurer_Event"); if (player:needToZone()) then player:startEvent(127); -- chat about my work elseif (pFame < 2 and MomTheAdventurer ~= QUEST_ACCEPTED and questStatus == 0) then player:startEvent(0x00e6); elseif (MomTheAdventurer >= QUEST_ACCEPTED and questStatus == 2) then if (player:seenKeyItem(LETTER_FROM_ROH_LATTEH)) then player:startEvent(0x00ea); elseif (player:hasKeyItem(LETTER_FROM_ROH_LATTEH)) then player:startEvent(0x00e9); end elseif (pFame >= 2 and player:getQuestStatus(BASTOK,THE_SIGNPOST_MARKS_THE_SPOT) == QUEST_AVAILABLE) then player:startEvent(0x00eb); else player:startEvent(0x007f); 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 == 0x00e6 and option == 0) then if (player:getFreeSlotsCount(0) > 0) then player:addQuest(BASTOK,MOM_THE_ADVENTURER); player:setVar("MomTheAdventurer_Event",1); player:addItem(4096); player:messageSpecial(ITEM_OBTAINED,4096); -- Fire Crystal else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,4096); end elseif (csid == 0x00e9 or csid == 0x00ea) then if (player:seenKeyItem(LETTER_FROM_ROH_LATTEH)) then gilReward = 100; else gilReward = 200; end player:needToZone(true); player:delKeyItem(LETTER_FROM_ROH_LATTEH); player:addTitle(RINGBEARER); player:addGil(GIL_RATE*gilReward); player:messageSpecial(GIL_OBTAINED, GIL_RATE*gilReward); player:setVar("MomTheAdventurer_Event",0); if (player:getQuestStatus(BASTOK,MOM_THE_ADVENTURER) == QUEST_ACCEPTED) then player:addFame(BASTOK,50); player:completeQuest(BASTOK,MOM_THE_ADVENTURER); else player:addFame(BASTOK,8) end elseif (csid == 0x00eb and option == 0) then player:addQuest(BASTOK,THE_SIGNPOST_MARKS_THE_SPOT); player:setVar("MomTheAdventurer_Event",0); end end;
gpl-3.0