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
MonokuroInzanaito/ygopro-777DIY
expansions/script/c14140010.lua
1
3539
--祝祭初学 local m=14140010 local cm=_G["c"..m] function cm.initial_effect(c) local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_TOHAND+CATEGORY_SEARCH) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,m+EFFECT_COUNT_CODE_OATH) e1:SetTarget(cm.target) e1:SetOperation(cm.operation) c:RegisterEffect(e1) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_TRAP_ACT_IN_HAND) e1:SetCondition(function(e) return not Duel.IsExistingMatchingCard(function(c) return not c:IsSetCard(0x360) and c:IsFaceup() end,e:GetHandlerPlayer(),LOCATION_MZONE,0,1,nil) end) e1:SetValue(1) c:RegisterEffect(e1) local e1=Effect.CreateEffect(c) e1:SetDescription(m*16+1) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_FREE_CHAIN) e1:SetRange(LOCATION_SZONE) e1:SetCountLimit(1) e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP) e1:SetCondition(function() local ph=Duel.GetCurrentPhase() return ph>PHASE_MAIN1 and ph<PHASE_MAIN2 end) e1:SetTarget(cm.xyztg) e1:SetOperation(cm.xyzop) c:RegisterEffect(e1) end function cm.spfilter1(c,e,tp) return c:IsSetCard(0x360) and c:IsType(TYPE_MONSTER) and (c:IsAbleToHand() or (c:IsCanBeSpecialSummoned(e,0,tp,false,false) and Duel.GetLocationCount(tp,LOCATION_MZONE)>0)) end function cm.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then local g=Duel.GetMatchingGroup(cm.spfilter1,tp,LOCATION_DECK,0,nil,e,tp) return g:GetClassCount(Card.GetCode)>=3 end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function cm.operation(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local g=Duel.GetMatchingGroup(cm.spfilter1,tp,LOCATION_DECK,0,nil) if g:GetClassCount(Card.GetCode)>=3 then local cg=Group.CreateGroup() for i=1,3 do Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SELF) local sg=g:Select(tp,1,1,nil) g:Remove(Card.IsCode,nil,sg:GetFirst():GetCode()) cg:Merge(sg) end Duel.ConfirmCards(1-tp,cg) Duel.ShuffleDeck(tp) Duel.Hint(HINT_SELECTMSG,1-tp,HINTMSG_OPPO) local tg=cg:Select(1-tp,1,1,nil) Duel.ConfirmCards(tp,cg) local tc=tg:GetFirst() Duel.Hint(HINT_CARD,0,tc:GetOriginalCode()) local b1=tc:IsAbleToHand() local b2=tc:IsCanBeSpecialSummoned(e,0,tp,false,false) and Duel.GetLocationCount(tp,LOCATION_MZONE)>0 local op if b1 and b2 then op=Duel.SelectOption(tp,m*16,m*16+1) elseif b1 and not b2 then op=Duel.SelectOption(tp,m*16) elseif b2 and not b2 then op=Duel.SelectOption(tp,m*16+1)+1 end if op==0 then Duel.SendtoHand(tc,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,tc) elseif op==1 then Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP) end Duel.ShuffleDeck(tp) end end function cm.xyzfilter(c) if not c:IsSetCard(0x360) then return false end return c:IsXyzSummonable(nil) or c:IsSynchroSummonable(nil) end function cm.xyztg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cm.xyzfilter,tp,LOCATION_EXTRA,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function cm.xyzop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local g=Duel.GetMatchingGroup(cm.xyzfilter,tp,LOCATION_EXTRA,0,nil) if g:GetCount()>0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local tg=g:Select(tp,1,1,nil) Duel.SpecialSummonRule(tp,tg:GetFirst()) end end
gpl-3.0
davidedmonds/darkstar
scripts/zones/Southern_San_dOria/npcs/Benaige.lua
36
1982
----------------------------------- -- Area: Southern San d'Oria -- NPC: Benaige -- Standard Merchant NPC -- @zone 230 -- @pos-142,-6 47 ----------------------------------- package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/shop"); require("scripts/globals/quests"); require("scripts/zones/Southern_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- "Flyers for Regine" conditional script FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE); if (FlyerForRegine == 1) then count = trade:getItemCount(); MagicFlyer = trade:hasItemQty(532,1); if (MagicFlyer == true and count == 1) then player:messageSpecial(FLYER_REFUSED); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc,BENAIGE_SHOP_DIALOG); stock = {0x0274,234,1, --Cinnamon 0x0275,43,1, --Millioncorn 0x026e,43,2, --Dried Marjoram 0x0262,54,2, --San d'Orian Flour 0x0273,36,2, --Maple Sugar 0x0730,1800,2, --Semolina 0x165e,442,2, --Zucchini 0x166c,511,2, --Paprika 0x026d,25,3, --Crying Mustard 0x0263,36,3, --Rye Flour 0x03a8,14,3, --Rock Salt 0x119d,10,3, --Distilled Water 0x1472,198,3} --Cibol showNationShop(player, SANDORIA, stock); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
MonokuroInzanaito/ygopro-777DIY
expansions/script/c37564017.lua
1
2392
--Blue Rose Ruin local m=37564017 local cm=_G["c"..m] xpcall(function() require("expansions/script/c37564765") end,function() require("script/c37564765") end) cm.Senya_name_with_rose=true function cm.initial_effect(c) local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCondition(cm.condition) e1:SetCost(cm.cost) e1:SetCountLimit(1,m+EFFECT_COUNT_CODE_OATH) e1:SetTarget(cm.target) e1:SetOperation(cm.activate) c:RegisterEffect(e1) Duel.AddCustomActivityCounter(m,ACTIVITY_SPSUMMON,cm.counterfilter) end function cm.counterfilter(c) return Senya.check_set_elem(c) or c:GetSummonLocation()~=LOCATION_EXTRA end function cm.condition(e,tp,eg,ep,ev,re,r,rp) return Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0)==0 and Duel.GetLocationCount(tp,LOCATION_MZONE)>0 end function cm.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetCustomActivityCount(m,tp,ACTIVITY_SPSUMMON)==0 end Duel.PayLPCost(tp,math.floor(Duel.GetLP(tp)/2)) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_OATH) e1:SetTargetRange(1,0) e1:SetTarget(cm.splimit) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) end function cm.splimit(e,c,sump,sumtype,sumpos,targetp,se) return not Senya.check_set_elem(c) and c:IsLocation(LOCATION_EXTRA) end function cm.filter(c,e,tp) return Senya.check_set_elem(c) and c:GetRank()==4 and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function cm.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCountFromEx(tp)>0 and Duel.IsExistingMatchingCard(cm.filter,tp,LOCATION_EXTRA,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function cm.activate(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCountFromEx(tp)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,cm.filter,tp,LOCATION_EXTRA,0,1,1,nil,e,tp) if g:GetCount()>0 then local tc=g:GetFirst() Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP) if e:IsHasType(EFFECT_TYPE_ACTIVATE) and e:GetHandler():IsRelateToEffect(e) then Duel.BreakEffect() e:GetHandler():CancelToGrave() Duel.Overlay(tc,Group.FromCards(e:GetHandler())) end end end
gpl-3.0
capn-damo/scripts
conky/Nvidia-gauges-narrow.lua
1
15114
--============================================================================== -- Nvidia-gauges.lua, based on sun_rings -- by damo, August 2018 <damo@bunsenlabs.org> --============================================================================== -- sun_rings.lua -- -- Date : 05 July 2017 -- Author : Sun For Miles -- Version : v0.41 -- License : Distributed under the terms of GNU GPL version 2 or later -- -- This version is a modification of seamod_rings.lua which is modification of -- lunatico_rings.lua which is modification of conky_orange.lua -- -- conky_orange.lua: http://gnome-look.org/content/show.php?content=137503 -- lunatico_rings.lua: http://gnome-look.org/content/show.php?content=142884 -- seamod_rings.lua: http://custom-linux.deviantart.com/art/Conky-Seamod-v0-1-283461046 --============================================================================== require 'cairo' -- gauge DATA gauge = { { name='nvidia', arg='temp', max_value=100, x=50, y=55, graph_radius=30, graph_thickness=7, graph_start_angle=225, graph_unit_angle=2.7, graph_unit_thickness=2.7, graph_bg_colour=0xffffff, graph_bg_alpha=0.1, graph_fg_colour=0x76DFE6, graph_fg_alpha=0.3, hand_fg_colour=0x05C5DA, hand_fg_alpha=0.5, txt_radius=22, hand_radius=24, hand_width = 2, txt_weight=0, txt_size=9.0, txt_fg_colour=0x678b8b, txt_fg_alpha=0, graduation_radius=23, graduation_thickness=0, graduation_mark_thickness=2, graduation_unit_angle=2.7, graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3, caption='', caption_weight=0.5, caption_size=12.0, caption_fg_colour=0x05C5DA, caption_fg_alpha=0.7, font = 'Noto Sans Mono', }, -- This is a bit of a cheat: layered bg, for red sector, with fg no alpha { -- gpu high temps bg section (red) name='nvidia', arg='temp', max_value=6, x=50, y=55, graph_radius=30, graph_thickness=7, graph_start_angle=119, graph_unit_angle=2.7, graph_unit_thickness=2.7, graph_bg_colour=0xff0000, graph_bg_alpha=0.3, graph_fg_colour=0xCE7646, graph_fg_alpha=0, hand_fg_colour=0x477CAF, hand_fg_alpha=0.0, txt_radius=22, hand_radius=0, hand_width = 0, txt_weight=0, txt_size=9.0, txt_fg_colour=0xCE7646, txt_fg_alpha=0, graduation_radius=23, graduation_thickness=8, graduation_mark_thickness=0, graduation_unit_angle=2.7, graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.5, caption='', caption_weight=0.5, caption_size=8.0, caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.7, font = 'Noto Sans Mono', }, { name='nvidia', arg='gpuutil', max_value=100, x=90, y=115, graph_radius=30, graph_thickness=7, graph_start_angle=225, graph_unit_angle=2.7, graph_unit_thickness=2.7, graph_bg_colour=0xffffff, graph_bg_alpha=0.1, graph_fg_colour=0x76DFE6, graph_fg_alpha=0.3, hand_fg_colour=0x05C5DA, hand_fg_alpha=0.5, txt_radius=22, hand_radius=24, hand_width = 2, txt_weight=0, txt_size=9.0, txt_fg_colour=0x678b8b, txt_fg_alpha=0, graduation_radius=23, graduation_thickness=0, graduation_mark_thickness=2, graduation_unit_angle=2.7, graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3, caption='', caption_weight=0.5, caption_size=12.0, caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.5, font = 'Noto Sans Mono', }, { name='nvidia', arg='memutil', max_value=100, x=130, y=175, graph_radius=30, graph_thickness=7, graph_start_angle=225, graph_unit_angle=2.7, graph_unit_thickness=2.7, graph_bg_colour=0xffffff, graph_bg_alpha=0.1, graph_fg_colour=0x76DFE6, graph_fg_alpha=0.3, hand_fg_colour=0x05C5DA, hand_fg_alpha=0.5, txt_radius=22, hand_radius=24, hand_width = 2, txt_weight=0, txt_size=9.0, txt_fg_colour=0x678b8b, txt_fg_alpha=0, graduation_radius=23, graduation_thickness=0, graduation_mark_thickness=2, graduation_unit_angle=2.7, graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3, caption='', caption_weight=0.5, caption_size=12.0, caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.5, font = 'Noto Sans Mono', }, { name='nvidia', arg='fanlevel', max_value=100, x=170, y=235, graph_radius=30, graph_thickness=7, graph_start_angle=225, graph_unit_angle=2.7, graph_unit_thickness=2.7, graph_bg_colour=0xffffff, graph_bg_alpha=0.1, graph_fg_colour=0x76DFE6, graph_fg_alpha=0.3, hand_fg_colour=0x05C5DA, hand_fg_alpha=0.5, hand_width = 2, txt_radius=22, hand_radius=24, txt_weight=0, txt_size=9.0, txt_fg_colour=0x678b8b, txt_fg_alpha=0, graduation_radius=23, graduation_thickness=0, graduation_mark_thickness=2, graduation_unit_angle=2.7, graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3, caption='', caption_weight=0.5, caption_size=12.0, caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.5, font = 'Noto Sans Mono', }, { name='nvidia_power', arg='', max_value=300, x=210, y=295, graph_radius=30, graph_thickness=7, graph_start_angle=225, graph_unit_angle=0.9, graph_unit_thickness=2.7, graph_bg_colour=0xffffff, graph_bg_alpha=0.1, graph_fg_colour=0x76DFE6, graph_fg_alpha=0.3, hand_fg_colour=0x05C5DA, hand_fg_alpha=0.5, txt_radius=22, hand_radius=24, hand_width = 2, txt_weight=0, txt_size=9.0, txt_fg_colour=0x678b8b, txt_fg_alpha=0, graduation_radius=23, graduation_thickness=0, graduation_mark_thickness=2, graduation_unit_angle=0.9, graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3, caption='true', caption_weight=0.5, caption_size=10.0, caption_fg_colour=0x05C5DA, caption_fg_alpha=1.0, font = 'Noto Sans Mono', }, } ------------------------------------------------------------------------------- -- rgb_to_r_g_b -- converts color in hexa to decimal -- function rgb_to_r_g_b(colour, alpha) return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha end ------------------------------------------------------------------------------- -- angle_to_position -- convert degree to rad and rotate (0 degree is top/north) -- function angle_to_position(start_angle, current_angle) local pos = current_angle + start_angle return ( ( pos * (2 * math.pi / 360) ) - (math.pi / 2) ) end ------------------------------------------------------------------------------- -- displays gauges -- draw_gauge_ring function draw_gauge_ring(display, data, value) local max_value = data['max_value'] local x, y = data['x'], data['y'] local graph_radius = data['graph_radius'] local hand_radius = data['hand_radius'] local hand_width = data['hand_width'] local graph_thickness, graph_unit_thickness = data['graph_thickness'], data['graph_unit_thickness'] local graph_start_angle = data['graph_start_angle'] local graph_unit_angle = data['graph_unit_angle'] local graph_bg_colour, graph_bg_alpha = data['graph_bg_colour'], data['graph_bg_alpha'] local graph_fg_colour, graph_fg_alpha = data['graph_fg_colour'], data['graph_fg_alpha'] local hand_fg_colour, hand_fg_alpha = data['hand_fg_colour'], data['hand_fg_alpha'] local graph_end_angle = (max_value * graph_unit_angle) % 360 local font = data['font'] local caption = data['caption'] -- background ring cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, 0), angle_to_position(graph_start_angle, graph_end_angle)) cairo_set_source_rgba(display, rgb_to_r_g_b(graph_bg_colour, graph_bg_alpha)) cairo_set_line_width(display, graph_thickness) cairo_stroke(display) -- arc of value local val = value % (max_value + 1) local start_arc = 0 local stop_arc = 0 local i = 1 while i <= val do start_arc = (graph_unit_angle * i) - graph_unit_thickness stop_arc = (graph_unit_angle * i) cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc)) cairo_set_source_rgba(display, rgb_to_r_g_b(graph_fg_colour, graph_fg_alpha)) cairo_stroke(display) i = i + 1 end local angle = start_arc -- hand start_arc = (graph_unit_angle * val) - graph_unit_thickness stop_arc = (graph_unit_angle * val) cairo_set_line_width(display, hand_width) cairo_move_to(display,x,y) cairo_arc(display, x, y, hand_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, start_arc)) cairo_set_source_rgba(display, rgb_to_r_g_b(hand_fg_colour, hand_fg_alpha)) cairo_stroke(display) -- graduations marks local graduation_radius = data['graduation_radius'] local graduation_thickness, graduation_mark_thickness = data['graduation_thickness'], data['graduation_mark_thickness'] local graduation_unit_angle = data['graduation_unit_angle'] local graduation_fg_colour, graduation_fg_alpha = data['graduation_fg_colour'], data['graduation_fg_alpha'] if graduation_radius > 0 and graduation_thickness > 0 and graduation_unit_angle > 0 then local nb_graduation = graph_end_angle / graduation_unit_angle local i = 0 while i < nb_graduation do cairo_set_line_width(display, graduation_thickness) start_arc = (graduation_unit_angle * i) - (graduation_mark_thickness / 2) stop_arc = (graduation_unit_angle * i) + (graduation_mark_thickness / 2) cairo_arc(display, x, y, graduation_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc)) cairo_set_source_rgba(display,rgb_to_r_g_b(graduation_fg_colour,graduation_fg_alpha)) cairo_stroke(display) cairo_set_line_width(display, graph_thickness) i = i + 1 end end -- text local txt_radius = data['txt_radius'] local txt_weight, txt_size = data['txt_weight'], data['txt_size'] local txt_fg_colour, txt_fg_alpha = data['txt_fg_colour'], data['txt_fg_alpha'] local movex = txt_radius * math.cos(angle_to_position(graph_start_angle, angle)) local movey = txt_radius * math.sin(angle_to_position(graph_start_angle, angle)) cairo_select_font_face (display, font, CAIRO_FONT_SLANT_NORMAL, txt_weight) cairo_set_font_size (display, txt_size) cairo_set_source_rgba (display, rgb_to_r_g_b(txt_fg_colour, txt_fg_alpha)) cairo_move_to (display, x + movex - (txt_size / 2), y + movey + 3) cairo_show_text (display, value) cairo_stroke (display) -- caption if caption == "true" and data['arg'] == "" then caption = os.caption("nvidia-smi --format=csv,noheader --query-gpu=power.draw",false) else caption = data['caption'] end local caption_weight, caption_size = data['caption_weight'], data['caption_size'] local caption_fg_colour, caption_fg_alpha = data['caption_fg_colour'], data['caption_fg_alpha'] local tox = graph_radius * (math.cos((graph_start_angle * 2 * math.pi / 360)-(math.pi/2))) local toy = graph_radius * (math.sin((graph_start_angle * 2 * math.pi / 360)-(math.pi/2))) cairo_select_font_face (display, font, CAIRO_FONT_SLANT_NORMAL, caption_weight); cairo_set_font_size (display, caption_size) cairo_set_source_rgba (display, rgb_to_r_g_b(caption_fg_colour, caption_fg_alpha)) cairo_move_to (display, x + tox + 2, y + toy + 15) -- bad hack but not enough time ! --if graph_start_angle < 105 then --cairo_move_to (display, x + tox - 30, y + toy + 1) --end cairo_show_text (display, caption) cairo_stroke (display) end function get_caption(caption_text,arg) if caption_text == "true" and arg == "" then return "power" end end function os.capture(cmd, raw) local f = assert(io.popen(cmd, 'r')) local s = assert(f:read('*a')) f:close() if raw then return n end s = string.gsub(s, '^%s+', '') s = string.gsub(s, '%s+$', '') s = string.gsub(s, 'W',' ') -- remove "Watts symbol" s = string.gsub(s, '[\n\r]+', ' ') n = tonumber(s) return n end function os.caption(cmd, raw) local f = assert(io.popen(cmd, 'r')) local s = assert(f:read('*a')) f:close() if raw then return s end s = string.gsub(s, '^%s+', '') s = string.gsub(s, '%s+$', '') s = string.gsub(s, '[\n\r]+', ' ') return s end ------------------------------------------------------------------------------- -- go_gauge_rings -- loads data and displays gauges -- function go_gauge_rings(display) local function load_rings(display, data) if data['name'] == 'nvidia' then str = string.format('${%s %s}',data['name'], data['arg']) str = conky_parse(str) value = tonumber(str) draw_gauge_ring(display, data, value) else local power = os.capture("nvidia-smi --format=csv,noheader --query-gpu=power.draw",false) value = tonumber(power) draw_gauge_ring(display, data, value) end end for i in pairs(gauge) do load_rings(display, gauge[i]) end end ------------------------------------------------------------------------------- -- MAIN function conky_main() if conky_window == nil then return end local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height) local display = cairo_create(cs) local updates = conky_parse('${updates}') update_num = tonumber(updates) if update_num > 5 then go_gauge_rings(display) end cairo_surface_destroy(cs) cairo_destroy(display) end
gpl-2.0
iGhibli/FlyingGame
FlyingGame/src/framework/cc/ui/UIGroup.lua
10
3811
--[[ Copyright (c) 2011-2014 chukong-inc.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ]] -------------------------------- -- @module UIGroup --[[-- quick UIGroup控件 ]] local UIBoxLayout = import(".UIBoxLayout") local UIImage = import(".UIImage") local UIGroup = class("UIGroup", function() return display.newNode() end) -- start -- -------------------------------- -- UIGroup构建函数 -- @function [parent=#UIGroup] new -- end -- function UIGroup:ctor() makeUIControl_(self) self:setLayout(UIBoxLayout.new(display.LEFT_TO_RIGHT)) self:setLayoutSizePolicy(display.AUTO_SIZE, display.AUTO_SIZE) self:align(display.LEFT_BOTTOM) end -- start -- -------------------------------- -- 添加一个控件 -- @function [parent=#UIGroup] addWidget -- @param node widget 控件 -- @return UIGroup#UIGroup -- end -- function UIGroup:addWidget(widget) self:addChild(widget) self:getLayout():addWidget(widget) return self end -- start -- -------------------------------- -- 触摸监听函数 -- @function [parent=#UIGroup] onTouch -- @param function listener 函数 -- @return UIGroup#UIGroup -- end -- function UIGroup:onTouch(listener) if not listener then listener = function() return true end end if USE_DEPRECATED_EVENT_ARGUMENTS then self:addNodeEventListener(cc.NODE_TOUCH_EVENT, function(event) return listener(event.name, event.x, event.y, event.prevX, event.prevY) end) else self:addNodeEventListener(cc.NODE_TOUCH_EVENT, listener) end return self end -- start -- -------------------------------- -- 打开触摸功能 -- @function [parent=#UIGroup] enableTouch -- @param boolean enabled -- @return UIGroup#UIGroup -- end -- function UIGroup:enableTouch(enabled) self:setTouchEnabled(enabled) return self end -- start -- -------------------------------- -- 设置大小 -- @function [parent=#UIGroup] setLayoutSize -- @param number width -- @param number height -- @return UIGroup#UIGroup -- end -- function UIGroup:setLayoutSize(width, height) self:getComponent("components.ui.LayoutProtocol"):setLayoutSize(width, height) if self.backgroundSprite_ then self.backgroundSprite_:setLayoutSize(self:getLayoutSize()) end return self end -- start -- -------------------------------- -- 设置背景图片 -- @function [parent=#UIGroup] setBackgroundImage -- @param string filename 图片名 -- @param table args 图片控件的参数表 -- @return UIGroup#UIGroup -- @see UIImage -- end -- function UIGroup:setBackgroundImage(filename, args) self.backgroundSprite_ = UIImage.new(filename, args):setLayoutSize(self:getLayoutSize()) self:addChild(self.backgroundSprite_) return self end function UIGroup:clone_() reAddUIComponent_(self) end return UIGroup
gpl-3.0
mobinantispam/antispam412
plugins/twitter_send.lua
627
1555
do local OAuth = require "OAuth" local consumer_key = "" local consumer_secret = "" local access_token = "" local access_token_secret = "" local client = OAuth.new(consumer_key, consumer_secret, { RequestToken = "https://api.twitter.com/oauth/request_token", AuthorizeUser = {"https://api.twitter.com/oauth/authorize", method = "GET"}, AccessToken = "https://api.twitter.com/oauth/access_token" }, { OAuthToken = access_token, OAuthTokenSecret = access_token_secret }) function run(msg, matches) if consumer_key:isempty() then return "Twitter Consumer Key is empty, write it in plugins/twitter_send.lua" end if consumer_secret:isempty() then return "Twitter Consumer Secret is empty, write it in plugins/twitter_send.lua" end if access_token:isempty() then return "Twitter Access Token is empty, write it in plugins/twitter_send.lua" end if access_token_secret:isempty() then return "Twitter Access Token Secret is empty, write it in plugins/twitter_send.lua" end if not is_sudo(msg) then return "You aren't allowed to send tweets" end local response_code, response_headers, response_status_line, response_body = client:PerformRequest("POST", "https://api.twitter.com/1.1/statuses/update.json", { status = matches[1] }) if response_code ~= 200 then return "Error: "..response_code end return "Tweet sent" end return { description = "Sends a tweet", usage = "!tw [text]: Sends the Tweet with the configured account.", patterns = {"^!tw (.+)"}, run = run } end
gpl-2.0
MonokuroInzanaito/ygopro-777DIY
expansions/script/c80060022.lua
1
5519
--终结的炽天使 柊深夜 function c80060022.initial_effect(c) --synchro summon aux.AddSynchroProcedure(c,aux.FilterBoolFunction(Card.IsSetCard,0x92d7),aux.NonTuner(Card.IsSetCard,0x92d7),1) c:EnableReviveLimit() --pendulum summon aux.EnablePendulumAttribute(c,false) --pendulum set local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_PZONE) e1:SetCountLimit(1,80060022) e1:SetTarget(c80060022.pctg) e1:SetOperation(c80060022.pcop) c:RegisterEffect(e1) --destroy local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(80060022,0)) e2:SetCategory(CATEGORY_DESTROY) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetCode(EVENT_SPSUMMON_SUCCESS) e2:SetCondition(c80060022.descon) e2:SetTarget(c80060022.destg) e2:SetOperation(c80060022.desop) c:RegisterEffect(e2) --pendulum local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(80060022,2)) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetProperty(EFFECT_FLAG_DELAY) e3:SetCode(EVENT_DESTROYED) e3:SetCondition(c80060022.pencon) e3:SetTarget(c80060022.pentg) e3:SetOperation(c80060022.penop) c:RegisterEffect(e3) --indes local e4=Effect.CreateEffect(c) e4:SetType(EFFECT_TYPE_SINGLE) e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e4:SetRange(LOCATION_MZONE) e4:SetCode(EFFECT_INDESTRUCTABLE_EFFECT) e4:SetValue(1) c:RegisterEffect(e4) --special summon local e5=Effect.CreateEffect(c) e5:SetCategory(CATEGORY_SPECIAL_SUMMON) e5:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e5:SetRange(LOCATION_PZONE) e5:SetCode(EVENT_DESTROYED) e5:SetCountLimit(1,80060015) e5:SetCondition(c80060022.spcon) e5:SetTarget(c80060022.sptg) e5:SetOperation(c80060022.spop) c:RegisterEffect(e5) --act limit local e6=Effect.CreateEffect(c) e6:SetType(EFFECT_TYPE_FIELD) e6:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e6:SetCode(EFFECT_CANNOT_ACTIVATE) e6:SetRange(LOCATION_MZONE) e6:SetTargetRange(0,1) e6:SetValue(c80060022.aclimit) c:RegisterEffect(e6) end function c80060022.descon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetSummonType()==SUMMON_TYPE_SYNCHRO end function c80060022.desfilter(c) return c:IsType(TYPE_SPELL+TYPE_TRAP) end function c80060022.destg(e,tp,eg,ep,ev,re,r,rp,chk) local seq=e:GetHandler():GetSequence() local g=Group.CreateGroup() local dc=Duel.GetFieldCard(1-tp,LOCATION_MZONE,4-seq) if dc then g:AddCard(dc) end dc=Duel.GetFieldCard(1-tp,LOCATION_SZONE,4-seq) if dc then g:AddCard(dc) end if chk==0 then return g:GetCount()~=0 end Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0) Duel.SetChainLimit(c80060022.chainlm) end function c80060022.desop(e,tp,eg,ep,ev,re,r,rp) local seq=e:GetHandler():GetSequence() local g=Group.CreateGroup() local tc=Duel.GetFieldCard(1-tp,LOCATION_MZONE,4-seq) if tc then g:AddCard(tc) end tc=Duel.GetFieldCard(1-tp,LOCATION_SZONE,4-seq) if tc then g:AddCard(tc) end Duel.Destroy(g,REASON_EFFECT) end function c80060022.chainlm(e,rp,tp) return tp==rp end function c80060022.pencon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return bit.band(r,REASON_EFFECT+REASON_BATTLE)~=0 and c:IsPreviousLocation(LOCATION_MZONE) and c:IsFaceup() end function c80060022.pentg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.CheckLocation(tp,LOCATION_SZONE,6) or Duel.CheckLocation(tp,LOCATION_SZONE,7) end end function c80060022.penop(e,tp,eg,ep,ev,re,r,rp) if not Duel.CheckLocation(tp,LOCATION_SZONE,6) and not Duel.CheckLocation(tp,LOCATION_SZONE,7) then return false end local c=e:GetHandler() if c:IsRelateToEffect(e) then Duel.MoveToField(c,tp,tp,LOCATION_SZONE,POS_FACEUP,true) end end function c80060022.pcfilter(c) return c:IsType(TYPE_PENDULUM) and not c:IsForbidden() and c:IsSetCard(0x92d7) end function c80060022.pctg(e,tp,eg,ep,ev,re,r,rp,chk) local seq=e:GetHandler():GetSequence() if chk==0 then return Duel.CheckLocation(tp,LOCATION_SZONE,13-seq) and Duel.IsExistingMatchingCard(c80060022.pcfilter,tp,LOCATION_DECK,0,1,nil) end end function c80060022.pcop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local seq=e:GetHandler():GetSequence() if not Duel.CheckLocation(tp,LOCATION_SZONE,13-seq) then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOFIELD) local g=Duel.SelectMatchingCard(tp,c80060022.pcfilter,tp,LOCATION_DECK,0,1,1,nil) if g:GetCount()>0 then Duel.MoveToField(g:GetFirst(),tp,tp,LOCATION_SZONE,POS_FACEUP,true) end end function c80060022.cfilter(c,tp) return c:IsPreviousLocation(LOCATION_MZONE) and c:GetPreviousControler()==tp and c:IsReason(REASON_EFFECT) end function c80060022.spcon(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(c80060022.cfilter,1,nil,tp) end function c80060022.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 c80060022.spop(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 c80060022.aclimit(e,re,tp) return (re:GetHandler():GetType()==TYPE_SPELL+TYPE_QUICKPLAY or re:GetHandler():GetType()==TYPE_TRAP+TYPE_COUNTER) and re:IsHasType(EFFECT_TYPE_ACTIVATE) end
gpl-3.0
will4wachter/Project1
scripts/zones/Norg/npcs/Colleraie.lua
38
1028
----------------------------------- -- Area: Norg -- NPC: Colleraie -- Type: Event Scene Replayer -- @zone: 252 -- @pos -24.684 0.097 -39.409 -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/Norg/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x00af); 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
davidedmonds/darkstar
scripts/globals/abilities/desperate_flourish.lua
18
2939
----------------------------------- -- Ability: Desperate Flourish -- Weighs down a target with a low rate of success. Requires one Finishing Move. -- Obtained: Dancer Level 30 -- Finishing Moves Used: 1 -- Recast Time: 00:20 -- Duration: ?? ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/weaponskills"); require("scripts/globals/magic"); ----------------------------------- -- onAbilityCheck ----------------------------------- function onAbilityCheck(player,target,ability) if (player:getAnimation() ~= 1) then return MSGBASIC_REQUIRES_COMBAT,0; else if (player:hasStatusEffect(EFFECT_FINISHING_MOVE_1)) then player:delStatusEffect(EFFECT_FINISHING_MOVE_1); return 0,0; elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_2)) then player:delStatusEffectSilent(EFFECT_FINISHING_MOVE_2); player:addStatusEffect(EFFECT_FINISHING_MOVE_1,1,0,7200); return 0,0; elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_3)) then player:delStatusEffectSilent(EFFECT_FINISHING_MOVE_3); player:addStatusEffect(EFFECT_FINISHING_MOVE_2,1,0,7200); return 0,0; elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_4)) then player:delStatusEffectSilent(EFFECT_FINISHING_MOVE_4); player:addStatusEffect(EFFECT_FINISHING_MOVE_3,1,0,7200); return 0,0; elseif (player:hasStatusEffect(EFFECT_FINISHING_MOVE_5)) then player:delStatusEffectSilent(EFFECT_FINISHING_MOVE_5); player:addStatusEffect(EFFECT_FINISHING_MOVE_4,1,0,7200); return 0,0; else return MSGBASIC_NO_FINISHINGMOVES,0; end end end; ----------------------------------- -- onUseAbility ----------------------------------- function onUseAbility(player,target,ability) local isSneakValid = player:hasStatusEffect(EFFECT_SNEAK_ATTACK); if (isSneakValid and not player:isBehind(target)) then isSneakValid = false; end local hitrate = getHitRate(player,target,true); if (math.random() <= hitrate or isSneakValid) then local bonus = 50 - target:getMod(MOD_STUNRES); local spell = getSpell(216); local resist = applyResistance(player,spell,target,0,player:getWeaponSkillType(SLOT_MAIN),bonus) if resist > 0.25 then target:delStatusEffectSilent(EFFECT_WEIGHT); target:addStatusEffect(EFFECT_WEIGHT, 50, 0, 60 * resist); else ability:setMsg(110); end ability:setMsg(127); return EFFECT_WEIGHT, getFlourishAnimation(player:getWeaponSkillType(SLOT_MAIN)), 2; else ability:setMsg(158); return 0; end end;
gpl-3.0
will4wachter/Project1
scripts/zones/Carpenters_Landing/npcs/Logging_Point.lua
6
1114
----------------------------------- -- Area: Carpenters Landing -- NPC: Logging Point ----------------------------------- package.loaded["scripts/zones/Carpenters_Landing/TextIDs"] = nil; ------------------------------------- require("scripts/globals/logging"); require("scripts/zones/Carpenters_Landing/TextIDs"); ----------------------------------- -- onTrade ----------------------------------- function onTrade(player,npc,trade) startLogging(player,player:getZone(),npc,trade,0x001E); end; ----------------------------------- -- onTrigger ----------------------------------- function onTrigger(player,npc) player:messageSpecial(LOGGING_IS_POSSIBLE_HERE,1021); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
will4wachter/Project1
scripts/globals/items/baked_popoto.lua
35
1283
----------------------------------------- -- ID: 4436 -- Item: Baked Popoto -- Food Effect: 30Min, All Races ----------------------------------------- -- Health 20 -- Dexterity -1 -- Vitality 2 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,1800,4436); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_HP, 20); target:addMod(MOD_DEX, -1); target:addMod(MOD_VIT, 2); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_HP, 20); target:delMod(MOD_DEX, -1); target:delMod(MOD_VIT, 2); end;
gpl-3.0
waterlgndx/darkstar
scripts/globals/items/hellsteak.lua
2
1653
----------------------------------------- -- ID: 5609 -- Item: hellsteak -- Food Effect: 180Min, All Races ----------------------------------------- -- Health 20 -- Strength 6 -- Intelligence -2 -- Health Regen While Healing 2 -- hMP +1 -- Attack % 18 (cap 145) -- Ranged ATT % 18 (cap 145) -- Dragon Killer 5 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(dsp.effect.FOOD) == true or target:hasStatusEffect(dsp.effect.FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; function onItemUse(target) target:addStatusEffect(dsp.effect.FOOD,0,0,10800,5609); end; function onEffectGain(target, effect) target:addMod(dsp.mod.HP, 20); target:addMod(dsp.mod.STR, 6); target:addMod(dsp.mod.INT, -2); target:addMod(dsp.mod.HPHEAL, 2); target:addMod(dsp.mod.MPHEAL, 1); target:addMod(dsp.mod.FOOD_ATTP, 18); target:addMod(dsp.mod.FOOD_ATT_CAP, 145); target:addMod(dsp.mod.FOOD_RATTP, 18); target:addMod(dsp.mod.FOOD_RATT_CAP, 145); target:addMod(dsp.mod.DRAGON_KILLER, 5); end; function onEffectLose(target, effect) target:delMod(dsp.mod.HP, 20); target:delMod(dsp.mod.STR, 6); target:delMod(dsp.mod.INT, -2); target:delMod(dsp.mod.HPHEAL, 2); target:delMod(dsp.mod.MPHEAL, 1); target:delMod(dsp.mod.FOOD_ATTP, 18); target:delMod(dsp.mod.FOOD_ATT_CAP, 145); target:delMod(dsp.mod.FOOD_RATTP, 18); target:delMod(dsp.mod.FOOD_RATT_CAP, 145); target:delMod(dsp.mod.DRAGON_KILLER, 5); end;
gpl-3.0
will4wachter/Project1
scripts/zones/Windurst_Waters/npcs/Tosuka-Porika.lua
2
5301
----------------------------------- -- Area: Windurst Waters -- NPC: Tosuka-Porika -- Involved in Quests: Hat in Hand -- Involved in Mission 2-1 -- @pos -26 -6 103 238 ----------------------------------- package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil; package.loaded["scripts/globals/missions"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/titles"); require("scripts/globals/missions"); require("scripts/globals/quests"); require("scripts/zones/Windurst_Walls/TextIDs"); require("scripts/globals/keyitems"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) -- cs notes -- 0x172 (370) = You have no mission, gtfo -- 0x17b (379) = Not sure yet (Adventurer from the other day?) -- 0x17c (380) = About the book of gods and "some adventurer" -- 0xa0 (160) = 1st cutscene of Windurst Mission 2-1 -- 0xa1 (161) = More info on 2-1, ifyou talk to him right after the previous cutscene again local bookwormStatus = player:getQuestStatus(WINDURST,EARLY_BIRD_CATCHES_THE_BOOKWORM); local glyphStatus = player:getQuestStatus(WINDURST,GLYPH_HANGER); local chasingStatus = player:getQuestStatus(WINDURST,CHASING_TALES); local Fame = player:getFameLevel(WINDURST); if (player:getCurrentMission(COP) == THE_ROAD_FORKS and player:getVar("MEMORIES_OF_A_MAIDEN_Status")==10)then player:startEvent(0x036B);--COP event -- Start Past Reflexion in First ----------- elseif(player:getCurrentMission(WINDURST) == LOST_FOR_WORDS) then MissionStatus = player:getVar("MissionStatus"); if(MissionStatus == 0) then player:startEvent(0x00a0); -- First CS for Mission 2-1 elseif(MissionStatus > 0 and MissionStatus < 6) then player:startEvent(0x00a1); -- During Mission 2-1 elseif(MissionStatus == 6) then player:startEvent(0x00a8); -- Finish Mission 2-1 end elseif(bookwormStatus == QUEST_AVAILABLE and glyphStatus == QUEST_COMPLETED and Fame >= 2 and player:needToZone() == false) then player:startEvent(0x0183); -- Start Quest "Early Bird Catches the Bookworm" elseif(bookwormStatus == QUEST_ACCEPTED) then player:startEvent(0x0184); -- During Quest "Early Bird Catches the Bookworm" elseif(player:getQuestStatus(WINDURST,HAT_IN_HAND) == QUEST_ACCEPTED or player:getVar("QuestHatInHand_var2") == 1) then function testflag(set,flag) return (set % (2*flag) >= flag) end if(testflag(tonumber(player:getVar("QuestHatInHand_var")),32) == false) then player:startEvent(0x0037); -- Show Off Hat end -- Book is A_SONG_OF_LOVE, Keyitem ID = 126 elseif(chasingStatus == QUEST_AVAILABLE and bookwormStatus == QUEST_COMPLETED and WindyMission ~= THE_JESTER_WHOD_BE_KING and Fame >= 3 and player:needToZone() == false) then player:startEvent(0x0193); -- Add initial cutscene elseif(chasingStatus == QUEST_ACCEPTED and player:getVar("CHASING_TALES_TRACK_BOOK") > 0) then player:startEvent(0x019c); elseif(player:hasKeyItem(149) ==true) then player:startEvent(0x019c); elseif(chasingStatus == QUEST_ACCEPTED) then player:startEvent(0x0196); -- Add folllow up cutscene -- Windurst Mission 7-1 -- elseif(player:getCurrentMission(WINDURST) == THE_SIXTH_MINISTRY and player:getVar("MissionStatus") == 0) then player:startEvent(0x02cb,0,OPTISTERY_RING); elseif(player:getCurrentMission(WINDURST) == THE_SIXTH_MINISTRY and player:getVar("MissionStatus") == 1) then player:startEvent(0x02cc,0,OPTISTERY_RING); elseif(player:getCurrentMission(WINDURST) == THE_SIXTH_MINISTRY and player:getVar("MissionStatus") == 2) then player:startEvent(0x02d4); else player:startEvent(0x0172); -- Standard Conversation end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); if(csid == 0x0037) then -- Show Off Hat player:setVar("QuestHatInHand_var",player:getVar("QuestHatInHand_var")+32); player:setVar("QuestHatInHand_count",player:getVar("QuestHatInHand_count")+1); elseif(csid == 0x00a0) then player:setVar("MissionStatus",1); elseif(csid == 0x00a8) then finishMissionTimeline(player,1,csid,option); elseif(csid == 0x0183 and option == 0) then -- Early Bird Gets The Bookworm player:addQuest(WINDURST,EARLY_BIRD_CATCHES_THE_BOOKWORM); elseif(csid == 0x0193 and option == 0) then player:addQuest(WINDURST,CHASING_TALES); elseif(csid ==0x036B)then player:setVar("MEMORIES_OF_A_MAIDEN_Status",11); elseif(csid == 0x02cb) then player:addKeyItem(OPTISTERY_RING); player:messageSpecial(KEYITEM_OBTAINED,OPTISTERY_RING); player:setVar("MissionStatus",1); elseif(csid == 0x02d4) then finishMissionTimeline(player,3,csid,option); player:setVar("Windurst_7-1Kills",0); end end;
gpl-3.0
will4wachter/Project1
scripts/zones/The_Eldieme_Necropolis/npcs/Brazier.lua
6
3608
----------------------------------- -- Area: The Eldieme Necropolis -- NPC: Brazier -- Involved in Quests: Save my Sister -- @pos 101 -33 -59 195 (F-9) -- @pos 259 -33 99 195 (H-7) -- @pos 99 -33 98 195 (F-7) -- @pos 259 -33 -58 195 (H-9) ----------------------------------- package.loaded["scripts/zones/The_Eldieme_Necropolis/TextIDs"] = nil; ----------------------------------- require("scripts/globals/keyitems"); require("scripts/globals/quests"); require("scripts/zones/The_Eldieme_Necropolis/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if(player:getQuestStatus(JEUNO,SAVE_MY_SISTER) == QUEST_ACCEPTED and player:getVar("saveMySisterFireLantern") < 4) then player:setVar("saveMySisterLanternID",npc:getID()); player:startEvent(0x002c); else player:messageSpecial(NOTHING_OUT_OF_ORDINARY); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); if(csid == 0x002c and option == 0) then local LanternOrder = player:getVar("saveMySisterFireLantern"); local npcID = player:getVar("saveMySisterLanternID"); player:setVar("saveMySisterLanternID",0); if(LanternOrder == 0) then if(npcID == 17576340) then --(F-9) -- "The Ducal Guard's lantern lights dimly." player:messageSpecial(THE_LIGHT_DIMLY,0,0,0,DUCAL_GUARDS_LANTERN_LIT); player:setVar("saveMySisterFireLantern",1); else -- "Unexpectedly, the Ducal Guard's lantern refuses to light." player:messageSpecial(REFUSE_TO_LIGHT,0,0,0,DUCAL_GUARDS_LANTERN_LIT); end elseif(LanternOrder == 1) then if(npcID == 17576341) then --(H-7) -- "The light of Ducal Guard's lantern has intensified." player:messageSpecial(THE_LIGHT_HAS_INTENSIFIED,0,0,0,DUCAL_GUARDS_LANTERN_LIT); player:setVar("saveMySisterFireLantern",2); else -- "For some strange reason, the light of the Ducal Guard's lantern goes out..." player:messageSpecial(LANTERN_GOES_OUT,0,0,0,DUCAL_GUARDS_LANTERN_LIT); player:setVar("saveMySisterFireLantern",0); end elseif(LanternOrder == 2) then if(npcID == 17576342) then --(F-7) -- "The light of Ducal Guard's lantern has intensified." player:messageSpecial(THE_LIGHT_HAS_INTENSIFIED,0,0,0,DUCAL_GUARDS_LANTERN_LIT); player:setVar("saveMySisterFireLantern",3); else -- "For some strange reason, the light of the Ducal Guard's lantern goes out..." player:messageSpecial(LANTERN_GOES_OUT,0,0,0,DUCAL_GUARDS_LANTERN_LIT); player:setVar("saveMySisterFireLantern",0); end elseif(LanternOrder == 3) then if(npcID == 17576343) then --(H-9) -- "The Ducal Guard's lantern is fully lit!" player:messageSpecial(THE_LIGHT_IS_FULLY_LIT,0,0,0,DUCAL_GUARDS_LANTERN_LIT); player:setVar("saveMySisterFireLantern",4); else -- "For some strange reason, the light of the Ducal Guard's lantern goes out..." player:messageSpecial(LANTERN_GOES_OUT,0,0,0,DUCAL_GUARDS_LANTERN_LIT); player:setVar("saveMySisterFireLantern",0); end end end end;
gpl-3.0
will4wachter/Project1
scripts/zones/Labyrinth_of_Onzozo/npcs/Grounds_Tome.lua
34
1146
----------------------------------- -- Area: Labyrinth of Onzozo -- NPC: Grounds Tome ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/groundsofvalor"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) startGov(GOV_EVENT_LABYRINTH_OF_ONZOZO,player); end; ----------------------------------- -- onEventSelection ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); updateGov(player,csid,option,771,772,773,774,775,776,0,0,0,0); end; ----------------------------------- -- onEventFinish Action ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); finishGov(player,csid,option,771,772,773,774,775,776,0,0,0,0,GOV_MSG_LABYRINTH_OF_ONZOZO); end;
gpl-3.0
kidaa/darkstar
scripts/zones/Port_San_dOria/npcs/Brifalien.lua
19
1772
----------------------------------- -- Area: Port San d'Oria -- NPC: Brifalien -- Involved in Quests: Riding on the Clouds -- @zone 232 -- @pos -20 -4 -74 ----------------------------------- package.loaded["scripts/zones/Port_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/keyitems"); require("scripts/globals/quests"); require("scripts/zones/Port_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if(player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE) == QUEST_ACCEPTED) then if(trade:hasItemQty(532,1) and trade:getItemCount() == 1) then -- Trade Magicmart Flyer player:messageSpecial(FLYER_REFUSED); end end if(player:getQuestStatus(JEUNO,RIDING_ON_THE_CLOUDS) == QUEST_ACCEPTED and player:getVar("ridingOnTheClouds_1") == 7) then if(trade:hasItemQty(1127,1) and trade:getItemCount() == 1) then -- Trade Kindred seal player:setVar("ridingOnTheClouds_1",0); player:tradeComplete(); player:addKeyItem(SCOWLING_STONE); player:messageSpecial(KEYITEM_OBTAINED,SCOWLING_STONE); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x024d); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
MonokuroInzanaito/ygopro-777DIY
expansions/script/c23308003.lua
1
5376
--义妹·爱匹莉娅 function c23308003.initial_effect(c) --pendulum summon aux.EnablePendulumAttribute(c,false) --Activate local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(23308003,3)) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e1) --fusion effect -- local e2=Effect.CreateEffect(c) -- e2:SetDescription(aux.Stringid(23308003,0)) -- e2:SetCategory(CATEGORY_SPECIAL_SUMMON) -- e2:SetType(EFFECT_TYPE_QUICK_O) -- e2:SetCode(EVENT_FREE_CHAIN) -- e2:SetHintTiming(0,TIMING_STANDBY_PHASE+0x1c0) -- e2:SetRange(LOCATION_MZONE+LOCATION_HAND) -- e2:SetCountLimit(1,23308003) -- e2:SetCost(c23308003.cost) -- e2:SetTarget(c23308003.sptg1) -- e2:SetOperation(c23308003.spop1) -- c:RegisterEffect(e2) --pemdilum effect local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(23308003,1)) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetType(EFFECT_TYPE_QUICK_O) e3:SetCode(EVENT_FREE_CHAIN) e3:SetHintTiming(0,TIMING_STANDBY_PHASE+0x1c0) e3:SetRange(LOCATION_MZONE+LOCATION_HAND) e3:SetCountLimit(1,74700031) e3:SetCost(c23308003.cost) e3:SetCondition(c23308003.con) e3:SetOperation(c23308003.spop2) c:RegisterEffect(e3) end function c23308003.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsReleasable() end Duel.Release(e:GetHandler(),REASON_COST) end function c23308003.ffilter1(c,e) return c:IsSetCard(0x999) and c:IsCanBeFusionMaterial() and not c:IsImmuneToEffect(e) end function c23308003.ffilter2(c,e,tp,m,f,chkf) return c:IsType(TYPE_FUSION) and (not f or f(c)) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,nil,chkf) end function c23308003.sptg1(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then local chkf=Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and PLAYER_NONE or tp local mg1=Duel.GetMatchingGroup(c23308003.ffilter1,tp,LOCATION_HAND+LOCATION_MZONE,0,e:GetHandler(),e) local res=Duel.IsExistingMatchingCard(c23308003.ffilter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,nil,chkf) if not res then local ce=Duel.GetChainMaterial(tp) if ce~=nil then local fgroup=ce:GetTarget() local mg2=fgroup(ce,e,tp):Filter(c23308003.ffilter1,nil) local mf=ce:GetValue() res=Duel.IsExistingMatchingCard(c23308003.ffilter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg2,mf,chkf) end end return res end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function c23308003.spop1(e,tp,eg,ep,ev,re,r,rp) local chkf=Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and PLAYER_NONE or tp local mg1=Duel.GetMatchingGroup(c23308003.ffilter1,tp,LOCATION_HAND+LOCATION_MZONE,0,e:GetHandler(),e) local sg1=Duel.GetMatchingGroup(c23308003.ffilter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf) local mg2=nil local sg2=nil local ce=Duel.GetChainMaterial(tp) if ce~=nil then local fgroup=ce:GetTarget() local mg2=fgroup(ce,e,tp):Filter(c23308003.ffilter1,nil) local mf=ce:GetValue() sg2=Duel.GetMatchingGroup(c23308003.ffilter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg2,mf,chkf) end if sg1:GetCount()>0 or (sg2~=nil and sg2:GetCount()>0) then local sg=sg1:Clone() if sg2 then sg:Merge(sg2) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local tg=sg:Select(tp,1,1,nil) local tc=tg:GetFirst() if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or not Duel.SelectYesNo(tp,ce:GetDescription())) then local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf) tc:SetMaterial(mat1) Duel.SendtoGrave(mat1,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION) Duel.BreakEffect() Duel.SpecialSummon(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP) else local mat2=Duel.SelectFusionMaterial(tp,tc,mg2,nil,chkf) local fop=ce:GetOperation() fop(ce,e,tp,tc,mat2) end tc:CompleteProcedure() end end function c23308003.confilter(c,e,tp,lscale,rscale) local lv=c:GetLevel() return (c:IsLocation(LOCATION_HAND) or c:IsFaceup()) and c:IsType(TYPE_PENDULUM) and lv>lscale and lv<rscale and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_PENDULUM,tp,false,false) end function c23308003.con(e) local c=e:GetHandler() local tp=c:GetControler() local lpz=Duel.GetFieldCard(tp,LOCATION_SZONE,6) local rpz=Duel.GetFieldCard(tp,LOCATION_SZONE,7) if lpz==nil or rpz==nil then return false end local lscale=lpz:GetLeftScale() local rscale=rpz:GetRightScale() if lscale>rscale then lscale,rscale=rscale,lscale end local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) if ft<=0 then return false else return Duel.IsExistingMatchingCard(c23308003.confilter,tp,LOCATION_HAND+LOCATION_EXTRA,0,1,e:GetHandler(),e,tp,lscale,rscale) end end function c23308003.spop2(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local lpz=Duel.GetFieldCard(tp,LOCATION_SZONE,6) local rpz=Duel.GetFieldCard(tp,LOCATION_SZONE,7) if lpz==nil or rpz==nil then return false end local lscale=lpz:GetLeftScale() local rscale=rpz:GetRightScale() if lscale>rscale then lscale,rscale=rscale,lscale end local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) if ft<=0 then return false end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local sg=Duel.SelectMatchingCard(tp,c23308003.confilter,tp,LOCATION_HAND+LOCATION_EXTRA,0,1,ft,e:GetHandler(),e,tp,lscale,rscale) local pg=Group.FromCards(lpz,rpz) Duel.HintSelection(pg) Duel.SpecialSummon(sg,SUMMON_TYPE_PENDULUM,tp,tp,false,false,POS_FACEUP) end
gpl-3.0
will4wachter/Project1
scripts/globals/items/watermelon.lua
35
1197
----------------------------------------- -- ID: 4491 -- Item: watermelon -- Food Effect: 5Min, All Races ----------------------------------------- -- Agility -6 -- Intelligence 4 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,300,4491); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_AGI, -6); target:addMod(MOD_INT, 4); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_AGI, -6); target:delMod(MOD_INT, 4); end;
gpl-3.0
iGhibli/FlyingGame
FlyingGame/src/framework/transition.lua
20
19757
--[[ Copyright (c) 2011-2014 chukong-inc.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ]] -------------------------------- -- @module transition --[[-- 为图像创造效果 ]] local transition = {} local ACTION_EASING = {} ACTION_EASING["BACKIN"] = {cc.EaseBackIn, 1} ACTION_EASING["BACKINOUT"] = {cc.EaseBackInOut, 1} ACTION_EASING["BACKOUT"] = {cc.EaseBackOut, 1} ACTION_EASING["BOUNCE"] = {cc.EaseBounce, 1} ACTION_EASING["BOUNCEIN"] = {cc.EaseBounceIn, 1} ACTION_EASING["BOUNCEINOUT"] = {cc.EaseBounceInOut, 1} ACTION_EASING["BOUNCEOUT"] = {cc.EaseBounceOut, 1} ACTION_EASING["ELASTIC"] = {cc.EaseElastic, 2, 0.3} ACTION_EASING["ELASTICIN"] = {cc.EaseElasticIn, 2, 0.3} ACTION_EASING["ELASTICINOUT"] = {cc.EaseElasticInOut, 2, 0.3} ACTION_EASING["ELASTICOUT"] = {cc.EaseElasticOut, 2, 0.3} ACTION_EASING["EXPONENTIALIN"] = {cc.EaseExponentialIn, 1} ACTION_EASING["EXPONENTIALINOUT"] = {cc.EaseExponentialInOut, 1} ACTION_EASING["EXPONENTIALOUT"] = {cc.EaseExponentialOut, 1} ACTION_EASING["IN"] = {cc.EaseIn, 2, 1} ACTION_EASING["INOUT"] = {cc.EaseInOut, 2, 1} ACTION_EASING["OUT"] = {cc.EaseOut, 2, 1} ACTION_EASING["RATEACTION"] = {cc.EaseRateAction, 2, 1} ACTION_EASING["SINEIN"] = {cc.EaseSineIn, 1} ACTION_EASING["SINEINOUT"] = {cc.EaseSineInOut, 1} ACTION_EASING["SINEOUT"] = {cc.EaseSineOut, 1} local actionManager = cc.Director:getInstance():getActionManager() -- start -- -------------------------------- -- 创建一个缓动效果 -- @function [parent=#transition] newEasing -- @param Action action 动作对象 -- @param string easingName 缓冲效果的名字, 具体参考 transition.execute() 方法 -- @param mixed more 创建缓冲效果的参数 -- @return mixed#mixed ret (return value: mixed) 结果 -- end -- function transition.newEasing(action, easingName, more) local key = string.upper(tostring(easingName)) if string.sub(key, 1, 6) == "CCEASE" then key = string.sub(key, 7) end local easing if ACTION_EASING[key] then local cls, count, default = unpack(ACTION_EASING[key]) if count == 2 then easing = cls:create(action, more or default) else easing = cls:create(action) end end return easing or action end -- start -- -------------------------------- -- 创建一个动作效果 -- @function [parent=#transition] create -- @param Action action 动作对象 -- @param table args 参数表格对象 -- @return mixed#mixed ret (return value: mixed) 结果 -- end -- function transition.create(action, args) args = checktable(args) if args.easing then if type(args.easing) == "table" then action = transition.newEasing(action, unpack(args.easing)) else action = transition.newEasing(action, args.easing) end end local actions = {} local delay = checknumber(args.delay) if delay > 0 then actions[#actions + 1] = cc.DelayTime:create(delay) end actions[#actions + 1] = action local onComplete = args.onComplete if type(onComplete) ~= "function" then onComplete = nil end if onComplete then actions[#actions + 1] = cc.CallFunc:create(onComplete) end if #actions > 1 then return transition.sequence(actions) else return actions[1] end end -- start -- -------------------------------- -- 执行一个动作效果 -- @function [parent=#transition] execute -- @param cc.Node target 显示对象 -- @param Action action 动作对象 -- @param table args 参数表格对象 -- @return mixed#mixed ret (return value: mixed) 结果 --[[-- 执行一个动作效果 ~~~ lua -- 等待 1.0 后开始移动对象 -- 耗时 1.5 秒,将对象移动到屏幕中央 -- 移动使用 backout 缓动效果 -- 移动结束后执行函数,显示 move completed transition.execute(sprite, MoveTo:create(1.5, cc.p(display.cx, display.cy)), { delay = 1.0, easing = "backout", onComplete = function() print("move completed") end, }) ~~~ transition.execute() 是一个强大的工具,可以为原本单一的动作添加各种附加特性。 transition.execute() 的参数表格支持下列参数: - delay: 等待多长时间后开始执行动作 - easing: 缓动效果的名字及可选的附加参数,效果名字不区分大小写 - onComplete: 动作执行完成后要调用的函数 - time: 执行动作需要的时间 transition.execute() 支持的缓动效果: - backIn - backInOut - backOut - bounce - bounceIn - bounceInOut - bounceOut - elastic, 附加参数默认为 0.3 - elasticIn, 附加参数默认为 0.3 - elasticInOut, 附加参数默认为 0.3 - elasticOut, 附加参数默认为 0.3 - exponentialIn, 附加参数默认为 1.0 - exponentialInOut, 附加参数默认为 1.0 - exponentialOut, 附加参数默认为 1.0 - In, 附加参数默认为 1.0 - InOut, 附加参数默认为 1.0 - Out, 附加参数默认为 1.0 - rateaction, 附加参数默认为 1.0 - sineIn - sineInOut - sineOut ]] -- end -- function transition.execute(target, action, args) assert(not tolua.isnull(target), "transition.execute() - target is not cc.Node") local action = transition.create(action, args) target:runAction(action) return action end -- start -- -------------------------------- -- 将显示对象旋转到指定角度,并返回 Action 动作对象。 -- @function [parent=#transition] rotateTo -- @param cc.Node target 显示对象 -- @param table args 参数表格对象 -- @return mixed#mixed ret (return value: mixed) 结果 --[[-- 将显示对象旋转到指定角度,并返回 Action 动作对象。 ~~~ lua -- 耗时 0.5 秒将 sprite 旋转到 180 度 transition.rotateTo(sprite, {rotate = 180, time = 0.5}) ~~~ ]] -- end -- function transition.rotateTo(target, args) assert(not tolua.isnull(target), "transition.rotateTo() - target is not cc.Node") -- local rotation = args.rotate local action = cc.RotateTo:create(args.time, args.rotate) return transition.execute(target, action, args) end -- start -- -------------------------------- -- 将显示对象移动到指定位置,并返回 Action 动作对象。 -- @function [parent=#transition] moveTo -- @param cc.Node target 显示对象 -- @param table args 参数表格对象 -- @return mixed#mixed ret (return value: mixed) 结果 --[[-- 将显示对象移动到指定位置,并返回 Action 动作对象。 ~~~ lua -- 移动到屏幕中心 transition.moveTo(sprite, {x = display.cx, y = display.cy, time = 1.5}) -- 移动到屏幕左边,不改变 y transition.moveTo(sprite, {x = display.left, time = 1.5}) -- 移动到屏幕底部,不改变 x transition.moveTo(sprite, {y = display.bottom, time = 1.5}) ~~~ ]] -- end -- function transition.moveTo(target, args) assert(not tolua.isnull(target), "transition.moveTo() - target is not cc.Node") local tx, ty = target:getPosition() local x = args.x or tx local y = args.y or ty local action = cc.MoveTo:create(args.time, cc.p(x, y)) return transition.execute(target, action, args) end -- start -- -------------------------------- -- 将显示对象移动一定距离,并返回 Action 动作对象。 -- @function [parent=#transition] moveBy -- @param cc.Node target 显示对象 -- @param table args 参数表格对象 -- @return mixed#mixed ret (return value: mixed) 结果 --[[-- 将显示对象移动一定距离,并返回 Action 动作对象。 ~~~ lua -- 向右移动 100 点,向上移动 100 点 transition.moveBy(sprite, {x = 100, y = 100, time = 1.5}) -- 向左移动 100 点,不改变 y transition.moveBy(sprite, {x = -100, time = 1.5}) -- 向下移动 100 点,不改变 x transition.moveBy(sprite, {y = -100, time = 1.5}) ~~~ ]] -- end -- function transition.moveBy(target, args) assert(not tolua.isnull(target), "transition.moveBy() - target is not cc.Node") local x = args.x or 0 local y = args.y or 0 local action = cc.MoveBy:create(args.time, cc.p(x, y)) return transition.execute(target, action, args) end -- start -- -------------------------------- -- 淡入显示对象,并返回 Action 动作对象。 -- @function [parent=#transition] fadeIn -- @param cc.Node target 显示对象 -- @param table args 参数表格对象 -- @return mixed#mixed ret (return value: mixed) 结果 --[[-- 淡入显示对象,并返回 Action 动作对象。 fadeIn 操作会首先将对象的透明度设置为 0(0%,完全透明),然后再逐步增加为 255(100%,完全不透明)。 如果不希望改变对象当前的透明度,应该用 fadeTo()。 ~~~ lua action = transition.fadeIn(sprite, {time = 1.5}) ~~~ ]] -- end -- function transition.fadeIn(target, args) assert(not tolua.isnull(target), "transition.fadeIn() - target is not cc.Node") local action = cc.FadeIn:create(args.time) return transition.execute(target, action, args) end -- start -- -------------------------------- -- 淡出显示对象,并返回 Action 动作对象。 -- @function [parent=#transition] fadeOut -- @param cc.Node target 显示对象 -- @param table args 参数表格对象 -- @return mixed#mixed ret (return value: mixed) 结果 --[[-- 淡出显示对象,并返回 Action 动作对象。 fadeOut 操作会首先将对象的透明度设置为 255(100%,完全不透明),然后再逐步减少为 0(0%,完全透明)。 如果不希望改变对象当前的透明度,应该用 fadeTo()。 ~~~ lua action = transition.fadeOut(sprite, {time = 1.5}) ~~~ ]] -- end -- function transition.fadeOut(target, args) assert(not tolua.isnull(target), "transition.fadeOut() - target is not cc.Node") local action = cc.FadeOut:create(args.time) return transition.execute(target, action, args) end -- start -- -------------------------------- -- 将显示对象的透明度改变为指定值,并返回 Action 动作对象。 -- @function [parent=#transition] fadeTo -- @param cc.Node target 显示对象 -- @param table args 参数表格对象 -- @return mixed#mixed ret (return value: mixed) 结果 --[[-- 将显示对象的透明度改变为指定值,并返回 Action 动作对象。 ~~~ lua -- 不管显示对象当前的透明度是多少,最终设置为 128 transition.fadeTo(sprite, {opacity = 128, time = 1.5}) ~~~ ]] -- end -- function transition.fadeTo(target, args) assert(not tolua.isnull(target), "transition.fadeTo() - target is not cc.Node") local opacity = checkint(args.opacity) if opacity < 0 then opacity = 0 elseif opacity > 255 then opacity = 255 end local action = cc.FadeTo:create(args.time, opacity) return transition.execute(target, action, args) end -- start -- -------------------------------- -- 将显示对象缩放到指定比例,并返回 Action 动作对象。 -- @function [parent=#transition] scaleTo -- @param cc.Node target 显示对象 -- @param table args 参数表格对象 -- @return mixed#mixed ret (return value: mixed) 结果 --[[-- 将显示对象缩放到指定比例,并返回 Action 动作对象。 ~~~ lua -- 整体缩放为 50% transition.scaleTo(sprite, {scale = 0.5, time = 1.5}) -- 单独水平缩放 transition.scaleTo(sprite, {scaleX = 0.5, time = 1.5}) -- 单独垂直缩放 transition.scaleTo(sprite, {scaleY = 0.5, time = 1.5}) ~~~ ]] -- end -- function transition.scaleTo(target, args) assert(not tolua.isnull(target), "transition.scaleTo() - target is not cc.Node") local action if args.scale then action = cc.ScaleTo:create(checknumber(args.time), checknumber(args.scale)) elseif args.scaleX or args.scaleY then local scaleX, scaleY if args.scaleX then scaleX = checknumber(args.scaleX) else scaleX = target:getScaleX() end if args.scaleY then scaleY = checknumber(args.scaleY) else scaleY = target:getScaleY() end action = cc.ScaleTo:create(checknumber(args.time), scaleX, scaleY) end return transition.execute(target, action, args) end -- start -- -------------------------------- -- 创建一个动作序列对象。 -- @function [parent=#transition] sequence -- @param table args 动作的表格对象 -- @return Sequence#Sequence ret (return value: cc.Sequence) 动作序列对象 --[[-- 创建一个动作序列对象。 ~~~ lua local sequence = transition.sequence({ cc.MoveTo:create(0.5, cc.p(display.cx, display.cy)), cc.FadeOut:create(0.2), cc.DelayTime:create(0.5), cc.FadeIn:create(0.3), }) sprite:runAction(sequence) ~~~ ]] -- end -- function transition.sequence(actions) if #actions < 1 then return end if #actions < 2 then return actions[1] end local prev = actions[1] for i = 2, #actions do prev = cc.Sequence:create(prev, actions[i]) end return prev end -- start -- -------------------------------- -- 在显示对象上播放一次动画,并返回 Action 动作对象。 -- @function [parent=#transition] playAnimationOnce -- @param cc.Node target 显示对象 -- @param cc.Node animation 动作对象 -- @param boolean removeWhenFinished 播放完成后删除显示对象 -- @param function onComplete 播放完成后要执行的函数 -- @param number delay 播放前等待的时间 -- @return table#table ret (return value: table) 动作表格对象 --[[-- 在显示对象上播放一次动画,并返回 Action 动作对象。 ~~~ lua local frames = display.newFrames("Walk%04d.png", 1, 20) local animation = display.newAnimation(frames, 0.5 / 20) -- 0.5s play 20 frames transition.playAnimationOnce(sprite, animation) ~~~ 还可以用 Sprite 对象的 playAnimationOnce() 方法来直接播放动画: ~~~ lua local frames = display.newFrames("Walk%04d.png", 1, 20) local animation = display.newAnimation(frames, 0.5 / 20) -- 0.5s play 20 frames sprite:playAnimationOnce(animation) ~~~ playAnimationOnce() 提供了丰富的功能,例如在动画播放完成后就删除用于播放动画的 Sprite 对象。例如一个爆炸效果: ~~~ lua local frames = display.newFrames("Boom%04d.png", 1, 8) local boom = display.newSprite(frames[1]) -- playAnimationOnce() 第二个参数为 true 表示动画播放完后删除 boom 这个 Sprite 对象 -- 这样爆炸动画播放完毕,就自动清理了不需要的显示对象 boom:playAnimationOnce(display.newAnimation(frames, 0.3/ 8), true) ~~~ 此外,playAnimationOnce() 还允许在动画播放完成后执行一个指定的函数,以及播放动画前等待一段时间。合理运用这些功能,可以大大简化我们的游戏代码。 ]] -- end -- function transition.playAnimationOnce(target, animation, removeWhenFinished, onComplete, delay) local actions = {} if type(delay) == "number" and delay > 0 then target:setVisible(false) actions[#actions + 1] = cc.DelayTime:create(delay) actions[#actions + 1] = cc.Show:create() end actions[#actions + 1] = cc.Animate:create(animation) if removeWhenFinished then actions[#actions + 1] = cc.RemoveSelf:create() end if onComplete then actions[#actions + 1] = cc.CallFunc:create(onComplete) end local action if #actions > 1 then action = transition.sequence(actions) else action = actions[1] end target:runAction(action) return action end -- start -- -------------------------------- -- 在显示对象上循环播放动画,并返回 Action 动作对象。 -- @function [parent=#transition] playAnimationForever -- @param cc.Node target 显示对象 -- @param cc.Node animation 动作对象 -- @param number delay 播放前等待的时间 -- @return table#table ret (return value: table) 动作表格对象 --[[-- 在显示对象上循环播放动画,并返回 Action 动作对象。 ~~~ lua local frames = display.newFrames("Walk%04d.png", 1, 20) local animation = display.newAnimation(frames, 0.5 / 20) -- 0.5s play 20 frames sprite:playAnimationForever(animation) ~~~ ]] -- end -- function transition.playAnimationForever(target, animation, delay) local animate = cc.Animate:create(animation) local action if type(delay) == "number" and delay > 0 then target:setVisible(false) local sequence = transition.sequence({ cc.DelayTime:create(delay), cc.Show:create(), animate, }) action = cc.RepeatForever:create(sequence) else action = cc.RepeatForever:create(animate) end target:runAction(action) return action end -- start -- -------------------------------- -- 停止一个正在执行的动作 -- @function [parent=#transition] removeAction -- @param mixed target --[[-- 停止一个正在执行的动作 ~~~ lua -- 开始移动 local action = transition.moveTo(sprite, {time = 2.0, x = 100, y = 100}) .... transition.removeAction(action) -- 停止移动 ~~~ ]] -- end -- function transition.removeAction(action) if not tolua.isnull(action) then actionManager:removeAction(action) end end -- start -- -------------------------------- -- 停止一个显示对象上所有正在执行的动作 -- @function [parent=#transition] stopTarget -- @param mixed target --[[-- 停止一个显示对象上所有正在执行的动作 ~~~ lua -- 开始移动 transition.moveTo(sprite, {time = 2.0, x = 100, y = 100}) transition.fadeOut(sprite, {time = 2.0}) .... transition.stopTarget(sprite) ~~~ 注意:显示对象的 performWithDelay() 方法是用动作来实现延时回调操作的,所以如果停止显示对象上的所有动作,会清除该对象上的延时回调操作。 ]] -- end -- function transition.stopTarget(target) if not tolua.isnull(target) then actionManager:removeAllActionsFromTarget(target) end end -- start -- -------------------------------- -- 暂停显示对象上所有正在执行的动作 -- @function [parent=#transition] pauseTarget -- @param mixed target -- end -- function transition.pauseTarget(target) if not tolua.isnull(target) then actionManager:pauseTarget(target) end end -- start -- -------------------------------- -- 恢复显示对象上所有暂停的动作 -- @function [parent=#transition] resumeTarget -- @param mixed target -- end -- function transition.resumeTarget(target) if not tolua.isnull(target) then actionManager:resumeTarget(target) end end return transition
gpl-3.0
MonokuroInzanaito/ygopro-777DIY
expansions/script/c37564811.lua
1
2406
--Three Magic -3L Remix- local m=37564811 local cm=_G["c"..m] xpcall(function() require("expansions/script/c37564765") end,function() require("script/c37564765") end) cm.Senya_name_with_remix=true function cm.initial_effect(c) --Senya.CommonEffect_3L(c,m) local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(m,0)) e1:SetCategory(CATEGORY_TOHAND) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_SUMMON_SUCCESS) e1:SetProperty(EFFECT_FLAG_CARD_TARGET+0x14000) e1:SetCountLimit(1,m) e1:SetTarget(cm.target) e1:SetOperation(cm.operation) c:RegisterEffect(e1) local e3=e1:Clone() e3:SetCode(EVENT_SPSUMMON_SUCCESS) c:RegisterEffect(e3) end function cm.effect_operation_3L(c,ctlm) local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(m,1)) e3:SetCategory(CATEGORY_DISABLE_SUMMON+CATEGORY_TOHAND) e3:SetType(EFFECT_TYPE_QUICK_O) e3:SetRange(LOCATION_MZONE) e3:SetCode(EVENT_SPSUMMON) e3:SetCountLimit(ctlm) e3:SetCost(Senya.DescriptionCost()) e3:SetCondition(cm.discon) e3:SetTarget(cm.distg) e3:SetOperation(cm.disop) e3:SetReset(RESET_EVENT+0x1fe0000) c:RegisterEffect(e3,true) return e3 end function cm.filter(c) return Senya.check_set_3L(c) and c:IsAbleToHand() end function cm.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and cm.filter(chkc) end if chk==0 then return Duel.IsExistingTarget(cm.filter,tp,LOCATION_GRAVE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectTarget(tp,cm.filter,tp,LOCATION_GRAVE,0,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0) end function cm.operation(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.SendtoHand(tc,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,tc) end end function cm.dfilter(c,tp) return c:GetSummonPlayer()==tp end function cm.discon(e,tp,eg,ep,ev,re,r,rp) return Duel.GetCurrentChain()==0 and eg:IsExists(cm.dfilter,1,nil,1-tp) end function cm.distg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end local g=eg:Filter(cm.dfilter,nil,1-tp) Duel.SetOperationInfo(0,CATEGORY_DISABLE_SUMMON,g,g:GetCount(),0,0) Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,g:GetCount(),0,0) end function cm.disop(e,tp,eg,ep,ev,re,r,rp) local g=eg:Filter(cm.dfilter,nil,1-tp) Duel.NegateSummon(g) Duel.SendtoHand(g,nil,REASON_EFFECT) end
gpl-3.0
drupalhunter-team/TrackMonitor
Bin/Scripts AM335x/resetPump.lua
1
2328
require "Scripts Common/tables" require "Scripts AM335x/functions" require "Scripts AM335x/commands" ScenarioBegin("Reset") TestCaseBegin("cmdResetPumpReq invalid mode") -- Need board answer sendResetPump(Address["PC"], 8) emulateRemoteRep(Address["RM48"], Cmd["reset"], Code["CODE_NONE"], false) emulateRemoteRep(Address["STM32"], Cmd["reset"], Code["CODE_NONE"], false) VerifyThat(CheckFrameValid(2000) == true, "Frame valid") VerifyThat(checkFrameNumber(0) == true, "Frame number valid") VerifyThat(checkCodeId(Cmd["resetPump"]) == true, "Frame command valid") VerifyThat(checkSize(1) == true, "Frame size valid") VerifyThat(checkCode(13, Code["CODE_INVALID_MODE"]) == true, "Frame size valid") ValidateRequirement("CC8050_SRS_Pump_Boot_Com0016 (1)") ValidateRequirement("CC8050_SRS_Pump_Boot_Com0018 (1)") TestCaseEnd() TestCaseBegin("cmdResetPumpReq failure board connected") sendResetPump(Address["PC"], 2) VerifyThat(CheckFrameValid(13000) == true, "Frame valid") VerifyThat(checkFrameNumber(0) == true, "Frame number valid") VerifyThat(checkCodeId(Cmd["resetPump"]) == true, "Frame command valid") VerifyThat(checkSize(1) == true, "Frame size valid") VerifyThat(checkCode(13, Code["CODE_FAILURE_CONNECTED_BOARD_COM"]) == true, "Frame size valid") ValidateRequirement("CC8050_SRS_Pump_Boot_Com0017 (1)") TestCaseEnd() TestCaseBegin("cmdResetPumpReq valid") -- Need board answer sendResetPump(Address["PC"], 2) emulateRemoteRep(Address["RM48"], Cmd["reset"], Code["CODE_NONE"], false) emulateRemoteRep(Address["STM32"], Cmd["reset"], Code["CODE_NONE"], false) VerifyThat(CheckFrameValid(2000) == true, "Frame valid") VerifyThat(checkFrameNumber(0) == true, "Frame number valid") VerifyThat(checkCodeId(Cmd["resetPump"]) == true, "Frame command valid") VerifyThat(checkSize(1) == true, "Frame size valid") VerifyThat(checkCode(13, Code["CODE_NONE"]) == true, "Frame size valid") ValidateRequirement("CC8050_SRS_Pump_Boot_Com0015 (1)") ValidateRequirement("CC8050_SRS_Pump_Boot_Com0019 (1)") WaitMs(8000) TestCaseEnd() ScenarioEnd()
mit
mammadfucklif/mammadassassin
plugins/id.lua
50
4275
local function user_print_name(user) if user.print_name then return user.print_name end local text = '' if user.first_name then text = user.last_name..' ' end if user.lastname then text = text..user.last_name end return text end local function returnids(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name local text = 'IDs for chat '..chatname ..' ('..chat_id..')\n' ..'There are '..result.members_num..' members' ..'\n---------\n' for k,v in pairs(result.members) do text = text .. v.print_name .. " (user#id" .. v.id .. ")\n" end send_large_msg(receiver, text) end local function run(msg, matches) local receiver = get_receiver(msg) if matches[1] == "ایدی" then local text = user_print_name(msg.from) .. ' (user#id' .. msg.from.id .. ')' if is_chat_msg(msg) then text = text .. "\nYou are in group " .. user_print_name(msg.to) .. " (chat#id" .. msg.to.id .. ")" end return text elseif matches[1] == "chat" then -- !ids? (chat) (%d+) if matches[2] and is_sudo(msg) then local chat = 'chat#id'..matches[2] chat_info(chat, returnids, {receiver=receiver}) else if not is_chat_msg(msg) then return "You are not in a group." end local chat = get_receiver(msg) chat_info(chat, returnids, {receiver=receiver}) end elseif matches[1] == "member" and matches[2] == "@" then local nick = matches[3] local chat = get_receiver(msg) if not is_chat_msg(msg) then return "You are not in a group." end chat_info(chat, function (extra, success, result) local receiver = extra.receiver local nick = extra.nick local found for k,user in pairs(result.members) do if user.username == nick then found = user end end if not found then send_msg(receiver, "User not found on this chat.", ok_cb, false) else local text = "ID: "..found.id send_msg(receiver, text, ok_cb, false) end end, {receiver=chat, nick=nick}) elseif matches[1] == "members" and matches[2] == "name" then local text = matches[3] local chat = get_receiver(msg) if not is_chat_msg(msg) then return "You are not in a group." end chat_info(chat, function (extra, success, result) local members = result.members local receiver = extra.receiver local text = extra.text local founds = {} for k,member in pairs(members) do local fields = {'first_name', 'print_name', 'username'} for k,field in pairs(fields) do if member[field] and type(member[field]) == "string" then if member[field]:match(text) then local id = tostring(member.id) founds[id] = member end end end end if next(founds) == nil then -- Empty table send_msg(receiver, "User not found on this chat.", ok_cb, false) else local text = "" for k,user in pairs(founds) do local first_name = user.first_name or "" local print_name = user.print_name or "" local user_name = user.user_name or "" local id = user.id or "" -- This would be funny text = text.."First name: "..first_name.."\n" .."Print name: "..print_name.."\n" .."User name: "..user_name.."\n" .."ID: "..id end send_msg(receiver, text, ok_cb, false) end end, {receiver=chat, text=text}) end end return { description = "Know your id or the id of a chat members.", usage = { "ایدی: Return your ID and the chat id if you are in one.", "!ids chat: Return the IDs of the current chat members.", "!ids chat <chat_id>: Return the IDs of the <chat_id> members.", "!id member @<user_name>: Return the member @<user_name> ID from the current chat", "!id members name <text>: Search for users with <text> on first_name, print_name or username on current chat" }, patterns = { "^ایدی$", "^!ids? (chat) (%d+)$", "^!ids? (chat)$", "^!id (member) (@)(.+)", "^!id (members) (name) (.+)" }, run = run }
gpl-2.0
will4wachter/Project1
scripts/zones/Labyrinth_of_Onzozo/npcs/Treasure_Chest.lua
1
3515
----------------------------------- -- Area: Labyrinth of Onzozo -- NPC: Treasure Chest -- @zone 213 ----------------------------------- package.loaded["scripts/zones/Labyrinth_of_Onzozo/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/treasure"); require("scripts/globals/quests"); require("scripts/zones/Labyrinth_of_Onzozo/TextIDs"); local TreasureType = "Chest"; local TreasureLvL = 43; local TreasureMinLvL = 33; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- trade:hasItemQty(1056,1); -- Treasure Key -- trade:hasItemQty(1115,1); -- Skeleton Key -- trade:hasItemQty(1023,1); -- Living Key -- trade:hasItemQty(1022,1); -- Thief's Tools local questItemNeeded = 0; -- Player traded a key. if((trade:hasItemQty(1056,1) or trade:hasItemQty(1115,1) or trade:hasItemQty(1023,1) or trade:hasItemQty(1022,1)) and trade:getItemCount() == 1) then local zone = player:getZone(); -- IMPORTANT ITEM: L'Ancienne & Map ----------- if(player:hasKeyItem(MAP_OF_THE_LABYRINTH_OF_ONZOZO) == false) then questItemNeeded = 1; elseif(player:getQuestStatus(BASTOK,A_TEST_OF_TRUE_LOVE) == QUEST_ACCEPTED and player:hasKeyItem(LANCIENNE) == false) then questItemNeeded = 2; end -------------------------------------- local pack = openChance(player,npc,trade,TreasureType,TreasureLvL,TreasureMinLvL,questItemNeeded); local success = 0; if(pack[2] ~= nil) then player:messageSpecial(pack[2]); success = pack[1]; else success = pack[1]; end if(success ~= -2) then player:tradeComplete(); if(math.random() <= success) then -- Succeded to open the coffer player:messageSpecial(CHEST_UNLOCKED); if(questItemNeeded == 1) then player:addKeyItem(MAP_OF_THE_LABYRINTH_OF_ONZOZO); player:messageSpecial(KEYITEM_OBTAINED,MAP_OF_THE_LABYRINTH_OF_ONZOZO); -- Map of the Labyrinth of Onzozo elseif(questItemNeeded == 2) then player:setVar("ATestOfTrueLoveProgress",player:getVar("ATestOfTrueLoveProgress")+1); player:addKeyItem(LANCIENNE); player:messageSpecial(KEYITEM_OBTAINED,LANCIENNE); -- L'Ancienne for A Test Of True Love quest else player:setVar("["..zone.."]".."Treasure_"..TreasureType,os.time() + math.random(CHEST_MIN_ILLUSION_TIME,CHEST_MAX_ILLUSION_TIME)); local loot = chestLoot(zone,npc); -- print("loot array: "); -- debug -- print("[1]", loot[1]); -- debug -- print("[2]", loot[2]); -- debug if(loot[1]=="gil") then player:addGil(math.random(100000,500000)); player:messageSpecial(GIL_OBTAINED,math.random(100000,500000)); else -- Item player:addItem(loot[2]); player:messageSpecial(ITEM_OBTAINED,loot[2]); end end UpdateTreasureSpawnPoint(npc:getID()); end end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:messageSpecial(CHEST_LOCKED,1056); 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
waterlgndx/darkstar
scripts/zones/The_Boyahda_Tree/TextIDs.lua
2
1511
-- Variable TextID Description text -- General Texts ITEM_CANNOT_BE_OBTAINED = 6381; -- You cannot obtain the item <item>. Come back after sorting your inventory. ITEM_OBTAINED = 6387; -- Obtained: <item> GIL_OBTAINED = 6388; -- Obtained <number> gil KEYITEM_OBTAINED = 6390; -- Obtained key item: <keyitem> FISHING_MESSAGE_OFFSET = 7048; -- You can't fish here. HOMEPOINT_SET = 11432; -- Home point set! -- Treasure Coffer/Chest Dialog CHEST_UNLOCKED = 7155; -- You unlock the chest! CHEST_FAIL = 7156; -- Fails to open the chest. CHEST_TRAP = 7157; -- The chest was trapped! CHEST_WEAK = 7158; -- You cannot open the chest when you are in a weakened state. CHEST_MIMIC = 7159; -- The chest was a mimic! CHEST_MOOGLE = 7160; -- You cannot open the chest while participating in the moogle event. CHEST_ILLUSION = 7161; -- The chest was but an illusion... CHEST_LOCKED = 7162; -- The chest appears to be locked. -- WS Quest NOTHING_OUT_OF_ORDINARY = 7392; -- There is nothing out of the ordinary here. SENSE_OMINOUS_PRESENCE = 7391; -- You sense an ominous presence... -- Quests CAN_SEE_SKY = 7168; -- You can see the sky from here. SOMETHING_NOT_RIGHT = 7169; -- Something is not right! CANNOT_SEE_MOON = 7170; -- You cannot see the moon right now. -- conquest Base CONQUEST_BASE = 7171; -- Tallying conquest results...
gpl-3.0
MonokuroInzanaito/ygopro-777DIY
expansions/script/c80060040.lua
1
6330
--终结的炽天使 吸血鬼女王·克鲁鲁 function c80060040.initial_effect(c) --xyz summon aux.AddXyzProcedure(c,aux.FilterBoolFunction(Card.IsSetCard,0x92d7),8,2,c80060040.ovfilter,aux.Stringid(80060040,0),5) c:EnableReviveLimit() --pendulum summon aux.EnablePendulumAttribute(c,false) --indes local e0=Effect.CreateEffect(c) e0:SetType(EFFECT_TYPE_SINGLE) e0:SetCode(EFFECT_INDESTRUCTABLE_BATTLE) e0:SetValue(1) c:RegisterEffect(e0) --cannot set local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CANNOT_SSET) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetRange(LOCATION_MZONE) e1:SetTargetRange(0,1) c:RegisterEffect(e1) --splimit local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_CANNOT_DISABLE) e2:SetRange(LOCATION_PZONE) e2:SetTargetRange(1,0) e2:SetCondition(c80060040.splimcon) e2:SetTarget(c80060040.splimit) c:RegisterEffect(e2) --cannot trigger local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD) e3:SetCode(EFFECT_CANNOT_TRIGGER) e3:SetProperty(EFFECT_FLAG_SET_AVAILABLE) e3:SetRange(LOCATION_MZONE) e3:SetTargetRange(0,LOCATION_SZONE) e3:SetTarget(c80060040.distg) c:RegisterEffect(e3) --spsummon local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(80060040,1)) e4:SetCategory(CATEGORY_SPECIAL_SUMMON) e4:SetType(EFFECT_TYPE_IGNITION) e4:SetRange(LOCATION_PZONE) e4:SetCost(c80060040.spcost) e4:SetTarget(c80060040.sptg) e4:SetOperation(c80060040.spop) c:RegisterEffect(e4) --pendulum local e5=Effect.CreateEffect(c) e5:SetDescription(aux.Stringid(80060040,2)) e5:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e5:SetCode(EVENT_DESTROYED) e5:SetProperty(EFFECT_FLAG_DELAY) e5:SetTarget(c80060040.pentg) e5:SetOperation(c80060040.penop) c:RegisterEffect(e5) --Untargetable local e6=Effect.CreateEffect(c) e6:SetType(EFFECT_TYPE_FIELD) e6:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET) e6:SetRange(LOCATION_PZONE) e6:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE) e6:SetTargetRange(LOCATION_MZONE,0) e6:SetTarget(c80060040.immtg) e6:SetValue(aux.tgoval) c:RegisterEffect(e6) --Indes local e7=e6:Clone() e7:SetCode(EFFECT_INDESTRUCTABLE_EFFECT) e7:SetValue(c80060040.tgvalue) c:RegisterEffect(e7) --damage local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(80060040,4)) e1:SetCategory(CATEGORY_DAMAGE) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetCountLimit(1,80060040) e1:SetRange(LOCATION_MZONE) e1:SetCost(c80060040.cost) e1:SetTarget(c80060040.target) e1:SetOperation(c80060040.operation) c:RegisterEffect(e1) end c80060040.pendulum_level=8 function c80060040.immtg(e,c) return c:IsFaceup() and c:IsSetCard(0x92d7) end function c80060040.tgvalue(e,re,rp) return rp~=e:GetHandlerPlayer() end function c80060040.ovfilter(c) return c:IsFaceup() and c:IsCode(80060012) and c:GetOverlayCount()==0 end function c80060040.splimcon(e) return not e:GetHandler():IsForbidden() end function c80060040.splimit(e,c) return not c:IsSetCard(0x92d7) end function c80060040.cfilter(c) return c:IsSetCard(0x92d7) and c:IsAbleToRemoveAsCost() end function c80060040.spcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c80060040.cfilter,tp,LOCATION_GRAVE,0,2,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,c80060040.cfilter,tp,LOCATION_GRAVE,0,2,2,nil) Duel.Remove(g,POS_FACEUP,REASON_COST) end function c80060040.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 c80060040.spop(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 local dg=Duel.GetMatchingGroup(Card.IsAbleToDeck,tp,0,LOCATION_HAND,nil) if Duel.SelectYesNo(tp,aux.Stringid(80060040,3)) then Duel.BreakEffect() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) local sg=dg:Select(tp,1,1,nil) Duel.HintSelection(sg) Duel.SendtoDeck(sg,nil,2,REASON_EFFECT) end end function c80060040.distg(e,c) return c:IsFacedown() end function c80060040.cost(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 c80060040.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c80060040.thfilter2,tp,LOCATION_GRAVE+LOCATION_EXTRA,0,1,nil) end Duel.SetTargetPlayer(1-tp) Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,0) end function c80060040.operation(e,tp,eg,ep,ev,re,r,rp) local p=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER) local d=Duel.GetMatchingGroupCount(c80060040.thfilter2,tp,LOCATION_GRAVE+LOCATION_EXTRA,0,nil,0x92d7)*400 if Duel.Damage(p,d,REASON_EFFECT) then if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end local g=Duel.GetMatchingGroup(c80060040.spfilter,tp,LOCATION_DECK+LOCATION_GRAVE,0,nil,e,tp) if g:GetCount()>0 and Duel.SelectYesNo(tp,aux.Stringid(80060040,5)) then Duel.BreakEffect() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local sg=g:Select(tp,1,1,nil) Duel.SpecialSummon(sg,0,tp,tp,false,false,POS_FACEUP) end end end function c80060040.spfilter(c,e,tp) return c:IsCode(80060010) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c80060040.thfilter2(c) return c:IsSetCard(0x92d7) and ((c:IsFaceup() and c:IsLocation(LOCATION_EXTRA) and c:IsType(TYPE_PENDULUM)) or c:IsLocation(LOCATION_GRAVE)) end function c80060040.pentg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.CheckLocation(tp,LOCATION_SZONE,6) or Duel.CheckLocation(tp,LOCATION_SZONE,7) end end function c80060040.penop(e,tp,eg,ep,ev,re,r,rp) if not Duel.CheckLocation(tp,LOCATION_SZONE,6) and not Duel.CheckLocation(tp,LOCATION_SZONE,7) then return false end local c=e:GetHandler() if c:IsRelateToEffect(e) then Duel.MoveToField(c,tp,tp,LOCATION_SZONE,POS_FACEUP,true) end end
gpl-3.0
waterlgndx/darkstar
scripts/globals/conquest.lua
2
51473
----------------------------------- -- -- Functions for Conquest system -- ----------------------------------- require("scripts/globals/keyitems"); require("scripts/globals/missions"); require("scripts/globals/common"); require("scripts/globals/zone"); ----------------------------------- ----------------------------------- -- convenience constants ----------------------------------- CONQUEST_TALLY_START = 0; CONQUEST_TALLY_END = 1; CONQUEST_UPDATE = 2; nationAlly = 3; ----------------------------------- -- San d'Oria inventory -- {Option,CP,Item} ----------------------------------- SandInv = {0x80A1,0x000A,0x1055,0x80A0,0x0007,0x1056,0x80A3,0x2328,0x3CB5, 0x80A2,0x09C4,0x3CB6,0x80A5,0x01F4,0x3D91,0x80A6,0x03E8,0x3D92, 0x80A7,0x07D0,0x3D93,0x8002,0x03E8,0x30DE,0x8003,0x03E8,0x31D1, 0x8004,0x03E8,0x32CC,0x8006,0x03E8,0x3596,0x8001,0x03E8,0x40A0, 0x8005,0x03E8,0x4133,0x8000,0x03E8,0x430F,0x8011,0x07D0,0x3156, 0x8012,0x07D0,0x3252,0x8014,0x07D0,0x32F5,0x8010,0x07D0,0x41D4, 0x8013,0x07D0,0x43D7,0x8022,0x0FA0,0x308F,0x8023,0x0FA0,0x318F, 0x8024,0x0FA0,0x328F,0x8021,0x0FA0,0x3330,0x8027,0x0FA0,0x34B7, 0x8025,0x0FA0,0x4168,0x8020,0x0FA0,0x41CC,0x8026,0x0FA0,0x42FE, 0x8034,0x1F40,0x3030,0x8031,0x1F40,0x310F,0x8032,0x1F40,0x320F, 0x8033,0x1F40,0x3597,0x8030,0x1F40,0x40D9,0x8042,0x3E80,0x3018, 0x8043,0x3E80,0x3019,0x8046,0x3E80,0x318E,0x8047,0x3E80,0x328E, 0x8045,0x3E80,0x3331,0x8044,0x3E80,0x3333,0x8048,0x3E80,0x33A4, 0x8049,0x3E80,0x3598,0x8041,0x3E80,0x40BB,0x8040,0x3E80,0x41D3, 0x8056,0x5DC0,0x3021,0x8052,0x5DC0,0x308E,0x8054,0x5DC0,0x310E, 0x8055,0x5DC0,0x320E,0x8051,0x5DC0,0x3332,0x8050,0x5DC0,0x350C, 0x8053,0x5DC0,0x359A,0x8058,0x5DC0,0x40D7,0x8059,0x5DC0,0x41A5, 0x8057,0x5DC0,0x42AB,0x8062,0x7D00,0x34F5,0x8061,0x7D00,0x41F6, 0x8060,0x7D00,0x4932,0x8072,0x9C40,0x3354,0x8070,0x9C40,0x36BD, 0x8071,0x9C40,0x36BE,0x8083,0xBB80,0x41FD,0x8080,0xBB80,0x4239, 0x8082,0xBB80,0x4432,0x8081,0xBB80,0x460E,0x8090,0xDAC0,0x385C, 0x80A4,0x1388,0x44AF,0x80A8,0x1388,0x6F7C}; ----------------------------------- -- Bastok inventory -- {Option,CP,Item} ----------------------------------- BastInv = {0x80A1,0x000A,0x1055,0x80A0,0x0007,0x1056,0x80A3,0x2328,0x3CB5, 0x80A2,0x09C4,0x3CB6,0x80A5,0x01F4,0x3D91,0x80A6,0x03E8,0x3D92, 0x80A7,0x07D0,0x3D93,0x8003,0x03E8,0x30DD,0x8004,0x03E8,0x31D0, 0x8005,0x03E8,0x32CB,0x8000,0x03E8,0x4031,0x8002,0x03E8,0x4108, 0x8007,0x03E8,0x418C,0x8006,0x03E8,0x42E8,0x8001,0x03E8,0x4347, 0x8014,0x07D0,0x3031,0x8011,0x07D0,0x3155,0x8012,0x07D0,0x3251, 0x8013,0x07D0,0x4169,0x8010,0x07D0,0x4298,0x8022,0x0FA0,0x3096, 0x8023,0x0FA0,0x3116,0x8024,0x0FA0,0x3196,0x8025,0x0FA0,0x3216, 0x8026,0x0FA0,0x3296,0x8021,0x0FA0,0x332A,0x8029,0x0FA0,0x34B9, 0x8028,0x0FA0,0x3606,0x8020,0x0FA0,0x4148,0x8027,0x0FA0,0x41A6, 0x8031,0x1F40,0x3086,0x8032,0x1F40,0x3186,0x8033,0x1F40,0x3286, 0x8034,0x1F40,0x3599,0x8030,0x1F40,0x4084,0x8035,0x1F40,0x4383, 0x8042,0x3E80,0x3106,0x8043,0x3E80,0x3206,0x8041,0x3E80,0x332B, 0x8040,0x3E80,0x4091,0x8044,0x3E80,0x42E9,0x8045,0x3E80,0x4365, 0x8053,0x5DC0,0x3010,0x8055,0x5DC0,0x3308,0x8050,0x5DC0,0x332C, 0x8051,0x5DC0,0x350E,0x8052,0x5DC0,0x40AD,0x8054,0x5DC0,0x42FF, 0x8062,0x7D00,0x34F6,0x8060,0x7D00,0x3E55,0x8061,0x7D00,0x458F, 0x8072,0x9C40,0x3355,0x8071,0x9C40,0x3638,0x8070,0x9C40,0x36BF, 0x8080,0xBB80,0x419F,0x8081,0xBB80,0x4431,0x8083,0xBB80,0x44F7, 0x8082,0xBB80,0x4714,0x8090,0xDAC0,0x385D,0x80A4,0x1388,0x44B0, 0x80A8,0x1388,0x6F7C}; ----------------------------------- -- Windurst inventory -- {Option,CP,Item} ----------------------------------- WindInv = {0x80A1,0x000A,0x1055,0x8044,0x3E80,0x31BE,0x8025,0x0FA0,0x32B6, 0x80A0,0x0007,0x1056,0x8045,0x3E80,0x323E,0x8027,0x0FA0,0x33A5, 0x80A3,0x2328,0x3CB5,0x8046,0x3E80,0x32BE,0x8028,0x0FA0,0x34B8, 0x80A2,0x09C4,0x3CB6,0x8041,0x3E80,0x332E,0x8026,0x0FA0,0x416B, 0x80A5,0x01F4,0x3D91,0x8047,0x3E80,0x41AA,0x8020,0x0FA0,0x4188, 0x80A6,0x03E8,0x3D92,0x8048,0x3E80,0x4136,0x8033,0x1F40,0x3146, 0x80A7,0x07D0,0x3D93,0x8040,0x3E80,0x42BA,0x8034,0x1F40,0x31C7, 0x8003,0x03E8,0x3273,0x8050,0x5DC0,0x332F,0x8035,0x1F40,0x3246, 0x8002,0x03E8,0x403A,0x8051,0x5DC0,0x350D,0x8036,0x1F40,0x32C6, 0x8001,0x03E8,0x4284,0x8053,0x5DC0,0x41A8,0x8032,0x1F40,0x332D, 0x8004,0x03E8,0x42EA,0x8054,0x5DC0,0x41A9,0x8030,0x1F40,0x404F, 0x8000,0x03E8,0x4307,0x8052,0x5DC0,0x42C6,0x8038,0x1F40,0x411D, 0x8011,0x07D0,0x30C4,0x8061,0x7D00,0x304B,0x8037,0x1F40,0x41A7, 0x8012,0x07D0,0x316D,0x8062,0x7D00,0x34F7,0x8031,0x1F40,0x4382, 0x8013,0x07D0,0x31AF,0x8060,0x7D00,0x3E56,0x8042,0x3E80,0x30BE, 0x8014,0x07D0,0x3237,0x8072,0x9C40,0x3356,0x8043,0x3E80,0x313E, 0x8015,0x07D0,0x32AF,0x8070,0x9C40,0x36C0,0x80A4,0x1388,0x44B1, 0x8016,0x07D0,0x416A,0x8071,0x9C40,0x36C1,0x8024,0x0FA0,0x3236, 0x8017,0x07D0,0x4222,0x8082,0xBB80,0x4464,0x8090,0xDAC0,0x385E, 0x8010,0x07D0,0x42CF,0x8081,0xBB80,0x447A,0x8023,0x0FA0,0x31B6, 0x8021,0x0FA0,0x30B6,0x8083,0xBB80,0x44D1,0x8080,0xBB80,0x46E1, 0x8022,0x0FA0,0x3136,0x80A8,0x1388,0x6F7C}; ----------------------------------- -- Crystal Donate Array -- Conquest Point Required for recharged the ring + charge -- CP Reward for Supply Quest -- TP Fees ----------------------------------- DonateCrys = {4096,4097,4098,4099,4100,4101,4102,4103,4238,4239,4240,4241,4242,4243,4244,4245}; XpRing = {350,700,600}; RingCharg = {7,7,3}; supplyReward = {10,30,40,10,40,10,40,40,70,50,60,40,70,70,70,70,70,70,70}; tpFees = { 100, 100, 150, 100, 150, 100, 100, 150, 350, 400, 150, 250, 300, 500, 250, 350, 500, 0, 300 } ---------------------------------------------------------------- -- function tradeConquestGuard() ----------------------------------------------------------------- function tradeConquestGuard(player,npc,trade,guardnation,guardtype) -- Nation: -- dsp.nation.SANDORIA, dsp.nation.BASTOK, dsp.nation.WINDURST, dsp.nation.OTHER(Jeuno) -- Type: 1: city, 2: foreign, 3: outpost, 4: border local myCP = player:getCP(); local item = trade:getItemId(); local AddPoints = 0; if (player:getNation() == guardnation or guardnation == dsp.nation.OTHER) then if (guardtype ~= 3 and guardtype ~= 4) then -- all guard can trade crystal except outpost and border. if (item >= 4096 and item <= 4103 or item >= 4238 and item <= 4245) then for Crystal = 1,#DonateCrys,1 do local tcount = trade:getItemQty(DonateCrys[Crystal]) if (tcount > 0 and trade:hasItemQty(DonateCrys[Crystal],tcount)) then if (player:getRank() == 1) then player:showText(npc,CONQUEST - 7); break; elseif (player:getRankPoints() == 4000) then player:showText(npc,CONQUEST + 43); break; elseif (DonateCrys[Crystal] == 4102 or DonateCrys[Crystal] == 4103 or DonateCrys[Crystal] == 4244 or DonateCrys[Crystal] == 4245) then AddPoints = AddPoints + tcount * math.floor(4000 / (player:getRank() * 12 - 16)); else AddPoints = AddPoints + tcount * math.floor(4000 / (player:getRank() * 12 - 12)); end end end if (player:getRank() ~= 1 and player:getRankPoints() < 4000) then if (AddPoints + player:getRankPoints() >= 4000) then newpoint = (AddPoints + player:getRankPoints()) - 4000; player:addCP(newpoint); player:setRankPoints(4000); player:showText(npc,CONQUEST + 44); else --printf("point: %u",AddPoints); player:addRankPoints(AddPoints); player:showText(npc,CONQUEST + 45); end player:tradeComplete(); end end end if (item >= 15761 and item <= 15763) then -- All guard can recharge ring - I can't read number of charge atm if (trade:hasItemQty(item,1) and trade:getItemCount() == 1 and player:getVar("CONQUEST_RING_RECHARGE") < os.time() and (ALLOW_MULTIPLE_EXP_RINGS == 1 or checkConquestRing(player) < 2)) then if (myCP >= XpRing[item - 15760]) then player:delCP(XpRing[item - 15760]); player:tradeComplete(); player:addItem(item); player:setVar("CONQUEST_RING_RECHARGE",getConquestTally()); player:showText(npc,CONQUEST + 58,item,XpRing[item - 15760],RingCharg[(item - 15760)]); else player:showText(npc,CONQUEST + 55,item,XpRing[item - 15760]); end else -- TODO: Verify that message is retail correct. -- This gives feedback on a failure at least, and is grouped with the recharge messages. Confident enough for a commit. player:showText(npc,CONQUEST+56,item); -- "Please be aware that you can only purchase or recharge <item> once during the period between each conquest results tally. end end end end; function updateConquestGuard(player,csid,option,size,inventory) if (option >= 32768 and option <= 32944) then for Item = 1,size,3 do if (option == inventory[Item]) then local CPVerify = 1; if (player:getCP() >= inventory[Item + 1]) then CPVerify = 0; end; player:updateEvent(2,CPVerify,inventory[Item + 2]); break; end end end end; function finishConquestGuard(player,csid,option,size,inventory,guardnation) if (option == 1) then local duration = (player:getRank() + getNationRank(player:getNation()) + 3) * 3600; player:delStatusEffectSilent(dsp.effect.SIGIL); player:delStatusEffectSilent(dsp.effect.SANCTION); player:delStatusEffectSilent(dsp.effect.SIGNET); player:addStatusEffect(dsp.effect.SIGNET,0,0,duration); -- Grant Signet elseif (option >= 32768 and option <= 32944) then for Item = 1,size,3 do if (option == inventory[Item]) then if (player:getFreeSlotsCount() >= 1) then -- Logic to impose limits on exp bands if (option >= 32933 and option <= 32935) then if (checkConquestRing(player) > 0) then player:messageSpecial(CONQUEST+60,0,0,inventory[Item+2]); break; else player:setVar("CONQUEST_RING_TIMER",getConquestTally()); end end local itemCP; if (player:getNation() == guardnation or guardnation == dsp.nation.OTHER) then itemCP = inventory[Item + 1]; else if (inventory[Item + 1] <= 8000) then itemCP = inventory[Item + 1] * 2; else itemCP = inventory[Item + 1] + 8000; end; end; if (player:hasItem(inventory[Item + 2]) == false and player:getCP() >= itemCP) then player:delCP(itemCP); player:addItem(inventory[Item + 2],1); player:messageSpecial(ITEM_OBTAINED,inventory[Item + 2]); else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,inventory[Item + 2]); end; else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,inventory[Item + 2]); end; break; end; end; elseif (option >= 65541 and option <= 65565) then -- player chose supply quest. local region = option - 65541; player:addKeyItem(getSupplyKey(region)); player:messageSpecial(KEYITEM_OBTAINED,getSupplyKey(region)); player:setVar("supplyQuest_started",vanaDay()); player:setVar("supplyQuest_region",region); player:setVar("supplyQuest_fresh",getConquestTally()); end; end; ------------------------------------------------------------------------- -- function suppliesFresh(player) [NEED COMMAND] 0: delete old supply after weekly conquest tally ------------------------------------------------------------------------- function supplyRunFresh(player) local fresh = player:getVar("supplyQuest_fresh"); local started = player:getVar("supplyQuest_started"); local region = player:getVar("supplyQuest_region"); if ((fresh <= os.time() and (region > 0 or player:hasKeyItem(75))) or started <= 400) then -- Legacy support to remove supplies from the old system, otherwise they'd never go away. return 0; else return 1; end; end; ---------------------------------------------------------------- -- function getArg1(player) ----------------------------------------------------------------- windurst_bastok_ally = 0; sandy_windurst_ally = 0; sandy_bastok_ally = 0; function getArg1(guardnation,player) local pNation = player:getNation(); local output = 0; local signet = 0; if (guardnation == dsp.nation.WINDURST) then output = 33; elseif (guardnation == dsp.nation.SANDORIA) then output = 1; elseif (guardnation == dsp.nation.BASTOK) then output = 17; end if (guardnation == pNation) then signet = 0; elseif (pNation == dsp.nation.WINDURST) then if (guardnation == dsp.nation.BASTOK and windurst_bastok_ally == 1) or (guardnation == dsp.nation.SANDORIA and sandy_windurst_ally == 1) then signet = 1; else signet = 7; end elseif (pNation == dsp.nation.BASTOK) then if (guardnation == dsp.nation.WINDURST and windurst_bastok_ally == 1) or (guardnation == dsp.nation.SANDORIA and sandy_bastok_ally == 1) then signet = 2; else signet = 7; end elseif (pNation == dsp.nation.SANDORIA) then if (guardnation == dsp.nation.WINDURST and sandy_windurst_ally == 1) or (guardnation == dsp.nation.BASTOK and sandy_bastok_ally == 1) then signet = 4; else signet = 7; end end if (guardnation == dsp.nation.OTHER) then output = (pNation * 16) + (3 * 256) + 65537; else output = output + 256 * signet; end return output; end; ------------------------------------------------ -- function getExForceAvailable(guardnation,player) Expeditionary Force Menu [NOT IMPLEMENTED] ------------------------------------------------ function getExForceAvailable(guardnation,player) return 0; end; ------------------------------------------------ -- function conquest_ranking() computes part of argument 3 for gate guard events. -- it represents the conquest standing of the 3 nations. Verified. ------------------------------------------------ function conquestRanking() return getNationRank(dsp.nation.SANDORIA) + 4 * getNationRank(dsp.nation.BASTOK) + 16 * getNationRank(dsp.nation.WINDURST); end; ---------------------------------------------------------------- -- function getSupplyAvailable(nation,player) produces the supply quest mask for the nation based on the current conquest standings. ---------------------------------------------------------------- function getSupplyAvailable(nation,player) local mask = 2130706463; if (player:getVar("supplyQuest_started") == vanaDay()) then mask = 4294967295; -- Need to wait 1 vanadiel day end for nb = 0,15 do if (player:hasKeyItem(getSupplyKey(nb))) then mask = -1; -- if you have supply run already activated end end if (player:hasKeyItem(getSupplyKey(18))) then -- we need to skip 16 and 17 for now mask = -1; end if (mask ~= -1 and mask ~= 4294967295) then for i = 0,18 do if (GetRegionOwner(i) ~= nation or i == 16 or (i == 18 and player:hasCompletedMission(COP,DARKNESS_NAMED) == false)) then mask = mask + 2^(i + 5); end end end return mask; end; ---------------------------------------------------------------- -- function getArg6(player) computes argument 6 for gate guard events. This number encodes a player's rank and nationality: -- bits 1-4 encode the rank of the player (verified that bit 4 is part of the rank number so ranks could have gone up to 31.) -- bits 5-6 seem to encode the citizenship as below. This part needs more testing and verification. ----------------------------------------------------------------- function getArg6(player) local output = player:getRank(); local nation = player:getNation(); if (nation == dsp.nation.SANDORIA) then return output; elseif (nation == dsp.nation.BASTOK) then return output + 32; elseif (nation == dsp.nation.WINDURST) then return output + 64; end end; ------------------------------------------------ -- function getRewardExForce(guardnation,player) Expeditionary Force Reward [NOT IMPLEMENTED] ------------------------------------------------ function getRewardExForce(guardnation,player) return 0; end; ------------------------------------------------ -- function getKeySupply(region) ------------------------------------------------ function getSupplyKey(region) if (region <= 9) then return 75 + region; elseif (region == 10) then return 124; elseif (region <= 13) then return 74 + region; elseif (region <= 15) then return 248 + region; elseif (region == 18) then return 620; end end; ----------------------------------------------------------------- -- giltosetHP(player) returns the amount of gil it costs a player to set a homepoint at a foreign outpost/border guard. ----------------------------------------------------------------- function giltosetHP(guardnation,player) local rank = player:getRank(); if (getArg1(guardnation,player) < 0x700) then -- determine ifplayer is in same or allied nation as guard HPgil = 0; else if (rank <= 5) then HPgil = 100 * 2^(rank - 1); else HPgil = 800 * rank - 2400; end end return HPgil; end; ----------------------------------------------------------------- -- function hasOutpost(player, region) returns 1 ifthe player has the outpost of the indicated region under current allegiance. ----------------------------------------------------------------- function hasOutpost(player, region) local nation = player:getNation() local bit = {}; if (nation == dsp.nation.BASTOK) then supply_quests = player:getNationTeleport(dsp.nation.BASTOK); elseif (nation == dsp.nation.SANDORIA) then supply_quests = player:getNationTeleport(dsp.nation.SANDORIA); elseif (nation == dsp.nation.WINDURST) then supply_quests = player:getNationTeleport(dsp.nation.WINDURST); end; for i = 23,5,-1 do twop = 2^i if (supply_quests >= twop) then bit[i]=1; supply_quests = supply_quests - twop; else bit[i]=0; end; --printf("bit %u: %u \n",i,bit[i]); end; return bit[region]; end; ----------------------------------------------------------------- -- function OP_TeleFee(player,region) ----------------------------------------------------------------- function OP_TeleFee(player,region) if (hasOutpost(player, region+5) == 1) then if (GetRegionOwner(region) == player:getNation()) then return tpFees[region + 1]; else return tpFees[region + 1] * 3; end else return 0; end end; ----------------------------------------------------------------- -- Teleport Outpost > Nation ----------------------------------------------------------------- function toHomeNation(player) if (player:getNation() == dsp.nation.BASTOK) then player:setPos(89, 0 , -66, 0, 234); elseif (player:getNation() == dsp.nation.SANDORIA) then player:setPos(49, -1 , 29, 164, 231); else player:setPos(193, -12 , 220, 64, 240); end end; ----------------------------------------------------------------- -- function getTeleAvailable(nation) ----------------------------------------------------------------- function getTeleAvailable(nation) local mask = 2145386527; for i = 5,23 do if (GetRegionOwner(i - 5) ~= nation) then mask = mask + 2^i; end; end return mask; end; --------------------------------- -- Teleport Nation > Outpost --------------------------------- function toOutpost(player,option) -- Coordinates marked {R} have been obtained by packet capture from retail. Don't change them. -- Ronfaure if (option == 5) then player:setPos(-437.688, -20.255, -219.227, 124, 100); -- {R} -- Zulkheim elseif (option == 6) then player:setPos(148.231, -7.975 , 93.479, 154, 103); -- {R} -- Norvallen elseif (option == 7) then player:setPos(62.030, 0.463, -2.025, 67, 104); -- {R} -- Gustaberg elseif (option == 8) then player:setPos(-580.161, 39.578, 62.68, 89, 106); -- {R} -- Derfland elseif (option == 9) then player:setPos(465.820, 23.625, 423.164, 29, 109); -- {R} -- Sarutabaruta elseif (option == 10) then player:setPos(-17.921, -13.335, 318.156, 254, 115); -- {R} -- Kolshushu elseif (option == 11) then player:setPos(-480.237, -30.943, 58.079, 62, 118); -- {R} -- Aragoneu elseif (option == 12) then player:setPos(-297.047, 16.988, 418.026, 225, 119); -- {R} -- Fauregandi elseif (option == 13) then player:setPos(-18.690, -60.048, -109.243, 100, 111); -- {R} -- Valdeaunia elseif (option == 14) then player:setPos(211.210, -24.016, -207.338, 160, 112); -- {R} -- Qufim Island elseif (option == 15) then player:setPos(-243.049, -19.983, 306.712, 71, 126); -- {R} -- Li'Telor elseif (option == 16) then player:setPos(-37.669, 0.419, -141.216, 69, 121); -- {R} -- Kuzotz elseif (option == 17) then player:setPos(-249.983, 7.965, -252.976, 122, 114); -- {R} -- Vollbow elseif (option == 18) then player:setPos(-176.360, 7.624, -63.580, 122, 113); -- {R} -- Elshimo Lowlands elseif (option == 19) then player:setPos(-240.860, -0.031, -388.434, 64, 123); -- {R} -- Elshimo Uplands elseif (option == 20) then player:setPos(207.821, -0.128, -86.623, 159, 124); -- {R} -- Tu'Lia ?! elseif (option == 21) then player:setPos(4, -54, -600, 192, 130); -- Dummied out? -- Tavnazia elseif (option == 23) then player:setPos(-535.861, -7.149, -53.628, 122, 24); -- {R} end; end; ----------------------------------- -- Expeditionary Force -- {Option,Quest,Zone,MenuMask,MinimumLevel,KeyItem} NOT USED ----------------------------------- EXFORCE = {0x20006,ZULK_EF,0x67,0x000040,0x14,dsp.ki.ZULKHEIM_EF_INSIGNIA, 0x20007,NORV_EF,0x68,0x000080,0x19,dsp.ki.NORVALLEN_EF_INSIGNIA, 0x20009,DERF_EF,0x6D,0x000200,0x19,dsp.ki.DERFLAND_EF_INSIGNIA, 0x2000B,KOLS_EF,0x76,0x000800,0x14,dsp.ki.KOLSHUSHU_EF_INSIGNIA, 0x2000C,ARAG_EF,0x77,0x001000,0x19,dsp.ki.ARAGONEU_EF_INSIGNIA, 0x2000D,FAUR_EF,0x6F,0x002000,0x23,dsp.ki.FAUREGANDI_EF_INSIGNIA, 0x2000E,VALD_EF,0x70,0x004000,0x28,dsp.ki.VALDEAUNIA_EF_INSIGNIA, 0x2000F,QUFI_EF,0x7E,0x008000,0x19,dsp.ki.QUFIM_EF_INSIGNIA, 0x20010,LITE_EF,0x79,0x010000,0x23,dsp.ki.LITELOR_EF_INSIGNIA, 0x20011,KUZO_EF,0x72,0x020000,0x28,dsp.ki.KUZOTZ_EF_INSIGNIA, 0x20012,VOLL_EF,0x71,0x040000,0x41,dsp.ki.VOLLBOW_EF_INSIGNIA, 0x20013,ELLO_EF,0x7B,0x080000,0x23,dsp.ki.ELSHIMO_LOWLANDS_EF_INSIGNIA, 0x20014,ELUP_EF,0x7C,0x100000,0x2D,dsp.ki.ELSHIMO_UPLANDS_EF_INSIGNIA}; --------------------------------- -- --------------------------------- function getRegionalConquestOverseers(region) switch (region): caseof { --------------------------------- [dsp.region.RONFAURE] = function (x) -- West Ronfaure (100) --------------------------------- --print("RONFAURE"); local Doladepaiton = 17187523; npc = { -- Doladepaiton,dsp.nation.SANDORIA, -- Doladepaiton, R.K. Doladepaiton+7,dsp.nation.SANDORIA, -- Ballie, R.K. Doladepaiton+3,dsp.nation.SANDORIA, -- Flag Doladepaiton+11,dsp.nation.SANDORIA, -- Flag -- Doladepaiton+1,dsp.nation.BASTOK, -- Yoshihiro, I.M. Doladepaiton+8,dsp.nation.BASTOK, -- Molting Moth, I.M. Doladepaiton+4,dsp.nation.BASTOK, -- Flag Doladepaiton+13,dsp.nation.BASTOK, -- Flag -- Doladepaiton+2,dsp.nation.WINDURST, -- Kyanta-Pakyanta, W.W. Doladepaiton+9,dsp.nation.WINDURST, -- Tottoto, W.W. Doladepaiton+5,dsp.nation.WINDURST, -- Flag Doladepaiton+13,dsp.nation.WINDURST, -- Flag -- Doladepaiton+6,dsp.nation.BEASTMEN, -- Flag Doladepaiton+14,dsp.nation.BEASTMEN, -- Flag -- Doladepaiton+10,dsp.nation.OTHER, -- Harvetour } end, --------------------------------- [dsp.region.ZULKHEIM] = function (x) -- Valkurm_Dunes (103) --------------------------------- --print("ZULKHEIM"); local Quanteilleron = 17199707; npc = { -- Quanteilleron,dsp.nation.SANDORIA, -- Quanteilleron, R.K. Quanteilleron+7,dsp.nation.SANDORIA, -- Prunilla, R.K. Quanteilleron+3,dsp.nation.SANDORIA, -- flag Quanteilleron+12,dsp.nation.SANDORIA, -- flag -- Quanteilleron+1,dsp.nation.BASTOK, -- Tsunashige, I.M. Quanteilleron+8,dsp.nation.BASTOK, -- Fighting Ant, I.M. Quanteilleron+4,dsp.nation.BASTOK, -- flag Quanteilleron+13,dsp.nation.BASTOK, -- flag -- Quanteilleron+2,dsp.nation.WINDURST, -- Nyata-Mobuta, W.W. Quanteilleron+9,dsp.nation.WINDURST, -- Tebubu, W.W. Quanteilleron+5,dsp.nation.WINDURST, -- flag Quanteilleron+14,dsp.nation.WINDURST, -- flag -- Quanteilleron+6,dsp.nation.BEASTMEN, -- flag Quanteilleron+15,dsp.nation.BEASTMEN, -- flag -- Quanteilleron+10,dsp.nation.OTHER, -- Medicine Axe } end, --------------------------------- [dsp.region.NORVALLEN] = function (x) -- Jugner_Forest (104) --------------------------------- --print("NORVALLEN"); local Chaplion = 17203846; npc = { -- Chaplion,dsp.nation.SANDORIA, -- Chaplion, R.K. Chaplion+7,dsp.nation.SANDORIA, -- Taumiale, R.K. Chaplion+3,dsp.nation.SANDORIA, -- flag Chaplion+11,dsp.nation.SANDORIA, -- flag -- Chaplion+1,dsp.nation.BASTOK, -- Takamoto, I.M. Chaplion+8,dsp.nation.BASTOK, -- Pure Heart, I.M. Chaplion+4,dsp.nation.BASTOK, -- flag Chaplion+12,dsp.nation.BASTOK, -- flag -- Chaplion+2,dsp.nation.WINDURST, -- Bubchu-Bibinchu, W.W. Chaplion+9,dsp.nation.WINDURST, -- Geruru, W.W. Chaplion+5,dsp.nation.WINDURST, -- flag Chaplion+13,dsp.nation.WINDURST, -- flag -- Chaplion+6,dsp.nation.BEASTMEN, -- flag Chaplion+14,dsp.nation.BEASTMEN, -- flag -- Chaplion+10,dsp.nation.OTHER, -- Mionie } end, --------------------------------- [dsp.region.GUSTABERG] = function (x) -- North_Gustaberg (106) --------------------------------- --print("GUSTABERG"); local Ennigreaud = 17212058; npc = { -- Ennigreaud,dsp.nation.SANDORIA, -- Ennigreaud, R.K. Ennigreaud+7,dsp.nation.SANDORIA, -- Quellebie, R.K. Ennigreaud+3,dsp.nation.SANDORIA, -- flag Ennigreaud+11,dsp.nation.SANDORIA, -- flag -- Ennigreaud+1,dsp.nation.BASTOK, -- Shigezane, I.M. Ennigreaud+8,dsp.nation.BASTOK, -- Heavy Fog, I.M. Ennigreaud+4,dsp.nation.BASTOK, -- flag Ennigreaud+12,dsp.nation.BASTOK, -- flag -- Ennigreaud+2,dsp.nation.WINDURST, -- Kuuwari-Aori, W.W. Ennigreaud+9,dsp.nation.WINDURST, -- Butsutsu, W.W. Ennigreaud+5,dsp.nation.WINDURST, -- flag Ennigreaud+13,dsp.nation.WINDURST, -- flag -- Ennigreaud+6,dsp.nation.BEASTMEN, -- flag Ennigreaud+14,dsp.nation.BEASTMEN, -- flag -- Ennigreaud+10,dsp.nation.OTHER, -- Kuleo } end, --------------------------------- [dsp.region.DERFLAND] = function (x) -- Pashhow_Marshlands (109) --------------------------------- --print("DERFLAND"); local Mesachedeau = 17224324; npc = { -- Mesachedeau,dsp.nation.SANDORIA, -- Mesachedeau, R.K. Mesachedeau+7,dsp.nation.SANDORIA, -- Ioupie, R.K. Mesachedeau+3,dsp.nation.SANDORIA, -- flag Mesachedeau+11,dsp.nation.SANDORIA, -- flag -- Mesachedeau+1,dsp.nation.BASTOK, -- Souun, I.M. Mesachedeau+8,dsp.nation.BASTOK, -- Sharp Tooth, I.M. Mesachedeau+4,dsp.nation.BASTOK, -- flag Mesachedeau+12,dsp.nation.BASTOK, -- flag -- Mesachedeau+2,dsp.nation.WINDURST, -- Mokto-Lankto, W.W. Mesachedeau+9,dsp.nation.WINDURST, -- Shikoko, W.W. Mesachedeau+5,dsp.nation.WINDURST, -- flag Mesachedeau+13,dsp.nation.WINDURST, -- flag -- Mesachedeau+6,dsp.nation.BEASTMEN, -- flag Mesachedeau+14,dsp.nation.BEASTMEN, -- flag -- Mesachedeau+10,dsp.nation.OTHER, -- Tahmasp } end, --------------------------------- [dsp.region.SARUTABARUTA] = function (x) -- West_Sarutabaruta (115) --------------------------------- --print("SARUTABARUTA"); local Naguipeillont = 17248823; npc = { -- Naguipeillont,dsp.nation.SANDORIA, -- Naguipeillont, R.K. Naguipeillont+7,dsp.nation.SANDORIA, -- Banege, R.K. Naguipeillont+3,dsp.nation.SANDORIA, -- flag Naguipeillont+11,dsp.nation.SANDORIA, -- flag -- Naguipeillont+1,dsp.nation.BASTOK, -- Ryokei, I.M. Naguipeillont+8,dsp.nation.BASTOK, -- Slow Axe, I.M. Naguipeillont+4,dsp.nation.BASTOK, -- flag Naguipeillont+12,dsp.nation.BASTOK, -- flag -- Naguipeillont+2,dsp.nation.WINDURST, -- Roshina-Kuleshuna, W.W. Naguipeillont+9,dsp.nation.WINDURST, -- Darumomo, W.W. Naguipeillont+5,dsp.nation.WINDURST, -- flag Naguipeillont+13,dsp.nation.WINDURST, -- flag -- Naguipeillont+6,dsp.nation.BEASTMEN, -- flag Naguipeillont+14,dsp.nation.BEASTMEN, -- flag -- Naguipeillont+10,dsp.nation.OTHER, -- Mahien-Uhien } end, --------------------------------- [dsp.region.KOLSHUSHU] = function (x) -- Buburimu_Peninsula (118) --------------------------------- --print("KOLSHUSHU"); local Bonbavour = 17261148; npc = { -- Bonbavour,dsp.nation.SANDORIA, -- Bonbavour, R.K. Bonbavour+7,dsp.nation.SANDORIA, -- Craigine, R.K. Bonbavour+3,dsp.nation.SANDORIA, -- flag Bonbavour+11,dsp.nation.SANDORIA, -- flag -- Bonbavour+1,dsp.nation.BASTOK, -- Ishin, I.M. Bonbavour+8,dsp.nation.BASTOK, -- Wise Turtle, I.M. Bonbavour+4,dsp.nation.BASTOK, -- flag Bonbavour+12,dsp.nation.BASTOK, -- flag -- Bonbavour+2,dsp.nation.WINDURST, -- Ganemu-Punnemu, W.W. Bonbavour+9,dsp.nation.WINDURST, -- Mashasha, W.W. Bonbavour+5,dsp.nation.WINDURST, -- flag Bonbavour+13,dsp.nation.WINDURST, -- flag -- Bonbavour+6,dsp.nation.BEASTMEN, -- flag Bonbavour+14,dsp.nation.BEASTMEN, -- flag -- Bonbavour+10,dsp.nation.OTHER, -- Lobho Ukipturi } end, --------------------------------- [dsp.region.ARAGONEU] = function (x) -- Meriphataud_Mountains (119) --------------------------------- --print("ARAGONEU"); local Chegourt = 17265269; npc = { -- Chegourt,dsp.nation.SANDORIA, -- Chegourt, R.K. Chegourt+7,dsp.nation.SANDORIA, -- Buliame, R.K. Chegourt+3,dsp.nation.SANDORIA, -- flag Chegourt+11,dsp.nation.SANDORIA, -- flag -- Chegourt+1,dsp.nation.BASTOK, -- Akane, I.M. Chegourt+8,dsp.nation.BASTOK, -- Three Steps, I.M. Chegourt+4,dsp.nation.BASTOK, -- flag Chegourt+12,dsp.nation.BASTOK, -- flag -- Chegourt+2,dsp.nation.WINDURST, -- Donmo-Boronmo, W.W. Chegourt+9,dsp.nation.WINDURST, -- Daruru, W.W. Chegourt+5,dsp.nation.WINDURST, -- flag Chegourt+13,dsp.nation.WINDURST, -- flag -- Chegourt+6,dsp.nation.BEASTMEN, -- flag Chegourt+14,dsp.nation.BEASTMEN, -- flag -- Chegourt+10,dsp.nation.OTHER, -- Mushosho } end, --------------------------------- [dsp.region.FAUREGANDI] = function (x) -- Beaucedine_Glacier (111) --------------------------------- --print("FAUREGANDI"); local Parledaire = 17232207; npc = { -- Parledaire,dsp.nation.SANDORIA, -- Parledaire, R.K. Parledaire+7,dsp.nation.SANDORIA, -- Leaufetie, R.K. Parledaire+3,dsp.nation.SANDORIA, -- flag Parledaire+11,dsp.nation.SANDORIA, -- flag -- Parledaire+1,dsp.nation.BASTOK, -- Akane, I.M. Parledaire+8,dsp.nation.BASTOK, -- Rattling Rain, I.M. Parledaire+4,dsp.nation.BASTOK, -- flag Parledaire+12,dsp.nation.BASTOK, -- flag -- Parledaire+2,dsp.nation.WINDURST, -- Ryunchi-Pauchi, W.W. Parledaire+9,dsp.nation.WINDURST, -- Chopapa, W.W. Parledaire+5,dsp.nation.WINDURST, -- flag Parledaire+13,dsp.nation.WINDURST, -- flag -- Parledaire+6,dsp.nation.BEASTMEN, -- flag Parledaire+14,dsp.nation.BEASTMEN, -- flag -- Parledaire+10,dsp.nation.OTHER, -- Gueriette } end, --------------------------------- [dsp.region.VALDEAUNIA] = function (x) -- Xarcabard (112) --------------------------------- --print("VALDEAUNIA"); local Jeantelas = 17236288; npc = { -- Jeantelas,dsp.nation.SANDORIA, -- Jeantelas, R.K. Jeantelas+7,dsp.nation.SANDORIA, -- Pilcha, R.K. Jeantelas+3,dsp.nation.SANDORIA, -- flag Jeantelas+11,dsp.nation.SANDORIA, -- flag -- Jeantelas+1,dsp.nation.BASTOK, -- Kaya, I.M. Jeantelas+8,dsp.nation.BASTOK, -- Heavy Bear, I.M. Jeantelas+4,dsp.nation.BASTOK, -- flag Jeantelas+12,dsp.nation.BASTOK, -- flag -- Jeantelas+2,dsp.nation.WINDURST, -- Magumo-Yagimo, W.W. Jeantelas+9,dsp.nation.WINDURST, -- Tememe, W.W. Jeantelas+5,dsp.nation.WINDURST, -- flag Jeantelas+13,dsp.nation.WINDURST, -- flag -- Jeantelas+6,dsp.nation.BEASTMEN, -- flag Jeantelas+14,dsp.nation.BEASTMEN, -- flag -- Jeantelas+10,dsp.nation.OTHER, -- Pelogrant } end, --------------------------------- [dsp.region.QUFIMISLAND] = function (x) -- Qufim_Island (126) --------------------------------- --print("QUFIMISLAND"); local Pitoire = 17293714; npc = { -- Pitoire,dsp.nation.SANDORIA, -- Pitoire, R.K. Pitoire+7,dsp.nation.SANDORIA, -- Matica, R.K. Pitoire+3,dsp.nation.SANDORIA, -- flag Pitoire+11,dsp.nation.SANDORIA, -- flag -- Pitoire+1,dsp.nation.BASTOK, -- Sasa, I.M. Pitoire+8,dsp.nation.BASTOK, -- Singing Blade, I.M. Pitoire+4,dsp.nation.BASTOK, -- flag Pitoire+12,dsp.nation.BASTOK, -- flag -- Pitoire+2,dsp.nation.WINDURST, -- Tsonga-Hoponga, W.W. Pitoire+9,dsp.nation.WINDURST, -- Numumu, W.W. Pitoire+5,dsp.nation.WINDURST, -- flag Pitoire+13,dsp.nation.WINDURST, -- flag -- Pitoire+6,dsp.nation.BEASTMEN, -- flag Pitoire+14,dsp.nation.BEASTMEN, -- flag -- Pitoire+10,dsp.nation.OTHER, -- Jiwon } end, --------------------------------- [dsp.region.LITELOR] = function (x) -- The_Sanctuary_of_ZiTah (121) --------------------------------- --print("LITELOR"); local Credaurion = 17273363; npc = { -- Credaurion,dsp.nation.SANDORIA, -- Credaurion, R.K. Credaurion+7,dsp.nation.SANDORIA, -- Limion, R.K. Credaurion+3,dsp.nation.SANDORIA, -- flag Credaurion+11,dsp.nation.SANDORIA, -- flag -- Credaurion+1,dsp.nation.BASTOK, -- Calliope, I.M. Credaurion+8,dsp.nation.BASTOK, -- Dedden, I.M. Credaurion+4,dsp.nation.BASTOK, -- flag Credaurion+12,dsp.nation.BASTOK, -- flag -- Credaurion+2,dsp.nation.WINDURST, -- Ajimo-Majimo, W.W. Credaurion+9,dsp.nation.WINDURST, -- Ochocho, W.W. Credaurion+5,dsp.nation.WINDURST, -- flag Credaurion+13,dsp.nation.WINDURST, -- flag -- Credaurion+6,dsp.nation.BEASTMEN, -- flag Credaurion+14,dsp.nation.BEASTMEN, -- flag -- Credaurion+10,dsp.nation.OTHER, -- Kasim } end, --------------------------------- [dsp.region.KUZOTZ] = function (x) -- Eastern_Altepa_Desert (114) --------------------------------- --print("KUZOTZ"); local Eaulevisat = 17244625; npc = { -- Eaulevisat,dsp.nation.SANDORIA, -- Eaulevisat, R.K. Eaulevisat+7,dsp.nation.SANDORIA, -- Laimeve, R.K. Eaulevisat+3,dsp.nation.SANDORIA, -- flag Eaulevisat+11,dsp.nation.SANDORIA, -- flag -- Eaulevisat+1,dsp.nation.BASTOK, -- Lindgard, I.M. Eaulevisat+8,dsp.nation.BASTOK, -- Daborn, I.M. Eaulevisat+4,dsp.nation.BASTOK, -- flag Eaulevisat+12,dsp.nation.BASTOK, -- flag -- Eaulevisat+2,dsp.nation.WINDURST, -- Variko-Njariko, W.W. Eaulevisat+9,dsp.nation.WINDURST, -- Sahgygy, W.W. Eaulevisat+5,dsp.nation.WINDURST, -- flag Eaulevisat+13,dsp.nation.WINDURST, -- flag -- Eaulevisat+6,dsp.nation.BEASTMEN, -- flag Eaulevisat+14,dsp.nation.BEASTMEN, -- flag -- Eaulevisat+10,dsp.nation.OTHER, -- Sowande } end, --------------------------------- [dsp.region.VOLLBOW] = function (x) -- Cape_Teriggan (113) --------------------------------- --print("VOLLBOW"); local Salimardi = 17240472; npc = { -- Salimardi,dsp.nation.SANDORIA, -- Salimardi, R.K. Salimardi+7,dsp.nation.SANDORIA, -- Paise, R.K. Salimardi+3,dsp.nation.SANDORIA, -- flag Salimardi+11,dsp.nation.SANDORIA, -- flag -- Salimardi+1,dsp.nation.BASTOK, -- Sarmistha, I.M. Salimardi+8,dsp.nation.BASTOK, -- Dultwa, I.M. Salimardi+4,dsp.nation.BASTOK, -- flag Salimardi+12,dsp.nation.BASTOK, -- flag -- Salimardi+2,dsp.nation.WINDURST, -- Voranbo-Natanbo, W.W. Salimardi+9,dsp.nation.WINDURST, -- Orukeke, W.W. Salimardi+5,dsp.nation.WINDURST, -- flag Salimardi+13,dsp.nation.WINDURST, -- flag -- Salimardi+6,dsp.nation.BEASTMEN, -- flag Salimardi+14,dsp.nation.BEASTMEN, -- flag -- Salimardi+10,dsp.nation.OTHER, -- Bright Moon } end, --------------------------------- [dsp.region.ELSHIMOLOWLANDS] = function (x) -- Yuhtunga_Jungle (123) --------------------------------- --print("ELSHIMOLOWLANDS"); local Zorchorevi = 17281598; npc = { -- Zorchorevi,dsp.nation.SANDORIA, -- Zorchorevi, R.K. Zorchorevi+7,dsp.nation.SANDORIA, -- Mupia, R.K. Zorchorevi+3,dsp.nation.SANDORIA, -- flag Zorchorevi+11,dsp.nation.SANDORIA, -- flag -- Zorchorevi+1,dsp.nation.BASTOK, -- Mahol, I.M. Zorchorevi+8,dsp.nation.BASTOK, -- Bammiro, I.M. Zorchorevi+4,dsp.nation.BASTOK, -- flag Zorchorevi+12,dsp.nation.BASTOK, -- flag -- Zorchorevi+2,dsp.nation.WINDURST, -- Uphra-Kophra, W.W. Zorchorevi+9,dsp.nation.WINDURST, -- Richacha, W.W. Zorchorevi+5,dsp.nation.WINDURST, -- flag Zorchorevi+13,dsp.nation.WINDURST, -- flag -- Zorchorevi+6,dsp.nation.BEASTMEN, -- flag Zorchorevi+14,dsp.nation.BEASTMEN, -- flag -- Zorchorevi+10,dsp.nation.OTHER, -- Robino-Mobino } end, --------------------------------- [dsp.region.ELSHIMOUPLANDS] = function (x) -- Yhoator_Jungle (124) --------------------------------- --print("ELSHIMOUPLANDS"); local Ilieumort = 17285648; npc ={ -- Ilieumort,dsp.nation.SANDORIA, -- Ilieumort, R.K. Ilieumort+7,dsp.nation.SANDORIA, -- Emila, R.K. Ilieumort+3,dsp.nation.SANDORIA, -- flag Ilieumort+11,dsp.nation.SANDORIA, -- flag -- Ilieumort+1,dsp.nation.BASTOK, -- Mintoo, I.M. Ilieumort+8,dsp.nation.BASTOK, -- Guddal, I.M. Ilieumort+4,dsp.nation.BASTOK, -- flag Ilieumort+12,dsp.nation.BASTOK, -- flag -- Ilieumort+2,dsp.nation.WINDURST, -- Etaj-Pohtaj, W.W. Ilieumort+9,dsp.nation.WINDURST, -- Ghantata, W.W. Ilieumort+5,dsp.nation.WINDURST, -- flag Ilieumort+13,dsp.nation.WINDURST, -- flag -- Ilieumort+6,dsp.nation.BEASTMEN, -- flag Ilieumort+14,dsp.nation.BEASTMEN, -- flag -- Ilieumort+10,dsp.nation.OTHER, -- Mugha Dovajaiho } end, --------------------------------- [dsp.region.TULIA] = function (x) -- RuAun_Gardens (130) --------------------------------- --print("TULIA"); local RuAun_Banner = 17310080; npc = { -- RuAun_Banner,dsp.nation.SANDORIA, -- flag -- RuAun_Banner+1,dsp.nation.BASTOK, -- flag -- RuAun_Banner+2,dsp.nation.WINDURST, -- flag -- RuAun_Banner+3,dsp.nation.BEASTMEN, -- flag } end, --------------------------------- [dsp.region.MOVALPOLOS] = function (x) -- Oldton_Movalpolos --------------------------------- --print("MOVALPOLOS"); local Oldton_Banner_Offset = 16822509; npc = { -- Oldton_Banner_Offset,dsp.nation.SANDORIA, -- flag -- Oldton_Banner_Offset+1,dsp.nation.BASTOK, -- flag -- Oldton_Banner_Offset+2,dsp.nation.WINDURST, -- flag -- Oldton_Banner_Offset+3,dsp.nation.BEASTMEN, -- flag } end, --------------------------------- [dsp.region.TAVNAZIANARCH] = function (x) -- Lufaise_Meadows --------------------------------- --print("TAVNAZIA"); local Jemmoquel = 16875865; npc = { -- Jemmoquel,dsp.nation.SANDORIA, -- Jemmoquel, R.K. Jemmoquel+7,dsp.nation.SANDORIA, -- Chilaumme, R.K. Jemmoquel+3,dsp.nation.SANDORIA, -- flag Jemmoquel+11,dsp.nation.SANDORIA, -- flag -- Jemmoquel+1,dsp.nation.BASTOK, -- Yoram, I.M. Jemmoquel+8,dsp.nation.BASTOK, -- Ghost Talker, I.M. Jemmoquel+4,dsp.nation.BASTOK, -- flag Jemmoquel+12,dsp.nation.BASTOK, -- flag -- Jemmoquel+2,dsp.nation.WINDURST, -- Teldo-Moroldo, W.W. Jemmoquel+9,dsp.nation.WINDURST, -- Cotete, W.W. Jemmoquel+5,dsp.nation.WINDURST, -- flag Jemmoquel+13,dsp.nation.WINDURST, -- flag -- Jemmoquel+6,dsp.nation.BEASTMEN, -- flag Jemmoquel+14,dsp.nation.BEASTMEN, -- flag -- Jemmoquel+10,dsp.nation.OTHER, -- Jersey } end, } return npc; end; ----------------------------------- -- ----------------------------------- function SetRegionalConquestOverseers(region) local npclist = getRegionalConquestOverseers(region); local nation = GetRegionOwner(region); for i = 1, #npclist, 2 do local npc = GetNPCByID(npclist[i]); if (npc ~= nil) then if (npclist[i+1] == nation) then npc:setStatus(0); else npc:setStatus(2); end if (npclist[i+1] == dsp.nation.OTHER) then if (nation ~= dsp.nation.BEASTMEN) then npc:setStatus(0); else npc:setStatus(2); end end end end end; ----------------------------------- -- checkConquestRing ----------------------------------- function checkConquestRing(player) local count = 0; -- If not enabled by admin, do a count on Chariot, Empress, and Emperor Band if (ALLOW_MULTIPLE_EXP_RINGS ~= 1) then for i=15761,15763 do if (player:hasItem(i) == true) then count = count + 1; end end end -- One exp ring purchasable per conquest tally if (BYPASS_EXP_RING_ONE_PER_WEEK ~= 1 and player:getVar("CONQUEST_RING_TIMER") > os.time()) then count = 3; end return count; end; ----------------------------------- -- conquestUpdate ----------------------------------- function conquestUpdate(zone, player, updateType, messageBase) local ranking = getConquestBalance(); if (updateType == CONQUEST_TALLY_START) then player:messageText(player, messageBase, 5); elseif (updateType == CONQUEST_TALLY_END) then --Tallying conquest results... player:messageText(player, messageBase+1, 5); -- This region is currently under x control. local owner = GetRegionOwner(zone:getRegionID()); if (owner <= 3) then player:messageText(player, messageBase+2+owner, 5); else player:messageText(player, messageBase+6, 5); end local offset = 0; if (bit.band(ranking, 0x03) == 0x01) then offset = offset + 7; -- 7 if (bit.band(ranking, 0x30) == 0x10) then offset = offset + 1; -- 8 if (bit.band(ranking, 0x0C) == 0x0C) then offset = offset + 1; -- 9 end elseif (bit.band(ranking, 0x0C) == 0x08) then offset = offset + 3; -- 10 if (bit.band(ranking, 0x30) == 0x30) then offset = offset + 1; -- 11 end elseif (bit.band(ranking, 0x0C) == 0x04) then offset = offset + 6; -- 13 end elseif (bit.band(ranking, 0x0C) == 0x04) then offset = offset + 15; -- 15 if (bit.band(ranking, 0x30) == 0x02) then offset = offset + 3; -- 18 if (bit.band(ranking, 0x03) == 0x03) then offset = offset + 1; -- 19 end elseif (bit.band(ranking, 0x30) == 0x10) then offset = offset + 6; -- 21 end elseif (bit.band(ranking, 0x30) == 0x10) then offset = offset + 23; -- 23 if (bit.band(ranking, 0x0C) == 0x08) then offset = offset + 3; -- 26 if (bit.band(ranking, 0x30) == 0x30) then offset = offset + 1; -- 27 end end end -- Global balance of power: player:messageText(player, messageBase+offset, 5); if (isConquestAlliance()) then -- have formed an alliance. if (bit.band(ranking, 0x03) == 0x01) then player:messageText(player, messageBase+50, 5); elseif (bit.band(ranking, 0x0C) == 0x04) then player:messageText(player, messageBase+51, 5); elseif (bit.band(ranking, 0x30) == 0x10) then player:messageText(player, messageBase+52, 5); end end elseif (updateType == CONQUEST_UPDATE) then -- Conquest update: This region is currently under x control. local owner = GetRegionOwner(zone:getRegionID()); if (owner <= 3) then player:messageText(player, messageBase+32+owner, 5); else player:messageText(player, messageBase+31, 5); end local influence = GetRegionInfluence(zone:getRegionID()); if (influence >= 64) then -- The beastmen are on the rise. player:messageText(player, messageBase+37, 5); elseif (influence == 0) then -- All three nations are at a deadlock. player:messageText(player, messageBase+36, 5); else local sandoria = bit.band(influence, 0x03); local bastok = bit.rshift(bit.band(influence, 0x0C),2); local windurst = bit.rshift(bit.band(influence, 0x30),4); -- Regional influence: San d'Oria player:messageText(player, messageBase+41 - sandoria, 5); -- Bastok player:messageText(player, messageBase+45 - bastok, 5); -- Windurst player:messageText(player, messageBase+49 - windurst, 5); end if (isConquestAlliance()) then --are currently allied. if (bit.band(ranking, 0x03) == 0x01) then player:messageText(player, messageBase+53, 5); elseif (bit.band(ranking, 0x0C) == 0x04) then player:messageText(player, messageBase+54, 5); elseif (bit.band(ranking, 0x30) == 0x10) then player:messageText(player, messageBase+55, 5); end end end end;
gpl-3.0
MonokuroInzanaito/ygopro-777DIY
expansions/script/c80101009.lua
1
4476
--名刀-五虎退 function c80101009.initial_effect(c) c:SetUniqueOnField(1,0,80101009) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_EQUIP) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetTarget(c80101009.target) e1:SetOperation(c80101009.operation) c:RegisterEffect(e1) --Equip limit local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetCode(EFFECT_EQUIP_LIMIT) e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e3:SetValue(c80101009.eqlimit) c:RegisterEffect(e3) --Indes local ea=Effect.CreateEffect(c) ea:SetType(EFFECT_TYPE_EQUIP) ea:SetCode(EFFECT_INDESTRUCTABLE_BATTLE) ea:SetCondition(c80101009.flcon) ea:SetValue(1) c:RegisterEffect(ea) --salvage local e10=Effect.CreateEffect(c) e10:SetDescription(aux.Stringid(80101009,1)) e10:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e10:SetType(EFFECT_TYPE_IGNITION) e10:SetRange(LOCATION_GRAVE) e10:SetCountLimit(1,81101106) e10:SetCost(c80101009.cost) e10:SetTarget(c80101009.tg) e10:SetOperation(c80101009.op) c:RegisterEffect(e10) --atkdown local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_EQUIP) e2:SetCode(EFFECT_UPDATE_ATTACK) e2:SetCondition(c80101009.flcon) e2:SetValue(300) c:RegisterEffect(e2) --spsummon local e14=Effect.CreateEffect(c) e14:SetDescription(aux.Stringid(80101009,0)) e14:SetCategory(CATEGORY_SPECIAL_SUMMON) e14:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_CANNOT_NEGATE) e14:SetType(EFFECT_TYPE_IGNITION) e14:SetRange(LOCATION_SZONE) e14:SetCountLimit(1,80101009) e14:SetCost(c80101009.spcost) e14:SetOperation(c80101009.spop) c:RegisterEffect(e14) end function c80101009.cffilter(c) return c:IsSetCard(0x6400) and not c:IsCode(80101009) end function c80101009.spcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c80101009.cffilter,tp,LOCATION_DECK,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,c80101009.cffilter,tp,LOCATION_DECK,0,1,1,nil) Duel.SendtoGrave(g,REASON_COST) e:SetLabel(g:GetFirst():GetCode()) end function c80101009.spop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local c=e:GetHandler() local code=e:GetLabel() if c:IsRelateToEffect(e) and c:IsFaceup() then c:CopyEffect(code, RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END, 1) end end function c80101009.flcon(e) return (e:GetHandler():GetEquipTarget():IsSetCard(0x5400) and e:GetHandler():GetEquipTarget():IsType(TYPE_SYNCHRO)) or e:GetHandler():GetEquipTarget():IsCode(80101004) end function c80101009.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToDeckAsCost() end Duel.SendtoDeck(e:GetHandler(),nil,2,REASON_COST) end function c80101009.thfilter(c) return c:IsCode(80101004) and c:IsAbleToHand() end function c80101009.tg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c80101009.thfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function c80101009.op(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,c80101009.thfilter,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 c80101009.eqlimit(e,c) return c:IsSetCard(0x5400) end function c80101009.eqfilter1(c) return c:IsFaceup() and c:IsSetCard(0x5400) end function c80101009.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and c80101009.eqfilter1(chkc) end if chk==0 then return Duel.IsExistingTarget(c80101009.eqfilter1,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP) Duel.SelectTarget(tp,c80101009.eqfilter1,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0) end function c80101009.operation(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() if c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) and tc:IsFaceup() and c:CheckUniqueOnField(tp) then Duel.Equip(tp,c,tc) end end
gpl-3.0
davidedmonds/darkstar
scripts/zones/Outer_Horutoto_Ruins/Zone.lua
28
1816
----------------------------------- -- -- Zone: Outer_Horutoto_Ruins (194) -- ----------------------------------- package.loaded["scripts/zones/Outer_Horutoto_Ruins/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/zone"); require("scripts/zones/Outer_Horutoto_Ruins/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) local tomes = {17572305,17572306,17572307,17572308}; SetGroundsTome(tomes); UpdateTreasureSpawnPoint(17572286); end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) local cs = -1; if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then player:setPos(419.991,-9.637,716.991,190); end return cs; end; ----------------------------------- -- onConquestUpdate ----------------------------------- function onConquestUpdate(zone, updatetype) local players = zone:getPlayers(); for name, player in pairs(players) do conquestUpdate(zone, player, updatetype, CONQUEST_BASE); end end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
gpl-3.0
champtar/packages
utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/ltq-dsl.lua
26
3991
local ubus = require "ubus" local function scrape() local dsl_line_attenuation = metric("dsl_line_attenuation_db", "gauge") local dsl_signal_attenuation = metric("dsl_signal_attenuation_db", "gauge") local dsl_snr = metric("dsl_signal_to_noise_margin_db", "gauge") local dsl_aggregated_transmit_power = metric("dsl_aggregated_transmit_power_db", "gauge") local dsl_latency = metric("dsl_latency_seconds", "gauge") local dsl_datarate = metric("dsl_datarate", "gauge") local dsl_max_datarate = metric("dsl_max_datarate", "gauge") local dsl_error_seconds_total = metric("dsl_error_seconds_total", "counter") local dsl_errors_total = metric("dsl_errors_total", "counter") local dsl_erb_total = metric("dsl_erb_total", "counter") local u = ubus.connect() local m = u:call("dsl", "metrics", {}) -- dsl hardware/firmware information metric("dsl_info", "gauge", { atuc_vendor = m.atu_c.vendor, atuc_system_vendor = m.atu_c.system_vendor, chipset = m.chipset, firmware_version = m.firmware_version, api_version = m.api_version, driver_version = m.driver_version, }, 1) -- dsl line settings information metric("dsl_line_info", "gauge", { annex = m.annex, standard = m.standard, mode = m.mode, profile = m.profile, }, 1) local dsl_up if m.up then dsl_up = 1 else dsl_up = 0 end metric("dsl_up", "gauge", { detail = m.state, }, dsl_up) -- dsl line status data metric("dsl_uptime_seconds", "gauge", {}, m.uptime) -- dsl db measurements dsl_line_attenuation({direction="down"}, m.downstream.latn) dsl_line_attenuation({direction="up"}, m.upstream.latn) dsl_signal_attenuation({direction="down"}, m.downstream.satn) dsl_signal_attenuation({direction="up"}, m.upstream.satn) dsl_snr({direction="down"}, m.downstream.snr) dsl_snr({direction="up"}, m.upstream.snr) dsl_aggregated_transmit_power({direction="down"}, m.downstream.actatp) dsl_aggregated_transmit_power({direction="up"}, m.upstream.actatp) -- dsl performance data if m.downstream.interleave_delay ~= nil then dsl_latency({direction="down"}, m.downstream.interleave_delay / 1000000) dsl_latency({direction="up"}, m.upstream.interleave_delay / 1000000) end dsl_datarate({direction="down"}, m.downstream.data_rate) dsl_datarate({direction="up"}, m.upstream.data_rate) dsl_max_datarate({direction="down"}, m.downstream.attndr) dsl_max_datarate({direction="up"}, m.upstream.attndr) -- dsl errors dsl_error_seconds_total({err="forward error correction", loc="near"}, m.errors.near.fecs) dsl_error_seconds_total({err="forward error correction", loc="far"}, m.errors.far.fecs) dsl_error_seconds_total({err="errored", loc="near"}, m.errors.near.es) dsl_error_seconds_total({err="errored", loc="far"}, m.errors.far.es) dsl_error_seconds_total({err="severely errored", loc="near"}, m.errors.near.ses) dsl_error_seconds_total({err="severely errored", loc="far"}, m.errors.far.ses) dsl_error_seconds_total({err="loss of signal", loc="near"}, m.errors.near.loss) dsl_error_seconds_total({err="loss of signal", loc="far"}, m.errors.far.loss) dsl_error_seconds_total({err="unavailable", loc="near"}, m.errors.near.uas) dsl_error_seconds_total({err="unavailable", loc="far"}, m.errors.far.uas) dsl_errors_total({err="header error code error", loc="near"}, m.errors.near.hec) dsl_errors_total({err="header error code error", loc="far"}, m.errors.far.hec) dsl_errors_total({err="non pre-emptive crc error", loc="near"}, m.errors.near.crc_p) dsl_errors_total({err="non pre-emptive crc error", loc="far"}, m.errors.far.crc_p) dsl_errors_total({err="pre-emptive crc error", loc="near"}, m.errors.near.crcp_p) dsl_errors_total({err="pre-emptive crc error", loc="far"}, m.errors.far.crcp_p) -- dsl error vectors if m.erb ~= nil then dsl_erb_total({counter="sent"}, m.erb.sent) dsl_erb_total({counter="discarded"}, m.erb.discarded) end end return { scrape = scrape }
gpl-2.0
kidaa/darkstar
scripts/zones/Inner_Horutoto_Ruins/npcs/_5cb.lua
6
1300
----------------------------------- -- Area: Inner Horutoto Ruins -- NPC: _5cb (Gate of Darkness) -- @pos -228 0 99 192 ----------------------------------- package.loaded["scripts/zones/Inner_Horutoto_Ruins/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Inner_Horutoto_Ruins/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if(player:getCurrentMission(WINDURST) == THE_JESTER_WHO_D_BE_KING and player:getVar("MissionStatus") == 9) then player:startEvent(0x004B); else player:messageSpecial(DOOR_FIRMLY_CLOSED); end return 1; end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); if(csid == 0x004B) then player:setVar("MissionStatus",10) end end;
gpl-3.0
davidedmonds/darkstar
scripts/zones/Al_Zahbi/npcs/Zazarg.lua
38
1028
----------------------------------- -- Area: Al Zahbi -- NPC: Zazarg -- Type: Stoneserpent General -- @zone: 48 -- @pos -41.675 -8 104.452 -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/Al_Zahbi/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x010c); 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
MonokuroInzanaito/ygopro-777DIY
expansions/script/c20329008.lua
1
1316
--穴居者 丝命缠盘 function c20329008.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCost(c20329008.cost) e1:SetCondition(c20329008.condition) e1:SetOperation(c20329008.activate) c:RegisterEffect(e1) end function c20329008.condition(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 c20329008.costfilter(c) return c:IsAbleToGraveAsCost() and c:IsSetCard(0x284) end function c20329008.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c20329008.costfilter,tp,LOCATION_HAND,0,1,nil) end Duel.DiscardHand(tp,c20329008.costfilter,1,1,REASON_COST) end function c20329008.activate(e,tp,eg,ep,ev,re,r,rp) Duel.SkipPhase(1-tp,PHASE_BATTLE,RESET_PHASE+PHASE_END,1,1) Duel.SkipPhase(1-tp,PHASE_MAIN2,RESET_PHASE+PHASE_END,1) if Duel.IsExistingMatchingCard(c20329006.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) and Duel.SelectYesNo(tp,aux.Stringid(20329006,1)) then local sptc=Duel.SelectMatchingCard(tp,c20329006.spfilter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp) Duel.BreakEffect() Duel.SpecialSummon(sptc,0,tp,tp,false,false,POS_FACEUP) end end
gpl-3.0
lhog/Zero-K
effects/unused_chloe.lua
25
1910
-- chloe return { ["chloe"] = { glow = { air = true, class = [[CSimpleParticleSystem]], count = 20, ground = true, water = true, properties = { airdrag = 1, colormap = [[1 0.5 0 1 1 1 0.5 1 0.3 0.3 0.3 0 0 0 0 0.01 ]], directional = true, emitrot = 0, emitrotspread = 90, emitvector = [[0, 1, 0]], gravity = [[0, 0.0005, 0]], numparticles = 1, particlelife = [[5 i5]], particlelifespread = 10, particlesize = 3, particlesizespread = 0, particlespeed = 0.1, particlespeedspread = 0.1, pos = [[0, 0, 0]], sizegrowth = [[3 i-0.04]], sizemod = 1.0, texture = [[ksquareblur]], }, }, meteors = { air = true, class = [[CSimpleParticleSystem]], count = 20, ground = true, water = true, properties = { airdrag = 1, colormap = [[1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0.01 ]], directional = true, emitrot = 0, emitrotspread = 90, emitvector = [[0, 1, 0]], gravity = [[0, 0, 0]], numparticles = 1, particlelife = 40, particlelifespread = 1, particlesize = 2, particlesizespread = 2, particlespeed = 2, particlespeedspread = 0, pos = [[0, 0, 0]], sizegrowth = 0, sizemod = 1.0, texture = [[kthinmeteor]], }, }, }, }
gpl-2.0
will4wachter/Project1
scripts/zones/Southern_San_dOria_[S]/npcs/Areuhat1.lua
36
1069
----------------------------------- -- Area: Southern SandOria [S] -- NPC: Areuhat -- @zone 80 -- @pos 21 0 22 ----------------------------------- package.loaded["scripts/zones/Southern_San_dOria_[S]/TextIDs"] = nil; require("scripts/zones/Southern_San_dOria_[S]/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc, 13454); -- (Couldn't find default dialogue) How very good to see you again! 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
will4wachter/Project1
scripts/zones/Northern_San_dOria/npcs/Heruze-Moruze.lua
23
1776
----------------------------------- -- Area: Northern San d'Oria -- NPC: Heruze-Moruze -- Involved in Mission: 2-3 Windurst -- @pos -56 -3 36 231 ----------------------------------- package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/keyitems"); require("scripts/globals/missions"); require("scripts/zones/Northern_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if(player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE) == QUEST_ACCEPTED) then if(trade:hasItemQty(532,1) and trade:getItemCount() == 1) then -- Trade Magicmart_flyer player:messageSpecial(FLYER_REFUSED); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) pNation = player:getNation(); currentMission = player:getCurrentMission(pNation); if(pNation == WINDURST) then if(currentMission == THE_THREE_KINGDOMS and player:getVar("MissionStatus") == 1) then player:startEvent(0x0246); else player:startEvent(0x022a); end elseif(pNation == BASTOK) then player:startEvent(0x0242); elseif(pNation == SANDORIA) then player:startEvent(0x0241); 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 == 0x0246) then player:setVar("MissionStatus",2); end end;
gpl-3.0
davidedmonds/darkstar
scripts/globals/abilities/pets/geocrush.lua
18
1404
--------------------------------------------------- -- Geocrush --------------------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/monstertpmoves"); require("scripts/globals/magic"); --------------------------------------------------- function onAbilityCheck(player, target, ability) return 0,0; end; function onPetAbility(target, pet, skill) local dINT = math.floor(pet:getStat(MOD_INT) - target:getStat(MOD_INT)); local tp = skill:getTP(); local master = pet:getMaster(); local merits = 0; if (master ~= nil and master:isPC()) then merits = master:getMerit(MERIT_GEOCRUSH); end tp = tp + (merits - 40); if (tp > 300) then tp = 300; end --note: this formula is only accurate for level 75 - 76+ may have a different intercept and/or slope local damage = math.floor(512 + 1.72*(tp+1)); damage = damage + (dINT * 1.5); damage = MobMagicalMove(pet,target,skill,damage,ELE_EARTH,1,TP_NO_EFFECT,0); damage = mobAddBonuses(pet, nil, target, damage.dmg, ELE_EARTH); damage = AvatarFinalAdjustments(damage,pet,skill,target,MOBSKILL_MAGICAL,MOBPARAM_NONE,1); target:delHP(damage); target:updateEnmityFromDamage(pet,damage); if (target:hasStatusEffect(EFFECT_STUN) == false) then target:addStatusEffect(EFFECT_STUN,3,3,3); end return damage; end
gpl-3.0
will4wachter/Project1
scripts/zones/Windurst_Waters/npcs/Upih_Khachla.lua
6
2219
----------------------------------- -- Area: Windurst Waters -- NPC: Upih Khachla -- Standard Merchant NPC -- Confirmed shop stock, August 2013 ----------------------------------- require("scripts/globals/harvest_festivals") require("scripts/globals/shop"); require("scripts/globals/conquest"); package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil; require("scripts/zones/Windurst_Waters/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) onHalloweenTrade(player,trade,npc); end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc,UPIHKHACHLA_SHOP_DIALOG); stock = { 0x43A1, 1107,1, --Grenade 0x1010, 837,1, --Potion 0x03B7, 108,1, --Wijnruit 0x027C, 119,2, --Chamomile 0x1037, 736,2, --Echo Drops 0x1020, 4445,2, --Ether 0x1034, 290,3, --Antidote 0x0764, 3960,3, --Desalinator 0x026E, 44,3, --Dried Marjoram 0x1036, 2387,3, --Eye Drops 0x025D, 180,3, --Pickaxe 0x0765, 3960,3, --Salinator 0x03FC, 276,3, --Sickle 0x04D9, 354,3 --Twinkle Powder } rank = getNationRank(WINDURST); if (rank ~= 1) then table.insert(stock,0x03fe); --Thief's Tools table.insert(stock,3643); table.insert(stock,3); end if (rank == 3) then table.insert(stock,0x03ff); --Living Key table.insert(stock,5520); table.insert(stock,3); end showNationShop(player, WINDURST, stock); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
kidaa/darkstar
scripts/zones/AlTaieu/mobs/Jailer_of_Love.lua
23
5580
----------------------------------- -- Area: Al'Taieu -- NM: Jailer of Love ----------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) end; ----------------------------------- -- onMobEngaged ----------------------------------- function onMobEngaged(mob, target) mob:hideName(false); mob:untargetable(false); mob:AnimationSub(2); end; ----------------------------------- -- onMobFight Action ----------------------------------- function onMobFight(mob, target) -- Only 9 Qn'xzomit and 9 Qn'hpemde can be summoned. Ru'phuabo (Sharks) are unlimited. local XZOMITS = mob:getLocalVar("JoL_Qn_xzomit_Killed"); local HPEMDES = mob:getLocalVar("JoL_Qn_hpemde_Killed"); -- Increment these by 1 each time they are slain, in that mobs onMobDeath() script. if (mob:getLocalVar("JoL_Regen_Reduction") == 0) then if (mob:getLocalVar("JoL_Qn_xzomit_Killed") == 9 and mob:getLocalVar("JoL_Qn_hpemde_Killed") == 9) then mob:setLocalVar("JoL_Regen_Reduction", 1); mob:addMod(MOD_REGEN, -260) end end local lastPop = mob:getLocalVar("pop_pets"); if (os.time() - lastPop > 150) then local SPAWNS = mob:getLocalVar("SPAWNS"); local phuabo1 = GetMobAction(16912849); local phuabo2 = GetMobAction(16912852); local phuabo3 = GetMobAction(16912855); if (SPAWNS == 0) then -- Spawns first 3 xzomit SpawnMob(16912858, 300):updateEnmity(target); SpawnMob(16912859, 300):updateEnmity(target); SpawnMob(16912860, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); mob:setLocalVar("SPAWNS", 1); elseif (SPAWNS == 1) then -- spawns first 3 hpemde SpawnMob(16912867, 300):updateEnmity(target); SpawnMob(16912868, 300):updateEnmity(target); SpawnMob(16912869, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); mob:setLocalVar("SPAWNS", 2); elseif (SPAWNS == 2) then -- spawns first 3 phuabo SpawnMob(16912849, 300):updateEnmity(target); SpawnMob(16912850, 300):updateEnmity(target); SpawnMob(16912851, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); mob:setLocalVar("SPAWNS", 3); elseif (SPAWNS == 3) then -- Spawns second 3 xzomit SpawnMob(16912861, 300):updateEnmity(target); SpawnMob(16912862, 300):updateEnmity(target); SpawnMob(16912863, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); mob:setLocalVar("SPAWNS", 4); elseif (SPAWNS == 4) then -- spawns second 3 hpemde SpawnMob(16912870, 300):updateEnmity(target); SpawnMob(16912871, 300):updateEnmity(target); SpawnMob(16912872, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); mob:setLocalVar("SPAWNS", 5); elseif (SPAWNS == 5) then -- spawns second 3 phuabo SpawnMob(16912852, 300):updateEnmity(target); SpawnMob(16912853, 300):updateEnmity(target); SpawnMob(16912854, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); mob:setLocalVar("SPAWNS", 6); elseif (SPAWNS == 6) then -- Spawns last 3 xzomit SpawnMob(16912864, 300):updateEnmity(target); SpawnMob(16912865, 300):updateEnmity(target); SpawnMob(16912866, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); mob:setLocalVar("SPAWNS", 7); elseif (SPAWNS == 7) then -- spawns last 3 hpemde SpawnMob(16912873, 300):updateEnmity(target); SpawnMob(16912874, 300):updateEnmity(target); SpawnMob(16912875, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); mob:setLocalVar("SPAWNS", 8); elseif (SPAWNS >= 8) then -- switch to ONLY popping phuabo (still up to 3 at a time) if (phuabo1 == ACTION_NONE or phuabo1 == ACTION_SPAWN) then SpawnMob(16912849, 300):updateEnmity(target); SpawnMob(16912850, 300):updateEnmity(target); SpawnMob(16912851, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); elseif (phuabo2 == ACTION_NONE or phuabo2 == ACTION_SPAWN) then SpawnMob(16912852, 300):updateEnmity(target); SpawnMob(16912853, 300):updateEnmity(target); SpawnMob(16912854, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); elseif (phuabo3 == ACTION_NONE or phuabo3 == ACTION_SPAWN) then SpawnMob(16912855, 300):updateEnmity(target); SpawnMob(16912856, 300):updateEnmity(target); SpawnMob(16912857, 300):updateEnmity(target); mob:setLocalVar("pop_pets", os.time()); end end end end; ----------------------------------- -- onMobDespawn ----------------------------------- function onMobDespawn(mob) end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob, killer) local AV_CHANCE = 25; if (AV_CHANCE > math.random(0,99)) then SpawnMob(16912876, 180); end end;
gpl-3.0
davidedmonds/darkstar
scripts/zones/Port_Bastok/npcs/Ronan.lua
17
2570
----------------------------------- -- Area: Port Bastok -- NPC: Ronan -- Start & Finishes Quest: Out of One's Shell ----------------------------------- package.loaded["scripts/zones/Port_Bastok/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/titles"); require("scripts/globals/quests"); require("scripts/zones/Port_Bastok/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if (player:getQuestStatus(BASTOK,OUT_OF_ONE_S_SHELL) == QUEST_ACCEPTED and player:getVar("OutOfOneShell") == 0) then if (trade:hasItemQty(17397,3) and trade:getItemCount() == 3) then player:startEvent(0x0054); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) OutOfOneShell = player:getQuestStatus(BASTOK,OUT_OF_ONE_S_SHELL); if (OutOfOneShell == QUEST_ACCEPTED and player:getVar("OutOfOneShell") == 1) then if (player:needToZone()) then player:startEvent(0x0055); else player:startEvent(0x0056); end elseif (OutOfOneShell == QUEST_ACCEPTED) then player:showText(npc,RONAN_DIALOG_1); elseif (OutOfOneShell == QUEST_COMPLETED) then player:startEvent(0x0059); elseif (player:getQuestStatus(BASTOK,THE_QUADAV_S_CURSE) == QUEST_COMPLETED and player:getFameLevel(BASTOK) >= 2) then player:startEvent(0x0052); else player:startEvent(0x0025); 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 == 0x0052) then player:addQuest(BASTOK,OUT_OF_ONE_S_SHELL); elseif (csid == 0x0054) then player:needToZone(true); player:setVar("OutOfOneShell",1); player:tradeComplete(); elseif (csid == 0x0056) then if (player:getFreeSlotsCount() >= 1) then player:addTitle(SHELL_OUTER); player:setVar("OutOfOneShell",0); player:addItem(12501); player:messageSpecial(ITEM_OBTAINED,12501); player:addFame(BASTOK,BAS_FAME*120); player:completeQuest(BASTOK,OUT_OF_ONE_S_SHELL); else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,12501); end end end;
gpl-3.0
iwonasado/keys
VSCOKeys.lrdevplugin/Utils.lua
11
7411
--[[---------------------------------------------------------------------------- VSCO Keys for Adobe Lightroom Copyright (C) 2015 Visual Supply Company Licensed under GNU GPLv2 (or any later version). This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ------------------------------------------------------------------------------]] local function arrayInsert( ary, val, idx ) -- Needed because table.insert has issues -- An "array" is a table indexed by sequential -- positive integers (no empty slots) local lastUsed = #ary + 1 local nextAvail = lastUsed + 1 -- Determine correct index value local index = tonumber(idx) -- Don't use idx after this line! if (index == nil) or (index > nextAvail) then index = nextAvail elseif (index < 1) then index = 1 end -- Insert the value if ary[index] == nil then ary[index] = val else -- TBD: Should we try to allow for skipped indices? for j = nextAvail,index,-1 do ary[j] = ary[j-1] end ary[index] = val end end local function compareAnyTypes( op1, op2 ) -- Return the comparison result -- Inspired by http://lua-users.org/wiki/SortedIteration local type1, type2 = type(op1), type(op2) local num1, num2 = tonumber(op1), tonumber(op2) if ( num1 ~= nil) and (num2 ~= nil) then -- Number or numeric string return num1 < num2 -- Numeric compare elseif type1 ~= type2 then -- Different types return type1 < type2 -- String compare of type name -- From here on, types are known to match (need only single compare) elseif type1 == "string" then -- Non-numeric string return op1 < op2 -- Default compare elseif type1 == "boolean" then return op1 -- No compare needed! -- Handled above: number, string, boolean else -- What's left: function, table, thread, userdata return tostring(op1) < tostring(op2) -- String representation end end function pairsByKeys (tbl, func) -- Inspired by http://www.lua.org/pil/19.3.html -- and http://lua-users.org/wiki/SortedIteration if func == nil then func = compareAnyTypes end -- Build a sorted array of the keys from the passed table -- Use an insertion sort, since table.sort fails on non-numeric keys local ary = {} local lastUsed = 0 for key --[[, val--]] in pairs(tbl) do if (lastUsed == 0) then ary[1] = key else local done = false for j=1,lastUsed do -- Do an insertion sort if (func(key, ary[j]) == true) then arrayInsert( ary, key, j ) done = true break end end if (done == false) then ary[lastUsed + 1] = key end end lastUsed = lastUsed + 1 end -- Define (and return) the iterator function local i = 0 -- iterator variable local iter = function () -- iterator function i = i + 1 if ary[i] == nil then return nil else return ary[i], tbl[ary[i]] end end return iter end function table_print (tt, indent, done) done = done or {} indent = indent or 0 if type(tt) == "table" then local sb = {} for key, value in pairsByKeys (tt) do table.insert(sb, string.rep (" ", indent)) -- indent it if type (value) == "table" and not done [value] then done [value] = true table.insert(sb, "{\n"); table.insert(sb, table_print (value, indent + 2, done)) table.insert(sb, string.rep (" ", indent)) -- indent it table.insert(sb, "}\n"); elseif "number" == type(key) then table.insert(sb, string.format("\"%s\"\n", tostring(value))) else table.insert(sb, string.format( "%s = \"%s\"\n", tostring (key), tostring(value))) end end return table.concat(sb) else return tt .. "\n" end end function to_string( tbl ) if "nil" == type( tbl ) then return tostring(nil) elseif "table" == type( tbl ) then return table_print(tbl) elseif "string" == type( tbl ) then return tbl else return tostring(tbl) end end function StringIsNullOrEmpty(stringToCheck) return not (type(stringToCheck)=='string' and #stringToCheck > 0) end -- WARNING! This is not a UUID at all. It's just a mostly random number. Replace when you get a chance. function notUUID() local chars = {"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"} local uuid = {[9]="-",[14]="-",[15]="4",[19]="-",[24]="-"} local r, index for i = 1,36 do if(uuid[i]==nil)then -- r = 0 | Math.random()*16; r = math.random (16) if(i == 20 and BinDecHex) then -- (r & 0x3) | 0x8 index = tonumber(Hex2Dec(BMOr(BMAnd(Dec2Hex(r), Dec2Hex(3)), Dec2Hex(8)))) if(index < 1 or index > 16)then print("WARNING Index-19:",index) return UUID() -- should never happen - just try again if it does ;-) end else index = r end uuid[i] = chars[index] end end return table.concat(uuid) end function table.count(table) local count = 0 for k,v in pairs(table) do count = count + 1 end return count end function deepcopy(object) local lookup_table = {} local function _copy(object) if type(object) ~= "table" then return object elseif lookup_table[object] then return lookup_table[object] end local new_table = {} lookup_table[object] = new_table for index, value in pairs(object) do new_table[_copy(index)] = _copy(value) end return setmetatable(new_table, getmetatable(object)) end return _copy(object) end function table.shallowcopy(t) local t2 = {} for k,v in pairs(t) do t2[k] = v end return t2 end function trim(s) return s:match "^%s*(.-)%s*$" end function string.explode(d,p) local t, ll t={} ll=0 if(#p == 1) then return {p} end while true do l=string.find(p,d,ll,true) -- find the next d in the string if l~=nil then -- if "not not" found then.. table.insert(t, string.sub(p,ll,l-1)) -- Save it in our array. ll=l+1 -- save just after where we found it for searching next time. else table.insert(t, string.sub(p,ll)) -- Save what's left in our array. break -- Break at end, as it should be, according to the lua manual. end end return t end
gpl-2.0
will4wachter/Project1
scripts/zones/Windurst_Woods/npcs/Kuoh_Rhel.lua
19
3722
----------------------------------- -- Area: Windurst Woods -- NPC: Kuoh Rhel -- Type: Standard NPC -- @zone: 241 -- @pos 131.437 -6 -102.723 -- Starts quests: Chocobilious, In a Stew -- Note: In a Stew should only repeat once per conquest tally. The tally is not implemented at time of -- writing this quest. Once it is working please feel free to add it in ^^ ----------------------------------- package.loaded["scripts/zones/Windurst_Woods/TextIDs"] = nil; ----------------------------------- require("scripts/globals/quests"); require("scripts/globals/settings"); require("scripts/globals/titles"); require("scripts/zones/Windurst_Woods/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) chocobilious = player:getQuestStatus(WINDURST,CHOCOBILIOUS); IAS = player:getQuestStatus(WINDURST,IN_A_STEW); IASvar = player:getVar("IASvar"); -- In a Stew if (IAS == QUEST_AVAILABLE and chocobilious == QUEST_COMPLETED and player:getFameLevel (WINDURST) >= 3) then if(player:needToZone()) then player:startEvent(0x00E8); -- Post quest dialog from Chocobilious else player:startEvent(0x00EB); -- IAS start end elseif (IASvar == 4 and player:hasKeyItem(RANPIMONPIS_SPECIAL_STEW)) then player:startEvent(0x00EF); -- IAS turn in elseif (IAS == QUEST_ACCEPTED) then player:startEvent(0x00EC); -- reminder dialog -- Uncomment once conquest tally in place --elseif (IAS == QUEST_COMPLETED) then --player:startEvent(0x00F0); -- new dialog between repeats elseif (IAS == QUEST_COMPLETED) then player:startEvent(0x00EA); -- start repeat -- Chocobilious elseif (chocobilious == QUEST_AVAILABLE and player:getFameLevel(WINDURST) >= 2) then player:startEvent(0x00e0); -- Start quest elseif (chocobilious == QUEST_COMPLETED and player:needToZone() == true) then player:startEvent(0x00e8); -- Quest complete elseif (chocobilious == QUEST_ACCEPTED and player:getVar("ChocobiliousQuest") == 2) then player:startEvent(0x00e7); -- Talked to Tapoh elseif (chocobilious == QUEST_ACCEPTED) then player:startEvent(0x00e1); -- Post quest accepted else -- Standard dialog player:startEvent(0x00de); 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); --Chocobilious if (csid == 0x00e0 and option == 1) then -- Quest start player:addQuest(WINDURST,CHOCOBILIOUS); elseif (csid == 0x00e7) then -- finish Quest player:completeQuest(WINDURST,CHOCOBILIOUS); player:addFame(WINDURST,WIN_FAME*220); player:addGil(GIL_RATE*1500); player:messageSpecial(GIL_OBTAINED,GIL_RATE*1500); player:tradeComplete(); player:setVar("ChocobiliousQuest",0) player:needToZone(true); -- In a Stew elseif (csid == 0x00EB) then player:addQuest(WINDURST,IN_A_STEW); -- Quest start player:setVar("IASvar",1); elseif (csid == 0x00EF) then player:completeQuest(WINDURST,IN_A_STEW); -- finish Quest player:setVar("IASvar",0); player:addFame(WINDURST,WIN_FAME*50); player:addGil(GIL_RATE*900); player:messageSpecial(GIL_OBTAINED,GIL_RATE*900); player:delKeyItem(RANPIMONPIS_SPECIAL_STEW); elseif (csid == 0x0EA and option == 1) then -- start repeat player:setVar("IASvar",3); end end;
gpl-3.0
MonokuroInzanaito/ygopro-777DIY
expansions/script/c114000316.lua
1
2786
--ブルーソウルジェム -人魚姫の願い- function c114000316.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_RECOVER) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_DAMAGE_STEP) e1:SetCode(EVENT_DAMAGE) e1:SetCondition(c114000316.condition) e1:SetTarget(c114000316.target) e1:SetOperation(c114000316.operation) c:RegisterEffect(e1) --Sent to grave local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_SINGLE) e2:SetCode(EVENT_LEAVE_FIELD) e2:SetOperation(c114000316.desop) c:RegisterEffect(e2) --Destroy itself local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD) e3:SetRange(LOCATION_SZONE) e3:SetCode(EVENT_LEAVE_FIELD) e3:SetCondition(c114000316.descon2) e3:SetOperation(c114000316.desop2) c:RegisterEffect(e3) end --sp summon & recover function function c114000316.condition(e,tp,eg,ep,ev,re,r,rp) return ep==tp and tp~=rp end function c114000316.filter(c,e,tp) return c:IsSetCard(0xcabb) and c:IsLevelBelow(6) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c114000316.filter2(c) return c:IsSetCard(0xcabb) and c:IsType(TYPE_MONSTER) end function c114000316.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c114000316.filter,tp,LOCATION_DECK,0,1,nil,e,tp) and Duel.IsExistingMatchingCard(c114000316.filter2,tp,LOCATION_GRAVE,0,1,nil) end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(ev) Duel.SetOperationInfo(0,CATEGORY_RECOVER,nil,0,tp,ev) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) end function c114000316.operation(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not c:IsRelateToEffect(e) then return end local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) local rec=Duel.Recover(p,d,REASON_EFFECT) if rec~=ev or Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c114000316.filter,tp,LOCATION_DECK,0,1,1,nil,e,tp) local tc=g:GetFirst() if tc then Duel.SpecialSummon(tc,502,tp,tp,false,false,POS_FACEUP) c:SetCardTarget(tc) end end --continuous relationship function c114000316.desop(e,tp,eg,ep,ev,re,r,rp) local tc=e:GetHandler():GetFirstCardTarget() if tc and tc:IsLocation(LOCATION_MZONE) then Duel.SendtoGrave(tc,REASON_EFFECT) end end function c114000316.descon2(e,tp,eg,ep,ev,re,r,rp) local tc=e:GetHandler():GetFirstCardTarget() return tc and eg:IsContains(tc) and tc:IsReason(REASON_DESTROY) end function c114000316.desop2(e,tp,eg,ep,ev,re,r,rp) Duel.Destroy(e:GetHandler(),REASON_EFFECT) end
gpl-3.0
will4wachter/Project1
scripts/zones/Windurst_Waters_[S]/npcs/Aystise.lua
38
1045
----------------------------------- -- Area: Windurst Waters (S) -- NPC: Aystise -- Type: Standard NPC -- @zone: 94 -- @pos -69.805 -4.5 68.078 -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/Windurst_Waters_[S]/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x019a); 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
Thonik/FritoMod
fritomod/Metatables-StyleClient.lua
1
3375
if nil ~= require then require "fritomod/currying"; require "fritomod/Metatables"; require "fritomod/Lists"; end; if Metatables == nil then Metatables = {}; end; local function StyleName(s) assert(s ~= nil, "style must not be nil"); return tostring(s):lower(); end; local function FunctionTable(t, container) return ForcedFunction(t, function(style, func, ...) style = StyleName(style); func = Curry(func, ...); container[style] = func; end); end; -- TODO StyleClients are typically passed from logical UI object containers to their children. -- It'd be nice if we could have a Metatables.PrefixedStyleClient("Icon") that would minimize the -- collision by forcing every key to have the Icon prefix. -- -- This is still half-baked, but something like this will probably get written. function Metatables.StyleClient(t, ...) if not t then t = {}; end; assert(type(t) == "table", "t must be a table. Type: " .. type(t)); if IsCallable(t.Inherits) then -- It's already a style client return t; end; assert(getmetatable(t) == nil, "t must not have a metatable"); local styles = {}; do local trash={}; for k,v in pairs(t) do local name = StyleName(k); styles[name] = v; table.insert(trash,k); end; for i=1,#trash do t[trash[i]] = nil; end; end; t._styles = styles; local processors = {}; t.ProcessedStyle = FunctionTable(t, processors); local listeners = {}; t.AddListener = ForcedFunction(t, Curry(Lists.Insert, listeners)); local parents = {}; t._parents = parents; local function Update(old) local new = t:Compute(); for k,v in pairs(old) do if new[k] ~= old[k] then Lists.CallEach(listeners, k, new[k]); end; new[k] = nil; end; for k,v in pairs(new) do Lists.CallEach(listeners, k, new[k]); end; end; t.Inherits = ForcedFunction(t, function(parent) local old = t:Compute(); local remover = Lists.Insert(parents, parent); local lremover = Noop; if not parent.Inherits then Metatables.StyleClient(parent); end; local lremover = parent:AddListener(function(key, value) if styles[key] == nil then -- Cascade! Our effective style has changed. Lists.CallEach(listeners, key, value); end; end); Update(old); return Functions.OnlyOnce(function() local old=t:Compute(); lremover(); remover(); Update(old); end); end); t.Compute = ForcedFunction(t, function(rv) rv = rv or {}; for i=1,#parents do if parents[i].Compute then parents[i]:Compute(rv); end; end; Tables.Update(rv, styles); return rv; end); setmetatable(t, { __index = function(self, key) if key == nil then return nil; end; key = StyleName(key); local v = styles[key]; if v == nil then for i=#parents,1,-1 do v = parents[i][key]; if v ~= nil then break; end; end; end; return v; end, __newindex = function(self, key, value) key = StyleName(key); local p = processors[key]; if p then local rv = p(value); if rv ~= nil then value = rv; end; end; if value == styles[key] then return; end; styles[key] = value; -- Intentionally use self[key] to ensure nil values use inherited values. Lists.CallEach(listeners, key, self[key]); end }); for i=1, select("#", ...) do local parent = select(i, ...); t:Inherits(parent); end; return t; end;
mit
davidedmonds/darkstar
scripts/zones/Chocobo_Circuit/Zone.lua
36
1122
----------------------------------- -- -- Zone: Chocobo_Circuit -- ----------------------------------- require("scripts/globals/settings"); package.loaded["scripts/zones/Chocobo_Circuit/TextIDs"] = nil; require("scripts/zones/Chocobo_Circuit/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
MonokuroInzanaito/ygopro-777DIY
expansions/script/c60159115.lua
1
4805
--八枢罪 绯色怒火 function c60159115.initial_effect(c) --xyz summon aux.AddXyzProcedure(c,c60159115.mfilter,5,3,c60159115.ovfilter,aux.Stringid(60159115,0),3,c60159115.xyzop) c:EnableReviveLimit() --summon success local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e1:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_CANNOT_DISABLE) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetCondition(c60159115.atkcon) e1:SetOperation(c60159115.sumsuc) c:RegisterEffect(e1) --cannot target local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e2:SetRange(LOCATION_MZONE) e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET) e2:SetValue(c60159115.indval) c:RegisterEffect(e2) --indes local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e3:SetCode(EFFECT_INDESTRUCTABLE_EFFECT) e3:SetRange(LOCATION_MZONE) e3:SetValue(c60159115.indval2) c:RegisterEffect(e3) --Activate local e5=Effect.CreateEffect(c) e5:SetCategory(CATEGORY_DESTROY) e5:SetType(EFFECT_TYPE_QUICK_O) e5:SetCode(EVENT_CHAINING) e5:SetRange(LOCATION_MZONE) e5:SetProperty(EFFECT_FLAG_DAMAGE_STEP) e5:SetCountLimit(2) e5:SetCondition(c60159115.condition) e5:SetTarget(c60159115.target) e5:SetOperation(c60159115.activate) c:RegisterEffect(e5) --spsummon local e4=Effect.CreateEffect(c) e4:SetCategory(CATEGORY_TOHAND) e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e4:SetCode(EVENT_LEAVE_FIELD) e4:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e4:SetCondition(c60159115.spcon) e4:SetTarget(c60159115.sptg) e4:SetOperation(c60159115.spop) c:RegisterEffect(e4) end function c60159115.mfilter(c) return c:IsAttribute(ATTRIBUTE_FIRE) end function c60159115.ovfilter(c) return c:IsFaceup() and c:GetLevel()==5 and c:IsAttribute(ATTRIBUTE_FIRE) end function c60159115.cfilter(c) return c:IsSetCard(0x3b25) and c:IsType(TYPE_SPELL) and c:IsAbleToGraveAsCost() end function c60159115.xyzop(e,tp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c60159115.cfilter,tp,LOCATION_HAND,0,2,nil) end Duel.DiscardHand(tp,c60159115.cfilter,2,2,REASON_COST) e:GetHandler():RegisterFlagEffect(60159115,RESET_EVENT+0xfe0000+RESET_PHASE+PHASE_END,0,1) end function c60159115.atkcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetSummonType()==SUMMON_TYPE_XYZ and e:GetHandler():GetFlagEffect(60159115)>0 end function c60159115.cfilter2(c) return c:IsSetCard(0x3b25) and c:IsType(TYPE_SPELL) and c:IsAbleToRemove() end function c60159115.sumsuc(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,c60159115.cfilter2,tp,LOCATION_ONFIELD+LOCATION_GRAVE,0,2,2,nil) if g:GetCount()>0 then Duel.HintSelection(g) local tc2=g:GetFirst() while tc2 do if not tc2:IsFaceup() then Duel.ConfirmCards(1-tp,tc2) end tc2=g:GetNext() end Duel.Remove(g,POS_FACEUP,REASON_RULE) end end function c60159115.indval(e,re,tp) return tp~=e:GetHandlerPlayer() and re:IsActiveType(TYPE_EFFECT) and aux.TRUE(e,re,rp) end function c60159115.indval2(e,re,tp) return tp~=e:GetHandlerPlayer() and re:IsActiveType(TYPE_EFFECT) end function c60159115.condition(e,tp,eg,ep,ev,re,r,rp) return ep~=tp and re:GetHandler():IsOnField() end function c60159115.filter(c,rc) return c~=rc and c:IsDestructable() end function c60159115.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c60159115.filter,tp,0,LOCATION_ONFIELD,1,e:GetHandler(),re:GetHandler()) end local g=Duel.GetMatchingGroup(c60159115.filter,tp,0,LOCATION_ONFIELD,e:GetHandler(),re:GetHandler()) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0) end function c60159115.activate(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectMatchingCard(tp,c60159115.filter,tp,0,LOCATION_ONFIELD,1,1,e:GetHandler(),re:GetHandler()) if g:GetCount()>0 then Duel.HintSelection(g) Duel.Destroy(g,REASON_EFFECT) end end function c60159115.spcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetOverlayCount()>0 and e:GetHandler():GetPreviousLocation()==LOCATION_MZONE end function c60159115.spfilter(c) return c:IsSetCard(0x3b25) and c:IsType(TYPE_SPELL) and c:IsAbleToHand() end function c60159115.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chk==0 then return Duel.IsExistingMatchingCard(c60159115.spfilter,tp,LOCATION_REMOVED,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_REMOVED) end function c60159115.spop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,c60159115.spfilter,tp,LOCATION_REMOVED,0,1,1,nil) if g:GetCount()>0 then Duel.HintSelection(g) Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end
gpl-3.0
davidedmonds/darkstar
scripts/globals/effects/sigil.lua
24
3085
----------------------------------- -- -- EFFECT_SIGIL -- ----------------------------------- ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) local power = effect:getPower(); -- Tracks which bonus effects are in use. local subPower = effect:getSubPower(); -- subPower sets % required to trigger regen/refresh. if (power == 1 or power == 3 or power == 5 or power == 7 or power == 9 or power == 11 or power == 13 or power == 15) then -- target:addLatent(LATENT_SIGIL_REGEN, subPower+10, MOD_REGEN, 1); -- Not yet implemented end if (power == 2 or power == 3 or power == 6 or power == 7 or power == 10 or power == 11 or power >= 14) then -- target:addLatent(LATENT_SIGIL_REFRESH, subPower, MOD_REFRESH, 1); -- Not yet implemented end if (power >= 4 and power <= 7) then -- target:addMod(MOD_FOOD_DURATION), ???); -- food duration not implemented. elseif (power >= 8 and power <= 11) then -- target:addMod(MOD_EXPLOSS_REDUCTION), ???); -- exp loss reduction not implemented. elseif (power >= 12) then -- Possibly handle exp loss reduction in core instead..Maybe the food bonus also? -- target:addMod(MOD_FOOD_DURATION), ???); -- food duration not implemented. -- target:addLatent(LATENT_SIGIL_EXPLOSS, ?, MOD_EXPLOSS_REDUCTION, ?); -- exp loss reduction not implemented. end end; ----------------------------------- -- onEffectTick Action ----------------------------------- function onEffectTick(target,effect) end; ----------------------------------- -- onEffectLose Action ----------------------------------- function onEffectLose(target,effect) local power = effect:getPower(); -- Tracks which bonus effects are in use. local subPower = effect:getSubPower(); -- subPower sets % required to trigger regen/refresh. if (power == 1 or power == 3 or power == 5 or power == 7 or power == 9 or power == 11 or power == 13 or power == 15) then -- target:delLatent(LATENT_SIGIL_REGEN, subPower+10, MOD_REGEN, 1); -- Not yet implemented end if (power == 2 or power == 3 or power == 6 or power == 7 or power == 10 or power == 11 or power >= 14) then -- target:delLatent(LATENT_SIGIL_REFRESH, subPower, MOD_REFRESH, 1); -- Not yet implemented end if (effect:getPower() >= 4 and effect:getPower() <= 7) then -- target:delMod(MOD_FOOD_DURATION), ???); -- food duration not implemented. elseif (effect:getPower() >= 8 and effect:getPower() <= 11) then -- target:delMod(MOD_EXPLOSS_REDUCTION), ???); -- exp loss reduction not implemented. elseif (effect:getPower() >= 12) then -- target:delMod(MOD_FOOD_DURATION), ???); -- food duration not implemented. -- target:delMod(MOD_EXPLOSS_REDUCTION), ???); -- exp loss reduction not implemented. end end;
gpl-3.0
IonutStef/gamecode4
Extra/UtilityDemo/utility.lua
44
7963
-- Utility.lua -- A simple utility game -- A "better" random seed. This was taken from http://lua-users.org/wiki/MathLibraryTutorial math.randomseed(tonumber(tostring(os.time()):reverse():sub(1,6))) ----------------------------------------------------------------------------------------------------------------------- -- Actor ----------------------------------------------------------------------------------------------------------------------- Actor = class(nil, { _name = "<unnamed>", _hp = 100, _mp = 3, _minDamage = nil, -- must be overridden _maxDamage = nil, -- must be overridden _minHeal = 20, _maxHeal = 45, }); function Actor:DoAction(action, opponent) if (action == "attack") then local dead = self:_Attack(opponent); return dead; elseif (action == "run") then local success = self:_Run(); return success; elseif (action == "heal") then self:_Heal(); return false; else print("Unknown action: " .. action); return false; end end function Actor:PrintStatus() print(self._name .. "; hp = " .. self._hp .. "; mp = " .. self._mp); end function Actor:Hit(damage) self._hp = self._hp - damage; if (self._hp < 0) then print(self._name .. " is dead!"); return true; end return false; end function Actor:GetHp() return self._hp; end function Actor:GetMp() return self._mp; end function Actor:GetMinDamage() return self._minDamage; end function Actor:GetMaxDamage() return self._maxDamage; end function Actor:GetMinHeal() return self._minHeal; end function Actor:GetMaxHeal() return self._maxHeal; end function Actor:_Attack(opponent) assert(self._minDamage ~= nil and self._maxDamage ~= nil); local damage = math.random(self._minDamage, self._maxDamage); print(self._name .. " struck for " .. damage .. " damage"); return opponent:Hit(damage); end function Actor:_Run() if (math.random() > 0.5) then print(self._name .. " ran away!"); return true; else print(self._name .. " failed to run away!"); return false; end end function Actor:_Heal() if (self._mp > 0) then local healAmount = math.random(self._minHeal, self._maxHeal); print(self._name .. " healed " .. healAmount .. " hp."); self._hp = self._hp + healAmount; self._mp = self._mp - 1; else print(self._name .. " attempted to heal but had no MP left"); end end ----------------------------------------------------------------------------------------------------------------------- -- Teapot ----------------------------------------------------------------------------------------------------------------------- Teapot = class(Actor, { _name = "Teapot", _minDamage = 10, _maxDamage = 20, _mp = 5, -- teapots are more magical _actions = { "attack", "heal", "run" }; }); function Teapot:Decide(opponent) local bestUtility = 0; local bestAction = nil; for i, action in ipairs(self._actions) do -- build the world state local tempWorldState = WorldState:Create(); tempWorldState:Build(self, opponent); -- apply the action tempWorldState:ApplyAction(action, self, opponent); -- grab the utility local utility = tempWorldState:GetUtility(); if (utility > bestUtility) then bestUtility = utility; bestAction = action; end print("\tScoring action '" .. action .. "': utility = " .. utility); end print("\tChose " .. bestAction); return bestAction; end -- This is the world state object used by the teapot WorldState = class(nil, { opponentHp = nil, opponentMp = nil, survivalChance = nil, -- the chance that we won't die next attack, from 0 - 1 }); function WorldState:Build(teapot, opponent) self.opponentHp = opponent:GetHp(); self.opponentMp = opponent:GetMp(); self.survivalChance = self:_CalculateSurvivalChance(teapot:GetHp(), opponent); self.killChance = 1 - self:_CalculateSurvivalChance(opponent:GetHp(), teapot); end function WorldState:ApplyAction(action, teapot, opponent) if (action == "attack") then local averageDamage = ((teapot:GetMaxDamage() - teapot:GetMinDamage()) / 2) + teapot:GetMinDamage(); self.opponentHp = self.opponentHp - averageDamage; self.killChance = 1 - self:_CalculateSurvivalChance(self.opponentHp, teapot); elseif (action == "run") then self.survivalChance = 0.5; elseif (action == "heal") then if (teapot:GetMp() > 0) then local averageHeal = ((teapot:GetMaxHeal() - teapot:GetMinHeal()) / 2) + teapot:GetMinHeal(); local newHp = teapot:GetHp() + averageHeal; self.survivalChance = self:_CalculateSurvivalChance(newHp, opponent); end else print("Unknown action: " .. action); return false; end end function WorldState:GetUtility() local lifeScore = 100 * self.survivalChance; -- a state in which we're alive grants 100 points, modified by the chance that we might survive local attackScore = 100 - self.opponentHp; -- a state in which the opponent is hurt is always good; teapot will get more aggressive as player is hurt attackScore = attackScore + (attackScore * self.killChance); -- adjust the attack score by up to double if the opponent is within a turn of death return lifeScore + attackScore; end function WorldState:_CalculateSurvivalChance(defenderHp, attacker) if (defenderHp > attacker:GetMaxDamage()) then return 1; elseif (defenderHp <= attacker:GetMinDamage()) then return 0; else local range = attacker:GetMaxDamage() - attacker:GetMinDamage(); local percentage = (defenderHp - attacker:GetMinDamage()) / range; return percentage; end end ----------------------------------------------------------------------------------------------------------------------- -- Player ----------------------------------------------------------------------------------------------------------------------- Player = class(Actor, { _name = "Player", _minDamage = 15, _maxDamage = 30, }); ----------------------------------------------------------------------------------------------------------------------- -- Game class ----------------------------------------------------------------------------------------------------------------------- Game = class(nil, { _player = nil, _teapot = nil, }); function Game:Start() self._player = Player:Create(); self._teapot = Teapot:Create(); print("A Teapot draws near! Command?"); print("1) Attack"); print("2) Run"); print("3) Heal"); print("4) Status"); print("Q to quit"); end function Game:Update(action) -- player runs action local gameOver = self._player:DoAction(action, self._teapot); -- check for game end if (gameOver) then self:_Reset(); return; end -- teapot action action = self._teapot:Decide(self._player); gameOver = self._teapot:DoAction(action, self._player); -- check for game end if (gameOver) then self:_Reset(); return; end self:ShowStatus(); end function Game:ShowStatus() self._player:PrintStatus(); self._teapot:PrintStatus(); end function Game:_Reset() print("Game over!\n\n"); self:Start(); end ----------------------------------------------------------------------------------------------------------------------- -- Global game object ----------------------------------------------------------------------------------------------------------------------- g_game = Game:Create(); g_game:Start(); ----------------------------------------------------------------------------------------------------------------------- -- Player commands ----------------------------------------------------------------------------------------------------------------------- function Attack() g_game:Update("attack"); end function Run() g_game:Update("run"); end function Heal() g_game:Update("heal"); end function Status() g_game:ShowStatus(); end
lgpl-3.0
kidaa/darkstar
scripts/zones/Beadeaux/Zone.lua
13
3470
----------------------------------- -- -- Zone: Beadeaux (147) -- ----------------------------------- package.loaded["scripts/zones/Beadeaux/TextIDs"] = nil; ----------------------------------- require("scripts/globals/titles"); require("scripts/globals/missions"); require("scripts/globals/quests"); require("scripts/zones/Beadeaux/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) -- The Afflictor System (RegionID, X, Radius, Z) zone:registerRegion(1, -163, 10, -137, 0,0,0); -- 17379798 The Afflictor zone:registerRegion(2, -209, 10, -131, 0,0,0); -- 17379799 The Afflictor zone:registerRegion(3, -140, 10, 20, 0,0,0); -- 17379800 The Afflictor zone:registerRegion(4, 261, 10, 140, 0,0,0); -- 17379801 The Afflictor zone:registerRegion(5, 340, 10, 100, 0,0,0); -- 17379802 The Afflictor zone:registerRegion(6, 380, 10, 60, 0,0,0); -- 17379803 The Afflictor UpdateTreasureSpawnPoint(17379838); UpdateTreasureSpawnPoint(17379839); end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) local cs = -1; if((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then player:setPos(387.382,38.029,19.694,3); end if(prevZone == 109) then if(player:getQuestStatus(BASTOK, BLADE_OF_DARKNESS) == QUEST_ACCEPTED and player:getVar("ChaosbringerKills") >= 100) then cs = 0x0079; elseif(player:getCurrentMission(BASTOK) == THE_FOUR_MUSKETEERS and player:getVar("MissionStatus") == 1) then cs = 0x0078; elseif(player:getMainJob() == 8 and player:getQuestStatus(BASTOK,DARK_PUPPET) == QUEST_COMPLETED and player:getQuestStatus(BASTOK,BLADE_OF_EVIL) == QUEST_AVAILABLE) then cs = 0x007a; end end return cs; end; ----------------------------------- -- onConquestUpdate ----------------------------------- function onConquestUpdate(zone, updatetype) local players = zone:getPlayers(); for name, player in pairs(players) do conquestUpdate(zone, player, updatetype, CONQUEST_BASE); end end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) if (region:GetRegionID() <= 6) then if (player:hasStatusEffect(EFFECT_CURSE_I) == false and player:hasStatusEffect(EFFECT_SILENCE) == false) then player:addStatusEffect(EFFECT_CURSE_I,50,0,300); end end end; function onRegionLeave(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if(csid == 0x0079) then player:unlockJob(8); player:addTitle(DARK_SIDER); player:setVar("ZeruhnMines_Zeid_CS", 0); player:messageSpecial(YOU_CAN_NOW_BECOME_A_DARK_KNIGHT); player:completeQuest(BASTOK, BLADE_OF_DARKNESS); elseif(csid == 0x0078) then player:setVar("MissionStatus",2); player:setPos(-297, 1, 96, 1); elseif(csid == 0x007a) then player:addQuest(BASTOK,BLADE_OF_EVIL); end end;
gpl-3.0
davidedmonds/darkstar
scripts/zones/West_Ronfaure/npcs/Phairet.lua
17
2450
----------------------------------- -- Area: West Ronfaure -- NPC: Phairet -- Involved in Quest: The Trader in the Forest -- @pos -57 -1 -501 100 ----------------------------------- package.loaded["scripts/zones/West_Ronfaure/TextIDs"] = nil; ----------------------------------- require("scripts/globals/quests"); require("scripts/zones/West_Ronfaure/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) local theTraderInTheforest = player:getQuestStatus(SANDORIA,THE_TRADER_IN_THE_FOREST); if (theTraderInTheforest == QUEST_ACCEPTED) then if (trade:hasItemQty(592,1) == true and trade:getItemCount() == 1) then -- Trade Supplies Order player:startEvent(0x007c); end elseif (theTraderInTheforest == QUEST_COMPLETED) then if (trade:getGil() == 50) then if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,4367); else player:tradeComplete(); player:addItem(4367); player:messageSpecial(ITEM_OBTAINED,4367); -- Clump of Batagreens end end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local theTraderInTheforest = player:getQuestStatus(SANDORIA,THE_TRADER_IN_THE_FOREST); local hasBatagreens = player:hasItem(4367); -- Clump of Batagreens if (theTraderInTheforest == QUEST_ACCEPTED) then if (hasBatagreens == true) then player:startEvent(0x007d); else player:startEvent(0x0075); end elseif (theTraderInTheforest == QUEST_COMPLETED or hasBatagreens == false) then player:startEvent(0x007f,4367); else player:startEvent(0x0075); 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 == 0x007c) then if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,4367); else player:tradeComplete(); player:addItem(4367); player:messageSpecial(ITEM_OBTAINED, 4367); end end end;
gpl-3.0
MonokuroInzanaito/ygopro-777DIY
expansions/script/c114000845.lua
1
2192
--★大地の魔女っ娘 Rising Earth function c114000845.initial_effect(c) --spsummon local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e1:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_CHAIN_UNIQUE) e1:SetCode(EVENT_DESTROY) e1:SetRange(LOCATION_HAND) e1:SetCondition(c114000845.spcon) e1:SetTarget(c114000845.sptg) e1:SetOperation(c114000845.spop) c:RegisterEffect(e1) end function c114000845.cfilter(c,tp) return c:IsFaceup() and c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) and ( c:IsSetCard(0xcabb) or c:IsSetCard(0x1223) ) and c:GetReasonPlayer()~=tp end function c114000845.spcon(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(c114000845.cfilter,1,nil,tp) end function c114000845.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 c114000845.spop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)>0 then local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_DESTROY) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e1:SetCode(EVENT_BATTLE_START) if Duel.GetTurnPlayer()==c:GetControler() then e1:SetReset(RESET_EVENT+0x1ff0000+RESET_PHASE+PHASE_END+RESET_SELF_TURN,2) else e1:SetReset(RESET_EVENT+0x1ff0000+RESET_PHASE+PHASE_END+RESET_SELF_TURN) end e1:SetCondition(c114000845.descon) e1:SetTarget(c114000845.destg) e1:SetOperation(c114000845.desop) c:RegisterEffect(e1) end end function c114000845.descon(e,tp,eg,ep,ev,re,r,rp) local d=Duel.GetAttackTarget() if d==e:GetHandler() then d=Duel.GetAttacker() end e:SetLabelObject(d) return d~=nil end function c114000845.destg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_DESTROY,e:GetLabelObject(),1,0,0) end function c114000845.desop(e,tp,eg,ep,ev,re,r,rp) local d=e:GetLabelObject() if d:IsRelateToBattle() then Duel.Destroy(d,REASON_EFFECT) end end
gpl-3.0
kidaa/darkstar
scripts/globals/spells/knights_minne_iv.lua
13
1518
----------------------------------------- -- Spell: Knight's Minne IV -- Grants Defense bonus to all allies. ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnSpellCast ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) local sLvl = caster:getSkillLevel(SKILL_SNG); -- Gets skill level of Singing local iLvl = caster:getWeaponSkillLevel(SLOT_RANGED); local power = 30 + math.floor((sLvl + iLvl)/10); if(power >= 97) then power = 97; end local iBoost = caster:getMod(MOD_MINNE_EFFECT) + caster:getMod(MOD_ALL_SONGS_EFFECT); if (iBoost > 0) then power = power + 1 + (iBoost-1)*4; end power = power + caster:getMerit(MERIT_MINNE_EFFECT); if (caster:hasStatusEffect(EFFECT_SOUL_VOICE)) then power = power * 2; elseif (caster:hasStatusEffect(EFFECT_MARCATO)) then power = power * 1.5; end caster:delStatusEffect(EFFECT_MARCATO); local duration = 120; duration = duration * ((iBoost * 0.1) + (caster:getMod(MOD_SONG_DURATION_BONUS)/100) + 1); if (caster:hasStatusEffect(EFFECT_TROUBADOUR)) then duration = duration * 2; end if not (target:addBardSong(caster,EFFECT_MINNE,power,0,duration,caster:getID(), 0, 4)) then spell:setMsg(75); end return EFFECT_MINNE; end;
gpl-3.0
kidaa/darkstar
scripts/zones/Beaucedine_Glacier/mobs/Tundra_Tiger.lua
23
1425
----------------------------------- -- Area: Beaucedine Glacier -- MOB: Tundra Tiger -- Note: PH for Nue, Kirata ----------------------------------- require("scripts/globals/fieldsofvalor"); require("scripts/zones/Beaucedine_Glacier/MobIDs"); ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob,killer) checkRegime(killer,mob,46,1); checkRegime(killer,mob,47,1); -- Kirata mob = mob:getID(); if (Kirata_PH[mob] ~= nil) then ToD = GetServerVariable("[POP]Kirata"); if (ToD <= os.time(t) and GetMobAction(Kirata) == 0) then if (math.random((1),(15)) == 5) then UpdateNMSpawnPoint(Kirata); GetMobByID(Kirata):setRespawnTime(GetMobRespawnTime(mob)); SetServerVariable("[PH]Kirata", mob); DeterMob(mob, true); end end end -- Nue if (Nue_PH[mob] ~= nil) then ToD = GetServerVariable("[POP]Nue"); if (ToD <= os.time(t) and GetMobAction(Nue) == 0) then if (math.random((1),(15)) == 5) then UpdateNMSpawnPoint(Nue); GetMobByID(Nue):setRespawnTime(GetMobRespawnTime(mob)); SetServerVariable("[PH]Nue", mob); DeterMob(mob, true); end end end end;
gpl-3.0
will4wachter/Project1
scripts/zones/Kuftal_Tunnel/npcs/qm1.lua
9
1116
----------------------------------- -- Area: Kuftal Tunnel -- NPC: ??? (qm1) -- Note: Used to spawn Phantom Worm -- @pos 75.943 29.916 118.854 174 ----------------------------------- package.loaded["scripts/zones/Kuftal_Tunnel/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Kuftal_Tunnel/TextIDs"); ----------------------------------- -- onSpawn Action ----------------------------------- function onSpawn(npc) end; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) local x = npc:getXPos(); local y = npc:getYPos(); local z = npc:getZPos(); local mob = GetMobByID(17490233); -- Trade Darksteel ore if(GetMobAction(17490233) == 0 and trade:hasItemQty(645,1) and trade:getItemCount() == 1) then player:tradeComplete(); SpawnMob(17490233,180):updateEnmity(player); -- Phantom Worm mob:setPos(x+1,y,z+1); end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) end;
gpl-3.0
davidedmonds/darkstar
scripts/zones/Port_Jeuno/npcs/Shami.lua
17
18330
----------------------------------- -- Area: Port Jeuno -- NPC: Shami -- Orb Seller (BCNM) -- @pos -14 8 44 246 ----------------------------------- package.loaded["scripts/zones/Port_Jeuno/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/quests"); require("scripts/zones/Port_Jeuno/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) local NumberItem = trade:getItemCount(); local BeastmensSeal = player:getSeals(0); local KindredsSeal = player:getSeals(1); local KindredsCrest = player:getSeals(2); local HighKindredsCrest = player:getSeals(3); local SacredKindredsCrest = player:getSeals(4); ---------------------------------------------------------------------------------------------------------------------------- -------- Trading Seals/Crests to Shami ------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------- if (trade:hasItemQty(1126,NumberItem) and trade:getItemCount() == NumberItem) then player:startEvent(0x0141,0,BeastmensSeal + NumberItem); -- Giving Shami Beastmen's Seal player:addSeals(NumberItem,0); player:tradeComplete(trade); elseif (trade:hasItemQty(1127,NumberItem) and trade:getItemCount() == NumberItem) then player:startEvent(0x0141,1,KindredsSeal + NumberItem); -- Giving Shami Kindred's Seal player:addSeals(NumberItem,1); player:tradeComplete(trade); elseif (trade:hasItemQty(2955,NumberItem) and trade:getItemCount() == NumberItem) then player:startEvent(0x0141,2,KindredsCrest + NumberItem); -- Giving Shami Kindred's Crest player:addSeals(NumberItem,2); player:tradeComplete(trade); elseif (trade:hasItemQty(2956,NumberItem) and trade:getItemCount() == NumberItem) then player:startEvent(0x0141,3,HighKindredsCrest + NumberItem); -- Giving Shami High Kindred's Crest player:addSeals(NumberItem,3); player:tradeComplete(trade); elseif (trade:hasItemQty(2957,NumberItem) and trade:getItemCount() == NumberItem) then player:startEvent(0x0141,3,SacredKindredsCrest + NumberItem); -- Giving Shami High Kindred's Crest player:addSeals(NumberItem,4); player:tradeComplete(trade); ---------------------------------------------------------------------------------------------------------------------------- -------- Trading Cracked BCNM Orbs or checking where you can bring the Orb ------------------------------------------------ ---------------------------------------------------------------------------------------------------------------------------- elseif (trade:hasItemQty(1551,1) and NumberItem == 1) then if (player:getVar("CloudyOrbIsCracked") == 1) then player:startEvent(0x0016); -- Cloudy Orb is Cracked player:setVar("CloudyOrbIsCracked",0); else player:startEvent(0x0005); -- Cloudy Orb is ok, List where you can take the orb. end elseif (trade:hasItemQty(1552,1) and NumberItem == 1) then if (player:getVar("SkyOrbIsCracked") == 1) then player:startEvent(0x0016); -- Sky Orb is Cracked player:setVar("SkyOrbIsCracked",0); else player:startEvent(0x0009); -- Sky Orb is ok, List where you can take the orb. end elseif (trade:hasItemQty(1131,1) and NumberItem == 1) then if (player:getVar("StarOrbIsCracked") == 1) then player:startEvent(0x0016); -- Star Orb is Cracked player:setVar("StarOrbIsCracked",0); else player:startEvent(0x0009); -- Star Orb is ok, List where you can take the orb. end elseif (trade:hasItemQty(1177,1) and NumberItem == 1) then if (player:getVar("CometOrbIsCracked") == 1) then player:startEvent(0x0016); -- Comet Orb is Cracked player:setVar("CometOrbIsCracked",0); else player:startEvent(0x0009); -- Comet Orb is ok, List where you can take the orb. end elseif (trade:hasItemQty(1130,1) and NumberItem == 1) then if (player:getVar("MoonOrbIsCracked") == 1) then player:startEvent(0x0016); -- Moon Orb is Cracked player:setVar("MoonOrbIsCracked",0); else player:startEvent(0x0009); -- Moon Orb is ok, List where you can take the orb. end ---------------------------------------------------------------------------------------------------------------------------- -------- Trading Cracked KSNM Orbs or checking where you can bring the Orb ------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------- elseif (trade:hasItemQty(1180,1) and NumberItem == 1) then if (player:getVar("AtroposOrbIsCracked") == 1) then player:startEvent(0x0016); -- Atropos Orb is Cracked player:setVar("AtroposOrbIsCracked",0); else player:startEvent(0x0009); -- Atropos Orb is ok, List where you can take the orb. end elseif (trade:hasItemQty(1175,1) and NumberItem == 1) then if (player:getVar("ClothoOrbIsCracked") == 1) then player:startEvent(0x0016); -- Clotho Orb is Cracked player:setVar("ClothoOrbIsCracked",0); else player:startEvent(0x0009); -- Clotho Orb is ok, List where you can take the orb. end elseif (trade:hasItemQty(1178,1) and NumberItem == 1) then if (player:getVar("LachesisOrbIsCracked") == 1) then player:startEvent(0x0016) -- Lachesis Orb is Cracked player:setVar("LachesisOrbIsCracked",0); else player:startEvent(0x0009); -- Lachesis Orb is ok, List where you can take the orb. end elseif (trade:hasItemQty(1553,1) and NumberItem == 1) then if (player:getVar("ThemisOrbIsCracked") == 1) then player:startEvent(0x0016); -- Themis Orb is Cracked player:setVar("ThemisOrbIsCracked",0); else player:startEvent(0x000b); -- Themis Orb is ok, List where you can take the orb. end -- TODO : Add in trade-in for cracked Kindred Crest orbs (and High Kindred Crest) and find cutscene that tells you where you can bring it end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local oldBeastmensSeal = player:getVar("ShamiBeastmensSeal"); local oldKindredsSeal = player:getVar("ShamiKindredsSeal"); local oldKindredsCrest = player:getVar("ShamiKindredsCrest"); local oldHighKindredsCrest = player:getVar("ShamiHighKindredsCrest"); local BeastmensSeal = player:getSeals(0); local KindredsSeal = player:getSeals(1); local KindredsCrest = player:getSeals(2); local HighKindredsCrest = player:getSeals(3); local SacredKindredsCrest = player:getSeals(4); local WildcatJeuno = player:getVar("WildcatJeuno"); if (oldBeastmensSeal > 0) then player:addSeals(oldBeastmensSeal,0); player:setVar("ShamiBeastmensSeal",0); end if (oldKindredsSeal > 0) then player:addSeals(oldKindredsSeal,1); player:setVar("ShamiKindredsSeal",0); end if (oldKindredsCrest > 0) then player:addSeals(oldKindredsCrest,2); player:setVar("ShamiKindredsCrest",0); end if (oldHighKindredsCrest > 0) then player:addSeals(oldHighKindredsCrest,3); player:setVar("ShamiHighKindredsCrest",0); end -- TODO: player:startEvent(0x0142,0,0,0,0,1,0,1) -- First time talking to him WITH beastmen seal in inventory if (player:getQuestStatus(JEUNO,LURE_OF_THE_WILDCAT_JEUNO) == QUEST_ACCEPTED and player:getMaskBit(WildcatJeuno,17) == false) then player:startEvent(317); elseif (BeastmensSeal + KindredsSeal + KindredsCrest + HighKindredsCrest == 0) then player:startEvent(0x0017); -- Standard dialog ? else player:startEvent(0x0142,(KindredsSeal * 65536) + BeastmensSeal,(HighKindredsCrest * 65536) + KindredsCrest,SacredKindredsCrest,0,1,0,0); -- Standard dialog with menu end end; -- 0x0032 : 30 sceau conférie : choix entre clotho et lachésis -- 0x0018 : Après achat d'un orb (qu'bia, yughott, palborough, giddeus) -- 0x0008 : Après achat d'un orb (yughott, palborough, giddeus, qu'bia, ghelsba) -- 0x0004 : Après achat d'un orb (yughott, palborough, giddeus, ghelsba) -- 0x000a : Après achat d'un orb (yughott, palborough, giddeus) -- 0x0009 : Trade d'un orb ? (yughott, palborough, giddeus, ghelsba) -- 0x0005 : Trade d'un orb ? (yughott, palborough, giddeus, ghelsba) -- 0x000b : Trade d'un orb ? (yughott, palborough, giddeus) -- 0x001a : Trade d'un orb ? (qu'bia, yughott, palborough, giddeus) -- 0x001b : Trade d'un orb ? (qu'bia, chambre des oracles) -- 0x0016 : Trade d'un orb utilisé (il le recup) -- 0x0019 : Un seul échange autorisé par semaine -- 0x0141 : trade sceau + nombre player:startEvent(0x0141,0,15); -- 0 shbete, 1 s-confrerie, 2 s-demons, 3 s-seigneurdes hombre ----------------------------------- -- 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 BeastmensSeal = player:getSeals(0); local KindredsSeal = player:getSeals(1); local KindredsCrest = player:getSeals(2); local HighKindredsCrest = player:getSeals(3); local SacredKindredsCrest = player:getSeals(4); if (csid == 0x0016) then -- Player gave Shami a cracked orb player:tradeComplete(); elseif (option >= 508 and option ~= 1073741824) then -- Player has asked to retrieve seals (1073741824 means someone hit escape during cutscene, don't remove this or people will get free seals) local takingSealCount = 0; if ((option + 2)% 256 == 0) then if (player:getFreeSlotsCount() >=1) then takingSealCount = (option + 2)/256 - 1; -- Every seal requested adds 256 to the option value. The lowest is one seal which sets the option to 510, two seals would be 510 + 256. etc player:delSeals(takingSealCount,0); player:addItem(1126,takingSealCount); player:messageSpecial(ITEM_OBTAINED,1126); else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,1126); end elseif ((option + 1)% 256 == 0) then if (player:getFreeSlotsCount() >=1) then takingSealCount = (option + 1)/256 - 1; -- Every seal requested adds 256 to the option value. The lowest is one seal which sets the option to 511, two seals would be 511 + 256. etc player:delSeals(takingSealCount,1); player:addItem(1127,takingSealCount); player:messageSpecial(ITEM_OBTAINED,1127); else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,1127); end elseif ((option + 3)% 256 == 0) then if (player:getFreeSlotsCount() >=1) then takingSealCount = (option + 3)/256 - 1; -- Every seal requested adds 256 to the option value. The lowest is one seal which sets the option to 509, two seals would be 509 + 256. etc player:delSeals(takingSealCount,2); player:addItem(2955,takingSealCount); player:messageSpecial(ITEM_OBTAINED,2955); else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,2955); end elseif ((option + 4)% 256 == 0) then if (player:getFreeSlotsCount() >=1) then takingSealCount = (option + 4)/256 - 1; -- Every seal requested adds 256 to the option value. The lowest is one seal which sets the option to 508, two seals would be 508 + 256. etc player:delSeals(takingSealCount,3); player:addItem(2956,takingSealCount); player:messageSpecial(ITEM_OBTAINED,2956); else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,2956); end elseif ((option + 5)% 256 == 0) then if (player:getFreeSlotsCount() >=1) then takingSealCount = (option + 5)/256 - 1; -- Every seal requested adds 256 to the option value. The lowest is one seal which sets the option to 508, two seals would be 508 + 256. etc player:delSeals(takingSealCount,4); player:addItem(2957,takingSealCount); player:messageSpecial(ITEM_OBTAINED,2957); else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,2957); end end ---------------------------------------------------------------------------------------------------------------------------- -------- Begin BCNM orb Handout -------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------- elseif (csid == 0x0142) then if (option == 1 and BeastmensSeal >= 20) then -- Player asked for Cloudy orb if (player:getFreeSlotsCount() >= 1 and player:hasItem(1551) == false) then player:delSeals(20,0); player:addItem(1551); player:messageSpecial(ITEM_OBTAINED,1551); player:setVar("CloudyOrbIsCracked",0); elseif (player:hasItem(1551)) then player:addItem(1551); -- does not add the item but forces it to send the "you cannot carry anymore of these" message. else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,1551); end elseif (option == 2 and BeastmensSeal >= 30) then -- Player asked for Sky orb if (player:getFreeSlotsCount() >= 1 and player:hasItem(1552) == false) then player:delSeals(30,0); player:addItem(1552); player:messageSpecial(ITEM_OBTAINED,1552); player:setVar("SkyOrbIsCracked",0); elseif (player:hasItem(1552)) then player:addItem(1552); -- does not add the item but forces it to send the "you cannot carry anymore of these" message. else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,1552); end elseif (option == 3 and BeastmensSeal >= 40) then -- Player asked for Star orb if (player:getFreeSlotsCount() >= 1 and player:hasItem(1131) == false) then player:delSeals(40,0); player:addItem(1131); player:messageSpecial(ITEM_OBTAINED,1131); player:setVar("StarOrbIsCracked",0); elseif (player:hasItem(1131) == true) then player:addItem(1131); -- does not add the item but forces it to send the "you cannot carry anymore of these" message. else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,1131); end elseif (option == 4 and BeastmensSeal >= 50) then -- Player asked for Comet orb if (player:getFreeSlotsCount() >= 1 and player:hasItem(1177) == false) then player:delSeals(50,0); player:addItem(1177); player:messageSpecial(ITEM_OBTAINED,1177); player:setVar("CometOrbIsCracked",0); elseif (player:hasItem(1177)) then player:addItem(1177); -- does not add the item but forces it to send the "you cannot carry anymore of these" message. else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,1177); end elseif (option == 5 and BeastmensSeal >= 60) then -- Player asked for Moon orb if (player:getFreeSlotsCount() >= 1 and player:hasItem(1130) == false) then player:delSeals(60,0); player:addItem(1130); player:messageSpecial(ITEM_OBTAINED,1130); player:setVar("MoonOrbIsCracked",0); elseif (player:hasItem(1130)) then player:addItem(1130); -- does not add the item but forces it to send the "you cannot carry anymore of these" message. else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,1130); end ---------------------------------------------------------------------------------------------------------------------------- -------- Begin KSNM orb Handout -------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------- elseif (option == 6 and KindredsSeal >= 30) then -- Player asked for Clotho Orb if (player:getFreeSlotsCount() >= 1 and player:hasItem(1175) == false) then player:delSeals(30,1); player:addItem(1175); player:messageSpecial(ITEM_OBTAINED,1175); player:setVar("ClothoOrbIsCracked",0); elseif (player:hasItem(1175)) then player:addItem(1175); -- does not add the item but forces it to send the "you cannot carry anymore of these" message. else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,1175); end elseif (option == 7 and KindredsSeal >= 30) then -- Player asked for Lachesis Orb if (player:getFreeSlotsCount() >= 1 and player:hasItem(1178) == false) then player:delSeals(30,1); player:addItem(1178); player:messageSpecial(ITEM_OBTAINED,1178); player:setVar("LachesisOrbIsCracked",0); elseif (player:hasItem(1178) == true) then player:addItem(1178); -- does not add the item but forces it to send the "you cannot carry anymore of these" message. else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,1178); end elseif (option == 8 and KindredsSeal >= 30) then -- Player asked for Atropos Orb if (player:getFreeSlotsCount() >= 1 and player:hasItem(1180) == false) then player:delSeals(30,1); player:addItem(1180); player:messageSpecial(ITEM_OBTAINED,1180); player:setVar("AtroposOrbIsCracked",0); elseif (player:hasItem(1180)) then player:addItem(1180); -- does not add the item but forces it to send the "you cannot carry anymore of these" message. else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,1180); end elseif (option == 9 and KindredsSeal >= 99) then -- Player asked for Themis Orb if (player:getFreeSlotsCount() >= 1 and player:hasItem(1553) == false) then player:delSeals(99,1); player:addItem(1553); player:messageSpecial(ITEM_OBTAINED,1553); player:setVar("ThemisOrbIsCracked",0); elseif (player:hasItem(1553)) then player:addItem(1553); -- does not add the item but forces it to send the "you cannot carry anymore of these" message. else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,1553); end end -- TODO : Add in orbs for Kindred Crest exhcange (and High Kindred Crest) and find cutscene that tells you where you can bring it. elseif (csid == 317) then player:setMaskBit(player:getVar("WildcatJeuno"),"WildcatJeuno",17,true); end end;
gpl-3.0
idontalwaysnotlie/NeverEndingTD
game/dota_addons/NETD/scripts/vscripts/util.lua
2
13913
-- GREAT UTILITY FUNCTIONS -- The commented out functions are already integrated in buildinghelper.lua -- Returns a shallow copy of the passed table. --[[function shallowcopy(orig) local orig_type = type(orig) local copy if orig_type == 'table' then copy = {} for orig_key, orig_value in pairs(orig) do copy[orig_key] = orig_value end else -- number, string, boolean, etc copy = orig end return copy end function AbilityIterator(unit, callback) for i=0, unit:GetAbilityCount()-1 do local abil = unit:GetAbilityByIndex(i) if abil ~= nil then callback(abil) end end end function string.starts(String,Start) return string.sub(String,1,string.len(Start))==Start end function string.ends(String,End) return End=='' or string.sub(String,-string.len(End))==End end function VectorString(v) return 'x: ' .. v.x .. ' y: ' .. v.y .. ' z: ' .. v.z end function TableLength( t ) if t == nil or t == {} then return 0 end local len = 0 for k,v in pairs(t) do len = len + 1 end return len end ]] -- Remove all abilities on a unit. function ClearAbilities( unit ) for i=0, unit:GetAbilityCount()-1 do local abil = unit:GetAbilityByIndex(i) if abil ~= nil then unit:RemoveAbility(abil:GetAbilityName()) end end -- we have to put in dummies and remove dummies so the ability icon changes. -- it's stupid but volvo made us for i=1,6 do unit:AddAbility("samplerts_empty" .. tostring(i)) end for i=0, unit:GetAbilityCount()-1 do local abil = unit:GetAbilityByIndex(i) if abil ~= nil then unit:RemoveAbility(abil:GetAbilityName()) end end end -- goes through a unit's abilities and sets the abil's level to 1, -- spending an ability point if possible. function InitAbilities( hero ) for i=0, hero:GetAbilityCount()-1 do local abil = hero:GetAbilityByIndex(i) if abil ~= nil then if hero:IsHero() and hero:GetAbilityPoints() > 0 then hero:UpgradeAbility(abil) else abil:SetLevel(1) end end end end -- adds ability to a unit, sets the level to 1, then returns ability handle. function AddAbilityToUnit(unit, abilName) if not unit:HasAbility(abilName) then unit:AddAbility(abilName) end local abil = unit:FindAbilityByName(abilName) abil:SetLevel(1) return abil end function GetOppositeTeam( unit ) if unit:GetTeam() == DOTA_TEAM_GOODGUYS then return DOTA_TEAM_BADGUYS else return DOTA_TEAM_GOODGUYS end end -- returns true 50% of the time. function CoinFlip( ) return RollPercentage(50) end -- theta is in radians. function RotateVector2D(v,theta) local xp = v.x*math.cos(theta)-v.y*math.sin(theta) local yp = v.x*math.sin(theta)+v.y*math.cos(theta) return Vector(xp,yp,v.z):Normalized() end function PrintVector(v) print('x: ' .. v.x .. ' y: ' .. v.y .. ' z: ' .. v.z) end -- Given element and list, returns true if element is in the list. function TableContains( list, element ) if list == nil then return false end for k,v in pairs(list) do if k == element then return true end end return false end -- Given element and list, returns the position of the element in the list. -- Returns -1 if element was not found, or if list is nil. function GetIndex(list, element) if list == nil then return -1 end for i=1,#list do if list[i] == element then return i end end return -1 end -- useful with GameRules:SendCustomMessage function ColorIt( sStr, sColor ) if sStr == nil or sColor == nil then return end --Default is cyan. local color = "00FFFF" if sColor == "green" then color = "ADFF2F" elseif sColor == "purple" then color = "EE82EE" elseif sColor == "blue" then color = "00BFFF" elseif sColor == "orange" then color = "FFA500" elseif sColor == "pink" then color = "DDA0DD" elseif sColor == "red" then color = "FF6347" elseif sColor == "cyan" then color = "00FFFF" elseif sColor == "yellow" then color = "FFFF00" elseif sColor == "brown" then color = "A52A2A" elseif sColor == "magenta" then color = "FF00FF" elseif sColor == "teal" then color = "008080" end return "<font color='#" .. color .. "'>" .. sStr .. "</font>" end --[[ p: the raw point (Vector) center: center of the square. (Vector) length: length of 1 side of square. (Float) ]] function IsPointWithinSquare(p, center, length) if (p.x > center.x-length and p.x < center.x+length) and (p.y > center.y-length and p.y < center.y+length) then return true else return false end end --[[ Continuous collision algorithm for circular 2D bodies, see http://www.gvu.gatech.edu/people/official/jarek/graphics/material/collisionFitzgeraldForsthoefel.pdf body1 and body2 are tables that contain: v: velocity (Vector) c: center (Vector) r: radius (Float) Returns the time-till-collision. ]] function TimeTillCollision(body1,body2) local W = body2.v-body1.v local D = body2.c-body1.c local A = DotProduct(W,W) local B = 2*DotProduct(D,W) local C = DotProduct(D,D)-(body1.r+body2.r)*(body1.r+body2.r) local d = B*B-(4*A*C) if d>=0 then local t1=(-B-math.sqrt(d))/(2*A) if t1<0 then t1=2 end local t2=(-B+math.sqrt(d))/(2*A) if t2<0 then t2=2 end local m = math.min(t1,t2) --if ((-0.02<=m) and (m<=1.02)) then return m --end end return 2 end function DotProduct(v1,v2) return (v1.x*v2.x)+(v1.y*v2.y) end function PrintTable(t, indent, done) --print ( string.format ('PrintTable type %s', type(keys)) ) if type(t) ~= "table" then return end done = done or {} done[t] = true indent = indent or 0 local l = {} for k, v in pairs(t) do table.insert(l, k) end table.sort(l) for k, v in ipairs(l) do -- Ignore FDesc if v ~= 'FDesc' then local value = t[v] if type(value) == "table" and not done[value] then done [value] = true print(string.rep ("\t", indent)..tostring(v)..":") PrintTable (value, indent + 2, done) elseif type(value) == "userdata" and not done[value] then done [value] = true print(string.rep ("\t", indent)..tostring(v)..": "..tostring(value)) PrintTable ((getmetatable(value) and getmetatable(value).__index) or getmetatable(value), indent + 2, done) else if t.FDesc and t.FDesc[v] then print(string.rep ("\t", indent)..tostring(t.FDesc[v])) else print(string.rep ("\t", indent)..tostring(v)..": "..tostring(value)) end end end end end -- Colors COLOR_NONE = '\x06' COLOR_GRAY = '\x06' COLOR_GREY = '\x06' COLOR_GREEN = '\x0C' COLOR_DPURPLE = '\x0D' COLOR_SPINK = '\x0E' COLOR_DYELLOW = '\x10' COLOR_PINK = '\x11' COLOR_RED = '\x12' COLOR_LGREEN = '\x15' COLOR_BLUE = '\x16' COLOR_DGREEN = '\x18' COLOR_SBLUE = '\x19' COLOR_PURPLE = '\x1A' COLOR_ORANGE = '\x1B' COLOR_LRED = '\x1C' COLOR_GOLD = '\x1D' --============ Copyright (c) Valve Corporation, All rights reserved. ========== -- -- --============================================================================= --///////////////////////////////////////////////////////////////////////////// -- Debug helpers -- -- Things that are really for during development - you really should never call any of this -- in final/real/workshop submitted code --///////////////////////////////////////////////////////////////////////////// -- if you want a table printed to console formatted like a table (dont we already have this somewhere?) scripthelp_LogDeepPrintTable = "Print out a table (and subtables) to the console" logFile = "log/log.txt" function LogDeepSetLogFile( file ) logFile = file end function LogEndLine ( line ) AppendToLogFile(logFile, line .. "\n") end function _LogDeepPrintMetaTable( debugMetaTable, prefix ) _LogDeepPrintTable( debugMetaTable, prefix, false, false ) if getmetatable( debugMetaTable ) ~= nil and getmetatable( debugMetaTable ).__index ~= nil then _LogDeepPrintMetaTable( getmetatable( debugMetaTable ).__index, prefix ) end end function _LogDeepPrintTable(debugInstance, prefix, isOuterScope, chaseMetaTables ) prefix = prefix or "" local string_accum = "" if debugInstance == nil then LogEndLine( prefix .. "<nil>" ) return end local terminatescope = false local oldPrefix = "" if isOuterScope then -- special case for outer call - so we dont end up iterating strings, basically if type(debugInstance) == "table" then LogEndLine( prefix .. "{" ) oldPrefix = prefix prefix = prefix .. " " terminatescope = true else LogEndLine( prefix .. " = " .. (type(debugInstance) == "string" and ("\"" .. debugInstance .. "\"") or debugInstance)) end end local debugOver = debugInstance -- First deal with metatables if chaseMetaTables == true then if getmetatable( debugOver ) ~= nil and getmetatable( debugOver ).__index ~= nil then local thisMetaTable = getmetatable( debugOver ).__index if vlua.find(_LogDeepprint_alreadyseen, thisMetaTable ) ~= nil then LogEndLine( string.format( "%s%-32s\t= %s (table, already seen)", prefix, "metatable", tostring( thisMetaTable ) ) ) else LogEndLine(prefix .. "metatable = " .. tostring( thisMetaTable ) ) LogEndLine(prefix .. "{") table.insert( _LogDeepprint_alreadyseen, thisMetaTable ) _LogDeepPrintMetaTable( thisMetaTable, prefix .. " ", false ) LogEndLine(prefix .. "}") end end end -- Now deal with the elements themselves -- debugOver sometimes a string?? for idx, data_value in pairs(debugOver) do if type(data_value) == "table" then if vlua.find(_LogDeepprint_alreadyseen, data_value) ~= nil then LogEndLine( string.format( "%s%-32s\t= %s (table, already seen)", prefix, idx, tostring( data_value ) ) ) else local is_array = #data_value > 0 local test = 1 for idx2, val2 in pairs(data_value) do if type( idx2 ) ~= "number" or idx2 ~= test then is_array = false break end test = test + 1 end local valtype = type(data_value) if is_array == true then valtype = "array table" end LogEndLine( string.format( "%s%-32s\t= %s (%s)", prefix, idx, tostring(data_value), valtype ) ) LogEndLine(prefix .. (is_array and "[" or "{")) table.insert(_LogDeepprint_alreadyseen, data_value) _LogDeepPrintTable(data_value, prefix .. " ", false, true) LogEndLine(prefix .. (is_array and "]" or "}")) end elseif type(data_value) == "string" then LogEndLine( string.format( "%s%-32s\t= \"%s\" (%s)", prefix, idx, data_value, type(data_value) ) ) else LogEndLine( string.format( "%s%-32s\t= %s (%s)", prefix, idx, tostring(data_value), type(data_value) ) ) end end if terminatescope == true then LogEndLine( oldPrefix .. "}" ) end end function LogDeepPrintTable( debugInstance, prefix, isPublicScriptScope ) prefix = prefix or "" _LogDeepprint_alreadyseen = {} table.insert(_LogDeepprint_alreadyseen, debugInstance) _LogDeepPrintTable(debugInstance, prefix, true, isPublicScriptScope ) end --///////////////////////////////////////////////////////////////////////////// -- Fancy new LogDeepPrint - handles instances, and avoids cycles -- --///////////////////////////////////////////////////////////////////////////// -- @todo: this is hideous, there must be a "right way" to do this, im dumb! -- outside the recursion table of seen recurses so we dont cycle into our components that refer back to ourselves _LogDeepprint_alreadyseen = {} -- the inner recursion for the LogDeep print function _LogDeepToString(debugInstance, prefix) local string_accum = "" if debugInstance == nil then return "LogDeep Print of NULL" .. "\n" end if prefix == "" then -- special case for outer call - so we dont end up iterating strings, basically if type(debugInstance) == "table" or type(debugInstance) == "table" or type(debugInstance) == "UNKNOWN" or type(debugInstance) == "table" then string_accum = string_accum .. (type(debugInstance) == "table" and "[" or "{") .. "\n" prefix = " " else return " = " .. (type(debugInstance) == "string" and ("\"" .. debugInstance .. "\"") or debugInstance) .. "\n" end end local debugOver = type(debugInstance) == "UNKNOWN" and getclass(debugInstance) or debugInstance for idx, val in pairs(debugOver) do local data_value = debugInstance[idx] if type(data_value) == "table" or type(data_value) == "table" or type(data_value) == "UNKNOWN" or type(data_value) == "table" then if vlua.find(_LogDeepprint_alreadyseen, data_value) ~= nil then string_accum = string_accum .. prefix .. idx .. " ALREADY SEEN " .. "\n" else local is_array = type(data_value) == "table" string_accum = string_accum .. prefix .. idx .. " = ( " .. type(data_value) .. " )" .. "\n" string_accum = string_accum .. prefix .. (is_array and "[" or "{") .. "\n" table.insert(_LogDeepprint_alreadyseen, data_value) string_accum = string_accum .. _LogDeepToString(data_value, prefix .. " ") string_accum = string_accum .. prefix .. (is_array and "]" or "}") .. "\n" end else --string_accum = string_accum .. prefix .. idx .. "\t= " .. (type(data_value) == "string" and ("\"" .. data_value .. "\"") or data_value) .. "\n" string_accum = string_accum .. prefix .. idx .. "\t= " .. "\"" .. tostring(data_value) .. "\"" .. "\n" end end if prefix == " " then string_accum = string_accum .. (type(debugInstance) == "table" and "]" or "}") .. "\n" -- hack for "proving" at end - this is DUMB! end return string_accum end scripthelp_LogDeepString = "Convert a class/array/instance/table to a string" function LogDeepToString(debugInstance, prefix) prefix = prefix or "" _LogDeepprint_alreadyseen = {} table.insert(_LogDeepprint_alreadyseen, debugInstance) return _LogDeepToString(debugInstance, prefix) end scripthelp_LogDeepPrint = "Print out a class/array/instance/table to the console" function LogDeepPrint(debugInstance, prefix) prefix = prefix or "" LogEndLine(LogDeepToString(debugInstance, prefix)) end
gpl-2.0
davidedmonds/darkstar
scripts/globals/mobskills/Laser_Shower.lua
14
1190
--------------------------------------------- -- Laser_Shower -- -- Description: Deals Darkness damage to enemies within a fan-shaped area. -- Type: Breath -- Utsusemi/Blink absorb: Ignores shadows -- Range: Unknown cone -- Notes: --------------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/monstertpmoves"); require("scripts/globals/utils"); --------------------------------------------- function onMobSkillCheck(target,mob,skill) local mobID = mob:getID(); --(16908294 ,16908301 ,16908308 =omega ,16933124=proto-omega) local mobhp = mob:getHPP(); if (mobID == 16933124 and mobhp < 30 ) then -- omega second quadripedform return 0; end return 1; end; function onMobWeaponSkill(target, mob, skill) local dmgmod = MobBreathMove(mob, target, 0.2, 1.25, ELE_DARK, 1600); local dis = ((mob:checkDistance(target)*2) / 20); dmgmod = dmgmod * dis; utils.clamp(dmgmod, 50, 1600); local dmg = MobFinalAdjustments(dmgmod,mob,skill,target,MOBSKILL_BREATH,MOBPARAM_DARK,MOBPARAM_IGNORE_SHADOWS); target:delHP(dmg); return dmg; end;
gpl-3.0
kidaa/darkstar
scripts/zones/Apollyon/mobs/Water_Elemental.lua
119
2423
----------------------------------- -- Area: Apollyon SW -- NPC: elemental ----------------------------------- package.loaded["scripts/zones/Apollyon/TextIDs"] = nil; ----------------------------------- require("scripts/globals/limbus"); require("scripts/zones/Apollyon/TextIDs"); ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) end; ----------------------------------- -- onMobEngaged ----------------------------------- function onMobEngaged(mob,target) end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob,killer) local mobID = mob:getID(); -- print(mobID); local mobX = mob:getXPos(); local mobY = mob:getYPos(); local mobZ = mob:getZPos(); local elementalday = GetServerVariable("[SW_Apollyon]ElementalTrigger") - 1; local correctelement=false; switch (elementalday): caseof { [0] = function (x) if(mobID==16932913 or mobID==16932921 or mobID==16932929)then correctelement=true; end end , [1] = function (x) if(mobID==16932912 or mobID==16932920 or mobID==16932928 )then correctelement=true; end end , [2] = function (x) if(mobID==16932916 or mobID==16932924 or mobID==16932932 )then correctelement=true; end end , [3] = function (x) if(mobID==16932910 or mobID==16932918 or mobID==16932926 )then correctelement=true; end end , [4] = function (x) if(mobID==16932914 or mobID==16932922 or mobID==16932930 )then correctelement=true; end end , [5] = function (x) if(mobID==16932917 or mobID==16932925 or mobID==16932933 )then correctelement=true; end end , [6] = function (x) if(mobID==16932931 or mobID==16932915 or mobID==16932923 )then correctelement=true; end end , [7] = function (x) if(mobID==16932911 or mobID==16932919 or mobID==16932927 )then correctelement=true; end end , }; if(correctelement==true and IselementalDayAreDead()==true)then GetNPCByID(16932864+313):setPos(mobX,mobY,mobZ); GetNPCByID(16932864+313):setStatus(STATUS_NORMAL); end end;
gpl-3.0
NewbProgrammer101/Lord-of-the-Test
mods/lottpotion/potionbrewing.lua
2
12894
-- Base Ingredients minetest.register_node("lottpotion:glass_bottle_mese", { description = "Glass Bottle (Mese Water)", drawtype = "plantlike", tiles = {"vessels_glass_bottle.png^lottpotion_water_mese.png"}, inventory_image = "vessels_glass_bottle_inv.png^lottpotion_water_mese.png", wield_image = "vessels_glass_bottle_inv.png^lottpotion_water_mese.png", paramtype = "light", walkable = false, selection_box = { type = "fixed", fixed = {-0.25, -0.5, -0.25, 0.25, 0.4, 0.25} }, groups = {vessel=1,dig_immediate=3,attached_node=1}, sounds = default.node_sound_glass_defaults(), }) minetest.register_node("lottpotion:glass_bottle_geodes", { description = "Glass Bottle (Geodes Crystal Water)", drawtype = "plantlike", tiles = {"vessels_glass_bottle.png^lottpotion_water_geodes.png"}, inventory_image = "vessels_glass_bottle_inv.png^lottpotion_water_geodes.png", wield_image = "vessels_glass_bottle_inv.png^lottpotion_water_geodes.png", paramtype = "light", walkable = false, selection_box = { type = "fixed", fixed = {-0.25, -0.5, -0.25, 0.25, 0.4, 0.25} }, groups = {vessel=1,dig_immediate=3,attached_node=1}, sounds = default.node_sound_glass_defaults(), }) minetest.register_node("lottpotion:glass_bottle_seregon", { description = "Glass Bottle (Seregon Water)", drawtype = "plantlike", tiles = {"vessels_glass_bottle.png^lottpotion_water_seregon.png"}, inventory_image = "vessels_glass_bottle_inv.png^lottpotion_water_seregon.png", wield_image = "vessels_glass_bottle_inv.png^lottpotion_water_seregon.png", paramtype = "light", walkable = false, selection_box = { type = "fixed", fixed = {-0.25, -0.5, -0.25, 0.25, 0.4, 0.25} }, groups = {vessel=1,dig_immediate=3,attached_node=1}, sounds = default.node_sound_glass_defaults(), }) minetest.register_craft({ output = 'lottpotion:potion_brewer', recipe = { {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, {'', 'default:steel_ingot', ''}, {'group:stone', 'group:stone', 'group:stone'}, } }) lottpotion.potion_recipes = { cooking = { input_size = 1, output_size = 1 } } function lottpotion.register_recipe_type(typename, origdata) local data = {} for k, v in pairs(origdata) do data[k] = v end data.input_size = data.input_size or 1 data.output_size = data.output_size or 1 data.recipes = {} lottpotion.potion_recipes[typename] = data end local function get_recipe_index(items) local l = {} if items ~= nil then for i, stack in ipairs(items) do l[i] = ItemStack(stack):get_name() end end table.sort(l) return table.concat(l, "/") end local function register_recipe(typename, data) -- Handle aliases for i, stack in ipairs(data.input) do data.input[i] = ItemStack(stack):to_string() end if type(data.output) == "table" then for i, v in ipairs(data.output) do data.output[i] = ItemStack(data.output[i]):to_string() end else data.output = ItemStack(data.output):to_string() end local recipe = {time = data.time, input = {}, output = data.output} local index = get_recipe_index(data.input) for _, stack in ipairs(data.input) do recipe.input[ItemStack(stack):get_name()] = ItemStack(stack):get_count() end lottpotion.potion_recipes[typename].recipes[index] = recipe end function lottpotion.register_recipe(typename, data) minetest.after(0.01, register_recipe, typename, data) -- Handle aliases end function lottpotion.get_potion_recipe(typename, items) if typename == "cooking" then -- Already builtin in Minetest, so use that local result, new_input = minetest.get_craft_result({ method = "cooking", width = 1, items = items}) -- Compatibility layer if not result or result.time == 0 then return nil else return {time = result.time, new_input = new_input.items, output = result.item} end end local index = get_recipe_index(items) local recipe = lottpotion.potion_recipes[typename].recipes[index] if recipe then local new_input = {} for i, stack in ipairs(items) do if stack:get_count() < recipe.input[stack:get_name()] then return nil else new_input[i] = ItemStack(stack) new_input[i]:take_item(recipe.input[stack:get_name()]) end end return {time = recipe.time, new_input = new_input, output = recipe.output} else return nil end end lottpotion.register_recipe_type("potionbrew", { description = "Potion Brewing", input_size = 2, }) function lottpotion.register_potionbrew_recipe(data) data.time = data.time or 120 lottpotion.register_recipe("potionbrew", data) end local recipes = { --Base Potion {"lottplants:seregon", "lottpotion:glass_bottle_water", "lottpotion:glass_bottle_seregon"}, {"default:mese_crystal_fragment 1", "lottpotion:glass_bottle_water", "lottpotion:glass_bottle_mese"}, {"lottores:geodes_crystal_1", "lottpotion:glass_bottle_water", "lottpotion:glass_bottle_geodes"}, --Potions --Orc Draught {"lottmobs:meat_raw 5", "lottpotion:glass_bottle_seregon", "lottpotion:orcdraught_power1"}, {"lottmobs:meat_raw 5", "lottpotion:orcdraught_power1", "lottpotion:orcdraught_power2", 180}, {"lottmobs:meat_raw 5", "lottpotion:orcdraught_power2", "lottpotion:orcdraught_power3", 240}, --Spider Poison {"lottmobs:spiderpoison 2", "lottpotion:glass_bottle_seregon", "lottpotion:spiderpoison_power1"}, {"lottmobs:spiderpoison 2", "lottpotion:spiderpoison_power1", "lottpotion:spiderpoison_power2", 180}, {"lottmobs:spiderpoison 2", "lottpotion:spiderpoison_power2", "lottpotion:spiderpoison_power3", 240}, --Limpe {"lottplants:yavannamireleaf 10", "lottpotion:glass_bottle_mese", "lottpotion:limpe_power1"}, {"lottplants:yavannamireleaf 10", "lottpotion:limpe_power1", "lottpotion:limpe_power2", 180}, {"lottplants:yavannamireleaf 10", "lottpotion:limpe_power2", "lottpotion:limpe_power3", 240}, --Miruvor {"lottplants:yavannamirefruit 2", "lottpotion:glass_bottle_mese", "lottpotion:miruvor_power1"}, {"lottplants:yavannamirefruit 2", "lottpotion:miruvor_power1", "lottpotion:miruvor_power2", 180}, {"lottplants:yavannamirefruit 2", "lottpotion:miruvor_power2", "lottpotion:miruvor_power3", 240}, --Athelas Brew {"lottfarming:athelas 3", "lottpotion:glass_bottle_geodes", "lottpotion:athelasbrew_power1"}, {"lottfarming:athelas 3", "lottpotion:athelasbrew_power1", "lottpotion:athelasbrew_power2", 180}, {"lottfarming:athelas 3", "lottpotion:athelasbrew_power2", "lottpotion:athelasbrew_power3", 240}, --Ent Draught {"default:leaves 10", "lottpotion:glass_bottle_geodes", "lottpotion:entdraught_power1"}, {"default:leaves 10", "lottpotion:entdraught_power1", "lottpotion:entdraught_power2", 120}, {"default:leaves 10", "lottpotion:entdraught_power2", "lottpotion:entdraught_power3", 240}, } for _, data in pairs(recipes) do lottpotion.register_potionbrew_recipe({input = {data[1], data[2]}, output = data[3], time = data[4]}) end local machine_name = "Potion Brewer" local formspec = "size[8,9]".. "label[0,0;"..machine_name.."]".. "image[4,2;1,1;lottpotion_bubble_off.png]".. "image[3,2;1,1;lottpotion_arrow.png]".. "image[5,2;1,1;lottpotion_arrow.png]".. "label[3.2,3.2;Fuel:]".. "list[current_name;fuel;4,3;1,1;]".. "label[1,1.5;Ingredients:]".. "list[current_name;src;1,2;2,1;]".. "label[6,1.5;Result:]".. "list[current_name;dst;6,2;1,1;]".. "listring[current_name;src]".. "listring[current_player;main]".. "list[current_player;main;0,5;8,4;]" minetest.register_node("lottpotion:potion_brewer", { description = machine_name, drawtype = "plantlike", visual_scale = 1.0, tiles = {"lottpotion_potion_brewer.png"}, inventory_image = {"lottpotion_potion_brewer.png"}, wield_image = {"lottpotion_potion_brewer.png"}, paramtype = "light", sounds = default.node_sound_stone_defaults(), selection_box = { type = "fixed", fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3} }, groups = {cracky=2}, sounds = default.node_sound_stone_defaults(), on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("formspec", formspec) meta:set_string("infotext", machine_name) local inv = meta:get_inventory() inv:set_size("fuel", 1) inv:set_size("src", 2) inv:set_size("dst", 1) end, can_dig = lottpotion.can_dig, }) minetest.register_node("lottpotion:potion_brewer_active", { description = machine_name, drawtype = "plantlike", visual_scale = 1.0, tiles = {"lottpotion_potion_brewer_active.png"}, inventory_image = {"lottpotion_potion_brewer.png"}, wield_image = {"lottpotion_potion_brewer.png"}, paramtype = "light", light_source = 8, selection_box = { type = "fixed", fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3} }, drop = "lottpotion:potion_brewer", groups = {cracky=2, not_in_creative_inventory=1}, sounds = default.node_sound_stone_defaults(), can_dig = lottpotion.can_dig, }) minetest.register_abm({ nodenames = {"lottpotion:potion_brewer", "lottpotion:potion_brewer_active"}, interval = 1, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() if meta:get_string("infotext") == "" then local meta = minetest.get_meta(pos) meta:set_string("formspec", formspec) meta:set_string("infotext", machine_name) local inv = meta:get_inventory() inv:set_size("fuel", 1) inv:set_size("src", 2) inv:set_size("dst", 1) end if inv:get_size("src") == 1 then -- Old furnace -> convert it inv:set_size("src", 2) inv:set_stack("src", 2, inv:get_stack("src2", 1)) inv:set_size("src2", 0) end local recipe = nil for i, name in pairs({ "fuel_totaltime", "fuel_time", "src_totaltime", "src_time"}) do if not meta:get_float(name) then meta:set_float(name, 0.0) end end local result = lottpotion.get_potion_recipe("potionbrew", inv:get_list("src")) local was_active = false if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then was_active = true meta:set_int("fuel_time", meta:get_int("fuel_time") + 1) if result then meta:set_int("src_time", meta:get_int("src_time") + 1) if meta:get_int("src_time") >= result.time then meta:set_int("src_time", 0) local result_stack = ItemStack(result.output) if inv:room_for_item("dst", result_stack) then inv:set_list("src", result.new_input) inv:add_item("dst", result_stack) end end else meta:set_int("src_time", 0) end end if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then local percent = math.floor(meta:get_float("fuel_time") / meta:get_float("fuel_totaltime") * 100) meta:set_string("infotext", ("%s Brewing"):format(machine_name).." ("..percent.."%)") lottpotion.swap_node(pos, "lottpotion:potion_brewer_active") meta:set_string("formspec", "size[8,9]".. "label[0,0;"..machine_name.."]".. "image[4,2;1,1;lottpotion_bubble_off.png^[lowpart:".. (percent)..":lottpotion_bubble.png]".. "image[3,2;1,1;lottpotion_arrow.png]".. "image[5,2;1,1;lottpotion_arrow.png]".. "label[3.2,3.2;Fuel:]".. "list[current_name;fuel;4,3;1,1;]".. "label[1,1.5;Ingredients:]".. "list[current_name;src;1,2;2,1;]".. "label[6,1.5;Result:]".. "list[current_name;dst;6,2;1,1;]".. "list[current_player;main;0,5;8,4;]") return end local recipe = lottpotion.get_potion_recipe("potionbrew", inv:get_list("src")) if not recipe then if was_active then meta:set_string("infotext", ("%s is empty"):format(machine_name)) lottpotion.swap_node(pos, "lottpotion:potion_brewer") meta:set_string("formspec", formspec) end return end if not inv:room_for_item("dst", ItemStack(result.output)) then meta:set_string("infotext", ("%s Out Of Heat"):format(machine_name)) lottpotion.swap_node(pos, "lottpotion:potion_brewer") meta:set_string("formspec", formspec) return end local fuel = nil local afterfuel local fuellist = inv:get_list("fuel") if fuellist then fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist}) end if fuel.time <= 0 then meta:set_string("infotext", ("%s Out Of Heat"):format(machine_name)) lottpotion.swap_node(pos, "lottpotion:potion_brewer") meta:set_string("formspec", formspec) return end meta:set_string("fuel_totaltime", fuel.time) meta:set_string("fuel_time", 0) inv:set_stack("fuel", 1, afterfuel.items[1]) end, })
lgpl-2.1
MonokuroInzanaito/ygopro-777DIY
expansions/script/c33700120.lua
1
3399
--霓火城市 function c33700120.initial_effect(c) c:EnableCounterPermit(0x5) --activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_COUNTER) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetOperation(c33700120.activate) c:RegisterEffect(e1) --counter local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e2:SetCode(EVENT_TO_HAND) e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e2:SetRange(LOCATION_FZONE) e2:SetCondition(c33700120.ctcon) e2:SetOperation(c33700120.ctop) c:RegisterEffect(e2) -- local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(33700120,0)) e3:SetType(EFFECT_TYPE_QUICK_O) e3:SetCode(EVENT_CHAINING) e3:SetRange(LOCATION_FZONE) e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL) e3:SetCondition(c33700120.condition) e3:SetCost(c33700120.cost) e3:SetOperation(c33700120.operation) c:RegisterEffect(e3) -- local e4=Effect.CreateEffect(c) e4:SetCategory(CATEGORY_COUNTER) e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e4:SetCode(EVENT_TO_GRAVE) e4:SetTarget(c33700120.tg) e4:SetOperation(c33700120.op) c:RegisterEffect(e4) end function c33700120.filter(c) return c:GetCounter(0x5)>0 end function c33700120.activate(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local g=Duel.GetMatchingGroup(c33700120.filter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil) if g:GetCount()>0 then local ct local tg=g:GetFirst() while tg do if not tg:IsImmuneToEffect(e) then ct=ct+tg:GetCounter(0x5) Duel.RemoveCounter(tg,tp,0x5,tg:GetCounter(0x5),REASON_EFFECT) end tg=g:GetNext() end e:GetHandler():AddCounter(0x5,ct) end end function c33700120.cfilter(c,tp) return c:IsControler(tp) and c:IsPreviousLocation(LOCATION_DECK) end function c33700120.ctcon(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(c33700120.cfilter,1,nil,1-tp) end function c33700120.ctop(e,tp,eg,ep,ev,re,r,rp) e:GetHandler():AddCounter(0x5,1) end function c33700120.condition(e,tp,eg,ep,ev,re,r,rp) return ep==tp and re:IsActiveType(TYPE_MONSTER) and re:GetHandler():IsSetCard(0x443) and re:GetHandler():IsLocation(LOCATION_MZONE) end function c33700120.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():GetCounter(0x5)>0 end e:GetHandler():RemoveCounter(tp,0x5,1,REASON_COST) end function c33700120.activate(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local g=re:GetHandler() local e3=Effect.CreateEffect(e:GetHandler()) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetCode(EFFECT_CANNOT_DISEFFECT) e3:SetValue(1) e3:SetReset(RESET_EVENT+RESET_CHAIN) g:RegisterEffect(e3) --cannot disable local e4=Effect.CreateEffect(e:GetHandler()) e4:SetType(EFFECT_TYPE_SINGLE) e4:SetCode(EFFECT_CANNOT_DISABLE) e4:SetReset(RESET_EVENT+RESET_CHAIN) g:RegisterEffect(e4) end function c33700120.addfilter(c) return c:IsFaceup() and c:IsSetCard(0x443) end function c33700120.tg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c33700120.addfilter,tp,LOCATION_MZONE,0,1,nil) and e:GetHandler():GetCounter(0x5)>0 end end function c33700120.op(e,tp,eg,ep,ev,re,r,rp) local g=Duel.SelectMatchingCard(tp,c33700120.addfilter,tp,LOCATION_MZONE,0,1,1,nil) if g:GetCount()>0 then g:GetFirst():AddCounter(0x5,e:GetHandler():GetCounter(0x5)) end end
gpl-3.0
davidedmonds/darkstar
scripts/zones/Halvung/npcs/qm4.lua
19
1150
----------------------------------- -- Area: Halvung -- NPC: ??? (Spawn Achamoth(ZNM T3)) -- @pos -34 10 336 62 ----------------------------------- package.loaded["scripts/zones/Halvung/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Halvung/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if (trade:hasItemQty(2586,1) and trade:getItemCount() == 1) then -- Trade Rock Juice player:tradeComplete(); SpawnMob(17031600,180):updateClaim(player); 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
will4wachter/Project1
scripts/zones/Yorcia_Weald_U/Zone.lua
36
1119
----------------------------------- -- -- Zone: Yorcia Weald U -- ----------------------------------- require("scripts/globals/settings"); package.loaded["scripts/zones/Yorcia_Weald_U/TextIDs"] = nil; require("scripts/zones/Yorcia_Weald_U/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) cs = -1; return cs; end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
clark15b/xupnpd
src/plugins/xupnpd_generic.lua
2
1294
-- Copyright (C) 2011-2013 Anton Burdinuk -- clark15b@gmail.com -- https://tsdemuxer.googlecode.com/svn/trunk/xupnpd function generic_updatefeed(feed,friendly_name) local feed_name=string.match(feed,'.+/(.+).m3u$') if not feed_name then feed_name=string.gsub(friendly_name," ","_") end local feed_path=cfg.feeds_path..feed_name..'.m3u' local tmp_path=cfg.tmp_path..feed_name..'.m3u' if http.download(feed,tmp_path)<=0 then return false end if util.md5(tmp_path)~=util.md5(feed_path) then if os.execute(string.format('mv %s %s',tmp_path,feed_path))==0 then if cfg.debug>0 then print('feed \''..feed_name..'\' updated') end return true end else util.unlink(tmp_path) end return false end function generic_sendurl(generic_url,range) local rc,location location=generic_url for i=1,5,1 do rc,location=http.sendurl(location,1,range) if not location then break else if cfg.debug>0 then print('Redirect #'..i..' to: '..location) end end end end plugins['generic']={} plugins.generic.name="Generic" plugins.generic.desc="<i>m3u_url</i>" plugins.generic.sendurl=generic_sendurl plugins.generic.updatefeed=generic_updatefeed
gpl-2.0
will4wachter/Project1
scripts/zones/Windurst_Waters_[S]/npcs/Sahnn_Dhansett.lua
38
1054
----------------------------------- -- Area: Windurst Waters (S) -- NPC: Sahnn Dhansett -- Type: Standard NPC -- @zone: 94 -- @pos 112.820 -3.122 47.857 -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/Windurst_Waters_[S]/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x01a1); 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
failcoder/SVUI_-Core
_options/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua
1
56643
--- AceConfigDialog-3.0 generates AceGUI-3.0 based windows based on option tables. -- @class file -- @name AceConfigDialog-3.0 -- @release $Id: AceConfigDialog-3.0.lua 1089 2013-09-13 14:32:35Z nevcairiel $ local LibStub = LibStub local MAJOR, MINOR = "AceConfigDialog-3.0", 58 local AceConfigDialog, oldminor = LibStub:NewLibrary(MAJOR, MINOR) if not AceConfigDialog then return end AceConfigDialog.OpenFrames = AceConfigDialog.OpenFrames or {} AceConfigDialog.Status = AceConfigDialog.Status or {} AceConfigDialog.frame = AceConfigDialog.frame or CreateFrame("Frame") AceConfigDialog.frame.apps = AceConfigDialog.frame.apps or {} AceConfigDialog.frame.closing = AceConfigDialog.frame.closing or {} AceConfigDialog.frame.closeAllOverride = AceConfigDialog.frame.closeAllOverride or {} local gui = LibStub("AceGUI-3.0") local reg = LibStub("AceConfigRegistry-3.0") -- Lua APIs local tconcat, tinsert, tsort, tremove, tsort = table.concat, table.insert, table.sort, table.remove, table.sort local strmatch, format = string.match, string.format local assert, loadstring, error = assert, loadstring, error local pairs, next, select, type, unpack, wipe, ipairs = pairs, next, select, type, unpack, wipe, ipairs local rawset, tostring, tonumber = rawset, tostring, tonumber local math_min, math_max, math_floor = math.min, math.max, math.floor -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded -- List them here for Mikk's FindGlobals script -- GLOBALS: NORMAL_FONT_COLOR, GameTooltip, StaticPopupDialogs, ACCEPT, CANCEL, StaticPopup_Show -- GLOBALS: PlaySound, GameFontHighlight, GameFontHighlightSmall, GameFontHighlightLarge -- GLOBALS: CloseSpecialWindows, InterfaceOptions_AddCategory, geterrorhandler local emptyTbl = {} --[[ xpcall safecall implementation ]] local xpcall = xpcall local function errorhandler(err) return geterrorhandler()(err) end local function CreateDispatcher(argCount) local code = [[ local xpcall, eh = ... local method, ARGS local function call() return method(ARGS) end local function dispatch(func, ...) method = func if not method then return end ARGS = ... return xpcall(call, eh) end return dispatch ]] local ARGS = {} for i = 1, argCount do ARGS[i] = "arg"..i end code = code:gsub("ARGS", tconcat(ARGS, ", ")) return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler) end local Dispatchers = setmetatable({}, {__index=function(self, argCount) local dispatcher = CreateDispatcher(argCount) rawset(self, argCount, dispatcher) return dispatcher end}) Dispatchers[0] = function(func) return xpcall(func, errorhandler) end local function safecall(func, ...) return Dispatchers[select("#", ...)](func, ...) end local width_multiplier = 170 --[[ Group Types Tree - All Descendant Groups will all become nodes on the tree, direct child options will appear above the tree - Descendant Groups with inline=true and thier children will not become nodes Tab - Direct Child Groups will become tabs, direct child options will appear above the tab control - Grandchild groups will default to inline unless specified otherwise Select- Same as Tab but with entries in a dropdown rather than tabs Inline Groups - Will not become nodes of a select group, they will be effectivly part of thier parent group seperated by a border - If declared on a direct child of a root node of a select group, they will appear above the group container control - When a group is displayed inline, all descendants will also be inline members of the group ]] -- Recycling functions local new, del, copy --newcount, delcount,createdcount,cached = 0,0,0 do local pool = setmetatable({},{__mode="k"}) function new() --newcount = newcount + 1 local t = next(pool) if t then pool[t] = nil return t else --createdcount = createdcount + 1 return {} end end function copy(t) local c = new() for k, v in pairs(t) do c[k] = v end return c end function del(t) --delcount = delcount + 1 wipe(t) pool[t] = true end -- function cached() -- local n = 0 -- for k in pairs(pool) do -- n = n + 1 -- end -- return n -- end end -- picks the first non-nil value and returns it local function pickfirstset(...) for i=1,select("#",...) do if select(i,...)~=nil then return select(i,...) end end end --gets an option from a given group, checking plugins local function GetSubOption(group, key) if group.plugins then for plugin, t in pairs(group.plugins) do if t[key] then return t[key] end end end return group.args[key] end --Option member type definitions, used to decide how to access it --Is the member Inherited from parent options local isInherited = { set = true, get = true, func = true, confirm = true, validate = true, disabled = true, hidden = true } --Does a string type mean a literal value, instead of the default of a method of the handler local stringIsLiteral = { name = true, desc = true, icon = true, usage = true, width = true, image = true, fontSize = true, } --Is Never a function or method local allIsLiteral = { type = true, descStyle = true, imageWidth = true, imageHeight = true, } --gets the value for a member that could be a function --function refs are called with an info arg --every other type is returned local function GetOptionsMemberValue(membername, option, options, path, appName, ...) --get definition for the member local inherits = isInherited[membername] --get the member of the option, traversing the tree if it can be inherited local member if inherits then local group = options if group[membername] ~= nil then member = group[membername] end for i = 1, #path do group = GetSubOption(group, path[i]) if group[membername] ~= nil then member = group[membername] end end else member = option[membername] end --check if we need to call a functon, or if we have a literal value if ( not allIsLiteral[membername] ) and ( type(member) == "function" or ((not stringIsLiteral[membername]) and type(member) == "string") ) then --We have a function to call local info = new() --traverse the options table, picking up the handler and filling the info with the path local handler local group = options handler = group.handler or handler for i = 1, #path do group = GetSubOption(group, path[i]) info[i] = path[i] handler = group.handler or handler end info.options = options info.appName = appName info[0] = appName info.arg = option.arg info.handler = handler info.option = option info.type = option.type info.uiType = "dialog" info.uiName = MAJOR local a, b, c ,d --using 4 returns for the get of a color type, increase if a type needs more if type(member) == "function" then --Call the function a,b,c,d = member(info, ...) else --Call the method if handler and handler[member] then a,b,c,d = handler[member](handler, info, ...) else error(format("Method %s doesn't exist in handler for type %s", member, membername)) end end del(info) return a,b,c,d else --The value isnt a function to call, return it return member end end --[[calls an options function that could be inherited, method name or function ref local function CallOptionsFunction(funcname ,option, options, path, appName, ...) local info = new() local func local group = options local handler --build the info table containing the path -- pick up functions while traversing the tree if group[funcname] ~= nil then func = group[funcname] end handler = group.handler or handler for i, v in ipairs(path) do group = GetSubOption(group, v) info[i] = v if group[funcname] ~= nil then func = group[funcname] end handler = group.handler or handler end info.options = options info[0] = appName info.arg = option.arg local a, b, c ,d if type(func) == "string" then if handler and handler[func] then a,b,c,d = handler[func](handler, info, ...) else error(string.format("Method %s doesn't exist in handler for type func", func)) end elseif type(func) == "function" then a,b,c,d = func(info, ...) end del(info) return a,b,c,d end --]] --tables to hold orders and names for options being sorted, will be created with new() --prevents needing to call functions repeatedly while sorting local tempOrders local tempNames local function compareOptions(a,b) if not a then return true end if not b then return false end local OrderA, OrderB = tempOrders[a] or 100, tempOrders[b] or 100 if OrderA == OrderB then local NameA = (type(tempNames[a]) == "string") and tempNames[a] or "" local NameB = (type(tempNames[b]) == "string") and tempNames[b] or "" return NameA:upper() < NameB:upper() end if OrderA < 0 then if OrderB > 0 then return false end else if OrderB < 0 then return true end end return OrderA < OrderB end --builds 2 tables out of an options group -- keySort, sorted keys -- opts, combined options from .plugins and args local function BuildSortedOptionsTable(group, keySort, opts, options, path, appName) tempOrders = new() tempNames = new() if group.plugins then for plugin, t in pairs(group.plugins) do for k, v in pairs(t) do if not opts[k] then tinsert(keySort, k) opts[k] = v path[#path+1] = k tempOrders[k] = GetOptionsMemberValue("order", v, options, path, appName) tempNames[k] = GetOptionsMemberValue("name", v, options, path, appName) path[#path] = nil end end end end for k, v in pairs(group.args) do if not opts[k] then tinsert(keySort, k) opts[k] = v path[#path+1] = k tempOrders[k] = GetOptionsMemberValue("order", v, options, path, appName) tempNames[k] = GetOptionsMemberValue("name", v, options, path, appName) path[#path] = nil end end tsort(keySort, compareOptions) del(tempOrders) del(tempNames) end local function DelTree(tree) if tree.children then local childs = tree.children for i = 1, #childs do DelTree(childs[i]) del(childs[i]) end del(childs) end end local function CleanUserData(widget, event) local user = widget:GetUserDataTable() if user.path then del(user.path) end if widget.type == "TreeGroup" then local tree = user.tree widget:SetTree(nil) if tree then for i = 1, #tree do DelTree(tree[i]) del(tree[i]) end del(tree) end end if widget.type == "TabGroup" then widget:SetTabs(nil) if user.tablist then del(user.tablist) end end if widget.type == "DropdownGroup" then widget:SetGroupList(nil) if user.grouplist then del(user.grouplist) end if user.orderlist then del(user.orderlist) end end end -- - Gets a status table for the given appname and options path. -- @param appName The application name as given to `:RegisterOptionsTable()` -- @param path The path to the options (a table with all group keys) -- @return function AceConfigDialog:GetStatusTable(appName, path) local status = self.Status if not status[appName] then status[appName] = {} status[appName].status = {} status[appName].children = {} end status = status[appName] if path then for i = 1, #path do local v = path[i] if not status.children[v] then status.children[v] = {} status.children[v].status = {} status.children[v].children = {} end status = status.children[v] end end return status.status end --- Selects the specified path in the options window. -- The path specified has to match the keys of the groups in the table. -- @param appName The application name as given to `:RegisterOptionsTable()` -- @param ... The path to the key that should be selected function AceConfigDialog:SelectGroup(appName, ...) local path = new() local app = reg:GetOptionsTable(appName) if not app then error(("%s isn't registed with AceConfigRegistry, unable to open config"):format(appName), 2) end local options = app("dialog", MAJOR) local group = options local status = self:GetStatusTable(appName, path) if not status.groups then status.groups = {} end status = status.groups local treevalue local treestatus for n = 1, select("#",...) do local key = select(n, ...) if group.childGroups == "tab" or group.childGroups == "select" then --if this is a tab or select group, select the group status.selected = key --children of this group are no longer extra levels of a tree treevalue = nil else --tree group by default if treevalue then --this is an extra level of a tree group, build a uniquevalue for it treevalue = treevalue.."\001"..key else --this is the top level of a tree group, the uniquevalue is the same as the key treevalue = key if not status.groups then status.groups = {} end --save this trees status table for any extra levels or groups treestatus = status end --make sure that the tree entry is open, and select it. --the selected group will be overwritten if a child is the final target but still needs to be open treestatus.selected = treevalue treestatus.groups[treevalue] = true end --move to the next group in the path group = GetSubOption(group, key) if not group then break end tinsert(path, key) status = self:GetStatusTable(appName, path) if not status.groups then status.groups = {} end status = status.groups end del(path) reg:NotifyChange(appName) end local function OptionOnMouseOver(widget, event) --show a tooltip/set the status bar to the desc text local user = widget:GetUserDataTable() local opt = user.option local options = user.options local path = user.path local appName = user.appName GameTooltip:SetOwner(widget.frame, "ANCHOR_TOPRIGHT") local name = GetOptionsMemberValue("name", opt, options, path, appName) local desc = GetOptionsMemberValue("desc", opt, options, path, appName) local usage = GetOptionsMemberValue("usage", opt, options, path, appName) local descStyle = opt.descStyle if descStyle and descStyle ~= "tooltip" then return end GameTooltip:SetText(name, 1, .82, 0, 1) if opt.type == "multiselect" then GameTooltip:AddLine(user.text,0.5, 0.5, 0.8, 1) end if type(desc) == "string" then GameTooltip:AddLine(desc, 1, 1, 1, 1) end if type(usage) == "string" then GameTooltip:AddLine("Usage: "..usage, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1) end GameTooltip:Show() end local function OptionOnMouseLeave(widget, event) GameTooltip:Hide() end local function GetFuncName(option) local type = option.type if type == "execute" then return "func" else return "set" end end local function confirmPopup(appName, rootframe, basepath, info, message, func, ...) if not StaticPopupDialogs["ACECONFIGDIALOG30_CONFIRM_DIALOG"] then StaticPopupDialogs["ACECONFIGDIALOG30_CONFIRM_DIALOG"] = {} end local t = StaticPopupDialogs["ACECONFIGDIALOG30_CONFIRM_DIALOG"] for k in pairs(t) do t[k] = nil end t.text = message t.button1 = ACCEPT t.button2 = CANCEL t.preferredIndex = STATICPOPUP_NUMDIALOGS local dialog, oldstrata t.OnAccept = function() safecall(func, unpack(t)) if dialog and oldstrata then dialog:SetFrameStrata(oldstrata) end AceConfigDialog:Open(appName, rootframe, unpack(basepath or emptyTbl)) del(info) end t.OnCancel = function() if dialog and oldstrata then dialog:SetFrameStrata(oldstrata) end AceConfigDialog:Open(appName, rootframe, unpack(basepath or emptyTbl)) del(info) end for i = 1, select("#", ...) do t[i] = select(i, ...) or false end t.timeout = 0 t.whileDead = 1 t.hideOnEscape = 1 dialog = StaticPopup_Show("ACECONFIGDIALOG30_CONFIRM_DIALOG") if dialog then oldstrata = dialog:GetFrameStrata() dialog:SetFrameStrata("TOOLTIP") end end local function ActivateControl(widget, event, ...) --This function will call the set / execute handler for the widget --widget:GetUserDataTable() contains the needed info local user = widget:GetUserDataTable() local option = user.option local options = user.options local path = user.path local info = new() local func local group = options local funcname = GetFuncName(option) local handler local confirm local validate --build the info table containing the path -- pick up functions while traversing the tree if group[funcname] ~= nil then func = group[funcname] end handler = group.handler or handler confirm = group.confirm validate = group.validate for i = 1, #path do local v = path[i] group = GetSubOption(group, v) info[i] = v if group[funcname] ~= nil then func = group[funcname] end handler = group.handler or handler if group.confirm ~= nil then confirm = group.confirm end if group.validate ~= nil then validate = group.validate end end info.options = options info.appName = user.appName info.arg = option.arg info.handler = handler info.option = option info.type = option.type info.uiType = "dialog" info.uiName = MAJOR local name if type(option.name) == "function" then name = option.name(info) elseif type(option.name) == "string" then name = option.name else name = "" end local usage = option.usage local pattern = option.pattern local validated = true if option.type == "input" then if type(pattern)=="string" then if not strmatch(..., pattern) then validated = false end end end local success if validated and option.type ~= "execute" then if type(validate) == "string" then if handler and handler[validate] then success, validated = safecall(handler[validate], handler, info, ...) if not success then validated = false end else error(format("Method %s doesn't exist in handler for type execute", validate)) end elseif type(validate) == "function" then success, validated = safecall(validate, info, ...) if not success then validated = false end end end local rootframe = user.rootframe if type(validated) == "string" then --validate function returned a message to display if rootframe.SetStatusText then rootframe:SetStatusText(validated) else -- TODO: do something else. end PlaySound("igPlayerInviteDecline") del(info) return true elseif not validated then --validate returned false if rootframe.SetStatusText then if usage then rootframe:SetStatusText(name..": "..usage) else if pattern then rootframe:SetStatusText(name..": Expected "..pattern) else rootframe:SetStatusText(name..": Invalid Value") end end else -- TODO: do something else end PlaySound("igPlayerInviteDecline") del(info) return true else local confirmText = option.confirmText --call confirm func/method if type(confirm) == "string" then if handler and handler[confirm] then success, confirm = safecall(handler[confirm], handler, info, ...) if success and type(confirm) == "string" then confirmText = confirm confirm = true elseif not success then confirm = false end else error(format("Method %s doesn't exist in handler for type confirm", confirm)) end elseif type(confirm) == "function" then success, confirm = safecall(confirm, info, ...) if success and type(confirm) == "string" then confirmText = confirm confirm = true elseif not success then confirm = false end end --confirm if needed if type(confirm) == "boolean" then if confirm then if not confirmText then local name, desc = option.name, option.desc if type(name) == "function" then name = name(info) end if type(desc) == "function" then desc = desc(info) end confirmText = name if desc then confirmText = confirmText.." - "..desc end end local iscustom = user.rootframe:GetUserData("iscustom") local rootframe if iscustom then rootframe = user.rootframe end local basepath = user.rootframe:GetUserData("basepath") if type(func) == "string" then if handler and handler[func] then confirmPopup(user.appName, rootframe, basepath, info, confirmText, handler[func], handler, info, ...) else error(format("Method %s doesn't exist in handler for type func", func)) end elseif type(func) == "function" then confirmPopup(user.appName, rootframe, basepath, info, confirmText, func, info, ...) end --func will be called and info deleted when the confirm dialog is responded to return end end --call the function if type(func) == "string" then if handler and handler[func] then safecall(handler[func],handler, info, ...) else error(format("Method %s doesn't exist in handler for type func", func)) end elseif type(func) == "function" then safecall(func,info, ...) end local iscustom = user.rootframe:GetUserData("iscustom") local basepath = user.rootframe:GetUserData("basepath") or emptyTbl --full refresh of the frame, some controls dont cause this on all events if option.type == "color" then if event == "OnValueConfirmed" then if iscustom then AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath)) else AceConfigDialog:Open(user.appName, unpack(basepath)) end end elseif option.type == "range" then if event == "OnMouseUp" then if iscustom then AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath)) else AceConfigDialog:Open(user.appName, unpack(basepath)) end end --multiselects don't cause a refresh on 'OnValueChanged' only 'OnClosed' elseif option.type == "multiselect" then user.valuechanged = true else if iscustom then AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath)) else AceConfigDialog:Open(user.appName, unpack(basepath)) end end end del(info) end local function ActivateSlider(widget, event, value) local option = widget:GetUserData("option") local min, max, step = option.min or (not option.softMin and 0 or nil), option.max or (not option.softMax and 100 or nil), option.step if min then if step then value = math_floor((value - min) / step + 0.5) * step + min end value = math_max(value, min) end if max then value = math_min(value, max) end ActivateControl(widget,event,value) end --called from a checkbox that is part of an internally created multiselect group --this type is safe to refresh on activation of one control local function ActivateMultiControl(widget, event, ...) ActivateControl(widget, event, widget:GetUserData("highlight"), ...) local user = widget:GetUserDataTable() local iscustom = user.rootframe:GetUserData("iscustom") local basepath = user.rootframe:GetUserData("basepath") or emptyTbl if iscustom then AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath)) else AceConfigDialog:Open(user.appName, unpack(basepath)) end end local function MultiControlOnClosed(widget, event, ...) local user = widget:GetUserDataTable() if user.valuechanged then local iscustom = user.rootframe:GetUserData("iscustom") local basepath = user.rootframe:GetUserData("basepath") or emptyTbl if iscustom then AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath)) else AceConfigDialog:Open(user.appName, unpack(basepath)) end end end local function FrameOnClose(widget, event) local appName = widget:GetUserData("appName") AceConfigDialog.OpenFrames[appName] = nil gui:Release(widget) end local function CheckOptionHidden(option, options, path, appName) --check for a specific boolean option local hidden = pickfirstset(option.dialogHidden,option.guiHidden) if hidden ~= nil then return hidden end return GetOptionsMemberValue("hidden", option, options, path, appName) end local function CheckOptionDisabled(option, options, path, appName) --check for a specific boolean option local disabled = pickfirstset(option.dialogDisabled,option.guiDisabled) if disabled ~= nil then return disabled end return GetOptionsMemberValue("disabled", option, options, path, appName) end --[[ local function BuildTabs(group, options, path, appName) local tabs = new() local text = new() local keySort = new() local opts = new() BuildSortedOptionsTable(group, keySort, opts, options, path, appName) for i = 1, #keySort do local k = keySort[i] local v = opts[k] if v.type == "group" then path[#path+1] = k local inline = pickfirstset(v.dialogInline,v.guiInline,v.inline, false) local hidden = CheckOptionHidden(v, options, path, appName) if not inline and not hidden then tinsert(tabs, k) text[k] = GetOptionsMemberValue("name", v, options, path, appName) end path[#path] = nil end end del(keySort) del(opts) return tabs, text end ]] local function BuildSelect(group, options, path, appName) local groups = new() local order = new() local keySort = new() local opts = new() BuildSortedOptionsTable(group, keySort, opts, options, path, appName) for i = 1, #keySort do local k = keySort[i] local v = opts[k] if v.type == "group" then path[#path+1] = k local inline = pickfirstset(v.dialogInline,v.guiInline,v.inline, false) local hidden = CheckOptionHidden(v, options, path, appName) if not inline and not hidden then groups[k] = GetOptionsMemberValue("name", v, options, path, appName) tinsert(order, k) end path[#path] = nil end end del(opts) del(keySort) return groups, order end local function BuildSubGroups(group, tree, options, path, appName) local keySort = new() local opts = new() BuildSortedOptionsTable(group, keySort, opts, options, path, appName) for i = 1, #keySort do local k = keySort[i] local v = opts[k] if v.type == "group" then path[#path+1] = k local inline = pickfirstset(v.dialogInline,v.guiInline,v.inline, false) local hidden = CheckOptionHidden(v, options, path, appName) if not inline and not hidden then local entry = new() entry.value = k entry.text = GetOptionsMemberValue("name", v, options, path, appName) entry.icon = GetOptionsMemberValue("icon", v, options, path, appName) entry.iconCoords = GetOptionsMemberValue("iconCoords", v, options, path, appName) entry.disabled = CheckOptionDisabled(v, options, path, appName) if not tree.children then tree.children = new() end tinsert(tree.children,entry) if (v.childGroups or "tree") == "tree" then BuildSubGroups(v,entry, options, path, appName) end end path[#path] = nil end end del(keySort) del(opts) end local function BuildGroups(group, options, path, appName, recurse) local tree = new() local keySort = new() local opts = new() BuildSortedOptionsTable(group, keySort, opts, options, path, appName) for i = 1, #keySort do local k = keySort[i] local v = opts[k] if v.type == "group" then path[#path+1] = k local inline = pickfirstset(v.dialogInline,v.guiInline,v.inline, false) local hidden = CheckOptionHidden(v, options, path, appName) if not inline and not hidden then local entry = new() entry.value = k entry.text = GetOptionsMemberValue("name", v, options, path, appName) entry.icon = GetOptionsMemberValue("icon", v, options, path, appName) entry.disabled = CheckOptionDisabled(v, options, path, appName) tinsert(tree,entry) if recurse and (v.childGroups or "tree") == "tree" then BuildSubGroups(v,entry, options, path, appName) end end path[#path] = nil end end del(keySort) del(opts) return tree end local function InjectInfo(control, options, option, path, rootframe, appName) local user = control:GetUserDataTable() for i = 1, #path do user[i] = path[i] end user.rootframe = rootframe user.option = option user.options = options user.path = copy(path) user.appName = appName control:SetCallback("OnRelease", CleanUserData) control:SetCallback("OnLeave", OptionOnMouseLeave) control:SetCallback("OnEnter", OptionOnMouseOver) end --[[ options - root of the options table being fed container - widget that controls will be placed in rootframe - Frame object the options are in path - table with the keys to get to the group being fed --]] local function FeedOptions(appName, options,container,rootframe,path,group,inline) local keySort = new() local opts = new() BuildSortedOptionsTable(group, keySort, opts, options, path, appName) for i = 1, #keySort do local k = keySort[i] local v = opts[k] tinsert(path, k) local hidden = CheckOptionHidden(v, options, path, appName) local name = GetOptionsMemberValue("name", v, options, path, appName) if not hidden then if v.type == "group" then if inline or pickfirstset(v.dialogInline,v.guiInline,v.inline, false) then --Inline group local GroupContainer if name and name ~= "" then GroupContainer = gui:Create("InlineGroup") GroupContainer:SetTitle(name or "") else GroupContainer = gui:Create("SimpleGroup") end GroupContainer.width = "fill" GroupContainer:SetLayout("flow") container:AddChild(GroupContainer) FeedOptions(appName,options,GroupContainer,rootframe,path,v,true) end else --Control to feed local control local name = GetOptionsMemberValue("name", v, options, path, appName) if v.type == "execute" then local imageCoords = GetOptionsMemberValue("imageCoords",v, options, path, appName) local image, width, height = GetOptionsMemberValue("image",v, options, path, appName) if type(image) == "string" then control = gui:Create("Icon") if not width then width = GetOptionsMemberValue("imageWidth",v, options, path, appName) end if not height then height = GetOptionsMemberValue("imageHeight",v, options, path, appName) end if type(imageCoords) == "table" then control:SetImage(image, unpack(imageCoords)) else control:SetImage(image) end if type(width) ~= "number" then width = 32 end if type(height) ~= "number" then height = 32 end control:SetImageSize(width, height) control:SetLabel(name) else control = gui:Create("Button") control:SetText(name) end control:SetCallback("OnClick",ActivateControl) elseif v.type == "input" then local controlType = v.dialogControl or v.control or (v.multiline and "MultiLineEditBox") or "EditBox" control = gui:Create(controlType) if not control then geterrorhandler()(("Invalid Custom Control Type - %s"):format(tostring(controlType))) control = gui:Create(v.multiline and "MultiLineEditBox" or "EditBox") end if v.multiline and control.SetNumLines then control:SetNumLines(tonumber(v.multiline) or 4) end control:SetLabel(name) control:SetCallback("OnEnterPressed",ActivateControl) local text = GetOptionsMemberValue("get",v, options, path, appName) if type(text) ~= "string" then text = "" end control:SetText(text) elseif v.type == "toggle" then control = gui:Create("CheckBox") control:SetLabel(name) control:SetTriState(v.tristate) local value = GetOptionsMemberValue("get",v, options, path, appName) control:SetValue(value) control:SetCallback("OnValueChanged",ActivateControl) if v.descStyle == "inline" then local desc = GetOptionsMemberValue("desc", v, options, path, appName) control:SetDescription(desc) end local image = GetOptionsMemberValue("image", v, options, path, appName) local imageCoords = GetOptionsMemberValue("imageCoords", v, options, path, appName) if type(image) == "string" then if type(imageCoords) == "table" then control:SetImage(image, unpack(imageCoords)) else control:SetImage(image) end end elseif v.type == "range" then control = gui:Create("Slider") control:SetLabel(name) control:SetSliderValues(v.softMin or v.min or 0, v.softMax or v.max or 100, v.bigStep or v.step or 0) control:SetIsPercent(v.isPercent) local value = GetOptionsMemberValue("get",v, options, path, appName) if type(value) ~= "number" then value = 0 end control:SetValue(value) control:SetCallback("OnValueChanged",ActivateSlider) control:SetCallback("OnMouseUp",ActivateSlider) elseif v.type == "select" then local values = GetOptionsMemberValue("values", v, options, path, appName) if v.style == "radio" then local disabled = CheckOptionDisabled(v, options, path, appName) local width = GetOptionsMemberValue("width",v,options,path,appName) control = gui:Create("InlineGroup") control:SetLayout("Flow") control:SetTitle(name) control.width = "fill" control:PauseLayout() local optionValue = GetOptionsMemberValue("get",v, options, path, appName) local t = {} for value, text in pairs(values) do t[#t+1]=value end tsort(t) for k, value in ipairs(t) do local text = values[value] local radio = gui:Create("CheckBox") radio:SetLabel(text) radio:SetUserData("highlight", value) radio:SetUserData("text", text) radio:SetDisabled(disabled) radio:SetType("radio") radio:SetValue(optionValue == value) radio:SetCallback("OnValueChanged", ActivateMultiControl) InjectInfo(radio, options, v, path, rootframe, appName) control:AddChild(radio) if width == "double" then radio:SetWidth(width_multiplier * 2) elseif width == "half" then radio:SetWidth(width_multiplier / 2) elseif width == "full" then radio.width = "fill" else radio:SetWidth(width_multiplier) end end control:ResumeLayout() control:DoLayout() else local controlType = v.dialogControl or v.control or "Dropdown" control = gui:Create(controlType) if not control then geterrorhandler()(("Invalid Custom Control Type - %s"):format(tostring(controlType))) control = gui:Create("Dropdown") end local itemType = v.itemControl if itemType and not gui:GetWidgetVersion(itemType) then geterrorhandler()(("Invalid Custom Item Type - %s"):format(tostring(itemType))) itemType = nil end control:SetLabel(name) control:SetList(values, nil, itemType) local value = GetOptionsMemberValue("get",v, options, path, appName) if not values[value] then value = nil end control:SetValue(value) control:SetCallback("OnValueChanged", ActivateControl) end elseif v.type == "multiselect" then local values = GetOptionsMemberValue("values", v, options, path, appName) local disabled = CheckOptionDisabled(v, options, path, appName) local controlType = v.dialogControl or v.control local valuesort = new() if values then for value, text in pairs(values) do tinsert(valuesort, value) end end tsort(valuesort) if controlType then control = gui:Create(controlType) if not control then geterrorhandler()(("Invalid Custom Control Type - %s"):format(tostring(controlType))) end end if control then control:SetMultiselect(true) control:SetLabel(name) control:SetList(values) control:SetDisabled(disabled) control:SetCallback("OnValueChanged",ActivateControl) control:SetCallback("OnClosed", MultiControlOnClosed) local width = GetOptionsMemberValue("width",v,options,path,appName) if width == "double" then control:SetWidth(width_multiplier * 2) elseif width == "half" then control:SetWidth(width_multiplier / 2) elseif width == "full" then control.width = "fill" else control:SetWidth(width_multiplier) end --check:SetTriState(v.tristate) for i = 1, #valuesort do local key = valuesort[i] local value = GetOptionsMemberValue("get",v, options, path, appName, key) control:SetItemValue(key,value) end else control = gui:Create("InlineGroup") control:SetLayout("Flow") control:SetTitle(name) control.width = "fill" control:PauseLayout() local width = GetOptionsMemberValue("width",v,options,path,appName) for i = 1, #valuesort do local value = valuesort[i] local text = values[value] local check = gui:Create("CheckBox") check:SetLabel(text) check:SetUserData("highlight", value) check:SetUserData("text", text) check:SetDisabled(disabled) check:SetTriState(v.tristate) check:SetValue(GetOptionsMemberValue("get",v, options, path, appName, value)) check:SetCallback("OnValueChanged",ActivateMultiControl) InjectInfo(check, options, v, path, rootframe, appName) control:AddChild(check) if width == "double" then check:SetWidth(width_multiplier * 2) elseif width == "half" then check:SetWidth(width_multiplier / 2) elseif width == "full" then check.width = "fill" else check:SetWidth(width_multiplier) end end control:ResumeLayout() control:DoLayout() end del(valuesort) elseif v.type == "color" then control = gui:Create("ColorPicker") control:SetLabel(name) control:SetHasAlpha(GetOptionsMemberValue("hasAlpha",v, options, path, appName)) control:SetColor(GetOptionsMemberValue("get",v, options, path, appName)) control:SetCallback("OnValueChanged",ActivateControl) control:SetCallback("OnValueConfirmed",ActivateControl) elseif v.type == "keybinding" then control = gui:Create("Keybinding") control:SetLabel(name) control:SetKey(GetOptionsMemberValue("get",v, options, path, appName)) control:SetCallback("OnKeyChanged",ActivateControl) elseif v.type == "header" then control = gui:Create("Heading") control:SetText(name) control.width = "fill" elseif v.type == "description" then control = gui:Create("Label") control:SetText(name) local fontSize = GetOptionsMemberValue("fontSize",v, options, path, appName) if fontSize == "medium" then control:SetFontObject(GameFontHighlight) elseif fontSize == "large" then control:SetFontObject(GameFontHighlightLarge) else -- small or invalid control:SetFontObject(GameFontHighlightSmall) end local imageCoords = GetOptionsMemberValue("imageCoords",v, options, path, appName) local image, width, height = GetOptionsMemberValue("image",v, options, path, appName) if type(image) == "string" then if not width then width = GetOptionsMemberValue("imageWidth",v, options, path, appName) end if not height then height = GetOptionsMemberValue("imageHeight",v, options, path, appName) end if type(imageCoords) == "table" then control:SetImage(image, unpack(imageCoords)) else control:SetImage(image) end if type(width) ~= "number" then width = 32 end if type(height) ~= "number" then height = 32 end control:SetImageSize(width, height) end local width = GetOptionsMemberValue("width",v,options,path,appName) control.width = not width and "fill" end --Common Init if control then if control.width ~= "fill" then local width = GetOptionsMemberValue("width",v,options,path,appName) if width == "double" then control:SetWidth(width_multiplier * 2) elseif width == "half" then control:SetWidth(width_multiplier / 2) elseif width == "full" then control.width = "fill" else control:SetWidth(width_multiplier) end end if control.SetDisabled then local disabled = CheckOptionDisabled(v, options, path, appName) control:SetDisabled(disabled) end InjectInfo(control, options, v, path, rootframe, appName) container:AddChild(control) end end end tremove(path) end container:ResumeLayout() container:DoLayout() del(keySort) del(opts) end local function BuildPath(path, ...) for i = 1, select("#",...) do tinsert(path, (select(i,...))) end end local function TreeOnButtonEnter(widget, event, uniquevalue, button) local user = widget:GetUserDataTable() if not user then return end local options = user.options local option = user.option local path = user.path local appName = user.appName local feedpath = new() for i = 1, #path do feedpath[i] = path[i] end BuildPath(feedpath, ("\001"):split(uniquevalue)) local group = options for i = 1, #feedpath do if not group then return end group = GetSubOption(group, feedpath[i]) end local name = GetOptionsMemberValue("name", group, options, feedpath, appName) local desc = GetOptionsMemberValue("desc", group, options, feedpath, appName) GameTooltip:SetOwner(button, "ANCHOR_NONE") if widget.type == "TabGroup" then GameTooltip:SetPoint("BOTTOM",button,"TOP") else GameTooltip:SetPoint("LEFT",button,"RIGHT") end GameTooltip:SetText(name, 1, .82, 0, 1) if type(desc) == "string" then GameTooltip:AddLine(desc, 1, 1, 1, 1) end GameTooltip:Show() end local function TreeOnButtonLeave(widget, event, value, button) GameTooltip:Hide() end local function GroupExists(appName, options, path, uniquevalue) if not uniquevalue then return false end local feedpath = new() local temppath = new() for i = 1, #path do feedpath[i] = path[i] end BuildPath(feedpath, ("\001"):split(uniquevalue)) local group = options for i = 1, #feedpath do local v = feedpath[i] temppath[i] = v group = GetSubOption(group, v) if not group or group.type ~= "group" or CheckOptionHidden(group, options, temppath, appName) then del(feedpath) del(temppath) return false end end del(feedpath) del(temppath) return true end local function GroupSelected(widget, event, uniquevalue) local user = widget:GetUserDataTable() local options = user.options local option = user.option local path = user.path local rootframe = user.rootframe local feedpath = new() for i = 1, #path do feedpath[i] = path[i] end BuildPath(feedpath, ("\001"):split(uniquevalue)) local group = options for i = 1, #feedpath do group = GetSubOption(group, feedpath[i]) end widget:ReleaseChildren() AceConfigDialog:FeedGroup(user.appName,options,widget,rootframe,feedpath) del(feedpath) end --[[ -- INTERNAL -- This function will feed one group, and any inline child groups into the given container Select Groups will only have the selection control (tree, tabs, dropdown) fed in and have a group selected, this event will trigger the feeding of child groups Rules: If the group is Inline, FeedOptions If the group has no child groups, FeedOptions If the group is a tab or select group, FeedOptions then add the Group Control If the group is a tree group FeedOptions then its parent isnt a tree group: then add the tree control containing this and all child tree groups if its parent is a tree group, its already a node on a tree --]] function AceConfigDialog:FeedGroup(appName,options,container,rootframe,path, isRoot) local group = options --follow the path to get to the curent group local inline local grouptype, parenttype = options.childGroups, "none" for i = 1, #path do local v = path[i] group = GetSubOption(group, v) inline = inline or pickfirstset(v.dialogInline,v.guiInline,v.inline, false) parenttype = grouptype grouptype = group.childGroups end if not parenttype then parenttype = "tree" end --check if the group has child groups local hasChildGroups for k, v in pairs(group.args) do if v.type == "group" and not pickfirstset(v.dialogInline,v.guiInline,v.inline, false) and not CheckOptionHidden(v, options, path, appName) then hasChildGroups = true end end if group.plugins then for plugin, t in pairs(group.plugins) do for k, v in pairs(t) do if v.type == "group" and not pickfirstset(v.dialogInline,v.guiInline,v.inline, false) and not CheckOptionHidden(v, options, path, appName) then hasChildGroups = true end end end end container:SetLayout("flow") local scroll --Add a scrollframe if we are not going to add a group control, this is the inverse of the conditions for that later on if (not (hasChildGroups and not inline)) or (grouptype ~= "tab" and grouptype ~= "select" and (parenttype == "tree" and not isRoot)) then if container.type ~= "InlineGroup" and container.type ~= "SimpleGroup" then scroll = gui:Create("ScrollFrame") scroll:SetLayout("flow") scroll.width = "fill" scroll.height = "fill" container:SetLayout("fill") container:AddChild(scroll) container = scroll end end FeedOptions(appName,options,container,rootframe,path,group,nil) if scroll then container:PerformLayout() local status = self:GetStatusTable(appName, path) if not status.scroll then status.scroll = {} end scroll:SetStatusTable(status.scroll) end if hasChildGroups and not inline then local name = GetOptionsMemberValue("name", group, options, path, appName) if grouptype == "tab" then local tab = gui:Create("TabGroup") InjectInfo(tab, options, group, path, rootframe, appName) tab:SetCallback("OnGroupSelected", GroupSelected) tab:SetCallback("OnTabEnter", TreeOnButtonEnter) tab:SetCallback("OnTabLeave", TreeOnButtonLeave) local status = AceConfigDialog:GetStatusTable(appName, path) if not status.groups then status.groups = {} end tab:SetStatusTable(status.groups) tab.width = "fill" tab.height = "fill" local tabs = BuildGroups(group, options, path, appName) tab:SetTabs(tabs) tab:SetUserData("tablist", tabs) for i = 1, #tabs do local entry = tabs[i] if not entry.disabled then tab:SelectTab((GroupExists(appName, options, path,status.groups.selected) and status.groups.selected) or entry.value) break end end container:AddChild(tab) elseif grouptype == "select" then local select = gui:Create("DropdownGroup") select:SetTitle(name) InjectInfo(select, options, group, path, rootframe, appName) select:SetCallback("OnGroupSelected", GroupSelected) local status = AceConfigDialog:GetStatusTable(appName, path) if not status.groups then status.groups = {} end select:SetStatusTable(status.groups) local grouplist, orderlist = BuildSelect(group, options, path, appName) select:SetGroupList(grouplist, orderlist) select:SetUserData("grouplist", grouplist) select:SetUserData("orderlist", orderlist) local firstgroup = orderlist[1] if firstgroup then select:SetGroup((GroupExists(appName, options, path,status.groups.selected) and status.groups.selected) or firstgroup) end select.width = "fill" select.height = "fill" container:AddChild(select) --assume tree group by default --if parenttype is tree then this group is already a node on that tree elseif (parenttype ~= "tree") or isRoot then local tree = gui:Create("TreeGroup") InjectInfo(tree, options, group, path, rootframe, appName) tree:EnableButtonTooltips(false) tree.width = "fill" tree.height = "fill" tree:SetCallback("OnGroupSelected", GroupSelected) tree:SetCallback("OnButtonEnter", TreeOnButtonEnter) tree:SetCallback("OnButtonLeave", TreeOnButtonLeave) local status = AceConfigDialog:GetStatusTable(appName, path) if not status.groups then status.groups = {} end local treedefinition = BuildGroups(group, options, path, appName, true) tree:SetStatusTable(status.groups) tree:SetTree(treedefinition) tree:SetUserData("tree",treedefinition) for i = 1, #treedefinition do local entry = treedefinition[i] if not entry.disabled then tree:SelectByValue((GroupExists(appName, options, path,status.groups.selected) and status.groups.selected) or entry.value) break end end container:AddChild(tree) end end end local old_CloseSpecialWindows local function RefreshOnUpdate(this) for appName in pairs(this.closing) do if AceConfigDialog.OpenFrames[appName] then AceConfigDialog.OpenFrames[appName]:Hide() end if AceConfigDialog.BlizOptions and AceConfigDialog.BlizOptions[appName] then for key, widget in pairs(AceConfigDialog.BlizOptions[appName]) do if not widget:IsVisible() then widget:ReleaseChildren() end end end this.closing[appName] = nil end if this.closeAll then for k, v in pairs(AceConfigDialog.OpenFrames) do if not this.closeAllOverride[k] then v:Hide() end end this.closeAll = nil wipe(this.closeAllOverride) end for appName in pairs(this.apps) do if AceConfigDialog.OpenFrames[appName] then local user = AceConfigDialog.OpenFrames[appName]:GetUserDataTable() AceConfigDialog:Open(appName, unpack(user.basepath or emptyTbl)) end if AceConfigDialog.BlizOptions and AceConfigDialog.BlizOptions[appName] then for key, widget in pairs(AceConfigDialog.BlizOptions[appName]) do local user = widget:GetUserDataTable() if widget:IsVisible() then AceConfigDialog:Open(widget:GetUserData("appName"), widget, unpack(user.basepath or emptyTbl)) end end end this.apps[appName] = nil end this:SetScript("OnUpdate", nil) end -- Upgrade the OnUpdate script as well, if needed. if AceConfigDialog.frame:GetScript("OnUpdate") then AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate) end --- Close all open options windows function AceConfigDialog:CloseAll() AceConfigDialog.frame.closeAll = true AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate) if next(self.OpenFrames) then return true end end --- Close a specific options window. -- @param appName The application name as given to `:RegisterOptionsTable()` function AceConfigDialog:Close(appName) if self.OpenFrames[appName] then AceConfigDialog.frame.closing[appName] = true AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate) return true end end -- Internal -- Called by AceConfigRegistry function AceConfigDialog:ConfigTableChanged(event, appName) AceConfigDialog.frame.apps[appName] = true AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate) end reg.RegisterCallback(AceConfigDialog, "ConfigTableChange", "ConfigTableChanged") --- Sets the default size of the options window for a specific application. -- @param appName The application name as given to `:RegisterOptionsTable()` -- @param width The default width -- @param height The default height function AceConfigDialog:SetDefaultSize(appName, width, height) local status = AceConfigDialog:GetStatusTable(appName) if type(width) == "number" and type(height) == "number" then status.width = width status.height = height end end --- Open an option window at the specified path (if any). -- This function can optionally feed the group into a pre-created container -- instead of creating a new container frame. -- @paramsig appName [, container][, ...] -- @param appName The application name as given to `:RegisterOptionsTable()` -- @param container An optional container frame to feed the options into -- @param ... The path to open after creating the options window (see `:SelectGroup` for details) function AceConfigDialog:Open(appName, container, ...) if not old_CloseSpecialWindows then old_CloseSpecialWindows = CloseSpecialWindows CloseSpecialWindows = function() local found = old_CloseSpecialWindows() return self:CloseAll() or found end end local app = reg:GetOptionsTable(appName) if not app then error(("%s isn't registed with AceConfigRegistry, unable to open config"):format(appName), 2) end local options = app("dialog", MAJOR) local f local path = new() local name = GetOptionsMemberValue("name", options, options, path, appName) --If an optional path is specified add it to the path table before feeding the options --as container is optional as well it may contain the first element of the path if type(container) == "string" then tinsert(path, container) container = nil end for n = 1, select("#",...) do tinsert(path, (select(n, ...))) end --if a container is given feed into that if container then f = container f:ReleaseChildren() f:SetUserData("appName", appName) f:SetUserData("iscustom", true) if #path > 0 then f:SetUserData("basepath", copy(path)) end local status = AceConfigDialog:GetStatusTable(appName) if not status.width then status.width = 700 end if not status.height then status.height = 500 end if f.SetStatusTable then f:SetStatusTable(status) end if f.SetTitle then f:SetTitle(name or "") end else if not self.OpenFrames[appName] then f = gui:Create("Frame") self.OpenFrames[appName] = f else f = self.OpenFrames[appName] end f:ReleaseChildren() f:SetCallback("OnClose", FrameOnClose) f:SetUserData("appName", appName) if #path > 0 then f:SetUserData("basepath", copy(path)) end f:SetTitle(name or "") local status = AceConfigDialog:GetStatusTable(appName) f:SetStatusTable(status) end self:FeedGroup(appName,options,f,f,path,true) if f.Show then f:Show() end del(path) if AceConfigDialog.frame.closeAll then -- close all is set, but thats not good, since we're just opening here, so force it AceConfigDialog.frame.closeAllOverride[appName] = true end end -- convert pre-39 BlizOptions structure to the new format if oldminor and oldminor < 39 and AceConfigDialog.BlizOptions then local old = AceConfigDialog.BlizOptions local new = {} for key, widget in pairs(old) do local appName = widget:GetUserData("appName") if not new[appName] then new[appName] = {} end new[appName][key] = widget end AceConfigDialog.BlizOptions = new else AceConfigDialog.BlizOptions = AceConfigDialog.BlizOptions or {} end local function FeedToBlizPanel(widget, event) local path = widget:GetUserData("path") AceConfigDialog:Open(widget:GetUserData("appName"), widget, unpack(path or emptyTbl)) end local function ClearBlizPanel(widget, event) local appName = widget:GetUserData("appName") AceConfigDialog.frame.closing[appName] = true AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate) end --- Add an option table into the Blizzard Interface Options panel. -- You can optionally supply a descriptive name to use and a parent frame to use, -- as well as a path in the options table.\\ -- If no name is specified, the appName will be used instead. -- -- If you specify a proper `parent` (by name), the interface options will generate a -- tree layout. Note that only one level of children is supported, so the parent always -- has to be a head-level note. -- -- This function returns a reference to the container frame registered with the Interface -- Options. You can use this reference to open the options with the API function -- `InterfaceOptionsFrame_OpenToCategory`. -- @param appName The application name as given to `:RegisterOptionsTable()` -- @param name A descriptive name to display in the options tree (defaults to appName) -- @param parent The parent to use in the interface options tree. -- @param ... The path in the options table to feed into the interface options panel. -- @return The reference to the frame registered into the Interface Options. function AceConfigDialog:AddToBlizOptions(appName, name, parent, ...) local BlizOptions = AceConfigDialog.BlizOptions local key = appName for n = 1, select("#", ...) do key = key.."\001"..select(n, ...) end if not BlizOptions[appName] then BlizOptions[appName] = {} end if not BlizOptions[appName][key] then local group = gui:Create("BlizOptionsGroup") BlizOptions[appName][key] = group group:SetName(name or appName, parent) group:SetTitle(name or appName) group:SetUserData("appName", appName) if select("#", ...) > 0 then local path = {} for n = 1, select("#",...) do tinsert(path, (select(n, ...))) end group:SetUserData("path", path) end group:SetCallback("OnShow", FeedToBlizPanel) group:SetCallback("OnHide", ClearBlizPanel) InterfaceOptions_AddCategory(group.frame) return group.frame else error(("%s has already been added to the Blizzard Options Window with the given path"):format(appName), 2) end end
mit
will4wachter/Project1
scripts/zones/Metalworks/npcs/Mih_Ketto.lua
38
1037
----------------------------------- -- Area: Metalworks -- NPC: Mih Ketto -- Type: Standard NPC -- @zone: 237 -- @pos 24.046 -17 32.751 -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/Metalworks/TextIDs"] = nil; require("scripts/zones/Metalworks/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x00fd); 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
davidedmonds/darkstar
scripts/globals/items/serving_of_patriarch_sautee.lua
36
1253
----------------------------------------- -- ID: 5677 -- Item: Serving of Patriarch Sautee -- Food Effect: 4Hrs, All Races ----------------------------------------- -- MP 60 -- Mind 7 -- MP Recovered While Healing 7 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,10800,5677); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_MP, 60); target:addMod(MOD_MND, 7); target:addMod(MOD_MPHEAL, 7); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_MP, 60); target:delMod(MOD_MND, 7); target:delMod(MOD_MPHEAL, 7); end;
gpl-3.0
will4wachter/Project1
scripts/globals/items/serving_of_patriarch_sautee.lua
36
1253
----------------------------------------- -- ID: 5677 -- Item: Serving of Patriarch Sautee -- Food Effect: 4Hrs, All Races ----------------------------------------- -- MP 60 -- Mind 7 -- MP Recovered While Healing 7 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,10800,5677); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_MP, 60); target:addMod(MOD_MND, 7); target:addMod(MOD_MPHEAL, 7); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_MP, 60); target:delMod(MOD_MND, 7); target:delMod(MOD_MPHEAL, 7); end;
gpl-3.0
waterlgndx/darkstar
scripts/globals/items/high_breath_mantle.lua
2
1204
----------------------------------------- -- ID: 15487 -- Item: High Breath Mantle -- Item Effect: HP+38 / Enmity+5 ----------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); ----------------------------------------- function onItemCheck(target) local effect = target:getStatusEffect(dsp.effect.ENCHANTMENT); if (effect ~= nil) then if (effect:getSubType() == 15487) then target:delStatusEffect(dsp.effect.ENCHANTMENT); end; end; return 0; end; function onItemUse(target) if (target:hasStatusEffect(dsp.effect.ENCHANTMENT) == true) then target:delStatusEffect(dsp.effect.ENCHANTMENT); target:addStatusEffect(dsp.effect.ENCHANTMENT,0,0,1800,15487); else target:addStatusEffect(dsp.effect.ENCHANTMENT,0,0,1800,15487); end; end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(dsp.mod.HP, 38); target:addMod(dsp.mod.ENMITY, 5); end; function onEffectLose(target, effect) target:delMod(dsp.mod.HP, 38); target:delMod(dsp.mod.ENMITY, 5); end;
gpl-3.0
lhog/Zero-K
units/energysolar.lua
2
2359
return { energysolar = { unitname = [[energysolar]], name = [[Solar Collector]], description = [[Small Powerplant (+2)]], acceleration = 0, activateWhenBuilt = true, brakeRate = 0, buildCostMetal = 70, builder = false, buildingGroundDecalDecaySpeed = 30, buildingGroundDecalSizeX = 6, buildingGroundDecalSizeY = 6, buildingGroundDecalType = [[energysolar_aoplane.dds]], buildPic = [[energysolar.png]], category = [[SINK UNARMED STUPIDTARGET SOLAR]], corpse = [[DEAD]], customParams = { bait_level_target = 1, pylonrange = 100, aimposoffset = [[0 16 0]], midposoffset = [[0 0 0]], auto_close_time = 4, -- Unit AI off time. removewait = 1, removestop = 1, default_spacing = 0, }, damageModifier = 0.25, energyMake = 2, explodeAs = [[SMALL_BUILDINGEX]], footprintX = 5, footprintZ = 5, iconType = [[energy_med]], idleAutoHeal = 5, idleTime = 1800, maxDamage = 500, maxSlope = 18, maxVelocity = 0, maxWaterDepth = 0, noAutoFire = false, objectName = [[arm_solar.s3o]], onoffable = true, script = [[energysolar.lua]], selfDestructAs = [[SMALL_BUILDINGEX]], sightDistance = 273, turnRate = 0, useBuildingGroundDecal = true, workerTime = 0, yardMap = [[ooooooooooooooooooooooooo]], featureDefs = { DEAD = { blocking = true, featureDead = [[HEAP]], footprintX = 5, footprintZ = 5, object = [[arm_solar_dead.s3o]], }, HEAP = { blocking = false, footprintX = 5, footprintZ = 5, object = [[debris4x4a.s3o]], }, }, } }
gpl-2.0
kidaa/darkstar
scripts/globals/abilities/pets/burning_strike.lua
25
1274
--------------------------------------------------- -- Burning Strike M = 6? --------------------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/summon"); require("scripts/globals/magic"); require("scripts/globals/monstertpmoves"); --------------------------------------------------- function onAbilityCheck(player, target, ability) return 0,0; end; function onPetAbility(target, pet, skill) local numhits = 1; local accmod = 1; local dmgmod = 6; local totaldamage = 0; local damage = AvatarPhysicalMove(pet,target,skill,numhits,accmod,dmgmod,0,TP_NO_EFFECT,1,2,3); --get resist multiplier (1x if no resist) local resist = applyPlayerResistance(pet,-1,target,pet:getStat(MOD_INT)-target:getStat(MOD_INT),ELEMENTAL_MAGIC_SKILL, ELE_FIRE); --get the resisted damage damage.dmg = damage.dmg*resist; --add on bonuses (staff/day/weather/jas/mab/etc all go in this function) damage.dmg = mobAddBonuses(pet,spell,target,damage.dmg,1); totaldamage = AvatarFinalAdjustments(damage.dmg,pet,skill,target,MOBSKILL_PHYSICAL,MOBPARAM_SLASH,numhits); target:delHP(totaldamage); target:updateEnmityFromDamage(pet,totaldamage); return totaldamage; end
gpl-3.0
MonokuroInzanaito/ygopro-777DIY
expansions/script/c11111047.lua
1
2736
--最后的封印 function c11111047.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_NEGATE+CATEGORY_DESTROY+CATEGORY_DRAW) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_CHAINING) e1:SetCondition(c11111047.condition) e1:SetCost(c11111047.cost) e1:SetTarget(c11111047.target) e1:SetOperation(c11111047.activate) c:RegisterEffect(e1) end function c11111047.condition(e,tp,eg,ep,ev,re,r,rp) return (re:IsActiveType(TYPE_MONSTER) or re:IsHasType(EFFECT_TYPE_ACTIVATE)) and Duel.IsChainNegatable(ev) end function c11111047.cfilter(c) return c:IsFaceup() and c:IsType(TYPE_XYZ) and c:IsSetCard(0x15d) and c:IsAbleToRemoveAsCost() end function c11111047.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c11111047.cfilter,tp,LOCATION_MZONE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,c11111047.cfilter,tp,LOCATION_MZONE,0,1,1,nil) Duel.Remove(g,POS_FACEUP,REASON_COST+REASON_TEMPORARY) e:SetLabelObject(g:GetFirst()) end function c11111047.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,1) 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) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end end function c11111047.activate(e,tp,eg,ep,ev,re,r,rp) Duel.NegateActivation(ev) if re:GetHandler():IsRelateToEffect(re) and Duel.Destroy(eg,REASON_EFFECT)~=0 then Duel.BreakEffect() Duel.Draw(tp,1,REASON_EFFECT) end local tc=e:GetLabelObject() local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EVENT_PHASE+PHASE_STANDBY) if Duel.GetCurrentPhase()==PHASE_STANDBY and Duel.GetTurnPlayer()==tp then e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_STANDBY+RESET_SELF_TURN,3) else e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_STANDBY+RESET_SELF_TURN,2) end e1:SetLabelObject(tc) e1:SetCountLimit(1) e1:SetOperation(c11111047.retop) tc:SetTurnCounter(0) Duel.RegisterEffect(e1,tp) end function c11111047.retop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetTurnPlayer()~=tp then return end local c=e:GetLabelObject() local ct=c:GetTurnCounter() ct=ct+1 c:SetTurnCounter(ct) if ct==2 then if Duel.ReturnToField(c) then local g=Duel.GetMatchingGroup(Card.IsCode,tp,LOCATION_GRAVE,0,nil,11111047) if g:GetCount()>0 and Duel.SelectYesNo(tp,aux.Stringid(11111047,0))then Duel.BreakEffect() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL) local mg=g:Select(tp,1,1,nil) Duel.Overlay(c,mg) end end end end
gpl-3.0
lhog/Zero-K
LuaRules/Gadgets/lups_shockwaves.lua
7
3259
-- $Id: lups_shockwaves.lua 3171 2008-11-06 09:06:29Z det $ function gadget:GetInfo() return { name = "Shockwaves", desc = "", author = "jK", date = "Jan. 2008", license = "GNU GPL, v2 or later", layer = 0, enabled = true } end ------------------------------------------------------------------------------- -- Synced ------------------------------------------------------------------------------- if (gadgetHandler:IsSyncedCode()) then ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- local hasShockwave = {} -- other gadgets can do Script.SetWatchWeapon and it is a global setting local wantedList = {} --// find weapons which cause a shockwave for i = 1, #WeaponDefs do local wd = WeaponDefs[i] local customParams = wd.customParams or {} if (not customParams.lups_noshockwave) then local speed = 1 local life = 1 local normalShockwave = (wd.damageAreaOfEffect>70 and not wd.paralyzer and not customParams.disarmdamageonly) if customParams.lups_explodespeed then speed = wd.customParams.lups_explodespeed normalShockwave = true end if customParams.lups_explodelife then life = wd.customParams.lups_explodelife normalShockwave = true end if wd.description == "Implosion Bomb" then hasShockwave[wd.id] = {special = 1} wantedList[#wantedList + 1] = wd.id Script.SetWatchExplosion(wd.id, true) elseif normalShockwave then hasShockwave[wd.id] = { life = 23*life, speed = speed, growth = (wd.damageAreaOfEffect*1.1)/20*speed } wantedList[#wantedList + 1] = wd.id Script.SetWatchExplosion(wd.id, true) elseif (wd.type == "DGun") then hasShockwave[wd.id] = {DGun = true} wantedList[#wantedList + 1] = wd.id Script.SetWatchExplosion(wd.id, true) end end end function gadget:Explosion_GetWantedWeaponDef() return wantedList end function gadget:Explosion(weaponID, px, py, pz, ownerID) local shockwave = hasShockwave[weaponID] if shockwave then if shockwave.DGun then SendToUnsynced("lups_shockwave", px, py, pz, 4.0, 18, 0.13, true) elseif shockwave.special == 1 then SendToUnsynced("lups_shockwave", px, py, pz, 6, 30, 0.13, true) else SendToUnsynced("lups_shockwave", px, py, pz, shockwave.growth, shockwave.life) end end return false end ------------------------------------------------------------------------------- -- Unsynced ------------------------------------------------------------------------------- else ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- local function SpawnShockwave(_,px,py,pz, growth, life, strength, desintergrator) local Lups = GG['Lups'] if (desintergrator) then Lups.AddParticles('SphereDistortion',{pos={px,py,pz}, life=life, strength=strength, growth=growth}) else Lups.AddParticles('ShockWave',{pos={px,py,pz}, growth=growth, life=life}) end end function gadget:Initialize() gadgetHandler:AddSyncAction("lups_shockwave", SpawnShockwave) end function gadget:Shutdown() gadgetHandler.RemoveSyncAction("lups_shockwave") end end
gpl-2.0
solomid99/Sp_robot
plugins/anti-flood.lua
281
2422
local NUM_MSG_MAX = 5 -- Max number of messages per TIME_CHECK seconds local TIME_CHECK = 5 local function kick_user(user_id, chat_id) local chat = 'chat#id'..chat_id local user = 'user#id'..user_id chat_del_user(chat, user, function (data, success, result) if success ~= 1 then local text = 'I can\'t kick '..data.user..' but should be kicked' send_msg(data.chat, '', ok_cb, nil) end end, {chat=chat, user=user}) end local function run (msg, matches) if msg.to.type ~= 'chat' then return 'Anti-flood works only on channels' else local chat = msg.to.id local hash = 'anti-flood:enabled:'..chat if matches[1] == 'enable' then redis:set(hash, true) return 'Anti-flood enabled on chat' end if matches[1] == 'disable' then redis:del(hash) return 'Anti-flood disabled on chat' end end end local function pre_process (msg) -- Ignore service msg if msg.service then print('Service message') return msg end local hash_enable = 'anti-flood:enabled:'..msg.to.id local enabled = redis:get(hash_enable) if enabled then print('anti-flood enabled') -- Check flood if msg.from.type == 'user' then -- Increase the number of messages from the user on the chat local hash = 'anti-flood:'..msg.from.id..':'..msg.to.id..':msg-num' local msgs = tonumber(redis:get(hash) or 0) if msgs > NUM_MSG_MAX then local receiver = get_receiver(msg) local user = msg.from.id local text = 'User '..user..' is flooding' local chat = msg.to.id send_msg(receiver, text, ok_cb, nil) if msg.to.type ~= 'chat' then print("Flood in not a chat group!") elseif user == tostring(our_id) then print('I won\'t kick myself') elseif is_sudo(msg) then print('I won\'t kick an admin!') else -- Ban user -- TODO: Check on this plugin bans local bhash = 'banned:'..msg.to.id..':'..msg.from.id redis:set(bhash, true) kick_user(user, chat) end msg = nil end redis:setex(hash, TIME_CHECK, msgs+1) end end return msg end return { description = 'Plugin to kick flooders from group.', usage = {}, patterns = { '^!antiflood (enable)$', '^!antiflood (disable)$' }, run = run, privileged = true, pre_process = pre_process }
gpl-2.0
kidaa/darkstar
scripts/zones/Xarcabard/npcs/qm3.lua
17
1641
----------------------------------- -- Area: Xarcabard -- NPC: qm3 (???) -- Involved in Quests: Atop the Highest Mountains (for Boreal Coeurl) -- @pos 580 -9 290 112 ----------------------------------- package.loaded["scripts/zones/Xarcabard/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/quests"); require("scripts/zones/Xarcabard/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local BorealCoeurl = GetMobAction(17236203); if((OldSchoolG2 == false) or (BorealCoeurl == ACTION_NONE or BorealCoeurl == ACTION_SPAWN)) then if(player:getQuestStatus(JEUNO,ATOP_THE_HIGHEST_MOUNTAINS) == QUEST_ACCEPTED and player:hasKeyItem(SQUARE_FRIGICITE) == false) then player:addKeyItem(SQUARE_FRIGICITE); player:messageSpecial(KEYITEM_OBTAINED, SQUARE_FRIGICITE); else player:messageSpecial(ONLY_SHARDS); end else player:messageSpecial(ONLY_SHARDS); 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
davidedmonds/darkstar
scripts/zones/Valley_of_Sorrows/npcs/qm1.lua
16
1925
----------------------------------- -- Area: Valley of Sorrows -- NPC: qm1 (???) -- Note: Used to spawn Adamantoise and Aspidochelone -- @pos 0 0 -37 59 ----------------------------------- package.loaded["scripts/zones/Valley_of_Sorrows/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Valley_of_Sorrows/TextIDs"); require("scripts/globals/status"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) local Adamantoise = GetMobAction(17301537); local Aspidochelone = GetMobAction(17301538); -- Trade Clump of Red Pondweed if ((Aspidochelone == ACTION_NONE or Aspidochelone == ACTION_SPAWN) and trade:hasItemQty(3344,1) and trade:getItemCount() == 1) then -- Check trade, and if mob is ACTION_NONE (0) or waiting to spawn (24) if (LandKingSystem_HQ == 1 or LandKingSystem_HQ == 2) then player:tradeComplete(); SpawnMob(17301538,180):updateClaim(player); end -- Trade Clump of Blue Pondweed elseif ((Adamantoise == ACTION_NONE or Adamantoise == ACTION_SPAWN) and trade:hasItemQty(3343,1) and trade:getItemCount() == 1) then if (LandKingSystem_NQ == 1 or LandKingSystem_NQ == 2) then player:tradeComplete(); SpawnMob(17301537,180):updateClaim(player); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:messageSpecial(NOTHING_OUT_OF_ORDINARY); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
stevedonovan/luabuild
modules/luasocket/test/testclnt.lua
3
20387
local socket = require"socket" host = host or "127.0.0.1" port = port or "8443" math.mod = math.mod or function(x,y) return x % y end local outf = io.stdout function pass(...) local s = string.format(...) outf:write(s, "\n") end function fail(...) local s = string.format(...) io.stderr:write("ERROR: ", s, "!\n") --socket.sleep(3) remote 'quit' os.exit() end function warn(...) local s = string.format(...) outf:write("WARNING: ", s, "\n") end function remote(...) local s = string.format(...) s = string.gsub(s, "\n", ";") s = string.gsub(s, "%s+", " ") s = string.gsub(s, "^%s*", "") control:send(s .. "\n") control:receive() end function test(test) outf:write("----------------------------------------------\n", "testing: ", test, "\n", "----------------------------------------------\n") end function check_timeout(tm, sl, elapsed, err, opp, mode, alldone) if tm < sl then if opp == "send" then if not err then warn("must be buffered") elseif err == "timeout" then pass("proper timeout") else fail("unexpected error '%s'", err) end else if err ~= "timeout" then fail("should have timed out") else pass("proper timeout") end end else if mode == "total" then if elapsed == nil then print ("WHOOPS elapsed wuz nil!+++") elapsed = 0 end if elapsed > tm then if err ~= "timeout" then fail("should have timed out") else pass("proper timeout") end elseif elapsed < tm then if err then fail(err) else pass("ok") end else if alldone then if err then fail("unexpected error '%s'", err) else pass("ok") end else if err ~= "timeout" then fail(err) else pass("proper timeoutk") end end end else if err then fail(err) else pass("ok") end end end end if not socket._DEBUG then fail("Please define LUASOCKET_DEBUG and recompile LuaSocket") end outf:write("----------------------------------------------\n", "LuaSocket Test Procedures\n", "----------------------------------------------\n") start = socket.gettime() function reconnect() outf:write("attempting data connection... ") if data then data:close() end remote [[ if data then data:close() data = nil end data = server:accept() data:setoption("tcp-nodelay", true) ]] data, err = socket.connect(host, port) if not data then fail(err) else pass("connected!") end data:setoption("tcp-nodelay", true) end pass("attempting control connection...") control, err = socket.connect(host, port) if err then fail(err) else pass("connected!") end control:setoption("tcp-nodelay", true) ------------------------------------------------------------------------ function test_methods(sock, methods) for _, v in pairs(methods) do if type(sock[v]) ~= "function" then fail(sock.class .. " method '" .. v .. "' not registered") end end pass(sock.class .. " methods are ok") end ------------------------------------------------------------------------ function test_mixed(len) reconnect() local inter = math.ceil(len/4) local p1 = "unix " .. string.rep("x", inter) .. "line\n" local p2 = "dos " .. string.rep("y", inter) .. "line\r\n" local p3 = "raw " .. string.rep("z", inter) .. "bytes" local p4 = "end" .. string.rep("w", inter) .. "bytes" local bp1, bp2, bp3, bp4 remote (string.format("str = data:receive(%d)", string.len(p1)+string.len(p2)+string.len(p3)+string.len(p4))) sent, err = data:send(p1..p2..p3..p4) if err then fail(err) end remote "data:send(str); data:close()" bp1, err = data:receive() if err then fail(err) end bp2, err = data:receive() if err then fail(err) end bp3, err = data:receive(string.len(p3)) if err then fail(err) end bp4, err = data:receive("*a") if err then fail(err) end if bp1.."\n" == p1 and bp2.."\r\n" == p2 and bp3 == p3 and bp4 == p4 then pass("patterns match") else fail("patterns don't match") end end ------------------------------------------------------------------------ function test_asciiline(len) reconnect() local str, str10, back, err str = string.rep("x", math.mod(len, 10)) str10 = string.rep("aZb.c#dAe?", math.floor(len/10)) str = str .. str10 remote "str = data:receive()" sent, err = data:send(str.."\n") if err then fail(err) end remote "data:send(str ..'\\n')" back, err = data:receive() if err then fail(err) end if back == str then pass("lines match") else fail("lines don't match") end end ------------------------------------------------------------------------ function test_rawline(len) reconnect() local str, str10, back, err str = string.rep(string.char(47), math.mod(len, 10)) str10 = string.rep(string.char(120,21,77,4,5,0,7,36,44,100), math.floor(len/10)) str = str .. str10 remote "str = data:receive()" sent, err = data:send(str.."\n") if err then fail(err) end remote "data:send(str..'\\n')" back, err = data:receive() if err then fail(err) end if back == str then pass("lines match") else fail("lines don't match") end end ------------------------------------------------------------------------ function test_raw(len) reconnect() local half = math.floor(len/2) local s1, s2, back, err s1 = string.rep("x", half) s2 = string.rep("y", len-half) remote (string.format("str = data:receive(%d)", len)) sent, err = data:send(s1) if err then fail(err) end sent, err = data:send(s2) if err then fail(err) end remote "data:send(str)" back, err = data:receive(len) if err then fail(err) end if back == s1..s2 then pass("blocks match") else fail("blocks don't match") end end ------------------------------------------------------------------------ function test_totaltimeoutreceive(len, tm, sl) reconnect() local str, err, partial pass("%d bytes, %ds total timeout, %ds pause", len, tm, sl) remote (string.format ([[ data:settimeout(%d) str = string.rep('a', %d) data:send(str) print('server: sleeping for %ds') socket.sleep(%d) print('server: woke up') data:send(str) ]], 2*tm, len, sl, sl)) data:settimeout(tm, "total") local t = socket.gettime() str, err, partial, elapsed = data:receive(2*len) check_timeout(tm, sl, elapsed, err, "receive", "total", string.len(str or partial) == 2*len) end ------------------------------------------------------------------------ function test_totaltimeoutsend(len, tm, sl) reconnect() local str, err, total pass("%d bytes, %ds total timeout, %ds pause", len, tm, sl) remote (string.format ([[ data:settimeout(%d) str = data:receive(%d) print('server: sleeping for %ds') socket.sleep(%d) print('server: woke up') str = data:receive(%d) ]], 2*tm, len, sl, sl, len)) data:settimeout(tm, "total") str = string.rep("a", 2*len) total, err, partial, elapsed = data:send(str) check_timeout(tm, sl, elapsed, err, "send", "total", total == 2*len) end ------------------------------------------------------------------------ function test_blockingtimeoutreceive(len, tm, sl) reconnect() local str, err, partial pass("%d bytes, %ds blocking timeout, %ds pause", len, tm, sl) remote (string.format ([[ data:settimeout(%d) str = string.rep('a', %d) data:send(str) print('server: sleeping for %ds') socket.sleep(%d) print('server: woke up') data:send(str) ]], 2*tm, len, sl, sl)) data:settimeout(tm) str, err, partial, elapsed = data:receive(2*len) check_timeout(tm, sl, elapsed, err, "receive", "blocking", string.len(str or partial) == 2*len) end ------------------------------------------------------------------------ function test_blockingtimeoutsend(len, tm, sl) reconnect() local str, err, total pass("%d bytes, %ds blocking timeout, %ds pause", len, tm, sl) remote (string.format ([[ data:settimeout(%d) str = data:receive(%d) print('server: sleeping for %ds') socket.sleep(%d) print('server: woke up') str = data:receive(%d) ]], 2*tm, len, sl, sl, len)) data:settimeout(tm) str = string.rep("a", 2*len) total, err, partial, elapsed = data:send(str) check_timeout(tm, sl, elapsed, err, "send", "blocking", total == 2*len) end ------------------------------------------------------------------------ function empty_connect() reconnect() if data then data:close() data = nil end remote [[ if data then data:close() data = nil end data = server:accept() ]] data, err = socket.connect("", port) if not data then pass("ok") data = socket.connect(host, port) else pass("gethostbyname returns localhost on empty string...") end end ------------------------------------------------------------------------ function isclosed(c) return c:getfd() == -1 or c:getfd() == (2^32-1) end function active_close() reconnect() if isclosed(data) then fail("should not be closed") end data:close() if not isclosed(data) then fail("should be closed") end data = nil local udp = socket.udp() if isclosed(udp) then fail("should not be closed") end udp:close() if not isclosed(udp) then fail("should be closed") end pass("ok") end ------------------------------------------------------------------------ function test_closed() local back, partial, err local str = 'little string' reconnect() pass("trying read detection") remote (string.format ([[ data:send('%s') data:close() data = nil ]], str)) -- try to get a line back, err, partial = data:receive() if not err then fail("should have gotten 'closed'.") elseif err ~= "closed" then fail("got '"..err.."' instead of 'closed'.") elseif str ~= partial then fail("didn't receive partial result.") else pass("graceful 'closed' received") end reconnect() pass("trying write detection") remote [[ data:close() data = nil ]] total, err, partial = data:send(string.rep("ugauga", 100000)) if not err then pass("failed: output buffer is at least %d bytes long!", total) elseif err ~= "closed" then fail("got '"..err.."' instead of 'closed'.") else pass("graceful 'closed' received after %d bytes were sent", partial) end end ------------------------------------------------------------------------ function test_selectbugs() local r, s, e = socket.select(nil, nil, 0.1) assert(type(r) == "table" and type(s) == "table" and (e == "timeout" or e == "error")) pass("both nil: ok") local udp = socket.udp() udp:close() r, s, e = socket.select({ udp }, { udp }, 0.1) assert(type(r) == "table" and type(s) == "table" and (e == "timeout" or e == "error")) pass("closed sockets: ok") e = pcall(socket.select, "wrong", 1, 0.1) assert(e == false) e = pcall(socket.select, {}, 1, 0.1) assert(e == false) pass("invalid input: ok") end ------------------------------------------------------------------------ function accept_timeout() outf:write("accept with timeout (if it hangs, it failed): ") local s, e = socket.bind("*", 0, 0) assert(s, e) local t = socket.gettime() s:settimeout(1) local c, e = s:accept() assert(not c, "should not accept") assert(e == "timeout", string.format("wrong error message (%s)", e)) t = socket.gettime() - t assert(t < 2, string.format("took to long to give up (%gs)", t)) s:close() pass("good") end ------------------------------------------------------------------------ function connect_timeout() outf:write("connect with timeout (if it hangs, it failed!): ") local t = socket.gettime() local c, e = socket.tcp() assert(c, e) c:settimeout(0.1) local t = socket.gettime() local r, e = c:connect("10.0.0.1", 81) print(r, e) assert(not r, "should not connect") assert(socket.gettime() - t < 2, "took too long to give up.") c:close() print("ok") end ------------------------------------------------------------------------ function accept_errors() outf:write("not listening: ") local d, e = socket.bind("*", 0) assert(d, e); local c, e = socket.tcp(); assert(c, e); d:setfd(c:getfd()) d:settimeout(2) local r, e = d:accept() assert(not r and e) print("ok: ", e) outf:write("not supported: ") local c, e = socket.udp() assert(c, e); d:setfd(c:getfd()) local r, e = d:accept() assert(not r and e) print("ok: ", e) end ------------------------------------------------------------------------ function connect_errors() outf:write("connection refused: ") local c, e = socket.connect("localhost", 1); assert(not c and e) print("ok: ", e) outf:write("host not found: ") local c, e = socket.connect("host.is.invalid", 1); assert(not c and e, e) print("ok: ", e) end ------------------------------------------------------------------------ function rebind_test() do return end local c = socket.bind("localhost", 0) local i, p = c:getsockname() local s, e = socket.tcp() assert(s, e) s:setoption("reuseaddr", false) r, e = s:bind("localhost", p) assert(not r, "managed to rebind!") assert(e) print("ok: ", e) end ------------------------------------------------------------------------ function getstats_test() reconnect() local t = 0 for i = 1, 25 do local c = math.random(1, 100) remote (string.format ([[ str = data:receive(%d) data:send(str) ]], c)) data:send(string.rep("a", c)) data:receive(c) t = t + c local r, s, a = data:getstats() assert(r == t, "received count failed" .. tostring(r) .. "/" .. tostring(t)) assert(s == t, "sent count failed" .. tostring(s) .. "/" .. tostring(t)) end print("ok") end ------------------------------------------------------------------------ function test_nonblocking(size) reconnect() print("Testing " .. 2*size .. " bytes") remote(string.format([[ data:send(string.rep("a", %d)) socket.sleep(0.5) data:send(string.rep("b", %d) .. "\n") ]], size, size)) local err = "timeout" local part = "" local str data:settimeout(0) while 1 do str, err, part = data:receive("*l", part) if err ~= "timeout" then break end end assert(str == (string.rep("a", size) .. string.rep("b", size))) reconnect() remote(string.format([[ str = data:receive(%d) socket.sleep(0.5) str = data:receive(2*%d, str) data:send(str) ]], size, size)) data:settimeout(0) local start = 0 while 1 do ret, err, start = data:send(str, start+1) if err ~= "timeout" then break end end data:send("\n") data:settimeout(-1) local back = data:receive(2*size) assert(back == str, "'" .. back .. "' vs '" .. str .. "'") print("ok") end ------------------------------------------------------------------------ function test_readafterclose() local back, partial, err local str = 'little string' reconnect() pass("trying repeated '*a' pattern") remote (string.format ([[ data:send('%s') data:close() data = nil ]], str)) back, err, partial = data:receive("*a") assert(back == str, "unexpected data read") back, err, partial = data:receive("*a") assert(back == nil and err == "closed", "should have returned 'closed'") print("ok") reconnect() pass("trying active close before '*a'") remote (string.format ([[ data:close() data = nil ]])) data:close() back, err, partial = data:receive("*a") assert(back == nil and err == "closed", "should have returned 'closed'") print("ok") reconnect() pass("trying active close before '*l'") remote (string.format ([[ data:close() data = nil ]])) data:close() back, err, partial = data:receive() assert(back == nil and err == "closed", "should have returned 'closed'") print("ok") reconnect() pass("trying active close before raw 1") remote (string.format ([[ data:close() data = nil ]])) data:close() back, err, partial = data:receive(1) assert(back == nil and err == "closed", "should have returned 'closed'") print("ok") reconnect() pass("trying active close before raw 0") remote (string.format ([[ data:close() data = nil ]])) data:close() back, err, partial = data:receive(0) assert(back == nil and err == "closed", "should have returned 'closed'") print("ok") end test("method registration") test_methods(socket.tcp(), { "accept", "bind", "close", "connect", "dirty", "getfd", "getpeername", "getsockname", "getstats", "setstats", "listen", "receive", "send", "setfd", "setoption", "setpeername", "setsockname", "settimeout", "shutdown", }) test_methods(socket.udp(), { "close", "getpeername", "dirty", "getfd", "getpeername", "getsockname", "receive", "receivefrom", "send", "sendto", "setfd", "setoption", "setpeername", "setsockname", "settimeout" }) test("testing read after close") test_readafterclose() test("select function") test_selectbugs() test("connect function") connect_timeout() empty_connect() connect_errors() test("rebinding: ") rebind_test() test("active close: ") active_close() test("closed connection detection: ") test_closed() test("accept function: ") accept_timeout() accept_errors() test("getstats test") getstats_test() test("character line") test_asciiline(1) test_asciiline(17) test_asciiline(200) test_asciiline(4091) test_asciiline(80199) test_asciiline(8000000) test_asciiline(80199) test_asciiline(4091) test_asciiline(200) test_asciiline(17) test_asciiline(1) test("mixed patterns") test_mixed(1) test_mixed(17) test_mixed(200) test_mixed(4091) test_mixed(801990) test_mixed(4091) test_mixed(200) test_mixed(17) test_mixed(1) test("binary line") test_rawline(1) test_rawline(17) test_rawline(200) test_rawline(4091) test_rawline(80199) test_rawline(8000000) test_rawline(80199) test_rawline(4091) test_rawline(200) test_rawline(17) test_rawline(1) test("raw transfer") test_raw(1) test_raw(17) test_raw(200) test_raw(4091) test_raw(80199) test_raw(8000000) test_raw(80199) test_raw(4091) test_raw(200) test_raw(17) test_raw(1) test("non-blocking transfer") test_nonblocking(1) test_nonblocking(17) test_nonblocking(200) test_nonblocking(4091) test_nonblocking(80199) test_nonblocking(800000) test_nonblocking(80199) test_nonblocking(4091) test_nonblocking(200) test_nonblocking(17) test_nonblocking(1) test("total timeout on send") test_totaltimeoutsend(800091, 1, 3) test_totaltimeoutsend(800091, 2, 3) test_totaltimeoutsend(800091, 5, 2) test_totaltimeoutsend(800091, 3, 1) test("total timeout on receive") test_totaltimeoutreceive(800091, 1, 3) test_totaltimeoutreceive(800091, 2, 3) test_totaltimeoutreceive(800091, 3, 2) test_totaltimeoutreceive(800091, 3, 1) test("blocking timeout on send") test_blockingtimeoutsend(800091, 1, 3) test_blockingtimeoutsend(800091, 2, 3) test_blockingtimeoutsend(800091, 3, 2) test_blockingtimeoutsend(800091, 3, 1) test("blocking timeout on receive") test_blockingtimeoutreceive(800091, 1, 3) test_blockingtimeoutreceive(800091, 2, 3) test_blockingtimeoutreceive(800091, 3, 2) test_blockingtimeoutreceive(800091, 3, 1) remote 'quit' test(string.format("done in %.2fs", socket.gettime() - start))
mit
waterlgndx/darkstar
scripts/zones/Windurst_Waters/npcs/Yung_Yaam.lua
2
1253
----------------------------------- -- Area: Windurst Waters -- NPC: Yung Yaam -- Involved In Quest: Wondering Minstrel -- !pos -63 -4 27 238 ----------------------------------- package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Windurst_Waters/TextIDs"); require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/quests"); require("scripts/globals/titles"); ----------------------------------- function onTrade(player,npc,trade) end; function onTrigger(player,npc) --player:addFame(WINDURST,100) wonderingstatus = player:getQuestStatus(WINDURST,WONDERING_MINSTREL); fame = player:getFameLevel(WINDURST) if (wonderingstatus <= 1 and fame >= 5) then player:startEvent(637); -- WONDERING_MINSTREL: Quest Available / Quest Accepted elseif (wonderingstatus == QUEST_COMPLETED and player:needToZone()) then player:startEvent(643); -- WONDERING_MINSTREL: Quest After else player:startEvent(609); -- Standard Conversation end end; function onEventUpdate(player,csid,option) end; function onEventFinish(player,csid,option) end;
gpl-3.0
davidedmonds/darkstar
scripts/globals/weaponskills/shijin_spiral.lua
18
1806
----------------------------------- -- Shijin Spiral -- Hand-to-Hand weapon skill -- Skill Level: N/A -- Delivers a fivefold attack that Plagues the target. Chance of inflicting Plague varies with TP. -- In order to obtain Shijin Spiral, the quest Martial Mastery must be completed. -- Aligned with the Flame Gorget, Light Gorget & Aqua Gorget. -- Aligned with the Flame Belt, Light Belt & Aqua Belt. -- Element: None -- Modifiers: DEX: 73~85% -- 100%TP 200%TP 300%TP -- 1.0625 1.0625 1.0625 ----------------------------------- require("scripts/globals/status"); require("scripts/globals/settings"); require("scripts/globals/weaponskills"); ----------------------------------- function onUseWeaponSkill(player, target, wsID) local params = {}; params.numHits = 5; params.ftp100 = 1.0625; params.ftp200 = 1.0625; params.ftp300 = 1.0625; params.str_wsc = 0.0; params.dex_wsc = 0.85 + (player:getMerit(MERIT_SHIJIN_SPIRAL) / 100); params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0; params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0; params.canCrit = false; params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0; params.atkmulti = 1.05; local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, params); if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then params.dex_wsc = 0.7 + (player:getMerit(MERIT_SHIJIN_SPIRAL) / 100); end if damage > 0 then local tp = player:getTP(); local duration = (tp/100) + 4; if (target:hasStatusEffect(EFFECT_PLAGUE) == false) then target:addStatusEffect(EFFECT_PLAGUE, 5, 0, duration); end end damage = damage * WEAPON_SKILL_POWER return tpHits, extraHits, criticalHit, damage; end
gpl-3.0
kidaa/darkstar
scripts/globals/items/dish_of_spaghetti_boscaiola_+1.lua
35
1724
----------------------------------------- -- ID: 5201 -- Item: dish_of_spaghetti_boscaiola_+1 -- Food Effect: 30Min, All Races ----------------------------------------- -- Health % 18 -- Health Cap 125 -- Magic 40 -- Strength -5 -- Dexterity -2 -- Vitality 2 -- Mind 4 -- Magic Regen While Healing 1 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,1800,5201); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_FOOD_HPP, 18); target:addMod(MOD_FOOD_HP_CAP, 125); target:addMod(MOD_MP, 40); target:addMod(MOD_STR, -5); target:addMod(MOD_DEX, -2); target:addMod(MOD_VIT, 2); target:addMod(MOD_MND, 4); target:addMod(MOD_MPHEAL, 1); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_FOOD_HPP, 18); target:delMod(MOD_FOOD_HP_CAP, 125); target:delMod(MOD_MP, 40); target:delMod(MOD_STR, -5); target:delMod(MOD_DEX, -2); target:delMod(MOD_VIT, 2); target:delMod(MOD_MND, 4); target:delMod(MOD_MPHEAL, 1); end;
gpl-3.0
badboyam/telebot
plugins/danbooru.lua
616
1750
do local URL = "http://danbooru.donmai.us" local URL_NEW = "/posts.json" local URL_POP = "/explore/posts/popular.json" local scale_day = "?scale=day" local scale_week = "?scale=week" local scale_month = "?scale=month" local function get_post(url) local b, c, h = http.request(url) if c ~= 200 then return nil end local posts = json:decode(b) return posts[math.random(#posts)] end local function run(msg, matches) local url = URL if matches[1] == "!danbooru" then url = url .. URL_NEW else url = url .. URL_POP if matches[1] == "d" then url = url .. scale_day elseif matches[1] == "w" then url = url .. scale_week elseif matches[1] == "m" then url = url .. scale_month end end local post = get_post(url) if post then vardump(post) local img = URL .. post.large_file_url send_photo_from_url(get_receiver(msg), img) local txt = '' if post.tag_string_artist ~= '' then txt = 'Artist: ' .. post.tag_string_artist .. '\n' end if post.tag_string_character ~= '' then txt = txt .. 'Character: ' .. post.tag_string_character .. '\n' end if post.file_size ~= '' then txt = txt .. '[' .. math.ceil(post.file_size/1000) .. 'kb] ' .. URL .. post.file_url end return txt end end return { description = "Gets a random fresh or popular image from Danbooru", usage = { "!danbooru - gets a random fresh image from Danbooru 🔞", "!danboorud - random daily popular image 🔞", "!danbooruw - random weekly popular image 🔞", "!danboorum - random monthly popular image 🔞" }, patterns = { "^!danbooru$", "^!danbooru ?(d)$", "^!danbooru ?(w)$", "^!danbooru ?(m)$" }, run = run } end
gpl-2.0
Maxsteam/1bot
plugins/danbooru.lua
616
1750
do local URL = "http://danbooru.donmai.us" local URL_NEW = "/posts.json" local URL_POP = "/explore/posts/popular.json" local scale_day = "?scale=day" local scale_week = "?scale=week" local scale_month = "?scale=month" local function get_post(url) local b, c, h = http.request(url) if c ~= 200 then return nil end local posts = json:decode(b) return posts[math.random(#posts)] end local function run(msg, matches) local url = URL if matches[1] == "!danbooru" then url = url .. URL_NEW else url = url .. URL_POP if matches[1] == "d" then url = url .. scale_day elseif matches[1] == "w" then url = url .. scale_week elseif matches[1] == "m" then url = url .. scale_month end end local post = get_post(url) if post then vardump(post) local img = URL .. post.large_file_url send_photo_from_url(get_receiver(msg), img) local txt = '' if post.tag_string_artist ~= '' then txt = 'Artist: ' .. post.tag_string_artist .. '\n' end if post.tag_string_character ~= '' then txt = txt .. 'Character: ' .. post.tag_string_character .. '\n' end if post.file_size ~= '' then txt = txt .. '[' .. math.ceil(post.file_size/1000) .. 'kb] ' .. URL .. post.file_url end return txt end end return { description = "Gets a random fresh or popular image from Danbooru", usage = { "!danbooru - gets a random fresh image from Danbooru 🔞", "!danboorud - random daily popular image 🔞", "!danbooruw - random weekly popular image 🔞", "!danboorum - random monthly popular image 🔞" }, patterns = { "^!danbooru$", "^!danbooru ?(d)$", "^!danbooru ?(w)$", "^!danbooru ?(m)$" }, run = run } end
gpl-2.0
MonokuroInzanaito/ygopro-777DIY
expansions/script/c60159119.lua
1
4551
--八枢罪之始 祈愿 function c60159119.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e1) local e3=Effect.CreateEffect(c) e3:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetRange(LOCATION_SZONE) e3:SetCountLimit(1,60159119) e3:SetCost(c60159119.thcost) e3:SetTarget(c60159119.thtg) e3:SetOperation(c60159119.thop) c:RegisterEffect(e3) --draw local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_DRAW) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetRange(LOCATION_SZONE) e2:SetCode(EVENT_LEAVE_FIELD) e2:SetCountLimit(1,60159119) e2:SetCondition(c60159119.drcon) e2:SetTarget(c60159119.drtg) e2:SetOperation(c60159119.drop) c:RegisterEffect(e2) --spsummon local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e2:SetCode(EVENT_TO_GRAVE) e2:SetCountLimit(1,6019119+EFFECT_COUNT_CODE_DUEL) e2:SetCondition(c60159119.spcon) e2:SetTarget(c60159119.sptg) e2:SetOperation(c60159119.spop) c:RegisterEffect(e2) end function c60159119.cfilter(c) return c:IsSetCard(0x3b25) and c:IsType(TYPE_SPELL) and c:IsAbleToRemoveAsCost() end function c60159119.thcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c60159119.cfilter,tp,LOCATION_HAND+LOCATION_GRAVE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,c60159119.cfilter,tp,LOCATION_HAND+LOCATION_GRAVE,0,1,1,nil) Duel.Remove(g,POS_FACEUP,REASON_COST) end function c60159119.filter(c) return c:IsSetCard(0x3b25) and c:IsAbleToHand() end function c60159119.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c60159119.filter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function c60159119.thop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,c60159119.filter,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 c60159119.cfilter2(c,tp) return c:IsReason(REASON_EFFECT) and c:IsPreviousLocation(LOCATION_ONFIELD) and rp~=tp and c:IsType(TYPE_XYZ) and c:IsSetCard(0x3b25) end function c60159119.drcon(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(c60159119.cfilter2,1,nil,tp) end function c60159119.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 c60159119.drop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Draw(p,d,REASON_EFFECT) end function c60159119.spcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return c:GetPreviousControler()==tp and rp~=tp and bit.band(r,0x41)==0x41 and c:GetPreviousPosition(POS_FACEUP) and c:IsPreviousLocation(LOCATION_ONFIELD) end function c60159119.xyzfilter(c,e,tp,mc) return c:IsType(TYPE_XYZ) and c:IsSetCard(0x3b25) and c:GetRank()==5 and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_XYZ,tp,false,false) end function c60159119.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c60159119.xyzfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,e:GetHandler()) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function c60159119.spop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end if e:GetHandler():IsFaceup() and not e:GetHandler():IsPreviousLocation(LOCATION_DECK+LOCATION_HAND) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c60159119.xyzfilter,tp,LOCATION_EXTRA,0,1,1,nil,e,tp,e:GetHandler()) local sc=g:GetFirst() if sc then sc:SetMaterial(Group.FromCards(e:GetHandler())) Duel.Overlay(sc,Group.FromCards(e:GetHandler())) Duel.SpecialSummon(sc,SUMMON_TYPE_XYZ,tp,tp,false,false,POS_FACEUP) sc:CompleteProcedure() end end end
gpl-3.0
will4wachter/Project1
scripts/globals/mobskills/Dominion_Slash.lua
10
1573
--------------------------------------------- -- Domionion Slash -- -- Description: Performs an area of effect slashing weaponskill. Additional effect: Silence -- Type: Physical -- 2-3 Shadows -- Range: Unknown radial -- One source also mentions that it "can dispel important buffs." --------------------------------------------- require("/scripts/globals/settings"); require("/scripts/globals/status"); require("/scripts/globals/monstertpmoves"); --------------------------------------------- function OnMobSkillCheck(target,mob,skill) return 0; end; function OnMobWeaponSkill(target, mob, skill) -- TODO: Can skillchain? Unknown property. local numhits = 1; local accmod = 1; local dmgmod = 3.25; local info = MobPhysicalMove(mob,target,skill,numhits,accmod,dmgmod,TP_DMG_VARIES,1,2,3); local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_PHYSICAL,MOBPARAM_SLASH,MOBPARAM_2_SHADOW); MobStatusEffectMove(mob, target, EFFECT_SILENCE, 1, 0, 60); -- Due to conflicting information, making the dispel resistable. Correct/tweak if wrong. -- Dispel has no status effect or resistance gear, so 0s instead of nulls. local resist = applyPlayerResistance(mob,0,target,mob:getStat(MOD_INT)-target:getStat(MOD_INT),0,ELE_LIGHT); if(resist > 0.0625) then target:dispelStatusEffect(); end -- TODO: Dispel message -- Damage is HIGHLY conflicting. Witnessed anywhere from 300 to 900. -- TP DMG VARIES can sort of account for this, but I feel like it's still not right. target:delHP(dmg); return dmg; end;
gpl-3.0
waterlgndx/darkstar
scripts/zones/Metalworks/npcs/Pius.lua
2
1472
----------------------------------- -- Area: Metalworks -- NPC: Pius -- Involved In Mission: Journey Abroad -- !pos 99 -21 -12 237 ----------------------------------- package.loaded["scripts/zones/Metalworks/TextIDs"] = nil; ----------------------------------- require("scripts/globals/missions"); require("scripts/zones/Metalworks/TextIDs"); ----------------------------------- function onTrade(player,npc,trade) end; function onTrigger(player,npc) Mission = player:getCurrentMission(player:getNation()); MissionStatus = player:getVar("MissionStatus"); if (Mission == JOURNEY_TO_BASTOK and MissionStatus == 3 or Mission == JOURNEY_TO_BASTOK2 and MissionStatus == 8) then player:startEvent(355); elseif (Mission == THE_THREE_KINGDOMS_BASTOK and MissionStatus == 3 or Mission == THE_THREE_KINGDOMS_BASTOK2 and MissionStatus == 8) then player:startEvent(355,1); elseif (Mission == JOURNEY_TO_BASTOK or Mission == JOURNEY_TO_BASTOK2 or Mission == THE_THREE_KINGDOMS_BASTOK2 and MissionStatus < 11) then player:startEvent(356); else player:startEvent(350); end end; function onEventUpdate(player,csid,option) end; function onEventFinish(player,csid,option) if (csid == 355) then if (player:getVar("MissionStatus") == 3) then player:setVar("MissionStatus",4); else player:setVar("MissionStatus",9); end end end;
gpl-3.0
kidaa/darkstar
scripts/zones/Port_Bastok/npcs/Tete.lua
19
1293
----------------------------------- -- Area: Port Bastok -- NPC: Tete -- Continues Quest: The Wisdom Of Elders ----------------------------------- package.loaded["scripts/zones/Port_Bastok/TextIDs"] = nil; ------------------------------------ require("scripts/globals/settings"); require("scripts/globals/quests"); require("scripts/zones/Port_Bastok/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if(player:getQuestStatus(BASTOK,THE_WISDOM_OF_ELDERS) == QUEST_ACCEPTED) then player:startEvent(0x00af); else player:startEvent(0x0023); 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 == 0x00af) then player:setVar("TheWisdomVar",2); end end;
gpl-3.0
waterlgndx/darkstar
scripts/globals/spells/wind_carol.lua
2
1566
----------------------------------------- -- Spell: Wind Carol -- Increases wind resistance for party members within the area of effect. ----------------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); require("scripts/globals/msg"); ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) local sLvl = caster:getSkillLevel(dsp.skill.SINGING); -- Gets skill level of Singing local iLvl = caster:getWeaponSkillLevel(dsp.slot.RANGED); local power = 20; if (sLvl+iLvl > 200) then power = power + math.floor((sLvl+iLvl-200) / 10); end if (power >= 40) then power = 40; end local iBoost = caster:getMod(dsp.mod.CAROL_EFFECT) + caster:getMod(dsp.mod.ALL_SONGS_EFFECT); power = power + iBoost*5; if (caster:hasStatusEffect(dsp.effect.SOUL_VOICE)) then power = power * 2; elseif (caster:hasStatusEffect(dsp.effect.MARCATO)) then power = power * 1.5; end caster:delStatusEffect(dsp.effect.MARCATO); local duration = 120; duration = duration * ((iBoost * 0.1) + (caster:getMod(dsp.mod.SONG_DURATION_BONUS)/100) + 1); if (caster:hasStatusEffect(dsp.effect.TROUBADOUR)) then duration = duration * 2; end if not (target:addBardSong(caster,dsp.effect.CAROL,power,0,duration,caster:getID(), dsp.magic.ele.WIND, 1)) then spell:setMsg(dsp.msg.basic.MAGIC_NO_EFFECT); end return dsp.effect.CAROL; end;
gpl-3.0
davidedmonds/darkstar
scripts/globals/items/strip_of_bison_jerky.lua
35
1398
----------------------------------------- -- ID: 5207 -- Item: strip_of_bison_jerky -- Food Effect: 60Min, All Races ----------------------------------------- -- Strength 5 -- Mind -2 -- Attack % 18 -- Attack Cap 70 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,3600,5207); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_STR, 5); target:addMod(MOD_MND, -2); target:addMod(MOD_FOOD_ATTP, 18); target:addMod(MOD_FOOD_ATT_CAP, 70); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_STR, 5); target:delMod(MOD_MND, -2); target:delMod(MOD_FOOD_ATTP, 18); target:delMod(MOD_FOOD_ATT_CAP, 70); end;
gpl-3.0
will4wachter/Project1
scripts/globals/items/strip_of_bison_jerky.lua
35
1398
----------------------------------------- -- ID: 5207 -- Item: strip_of_bison_jerky -- Food Effect: 60Min, All Races ----------------------------------------- -- Strength 5 -- Mind -2 -- Attack % 18 -- Attack Cap 70 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,3600,5207); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_STR, 5); target:addMod(MOD_MND, -2); target:addMod(MOD_FOOD_ATTP, 18); target:addMod(MOD_FOOD_ATT_CAP, 70); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_STR, 5); target:delMod(MOD_MND, -2); target:delMod(MOD_FOOD_ATTP, 18); target:delMod(MOD_FOOD_ATT_CAP, 70); end;
gpl-3.0
davidedmonds/darkstar
scripts/zones/Gusgen_Mines/npcs/_5ga.lua
34
1361
----------------------------------- -- Area: Gusgen Mines -- NPC: _5ga (Lever C) -- @pos 44 -40.561 -54.199 196 ----------------------------------- package.loaded["scripts/zones/Gusgen_Mines/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Gusgen_Mines/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) --local nID = npc:getID(); --printf("id: %u", nID); local Lever = npc:getID(); npc:openDoor(2); -- Lever animation if (GetNPCByID(Lever-6):getAnimation() == 9) then GetNPCByID(Lever-6):setAnimation(8);--open door C (_5g0) GetNPCByID(Lever-5):setAnimation(9);--close door B (_5g1) GetNPCByID(Lever-4):setAnimation(9);--close door A (_5g2) 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
MonokuroInzanaito/ygopro-777DIY
expansions/script/c23310023.lua
1
3186
--灵魂歌手 function c23310023.initial_effect(c) --xyz summon aux.AddXyzProcedure(c,nil,3,2) c:EnableReviveLimit() -- local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(23310023,0)) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetCondition(c23310023.discon) e1:SetCost(c23310023.discost) e1:SetTarget(c23310023.distg) e1:SetOperation(c23310023.disop) c:RegisterEffect(e1) --todeck local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(23310023,1)) e2:SetCategory(CATEGORY_DESTROY+CATEGORY_TODECK) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_MZONE) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetCountLimit(1,23310023) e2:SetTarget(c23310023.tdtg) e2:SetOperation(c23310023.tdop) c:RegisterEffect(e2) end function c23310023.discon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetSummonType()==SUMMON_TYPE_XYZ end function c23310023.discost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,2,REASON_COST) end e:GetHandler():RemoveOverlayCard(tp,2,2,REASON_COST) end function c23310023.distg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetOverlayCount(tp,1,1)>e:GetHandler():GetOverlayCount() end end function c23310023.disfilter(c,oc) return c:GetOverlayTarget()==oc end function c23310023.disop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetOverlayCount(tp,1,1)>e:GetHandler():GetOverlayCount() then local g1=Duel.GetOverlayGroup(tp,1,1) g1:Remove(c23310023.disfilter,nil,e:GetHandler()) Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(23310023,1)) local mg2=g1:Select(tp,1,2,nil) local oc1=mg2:GetFirst():GetOverlayTarget() local oc2=mg2:GetNext():GetOverlayTarget() Duel.Overlay(e:GetHandler(),mg2) Duel.RaiseSingleEvent(oc1,EVENT_DETACH_MATERIAL,e,0,0,0,0) if oc2~=oc1 then Duel.RaiseSingleEvent(oc2,EVENT_DETACH_MATERIAL,e,0,0,0,0) end end end function c23310023.tdtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.CheckRemoveOverlayCard(tp,1,1,1,REASON_EFFECT) end end function c23310023.filter(c) return c:GetOverlayCount()==0 and c:IsType(TYPE_XYZ) end function c23310023.tdop(e,tp,eg,ep,ev,re,r,rp) local sg=Duel.GetMatchingGroup(Card.CheckRemoveOverlayCard,tp,LOCATION_MZONE,LOCATION_MZONE,nil,tp,1,REASON_EFFECT) if sg:GetCount()==0 then return end if sg:GetCount()>1 then Duel.Hint(HINT_SELECTMSG,tp,532) sg=sg:Select(tp,1,1,nil) Duel.HintSelection(sg) end if sg:GetFirst()==e:GetHandler() then sg:GetFirst():RemoveOverlayCard(tp,1,1,REASON_EFFECT) local dg=Duel.GetMatchingGroup(c23310023.filter,tp,LOCATION_MZONE,LOCATION_MZONE,nil) if dg:GetCount()>0 and Duel.Destroy(dg,REASON_EFFECT)~=0 and Duel.IsExistingTarget(Card.IsAbleToDeck,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,nil) and Duel.SelectYesNo(tp,aux.Stringid(23310023,2)) then Duel.BreakEffect() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) local g=Duel.SelectMatchingCard(tp,Card.IsAbleToDeck,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,nil) if g:GetCount()>0 then Duel.HintSelection(g) Duel.SendtoDeck(g,nil,2,REASON_EFFECT) end end else sg:GetFirst():RemoveOverlayCard(tp,1,1,REASON_EFFECT) end end
gpl-3.0
davidedmonds/darkstar
scripts/zones/Pashhow_Marshlands/npcs/Cavernous_Maw.lua
29
1512
----------------------------------- -- Area: Pashhow Marshlands -- NPC: Cavernous Maw -- @pos 418 25 27 109 -- Teleports Players to Pashhow Marshlands [S] ----------------------------------- package.loaded["scripts/zones/Pashhow_Marshlands/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/teleports"); require("scripts/globals/campaign"); require("scripts/zones/Pashhow_Marshlands/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (ENABLE_WOTG == 1 and player:hasKeyItem(PURE_WHITE_FEATHER) and hasMawActivated(player,4)) then player:startEvent(0x0389); else player:messageSpecial(NOTHING_HAPPENS); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish Action ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x0389 and option == 1) then toMaw(player,15); end end;
gpl-3.0
MonokuroInzanaito/ygopro-777DIY
expansions/script/c29201061.lua
1
5688
--镜世录 黄泉归航 function c29201061.initial_effect(c) --send local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(29201061,0)) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e1:SetCode(EVENT_DAMAGE) e1:SetRange(LOCATION_GRAVE) e1:SetCondition(c29201061.recon) e1:SetTarget(c29201061.rectg) e1:SetOperation(c29201061.recop) c:RegisterEffect(e1) --spsummon local ea=Effect.CreateEffect(c) ea:SetDescription(aux.Stringid(29201061,1)) ea:SetCategory(CATEGORY_SPECIAL_SUMMON) ea:SetProperty(EFFECT_FLAG_CARD_TARGET) ea:SetType(EFFECT_TYPE_IGNITION) ea:SetRange(LOCATION_SZONE) ea:SetTarget(c29201061.target) ea:SetOperation(c29201061.operation) c:RegisterEffect(ea) --remove local e10=Effect.CreateEffect(c) e10:SetCategory(CATEGORY_DESTROY+CATEGORY_TOHAND+CATEGORY_SEARCH) e10:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e10:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e10:SetCode(EVENT_SPSUMMON_SUCCESS) e10:SetCountLimit(1,29201061) e10:SetCondition(c29201061.thcon) e10:SetTarget(c29201061.thtg) e10:SetOperation(c29201061.thop) c:RegisterEffect(e10) --splimit local e12=Effect.CreateEffect(c) e12:SetType(EFFECT_TYPE_FIELD) e12:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e12:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e12:SetRange(LOCATION_ONFIELD) e12:SetTargetRange(1,0) e12:SetTarget(c29201061.splimit) c:RegisterEffect(e12) local e13=Effect.CreateEffect(c) e13:SetType(EFFECT_TYPE_FIELD) e13:SetCode(EFFECT_CANNOT_SUMMON) e13:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e13:SetRange(LOCATION_ONFIELD) e13:SetTargetRange(1,0) e13:SetTarget(c29201061.splimit) c:RegisterEffect(e13) end function c29201061.thcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsPreviousLocation(LOCATION_SZONE) end function c29201061.thfilter(c) return c:IsSetCard(0x63e0) and c:IsType(TYPE_MONSTER) and not c:IsCode(29201061) and c:IsAbleToHand() end function c29201061.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(tp) and chkc:IsOnField() and chkc:IsDestructable() end if chk==0 then return Duel.IsExistingTarget(Card.IsDestructable,tp,LOCATION_ONFIELD,0,1,nil) and Duel.IsExistingMatchingCard(c29201061.thfilter,tp,LOCATION_DECK,0,1,nil) end local g=Duel.GetMatchingGroup(c29201061.thfilter,tp,LOCATION_DECK,0,nil) local ct=g:GetClassCount(Card.GetCode) if ct>2 then ct=2 end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local dg=Duel.SelectTarget(tp,Card.IsDestructable,tp,LOCATION_ONFIELD,0,1,ct,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,dg,dg:GetCount(),0,0) Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,dg:GetCount(),tp,LOCATION_DECK) end function c29201061.thop(e,tp,eg,ep,ev,re,r,rp) local dg=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect,nil,e) local ct=Duel.Destroy(dg,REASON_EFFECT) local g=Duel.GetMatchingGroup(c29201061.thfilter,tp,LOCATION_DECK,0,nil) if ct==0 or g:GetCount()==0 then return end if ct>g:GetClassCount(Card.GetCode) then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g1=g:Select(tp,1,1,nil) if ct==2 then g:Remove(Card.IsCode,nil,g1:GetFirst():GetCode()) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g2=g:Select(tp,1,1,nil) g1:Merge(g2) end Duel.SendtoHand(g1,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g1) end function c29201061.splimit(e,c) return not c:IsSetCard(0x63e0) end function c29201061.recon(e,tp,eg,ep,ev,re,r,rp) return ep==tp end function c29201061.rectg(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and c:GetLocation()==LOCATION_GRAVE end end function c29201061.recop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 then return end if c:GetLocation()~=LOCATION_GRAVE then return false end if c:IsRelateToEffect(e) then Duel.MoveToField(c,tp,tp,LOCATION_SZONE,POS_FACEUP,true) local e1=Effect.CreateEffect(e:GetHandler()) 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) Duel.RaiseEvent(c,EVENT_CUSTOM+29201000,e,0,tp,0,0) end end function c29201061.filter(c) return c:IsFaceup() and c:IsSetCard(0x63e0) and c:IsDestructable() end function c29201061.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c29201061.filter(chkc) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>-1 and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) and Duel.IsExistingTarget(c29201061.filter,tp,LOCATION_MZONE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectTarget(tp,c29201061.filter,tp,LOCATION_MZONE,0,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function c29201061.operation(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) and Duel.Destroy(tc,REASON_EFFECT)~=0 and c:IsRelateToEffect(e) then Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP) end end
gpl-3.0
mynameiscraziu/baby
plugins/sicktir.lua
4
2145
local function run(msg) if msg.text == "hi" then return "سلام خوش اومدی " end if msg.text == "Hi" then return "سلام خوش اومدی " end if msg.text == "Hello" then return "Hi bb" end if msg.text == "hello" then return "Hi honey" end if msg.text == "Salam" then return "Salam aleykom" end if msg.text == "salam" then return "گیریم سلام بعدش ؟" end if msg.text == "zac" then return "زاک رو که هزار بار گاییدم" end if msg.text == "Zac" then return "زاک که ننش زیرمه " end if msg.text == "ZAC" then return "برا شما بزنه ساک " end if msg.text == "Umbrella" then return "Yes?" end if msg.text == "umbrella" then return "رباتی که از ما اسکی رفت ؟" end if msg.text == "bot" then return "چیه ؟" end if msg.text == "Bot" then return "بناللللللل دیگ " end if msg.text == "?" then return "؟ این چیه اخه " end if msg.text == "Bye" then return "بسلامت " end if msg.text == "bye" then return "Bye Bye" end if msg.text == "kosenanat" then return "کس ننه خودت مادر جنده " end if msg.text =="Kosenanat" then return " کس ننه خودت مادر جنده " end if msg.text == "madar jende" then return " جنده ننته خارکونی " end if msg.text == " ننتو گاییدم " then return " ننت که الان میگاییدم بیا جمش کن " end if msg.text == " کیر " then return " دلت میخواد ؟" end if msg.text == " خوبی آبجی ؟" then return " کص لیسی ممنوع " end if msg.text == " mafia" then return " مافیا ک همشون چوس ممبر گاییدن نداره چچچ " end if msg.text == " MAFIA" then return " مافیا که همشون چوس ممبر گاییدن نداره چچچ " end end return { description = "Chat With Robot Server", usage = "chat with robot", patterns = { "^[Hh]i$", "^[Kk]osenanat$", "^[Mm]afia$, "^[Hh]ello$", "^[Zz]ac$", "^ZAC$", "^[Bb]ot$", "^[Uu]mbrella$", "^[Bb]ye$", "^?$", "^[Ss]alam$", }, run = run, --privileged = true, pre_process = pre_process }
gpl-2.0
waterlgndx/darkstar
scripts/zones/Temenos/npcs/Matter_Diffusion_Module.lua
2
5989
----------------------------------- -- Area: temenos -- NPC: Matter diffusion module -- !pos ----------------------------------- package.loaded["scripts/zones/Temenos/TextIDs"] = nil; ----------------------------------- require("scripts/globals/limbus"); require("scripts/globals/keyitems"); require("scripts/zones/Temenos/TextIDs"); function onTrade(player,npc,trade) local count = trade:getItemCount(); local InstanceTrade=0; if (player:hasKeyItem(dsp.ki.COSMOCLEANSE) and player:hasKeyItem(dsp.ki.WHITE_CARD) ) then if (count==1 and trade:hasItemQty(2127,1)) then -- Central Temenos - Basement 1 InstanceTrade=128; elseif (count==1 and trade:hasItemQty(1906,1)) then -- Central Temenos - 1st Floor InstanceTrade=64; elseif (count==1 and trade:hasItemQty(1905,1)) then -- Central Temenos - 2st Floor InstanceTrade=32; elseif (count==1 and trade:hasItemQty(1904,1)) then -- Central Temenos - 3st Floor InstanceTrade=16; elseif (count==3 and trade:hasItemQty(1986,1) and trade:hasItemQty(1908,1) and trade:hasItemQty(1907,1)) then --proto-ultima InstanceTrade=8; end else player:messageSpecial(CONDITION_FOR_LIMBUS_T); print("error player don't have cosmo clean"); end if (InstanceTrade~=0) then player:setVar("Limbus_Trade_Item-T",InstanceTrade); player:tradeComplete(); player:messageSpecial(CHIP_TRADE_T); player:startEvent(32000,0,0,0,InstanceTrade,0,0,0,0); player:setVar("limbusbitmap",InstanceTrade); end end; function onTrigger(player,npc) local instancelist ={}; local limbusbitmap = 0 ; local AllowLimbusToPlayer = true ; local currentlimbus= TryTobackOnCurrentLimbus(player); instancelist = TEMENOS_LIST; printf("currentlimbus: %u",currentlimbus); if (player:hasKeyItem(dsp.ki.COSMOCLEANSE)) then if (player:hasStatusEffect(dsp.effect.BATTLEFIELD) == false) then local LimbusTradeItem = player:getVar("Limbus_Trade_Item-T"); for nt = 1,#instancelist,2 do -- printf("list d'instance: %u",instancelist[nt]); if (instancelist[nt+1][1]==true and player:hasKeyItem(dsp.ki.WHITE_CARD)) then -- print("player_have_white_card"); limbusbitmap = limbusbitmap + instancelist[nt+1][4]; -- printf("bitmapadd: %u",instancelist[nt+1][4]); end if (instancelist[nt+1][2]==true and player:hasKeyItem(dsp.ki.RED_CARD)) then -- print("player_have_red_card"); limbusbitmap = limbusbitmap + instancelist[nt+1][4]; -- printf("bitmapadd: %u",instancelist[nt+1][4]); end if (instancelist[nt+1][3]==true and player:hasKeyItem(dsp.ki.BLACK_CARD)) then -- print("player_have_black_card"); limbusbitmap = limbusbitmap + instancelist[nt+1][4]; -- printf("bitmapadd: %u",instancelist[nt+1][4]); end end limbusbitmap= limbusbitmap + LimbusTradeItem; ----- /////////////////////////////////////////////on doit ajouter le mipmap pour l'item trade ici else local status = player:getStatusEffect(dsp.effect.BATTLEFIELD); local playerbcnmid = status:getPower(); -- check if the player has the key item for the current battlefield for nt = 1,#instancelist,2 do -- printf("list d'instance: %u",instancelist[nt]); if (instancelist[nt] == playerbcnmid) then if (instancelist[nt+1][1]== true and player:hasKeyItem(dsp.ki.WHITE_CARD) == false) then AllowLimbusToPlayer = false; end if (instancelist[nt+1][2]== true and player:hasKeyItem(dsp.ki.RED_CARD) == false ) then AllowLimbusToPlayer = false; end if (instancelist[nt+1][3]== true and player:hasKeyItem(dsp.ki.BLACK_CARD) == false ) then AllowLimbusToPlayer = false; end if (AllowLimbusToPlayer == true) then --player have the correct key item for the current battflield limbusbitmap = instancelist[nt+1][4]; end end end end if (limbusbitmap~= 0 ) then player:startEvent(32000,0,0,0,limbusbitmap,0,0,0,0); player:setVar("limbusbitmap",limbusbitmap); else player:messageSpecial(CONDITION_FOR_LIMBUS_T); print("player need a card for basic limbus"); end elseif (currentlimbus~=0) then for nt = 1,#instancelist,2 do -- printf("list d'instance: %u",instancelist[nt]); if (instancelist[nt] == currentlimbus) then limbusbitmap = instancelist[nt+1][4]; end end player:startEvent(32000,0,0,0,limbusbitmap,0,0,0,0); player:setVar("limbusbitmap",limbusbitmap); else player:messageSpecial(CONDITION_FOR_LIMBUS_T); print("error player don't have cosmo clean"); end end; function onEventUpdate(player,csid,option) if (csid == 32000) then if (player:hasStatusEffect(dsp.effect.BATTLEFIELD) == false) then ResetPlayerLimbusVariable(player); player:setVar("characterLimbusKey",0); else local status = player:getStatusEffect(dsp.effect.BATTLEFIELD); player:setVar("LimbusID",status:getPower()); player:setVar("characterLimbusKey",GetLimbusKeyFromInstance(status:getPower())); end player:updateEvent(2,player:getVar("limbusbitmap"),0,1,1,0); player:setVar("limbusbitmap",0); end end; function onEventFinish(player,csid,option) if (csid == 32000) then end end;
gpl-3.0
waterlgndx/darkstar
scripts/zones/Northern_San_dOria/npcs/Gulmama.lua
2
5153
----------------------------------- -- Area: Northern San d'Oria -- NPC: Gulmama -- Starts and Finishes Quest: Trial by Ice -- Involved in Quest: Class Reunion -- !pos -186 0 107 231 ----------------------------------- package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/titles"); require("scripts/globals/keyitems"); require("scripts/globals/quests"); require("scripts/zones/Northern_San_dOria/TextIDs"); ----------------------------------- function onTrade(player,npc,trade) end; function onTrigger(player,npc) local TrialByIce = player:getQuestStatus(SANDORIA,TRIAL_BY_ICE); local WhisperOfFrost = player:hasKeyItem(dsp.ki.WHISPER_OF_FROST); local realday = tonumber(os.date("%j")); -- %M for next minute, %j for next day local ClassReunion = player:getQuestStatus(WINDURST,CLASS_REUNION); local ClassReunionProgress = player:getVar("ClassReunionProgress"); ------------------------------------------------------------ -- Class Reunion if (ClassReunion == 1 and ClassReunionProgress == 4) then player:startEvent(713,0,1171,0,0,0,0,0,0); -- he gives you an ice pendulum and wants you to go to Cloister of Frost elseif (ClassReunion == 1 and ClassReunionProgress == 5 and player:hasItem(1171) == false) then player:startEvent(712,0,1171,0,0,0,0,0,0); -- lost the ice pendulum need another one ------------------------------------------------------------ elseif ((TrialByIce == QUEST_AVAILABLE and player:getFameLevel(SANDORIA) >= 6) or (TrialByIce == QUEST_COMPLETED and realday ~= player:getVar("TrialByIce_date"))) then player:startEvent(706,0,dsp.ki.TUNING_FORK_OF_ICE); -- Start and restart quest "Trial by ice" elseif (TrialByIce == QUEST_ACCEPTED and player:hasKeyItem(dsp.ki.TUNING_FORK_OF_ICE) == false and WhisperOfFrost == false) then player:startEvent(718,0,dsp.ki.TUNING_FORK_OF_ICE); -- Defeat against Shiva : Need new Fork elseif (TrialByIce == QUEST_ACCEPTED and WhisperOfFrost == false) then player:startEvent(707,0,dsp.ki.TUNING_FORK_OF_ICE,4); elseif (TrialByIce == QUEST_ACCEPTED and WhisperOfFrost) then local numitem = 0; if (player:hasItem(17492)) then numitem = numitem + 1; end -- Shiva's Claws if (player:hasItem(13242)) then numitem = numitem + 2; end -- Ice Belt if (player:hasItem(13561)) then numitem = numitem + 4; end -- Ice Ring if (player:hasItem(1207)) then numitem = numitem + 8; end -- Rust 'B' Gone if (player:hasSpell(302)) then numitem = numitem + 32; end -- Ability to summon Shiva player:startEvent(709,0,dsp.ki.TUNING_FORK_OF_ICE,4,0,numitem); else player:startEvent(710); -- Standard dialog end end; function onEventUpdate(player,csid,option) end; function onEventFinish(player,csid,option) if (csid == 706 and option == 1) then if (player:getQuestStatus(SANDORIA,TRIAL_BY_ICE) == QUEST_COMPLETED) then player:delQuest(SANDORIA,TRIAL_BY_ICE); end player:addQuest(SANDORIA,TRIAL_BY_ICE); player:setVar("TrialByIce_date", 0); player:addKeyItem(dsp.ki.TUNING_FORK_OF_ICE); player:messageSpecial(KEYITEM_OBTAINED,dsp.ki.TUNING_FORK_OF_ICE); elseif (csid == 718) then player:addKeyItem(dsp.ki.TUNING_FORK_OF_ICE); player:messageSpecial(KEYITEM_OBTAINED,dsp.ki.TUNING_FORK_OF_ICE); elseif (csid == 709) then local item = 0; if (option == 1) then item = 17492; -- Shiva's Claws elseif (option == 2) then item = 13242; -- Ice Belt elseif (option == 3) then item = 13561; -- Ice Ring elseif (option == 4) then item = 1207; -- Rust 'B' Gone end if (player:getFreeSlotsCount() == 0 and (option ~= 5 or option ~= 6)) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,item); else if (option == 5) then player:addGil(GIL_RATE*10000); player:messageSpecial(GIL_OBTAINED,GIL_RATE*10000); -- Gil elseif (option == 6) then player:addSpell(302); -- Avatar player:messageSpecial(SHIVA_UNLOCKED,0,0,4); else player:addItem(item); player:messageSpecial(ITEM_OBTAINED,item); -- Item end player:addTitle(dsp.title.HEIR_OF_THE_GREAT_ICE); player:delKeyItem(dsp.ki.WHISPER_OF_FROST); --Whisper of Frost, as a trade for the above rewards player:setVar("TrialByIce_date", os.date("%j")); -- %M for next minute, %j for next day player:addFame(SANDORIA,30); player:completeQuest(SANDORIA,TRIAL_BY_ICE); end elseif (csid == 713 or csid == 712) then if (player:getFreeSlotsCount() ~= 0) then player:addItem(1171); player:messageSpecial(ITEM_OBTAINED,1171); player:setVar("ClassReunionProgress",5); else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,1171); end; end; end;
gpl-3.0
drmingdrmer/lua-cjson
tests/bench.lua
145
3247
#!/usr/bin/env lua -- This benchmark script measures wall clock time and should be -- run on an unloaded system. -- -- Your Mileage May Vary. -- -- Mark Pulford <mark@kyne.com.au> local json_module = os.getenv("JSON_MODULE") or "cjson" require "socket" local json = require(json_module) local util = require "cjson.util" local function find_func(mod, funcnames) for _, v in ipairs(funcnames) do if mod[v] then return mod[v] end end return nil end local json_encode = find_func(json, { "encode", "Encode", "to_string", "stringify", "json" }) local json_decode = find_func(json, { "decode", "Decode", "to_value", "parse" }) local function average(t) local total = 0 for _, v in ipairs(t) do total = total + v end return total / #t end function benchmark(tests, seconds, rep) local function bench(func, iter) -- Use socket.gettime() to measure microsecond resolution -- wall clock time. local t = socket.gettime() for i = 1, iter do func(i) end t = socket.gettime() - t -- Don't trust any results when the run lasted for less than a -- millisecond - return nil. if t < 0.001 then return nil end return (iter / t) end -- Roughly calculate the number of interations required -- to obtain a particular time period. local function calc_iter(func, seconds) local iter = 1 local rate -- Warm up the bench function first. func() while not rate do rate = bench(func, iter) iter = iter * 10 end return math.ceil(seconds * rate) end local test_results = {} for name, func in pairs(tests) do -- k(number), v(string) -- k(string), v(function) -- k(number), v(function) if type(func) == "string" then name = func func = _G[name] end local iter = calc_iter(func, seconds) local result = {} for i = 1, rep do result[i] = bench(func, iter) end -- Remove the slowest half (round down) of the result set table.sort(result) for i = 1, math.floor(#result / 2) do table.remove(result, 1) end test_results[name] = average(result) end return test_results end function bench_file(filename) local data_json = util.file_load(filename) local data_obj = json_decode(data_json) local function test_encode() json_encode(data_obj) end local function test_decode() json_decode(data_json) end local tests = {} if json_encode then tests.encode = test_encode end if json_decode then tests.decode = test_decode end return benchmark(tests, 0.1, 5) end -- Optionally load any custom configuration required for this module local success, data = pcall(util.file_load, ("bench-%s.lua"):format(json_module)) if success then util.run_script(data, _G) configure(json) end for i = 1, #arg do local results = bench_file(arg[i]) for k, v in pairs(results) do print(("%s\t%s\t%d"):format(arg[i], k, v)) end end -- vi:ai et sw=4 ts=4:
mit
MonokuroInzanaito/ygopro-777DIY
expansions/script/c18755513.lua
1
1809
--缲狼的终章 function c18755513.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TODECK) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,18755513+EFFECT_COUNT_CODE_OATH) e1:SetTarget(c18755513.target) e1:SetOperation(c18755513.activate) c:RegisterEffect(e1) end function c18755513.filter(c) return c:IsType(TYPE_PENDULUM) and (c:IsLocation(LOCATION_GRAVE) or c:IsFaceup()) and c:IsAbleToDeck() and not c:IsHasEffect(EFFECT_NECRO_VALLEY) and c:IsSetCard(0x5abb) end function c18755513.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c18755513.filter,tp,LOCATION_EXTRA+LOCATION_GRAVE,0,1,nil) and not (Duel.GetFieldCard(tp,LOCATION_SZONE,6) and Duel.GetFieldCard(tp,LOCATION_SZONE,7)) end Duel.SetOperationInfo(0,CATEGORY_TODECK,nil,2,0,0) end function c18755513.activate(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(c18755513.filter,tp,LOCATION_EXTRA+LOCATION_GRAVE,0,nil) if g:GetCount()<1 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) local sg=g:Select(tp,1,2,nil) local ct=Duel.SendtoDeck(sg,nil,0,REASON_EFFECT) Duel.ShuffleDeck(tp) if ct>=1 then Duel.BreakEffect() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOFIELD) local vg1=Duel.SelectMatchingCard(tp,c18755513.sfilter,tp,LOCATION_DECK,0,1,1,nil) local tc1=vg1:GetFirst() if tc1 then Duel.MoveToField(tc1,tp,tp,LOCATION_SZONE,POS_FACEUP,true) end if ct==2 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOFIELD) local vg2=Duel.SelectMatchingCard(tp,c18755513.sfilter,tp,LOCATION_DECK,0,1,1,nil) local tc2=vg2:GetFirst() if tc2 then Duel.MoveToField(tc2,tp,tp,LOCATION_SZONE,POS_FACEUP,true) end end end end function c18755513.sfilter(c) return c:IsSetCard(0x5abb) and c:IsType(TYPE_PENDULUM) end
gpl-3.0
kidaa/darkstar
scripts/globals/items/mushroom_salad.lua
39
1426
----------------------------------------- -- ID: 5678 -- Item: Mushroom Salad -- Food Effect: 3 Hrs, All Races ----------------------------------------- -- MP 14% Cap 85 -- Agility 6 -- Mind 6 -- Strength -5 -- Vitality -5 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) result = 0; if (target:hasStatusEffect(EFFECT_FOOD)) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,10800,5678); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_FOOD_MPP, 14); target:addMod(MOD_FOOD_MP_CAP, 85); target:addMod(MOD_AGI, 6); target:addMod(MOD_MND, 6); target:addMod(MOD_STR, -5); target:addMod(MOD_VIT, -5); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_FOOD_MPP, 14); target:delMod(MOD_FOOD_MP_CAP, 85); target:delMod(MOD_AGI, 6); target:delMod(MOD_MND, 6); target:delMod(MOD_STR, -5); target:delMod(MOD_VIT, -5); end;
gpl-3.0
lhog/Zero-K
scripts/vehcapture.lua
6
6750
include "constants.lua" local spGetUnitRulesParam = Spring.GetUnitRulesParam local base, front, bigwheel, rear = piece('base', 'front', 'bigwheel', 'rear') local turret, arm_1, arm_2, arm_3, dish, panel_a1, panel_b1, panel_a2, panel_b2, flare = piece('turret', 'arm_1', 'arm_2', 'arm_3', 'dish', 'panel_a1', 'panel_b1', 'panel_a2', 'panel_b2', 'flare') local tracks1, tracks2, tracks3, tracks4 = piece('tracks1', 'tracks2', 'tracks3', 'tracks4') local wheels_s = { piece('wheels2', 'wheels3') } local wheels_m = { piece('wheels1', 'wheels4') } local tracks = 1 -- Signal definitions local SIG_ACTIVATE = 2 local SIG_ANIM = 4 local SIG_AIM = 1 local SIG_IDLE = 8 local WHEEL_SPIN_SPEED_S = math.rad(540) local WHEEL_SPIN_SPEED_M = math.rad(360) local WHEEL_SPIN_SPEED_L = math.rad(180) local WHEEL_SPIN_ACCEL_S = math.rad(15) local WHEEL_SPIN_ACCEL_M = math.rad(10) local WHEEL_SPIN_ACCEL_L = math.rad(5) local WHEEL_SPIN_DECEL_S = math.rad(25) local WHEEL_SPIN_DECEL_M = math.rad(25) local WHEEL_SPIN_DECEL_L = math.rad(15) local DEPLOY_SPEED = math.rad(90) local TURRET_SPEED = math.rad(60) local TURRET_ACCEL = math.rad(2) local ANIM_PERIOD = 66 local PIVOT_MOD = 1.6 --appox. equal to MAX_PIVOT / turnrate local MAX_PIVOT = math.rad(20) local MIN_PIVOT = math.rad(-20) local PIVOT_SPEED = math.rad(60) local MIN_DIFF = math.rad(0.01) local smokePiece = {base, turret} local function ImpactTilt(x,z) Turn(base, z_axis, math.rad(-z), math.rad(105)) Turn(base, x_axis, math.rad(x), math.rad(105)) WaitForTurn(base, z_axis) WaitForTurn(base, x_axis) Turn(base, z_axis, 0, math.rad(30)) Turn(base, x_axis, 0, math.rad(300)) end --[[ function script.HitByWeapon(x, z) StartThread(ImpactTilt, x, z) end ]] local function AnimControl() Signal(SIG_ANIM) SetSignalMask(SIG_ANIM) local lastHeading, currHeading, diffHeading, pivotAngle lastHeading = GetUnitValue(COB.HEADING)*GG.Script.headingToRad while true do tracks = tracks + 1 if tracks == 2 then Hide(tracks1) Show(tracks2) elseif tracks == 3 then Hide(tracks2) Show(tracks3) elseif tracks == 4 then Hide(tracks3) Show(tracks4) else tracks = 1 Hide(tracks4) Show(tracks1) end for i=1,#wheels_s do Spin(wheels_s[i], x_axis, WHEEL_SPIN_SPEED_S, WHEEL_SPIN_ACCEL_S) end for i=1,#wheels_m do Spin(wheels_m[i], x_axis, WHEEL_SPIN_SPEED_M, WHEEL_SPIN_ACCEL_M) end Spin(bigwheel, x_axis, WHEEL_SPIN_SPEED_L, WHEEL_SPIN_ACCEL_L) --pivot currHeading = GetUnitValue(COB.HEADING)*GG.Script.headingToRad diffHeading = (currHeading - lastHeading) if (diffHeading > 0 and diffHeading < MIN_DIFF) or (diffHeading < 0 and diffHeading > -MIN_DIFF) then diffHeading = MIN_DIFF -- to prevent segfaulting perfect alignment end -- Fix wrap location if diffHeading > math.pi then diffHeading = diffHeading - 2*math.pi end if diffHeading < -math.pi then diffHeading = diffHeading + 2*math.pi end -- Bound maximun pivot pivotAngle = diffHeading * PIVOT_MOD if pivotAngle > MAX_PIVOT then pivotAngle = MAX_PIVOT end if pivotAngle < MIN_PIVOT then pivotAngle = MIN_PIVOT end -- Turn slowly for small course corrections if math.abs(diffHeading) < 0.05 then Turn(front, y_axis, pivotAngle, PIVOT_SPEED*0.2) Turn(rear, y_axis, (0 - pivotAngle), PIVOT_SPEED*0.2) else Turn(front, y_axis, pivotAngle, PIVOT_SPEED) Turn(rear, y_axis, (0 - pivotAngle), PIVOT_SPEED) end lastHeading = currHeading Sleep(ANIM_PERIOD) end end local function IdleAnim() Signal(SIG_IDLE) SetSignalMask(SIG_IDLE) while true do local angle = math.random(0,360) Turn(turret, y_axis, math.rad(angle), TURRET_SPEED) Sleep(4000) end end local function RestoreAfterDelay() Sleep(7000) --Turn(arm_1, x_axis, math.rad(90), math.rad(45)) StartThread(IdleAnim) end function script.AimWeapon(num, heading, pitch) Signal(SIG_IDLE) Signal(SIG_AIM) SetSignalMask(SIG_AIM) Turn(turret, y_axis, heading, math.rad(240)) --Turn(arm_1, x_axis, math.rad(90) - pitch, math.rad(60)) --WaitForTurn(arm_1, x_axis) WaitForTurn(turret, y_axis) StartThread(RestoreAfterDelay) return (spGetUnitRulesParam(unitID, "cantfire") == 0) --checks for max capture end function script.AimFromWeapon(num) return flare end function script.QueryWeapon(num) return flare end function script.Create() StartThread(GG.Script.SmokeUnit, unitID, smokePiece) Turn(rear, y_axis, 0.01, PIVOT_SPEED) while (select(5, Spring.GetUnitHealth(unitID)) < 1) do Sleep (1000) end script.Activate() end function script.Activate() Signal(SIG_ACTIVATE) SetSignalMask(SIG_ACTIVATE) Turn(arm_1, x_axis, math.rad(-90), DEPLOY_SPEED) WaitForTurn(arm_1, x_axis) Turn(arm_2, x_axis, math.rad(30), DEPLOY_SPEED) Turn(arm_3, x_axis, math.rad(-40), DEPLOY_SPEED) WaitForTurn(arm_2, x_axis) WaitForTurn(arm_3, x_axis) Turn(panel_a1, z_axis, math.rad(-(30)), DEPLOY_SPEED) Turn(panel_a2, z_axis, math.rad(-(-30)), DEPLOY_SPEED) Turn(panel_b1, z_axis, math.rad(-(-30)), DEPLOY_SPEED) Turn(panel_b2, z_axis, math.rad(-(30)), DEPLOY_SPEED) WaitForTurn(panel_a1, z_axis) WaitForTurn(panel_a2, z_axis) WaitForTurn(panel_b1, z_axis) WaitForTurn(panel_b2, z_axis) StartThread(IdleAnim) end function script.Deactivate() Signal(SIG_ACTIVATE) SetSignalMask(SIG_ACTIVATE) Turn(turret, y_axis, 0, math.rad(TURRET_SPEED)) WaitForTurn(turret, y_axis) Turn(panel_a1, z_axis, 0, DEPLOY_SPEED) Turn(panel_a2, z_axis, 0, DEPLOY_SPEED) Turn(panel_b1, z_axis, 0, DEPLOY_SPEED) Turn(panel_b2, z_axis, 0, DEPLOY_SPEED) WaitForTurn(panel_a1, z_axis) WaitForTurn(panel_a2, z_axis) WaitForTurn(panel_b1, z_axis) WaitForTurn(panel_b2, z_axis) Turn(arm_2, x_axis, 0, DEPLOY_SPEED) Turn(arm_3, x_axis, 0, DEPLOY_SPEED) WaitForTurn(arm_2, x_axis) WaitForTurn(arm_3, x_axis) Turn(arm_1, x_axis, 0, DEPLOY_SPEED) end local function Stopping() Signal(SIG_ANIM) SetSignalMask(SIG_ANIM) StopSpin(bigwheel, x_axis, WHEEL_SPIN_DECEL_L) for i=1,#wheels_s do StopSpin(wheels_s[i], x_axis, WHEEL_SPIN_DECEL_M) end for i=1,#wheels_m do StopSpin(wheels_m[i], x_axis, WHEEL_SPIN_DECEL_M) end end function script.StartMoving() StartThread(AnimControl) end function script.StopMoving() StartThread(Stopping) end function script.Killed(recentDamage, maxHealth) local severity = recentDamage/maxHealth if severity <= .25 then Explode(front, SFX.NONE) Explode(rear, SFX.NONE) return 1 elseif severity <= .50 then Explode(front, SFX.NONE) Explode(rear, SFX.NONE) return 1 elseif severity <= .99 then Explode(front, SFX.SHATTER) Explode(rear, SFX.SMOKE + SFX.FIRE) return 2 else Explode(front, SFX.SHATTER) Explode(rear, SFX.SMOKE + SFX.FIRE + SFX.EXPLODE) return 2 end end
gpl-2.0