repo_name
stringlengths
6
78
path
stringlengths
4
206
copies
stringclasses
281 values
size
stringlengths
4
7
content
stringlengths
625
1.05M
license
stringclasses
15 values
Arcscion/Shadowlyre
scripts/zones/Gustav_Tunnel/mobs/Goblin_Reaper.lua
3
1165
---------------------------------- -- Area: Gustav Tunnel -- MOB: Goblin Reaper -- Note: Place holder Goblinsavior Heronox ----------------------------------- require("scripts/globals/groundsofvalor"); require("scripts/zones/Gustav_Tunnel/MobIDs"); ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob, player, isKiller) checkGoVregime(player,mob,764,3); checkGoVregime(player,mob,765,3); end; ----------------------------------- -- onMobDespawn ----------------------------------- function onMobDespawn(mob) local mobID = mob:getID(); if (Goblinsavior_Heronox_PH[mobID] ~= nil) then local ToD = GetServerVariable("[POP]Goblinsavior_Heronox"); if (ToD <= os.time() and GetMobAction(Goblinsavior_Heronox) == 0) then if (math.random(1,20) == 5) then UpdateNMSpawnPoint(Goblinsavior_Heronox); GetMobByID(Goblinsavior_Heronox):setRespawnTime(GetMobRespawnTime(mobID)); SetServerVariable("[PH]Goblinsavior_Heronox", mobID); DisallowRespawn(mobID, true); end end end end;
gpl-3.0
jono659/enko
scripts/globals/items/green_quiche.lua
35
1461
----------------------------------------- -- ID: 5170 -- Item: green_quiche -- Food Effect: 30Min, All Races ----------------------------------------- -- Magic 10 -- Agility 1 -- Vitality -1 -- Ranged ACC % 7 -- Ranged ACC Cap 15 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,1800,5170); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_MP, 10); target:addMod(MOD_AGI, 1); target:addMod(MOD_VIT, -1); target:addMod(MOD_FOOD_RACCP, 7); target:addMod(MOD_FOOD_RACC_CAP, 15); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_MP, 10); target:delMod(MOD_AGI, 1); target:delMod(MOD_VIT, -1); target:delMod(MOD_FOOD_RACCP, 7); target:delMod(MOD_FOOD_RACC_CAP, 15); end;
gpl-3.0
Arcscion/Shadowlyre
scripts/zones/Davoi/npcs/!.lua
3
2631
----------------------------------- -- Area: Davoi -- NPC: ! -- Involved in Mission: The Davoi Report -- !pos 164 0.1 -21 149 ----------------------------------- package.loaded["scripts/zones/Davoi/TextIDs"] = nil; ----------------------------------- require("scripts/globals/missions"); require("scripts/globals/keyitems"); require("scripts/zones/Davoi/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local CurrentMission = player:getCurrentMission(SANDORIA) if (CurrentMission == THE_DAVOI_REPORT and player:getVar("MissionStatus") == 1) then player:setVar("MissionStatus",2); player:addKeyItem(LOST_DOCUMENT); player:messageSpecial(KEYITEM_OBTAINED,LOST_DOCUMENT); elseif (CurrentMission == INFILTRATE_DAVOI and player:getVar("MissionStatus") >= 6 and player:getVar("MissionStatus") <= 9) then local X = npc:getXPos(); local Z = npc:getZPos(); if (X >= 292 and X <= 296 and Z >= -30 and Z <= -26 and player:hasKeyItem(EAST_BLOCK_CODE) == false) then player:setVar("MissionStatus",player:getVar("MissionStatus") + 1); player:addKeyItem(EAST_BLOCK_CODE); player:messageSpecial(KEYITEM_OBTAINED,EAST_BLOCK_CODE); elseif (X >= 333 and X <= 337 and Z >= -138 and Z <= -134 and player:hasKeyItem(SOUTH_BLOCK_CODE) == false) then player:setVar("MissionStatus",player:getVar("MissionStatus") + 1); player:addKeyItem(SOUTH_BLOCK_CODE); player:messageSpecial(KEYITEM_OBTAINED,SOUTH_BLOCK_CODE); elseif (X >= 161 and X <= 165 and Z >= -20 and Z <= -16 and player:hasKeyItem(NORTH_BLOCK_CODE) == false) then player:setVar("MissionStatus",player:getVar("MissionStatus") + 1); player:addKeyItem(NORTH_BLOCK_CODE); player:messageSpecial(KEYITEM_OBTAINED,NORTH_BLOCK_CODE); else player:messageSpecial(YOU_SEE_NOTHING); end else player:messageSpecial(YOU_SEE_NOTHING); 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
Arcscion/Shadowlyre
scripts/zones/Lower_Jeuno/npcs/Muckvix.lua
3
1526
----------------------------------- -- Area: Lower Jeuno -- NPC: Muckvix -- Involved in Mission: Magicite -- @zone 245 -- !pos -26.824 3.601 -137.082 ----------------------------------- package.loaded["scripts/zones/Lower_Jeuno/TextIDs"] = nil; ----------------------------------- require("scripts/globals/keyitems"); require("scripts/zones/Lower_Jeuno/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:hasKeyItem(SILVER_BELL) and player:hasKeyItem(YAGUDO_TORCH) == false) then if (player:getVar("YagudoTorchCS") == 1) then player:startEvent(0x00b8); else player:startEvent(0x0050); end else player:startEvent(0x000f); 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 == 0x00b8) then player:addKeyItem(YAGUDO_TORCH); player:messageSpecial(KEYITEM_OBTAINED,YAGUDO_TORCH); player:setVar("YagudoTorchCS",0); end end;
gpl-3.0
AlanZatarain/xsd-tools
templates/java-json.org/json-transform.lua
3
9859
[@lua -- helper functions local function isSimpleType(element) if element.content and element.attributes then return ((next(element.attributes) or next(element.content)) == nil) elseif element.fields then for k, _ in pairs(element.fields) do if k ~= '$' then return false end end return true end end local function isListType(typeName) return (typeName:match("^(list)%(.+%)") ~= nil) end local function isSingular(typeName) return (typeName == 1) end local function isRootElement(schema, type) for _, v in pairs(schema) do local elemName, elemType = next(v) if elemType == type then return true end end return false; end local function isTypeFoldable(schema, typedef) return (not isRootElement(schema, typedef) and isSimpleType(typedef) and typedef.fields['$']) end local function getListType(typeName) return typeName:match("list%((.+)%)") end local function makeJavaSafeName(name) if isListType(name) then return 'list('..makeJavaSafeName(getListType(name))..')' else return name:gsub('[%$,/,%-,%%,#,@,!,%^,&,*,%(,%), ,]', '_') end end -- assigns content field names (seperates element names from types) local function assignContentFieldNames(XSDTree) local typeTbl = {} local function _cmpType(typedef1, typedef2) local ty1 = type(typedef1) local ty2 = type(typedef2) if ty1 ~= ty2 then return false end -- non-table types can be directly compared if ty1 ~= 'table' and ty2 ~= 'table' then return t1 == t2 end -- compare table types for k1,v1 in pairs(typedef1) do local v2 = typedef2[k1] if v2 == nil or not _cmpType(v1,v2) then return false end end for k2,v2 in pairs(typedef2) do local v1 = typedef1[k2] if v1 == nil or not _cmpType(v1,v2) then return false end end return true end local function _getType(className, typedef, nCalls) nCalls = nCalls or 2 if typeTbl[className] then if _cmpType(typeTbl[className], typedef) then return className, typedef else return _getType(className..nCalls, typedef, nCalls + 1) end else typeTbl[className] = typedef return className, typedef end end local function _traverse(element, outElem) for field, value in pairs(element) do if "content" == field then outElem.content = {} for name, typedef in pairs(element.content) do -- handle elements being defined multiple times local className, classTypeDef = _getType(name, typedef) -- handle xs:simpleType content value -> JSON tag names if isSimpleType(classTypeDef) then name = '$' end -- modify schema outElem.content[name] = {} outElem.content[name][className] = {} _traverse(typedef, outElem.content[name][className]) end else outElem[field] = value end end return outElem end return _traverse({ attributes = {}, content = XSDTree }, {}).content end -- assign occurrence values local function assignTypeOccurence(XSDTree) local function _addOccurrenceModifier(className, typedef) if not isSimpleType(typedef) and not isRootElement(XSDTree, typedef) and not isSingular(typedef["maxOccurs"]) then return 'list('..className..')' else return className end end local function _traverse(element, outElem) for field, value in pairs(element) do if "content" == field then outElem.content = {} for jsonTag, classNameTbl in pairs(element.content) do local className, typedef = next(classNameTbl) -- add occurrence modification className = _addOccurrenceModifier(className, typedef) -- modify schema outElem.content[jsonTag] = {} outElem.content[jsonTag][className] = {} _traverse(typedef, outElem.content[jsonTag][className]) end else outElem[field] = value end end return outElem end return _traverse({ attributes = {}, content = XSDTree }, {}).content end -- fold 'content' & 'attribtues' into 'fields' & add json-jackson/jersey -- attribute prefix (@) local function assignJSONFields(XSDTree) local function _traverse(element, outElem) outElem.fields = {} for field, value in pairs(element) do if "attributes" == field then for jsonTag, classNameTbl in pairs(value) do local className, typedef = next(classNameTbl) outElem.fields['@'..jsonTag] = classNameTbl _traverse(typedef, outElem.fields['@'..jsonTag][className]) end outElem.attributes = nil elseif "content" == field then for jsonTag, classNameTbl in pairs(value) do local className, typedef = next(classNameTbl) outElem.fields[jsonTag] = classNameTbl _traverse(typedef, outElem.fields[jsonTag][className]) end outElem.content = nil end end return outElem end return _traverse({ attribtues = {}, content = XSDTree }, {}).fields end -- fold simpletypes that are not root elements local function foldSimpleTypes(XSDTree) local function _traverse(element, outElem) for field, value in pairs(element) do if "fields" == field then outElem.fields = {} for jsonTag, classNameTbl in pairs(value) do local className, typedef = next(classNameTbl) if isTypeFoldable(XSDTree, typedef) then local foldedTypeName, foldedTypedef = next(typedef.fields['$']) outElem.fields[jsonTag] = {} if isListType(className) then outElem.fields[jsonTag]['list('..foldedTypeName..')'] = foldedTypedef else outElem.fields[jsonTag][foldedTypeName] = foldedTypedef end else outElem.fields[jsonTag] = classNameTbl _traverse(typedef, outElem.fields[jsonTag][className]) end end end end return outElem end return _traverse({ fields = XSDTree }, {}).fields end -- fixup element/attribute type names which may be invalid java class names. -- Also capitalize the first character of the java class names if they are -- complex types local function fixupTypeNames(XSDTree) local function _traverse(element, outElem) for field, value in pairs(element) do if "fields" == field then outElem.fields = {} for jsonTag, classNameTbl in pairs(value) do local className, typedef = next(classNameTbl) outElem.fields[jsonTag] = {} if not isSimpleType(typedef) then if isListType(className) then local listType = className:match("list%((.+)%)") local fixedListType = makeJavaSafeName(listType) local upcasedListType= fixedListType:gsub("^%l", string.upper) local upcasedType = 'list('..upcasedListType..')' outElem.fields[jsonTag][upcasedType] = typedef _traverse(typedef, outElem.fields[jsonTag][upcasedType]) else local fixedType = makeJavaSafeName(className) local upcasedType = fixedType:gsub("^%l", string.upper) outElem.fields[jsonTag][upcasedType] = typedef _traverse(typedef, outElem.fields[jsonTag][upcasedType]) end elseif isRootElement(XSDTree, typedef) then local simpleType = makeJavaSafeName(className) local upcasedType = simpleType:gsub("^%l", string.upper) outElem.fields[jsonTag][upcasedType] = typedef _traverse(typedef, outElem.fields[jsonTag][upcasedType]) else local fixedTypeName = makeJavaSafeName(className) outElem.fields[jsonTag][fixedTypeName] = typedef _traverse(typedef, outElem.fields[jsonTag][fixedTypeName]) end end end end return outElem end return _traverse({ fields = XSDTree }, {}).fields end -- coalesce tree transformation passes into one function function JSONTransform(schema) return fixupTypeNames( foldSimpleTypes( assignJSONFields( assignTypeOccurence( assignContentFieldNames(schema))))) end ]
gpl-3.0
jono659/enko
scripts/globals/weaponskills/death_blossom.lua
6
5257
----------------------------------- -- Death Blossom -- Sword weapon skill (RDM only) -- Description: Delivers a threefold attack that lowers target's magic evasion. Chance of lowering target's magic evasion varies with TP. Murgleis: Aftermath effect varies with TP. -- Lowers magic evasion by up to 10. -- Effect lasts up to 55 seconds. -- Available only after completing the Unlocking a Myth (Red Mage) quest. -- Aligned with the Breeze Gorget, Thunder Gorget, Aqua Gorget & Snow Gorget. -- Aligned with the Breeze Belt, Thunder Belt, Aqua Belt & Snow Belt. -- Modifiers: STR:30% ; MND:50% -- 100%TP 200%TP 300%TP -- 4 4 4 ----------------------------------- require("scripts/globals/status"); require("scripts/globals/settings"); require("scripts/globals/weaponskills"); ----------------------------------- function onUseWeaponSkill(player, target, wsID) local params = {}; params.numHits = 3; --ftp damage mods (for Damage Varies with TP; lines are calculated in the function params.ftp100 = 4.0; params.ftp200 = 4.0; params.ftp300 = 4.0; --wscs are in % so 0.2=20% params.str_wsc = 0.3; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.5; params.chr_wsc = 0.0; --critical mods, again in % (ONLY USE FOR critICAL HIT VARIES WITH TP) params.crit100 = 0.0; params.crit200=0.0; params.crit300=0.0; params.canCrit = false; --accuracy mods (ONLY USE FOR accURACY VARIES WITH TP) , should be the acc at those %s NOT the penalty values. Leave 0 if acc doesnt vary with tp. params.acc100 = 0.0; params.acc200=0.0; params.acc300=0.0; --attack multiplier (only some WSes use this, this varies the actual ratio value, see Tachi: Kasha) 1 is default. params.atkmulti = 1; local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, params); if damage > 0 then local tp = player:getTP(); local duration = (tp/100 * 20) - 5; if(target:hasStatusEffect(EFFECT_MAGIC_EVASION_DOWN) == false) then target:addStatusEffect(EFFECT_MAGIC_EVASION_DOWN, 10, 0, duration); end end if((player:getEquipID(SLOT_MAIN) == 18995) and (player:getMainJob() == JOB_RDM)) then if(damage > 0) then -- AFTERMATH LV1 if ((player:getTP() >= 100) and (player:getTP() <= 110)) then player:addStatusEffect(EFFECT_AFTERMATH_LV1, 10, 0, 180, 0, 2); elseif ((player:getTP() >= 111) and (player:getTP() <= 120)) then player:addStatusEffect(EFFECT_AFTERMATH_LV1, 11, 0, 180, 0, 2); elseif ((player:getTP() >= 121) and (player:getTP() <= 130)) then player:addStatusEffect(EFFECT_AFTERMATH_LV1, 12, 0, 180, 0, 2); elseif ((player:getTP() >= 131) and (player:getTP() <= 140)) then player:addStatusEffect(EFFECT_AFTERMATH_LV1, 13, 0, 180, 0, 2); elseif ((player:getTP() >= 141) and (player:getTP() <= 150)) then player:addStatusEffect(EFFECT_AFTERMATH_LV1, 14, 0, 180, 0, 2); elseif ((player:getTP() >= 151) and (player:getTP() <= 160)) then player:addStatusEffect(EFFECT_AFTERMATH_LV1, 15, 0, 180, 0, 2); elseif ((player:getTP() >= 161) and (player:getTP() <= 170)) then player:addStatusEffect(EFFECT_AFTERMATH_LV1, 16, 0, 180, 0, 2); elseif ((player:getTP() >= 171) and (player:getTP() <= 180)) then player:addStatusEffect(EFFECT_AFTERMATH_LV1, 17, 0, 180, 0, 2); elseif ((player:getTP() >= 181) and (player:getTP() <= 190)) then player:addStatusEffect(EFFECT_AFTERMATH_LV1, 18, 0, 180, 0, 2); elseif ((player:getTP() >= 191) and (player:getTP() <= 199)) then player:addStatusEffect(EFFECT_AFTERMATH_LV1, 19, 0, 180, 0, 2); -- AFTERMATH LV2 elseif ((player:getTP() >= 200) and (player:getTP() <= 210)) then player:addStatusEffect(EFFECT_AFTERMATH_LV2, 24, 0, 180, 0, 3); elseif ((player:getTP() >= 211) and (player:getTP() <= 219)) then player:addStatusEffect(EFFECT_AFTERMATH_LV2, 28, 0, 180, 0, 3); elseif ((player:getTP() >= 221) and (player:getTP() <= 229)) then player:addStatusEffect(EFFECT_AFTERMATH_LV2, 32, 0, 180, 0, 3); elseif ((player:getTP() >= 231) and (player:getTP() <= 239)) then player:addStatusEffect(EFFECT_AFTERMATH_LV2, 36, 0, 180, 0, 3); elseif ((player:getTP() >= 241) and (player:getTP() <= 249)) then player:addStatusEffect(EFFECT_AFTERMATH_LV2, 40, 0, 180, 0, 3); elseif ((player:getTP() >= 251) and (player:getTP() <= 259)) then player:addStatusEffect(EFFECT_AFTERMATH_LV2, 44, 0, 180, 0, 3); elseif ((player:getTP() >= 261) and (player:getTP() <= 269)) then player:addStatusEffect(EFFECT_AFTERMATH_LV2, 48, 0, 180, 0, 3); elseif ((player:getTP() >= 271) and (player:getTP() <= 279)) then player:addStatusEffect(EFFECT_AFTERMATH_LV2, 52, 0, 180, 0, 3); elseif ((player:getTP() >= 281) and (player:getTP() <= 289)) then player:addStatusEffect(EFFECT_AFTERMATH_LV2, 56, 0, 180, 0, 3); elseif ((player:getTP() >= 291) and (player:getTP() <= 299)) then player:addStatusEffect(EFFECT_AFTERMATH_LV2, 59, 0, 180, 0, 3); -- AFTERMATH LV3 elseif ((player:getTP() == 300)) then player:addStatusEffect(EFFECT_AFTERMATH_LV3, 45, 0, 120, 0, 1); end end end damage = damage * WEAPON_SKILL_POWER return tpHits, extraHits, criticalHit, damage; end
gpl-3.0
Arcscion/Shadowlyre
scripts/globals/mobskills/dominion_slash.lua
15
1593
--------------------------------------------- -- Dominion 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/monstertpmoves"); require("scripts/globals/settings"); require("scripts/globals/status"); --------------------------------------------- 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
kidaa/darkstar
scripts/zones/Northern_San_dOria/npcs/Madaline.lua
36
1615
----------------------------------- -- Area: Northern San d'Oria -- NPC: Madaline -- Standard Info NPC ----------------------------------- package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/quests"); require("scripts/zones/Northern_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) Telmoda_Madaline = player:getVar("Telmoda_Madaline_Event"); if (Telmoda_Madaline ~= 1) then player:setVar(player,"Telmoda_Madaline_Event",1); player:startEvent(0x0213); else player:startEvent(0x0269); 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
kidaa/darkstar
scripts/zones/LaLoff_Amphitheater/npcs/qm1_1.lua
12
2355
----------------------------------- -- Area: LaLoff_Amphitheater -- NPC: Shimmering Circle (BCNM Entrances) ------------------------------------- package.loaded["scripts/zones/LaLoff_Amphitheater/TextIDs"] = nil; package.loaded["scripts/globals/bcnm"] = nil; ------------------------------------- require("scripts/globals/bcnm"); require("scripts/globals/titles"); require("scripts/globals/keyitems"); require("scripts/globals/quests"); require("scripts/globals/missions"); require("scripts/zones/LaLoff_Amphitheater/TextIDs"); -- Death cutscenes: -- player:startEvent(0x7d01,1,instance:getFastestTime(),1,instance:getTimeInside(),1,0,0); -- hume -- player:startEvent(0x7d01,1,instance:getFastestTime(),1,instance:getTimeInside(),1,1,0); -- taru -- player:startEvent(0x7d01,1,instance:getFastestTime(),1,instance:getTimeInside(),1,2,0); -- mithra -- player:startEvent(0x7d01,1,instance:getFastestTime(),1,instance:getTimeInside(),1,3,0); -- elvaan -- player:startEvent(0x7d01,1,instance:getFastestTime(),1,instance:getTimeInside(),1,4,0); -- galka -- player:startEvent(0x7d01,1,instance:getFastestTime(),1,instance:getTimeInside(),1,5,0); -- divine might -- param 1: entrance # -- param 2: fastest time -- param 3: unknown -- param 4: clear time -- param 5: zoneid -- param 6: exit cs (0-4 AA, 5 DM, 6-10 neo AA, 11 neo DM) -- param 7: skip (0 - no skip, 1 - prompt, 2 - force) -- param 8: 0 ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if(TradeBCNM(player,player:getZoneID(),trade,npc))then return; end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if(EventTriggerBCNM(player,npc))then return; end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("onUpdate CSID: %u",csid); -- printf("onUpdate RESULT: %u",option); if(EventUpdateBCNM(player,csid,option,1))then return; end end; ----------------------------------- -- onEventFinish Action ----------------------------------- function onEventFinish(player,csid,option) --printf("onFinish CSID: %u",csid); --printf("onFinish RESULT: %u",option); if(EventFinishBCNM(player,csid,option))then return; end end;
gpl-3.0
lhog/Zero-K
scripts/nanoaim.h.lua
8
2918
------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------- -- -- Author: jK @ 2010 -- -- How to use: -- -- 1. Add to the start of your script: include "nanoaim.h.lua" -- 2. After you define your pieces tell which you want to smoke e.g.: local nanoPieces = { piece "nano_aim" } -- 3. In your 'function script:Create()' add: StartThread(UpdateNanoDirectionThread, nanoPieces [, updateInterval = 1000 [, turnSpeed = 0.75*math.pi [, turnSpeedVert = turnSpeed ]]]) -- 4. In your 'function script.StartBuilding()' add: UpdateNanoDirection(nanoPieces [, turnSpeed = 0.75*math.pi [, turnSpeedVert = turnSpeed ]]) -- 5. Don't forget to set COB.INBUILDSTANCE:=1 & COB.INBUILDSTANCE:=0 in StartBuilding/StopBuilding -- ------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------- if GG.NanoAim then return end GG.NanoAim = {} function GG.NanoAim.UpdateNanoDirection(unitID, nanopieces,turnSpeed,turnSpeedVert) if not Spring.ValidUnitID(unitID) then return end local type, target, isFeature = Spring.Utilities.GetUnitNanoTarget(unitID) if (target) then local x,y,z if (type == "restore") then x,y,z = target[1],target[2],target[3] elseif (not isFeature) then x,y,z = Spring.GetUnitPosition(target) else x,y,z = Spring.GetFeaturePosition(target) end local ux,uy,uz = Spring.GetUnitPosition(unitID) local dx,dy,dz = x-ux,y-uy,z-uz local th = Spring.GetHeadingFromVector(dx,dz) local h = Spring.GetUnitHeading(unitID) local heading = (th - h) * math.pi / 32768 local length = math.sqrt(dx*dx + dy*dy + dz*dz) local norm_dy = (length > 0 and dy / length) or 0 local tp = math.asin(norm_dy) local p = math.asin(select(2,Spring.GetUnitDirection(unitID))) local pitch = p - tp turnSpeed = turnSpeed or (0.75*math.pi) turnSpeedVert = turnSpeedVert or turnSpeed local turned = false for i = 1,#nanopieces do local nano = nanopieces[i] local cur_head,cur_pitch = Spring.UnitScript.GetPieceRotation(nano) if (cur_head ~= heading)or(cur_pitch ~= pitch) then Turn(nano, y_axis, heading, turnSpeed) Turn(nano, x_axis, pitch, turnSpeedVert) turned = true end end if (turned) then WaitForTurn(nanopieces[1], y_axis) end end end function GG.NanoAim.UpdateNanoDirectionThread(unitID, nanopieces, updateInterval, turnSpeed,turnSpeedVert) updateInterval = updateInterval or 1000 while true and Spring.ValidUnitID(unitID) do GG.NanoAim.UpdateNanoDirection(unitID, nanopieces,turnSpeed,turnSpeedVert) Sleep(updateInterval) end end ------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------
gpl-2.0
waterlgndx/darkstar
scripts/zones/Dynamis-Xarcabard/mobs/Count_Zaebos.lua
7
1332
----------------------------------- -- Area: Dynamis Xarcabard -- MOB: Count Zaebos ----------------------------------- require("scripts/globals/status"); require("scripts/globals/dynamis"); require("scripts/zones/Dynamis-Xarcabard/TextIDs"); ----------------------------------- function onMobEngaged(mob,target) end; function onMobFight(mob,target) end; function onMobDeath(mob, player, isKiller) local Animate_Trigger = GetServerVariable("[DynaXarcabard]Boss_Trigger"); if (mob:isInBattlefieldList() == false) then mob:addInBattlefieldList(); Animate_Trigger = Animate_Trigger + 128; SetServerVariable("[DynaXarcabard]Boss_Trigger",Animate_Trigger); if (Animate_Trigger == 32767) then SpawnMob(17330911); -- 142 SpawnMob(17330912); -- 143 SpawnMob(17330177); -- Dynamis Lord GetMobByID(17330183):setSpawn(-364,-35.661,17.254); -- Set Ying and Yang's spawn points to their initial spawn point. GetMobByID(17330184):setSpawn(-364,-35.974,24.254); SpawnMob(17330183); SpawnMob(17330184); activateAnimatedWeapon(); -- Change subanim of all animated weapon end end if (Animate_Trigger == 32767) then player:messageSpecial(PRISON_OF_SOULS_HAS_SET_FREE); end end;
gpl-3.0
kidaa/darkstar
scripts/zones/Windurst_Walls/Zone.lua
28
2946
----------------------------------- -- -- Zone: Windurst_Walls (239) -- ----------------------------------- package.loaded["scripts/zones/Windurst_Walls/TextIDs"] = nil; ----------------------------------- require("scripts/globals/quests"); require("scripts/globals/keyitems"); require("scripts/globals/settings"); require("scripts/zones/Windurst_Walls/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) zone:registerRegion(1, -2,-17,140, 2,-16,142); end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) local cs = -1; -- MOG HOUSE EXIT if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then position = math.random(1,5) - 123; player:setPos(-257.5,-5.05,position,0); if (player:getMainJob() ~= player:getVar("PlayerMainJob")) then cs = 0x7534; end player:setVar("PlayerMainJob",0); elseif (ENABLE_ASA == 1 and player:getCurrentMission(ASA) == A_SHANTOTTO_ASCENSION and (prevZone == 238 or prevZone == 241) and player:getMainLvl()>=10) then cs = 0x01fe; 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) switch (region:GetRegionID()): caseof { [1] = function (x) -- Heaven's Tower enter portal player:startEvent(0x56); end, } end; ----------------------------------- -- onRegionLeave ----------------------------------- 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 == 0x56) then player:setPos(0,0,-22.40,192,242); elseif (csid == 0x7534 and option == 0) then player:setHomePoint(); player:messageSpecial(HOMEPOINT_SET); elseif (csid == 0x01fe) then player:startEvent(0x0202); elseif (csid == 0x0202) then player:completeMission(ASA,A_SHANTOTTO_ASCENSION); player:addMission(ASA,BURGEONING_DREAD); player:setVar("ASA_Status",0); end end;
gpl-3.0
lhog/Zero-K
LuaUI/Widgets/chili/Skins/DarkHive/skin.lua
8
4510
--// ============================================================================= --// Skin local skin = { info = { name = "DarkHive", version = "0.1", author = "luckywaldo7", } } --// ============================================================================= --// skin.general = { --font = "FreeSansBold.ttf", fontOutline = false, fontsize = 13, textColor = {1, 1, 1, 1}, --padding = {5, 5, 5, 5}, --// padding: left, top, right, bottom backgroundColor = {0.1, 0.1, 0.1, 0.7}, } skin.icons = { imageplaceholder = ":cl:placeholder.png", } skin.button = { TileImageBK = ":cl:tech_button.png", TileImageFG = ":cl:empty.png", tiles = {22, 22, 22, 22}, --// tile widths: left, top, right, bottom padding = {10, 10, 10, 10}, backgroundColor = {1, 1, 1, 0.7}, DrawControl = DrawButton, } skin.button_disabled = { TileImageBK = ":cl:tech_button.png", TileImageFG = ":cl:empty.png", tiles = {22, 22, 22, 22}, --// tile widths: left, top, right, bottom padding = {10, 10, 10, 10}, color = {0.3, .3, .3, 1}, backgroundColor = {0.1, 0.1, 0.1, 0.8}, DrawControl = DrawButton, } skin.checkbox = { TileImageFG = ":cl:tech_checkbox_checked.png", TileImageBK = ":cl:tech_checkbox_unchecked.png", tiles = {3, 3, 3, 3}, boxsize = 13, DrawControl = DrawCheckbox, } skin.imagelistview = { imageFolder = "folder.png", imageFolderUp = "folder_up.png", --DrawControl = DrawBackground, colorBK = {1, 1, 1, 0.3}, colorBK_selected = {1, 0.7, 0.1, 0.8}, colorFG = {0, 0, 0, 0}, colorFG_selected = {1, 1, 1, 1}, imageBK = ":cl:node_selected_bw.png", imageFG = ":cl:node_selected.png", tiles = {9, 9, 9, 9}, --tiles = {17, 15, 17, 20}, DrawItemBackground = DrawItemBkGnd, } --[[ skin.imagelistviewitem = { imageFG = ":cl:glassFG.png", imageBK = ":cl:glassBK.png", tiles = {17, 15, 17, 20}, padding = {12, 12, 12, 12}, DrawSelectionItemBkGnd = DrawSelectionItemBkGnd, } --]] skin.panel = { --TileImageFG = ":cl:glassFG.png", --TileImageBK = ":cl:glassBK.png", --tiles = {17, 15, 17, 20}, TileImageBK = ":cl:tech_button.png", TileImageFG = ":cl:empty.png", tiles = {22, 22, 22, 22}, backgroundColor = {1, 1, 1, 0.6}, DrawControl = DrawPanel, } skin.progressbar = { TileImageFG = ":cl:tech_progressbar_full.png", TileImageBK = ":cl:tech_progressbar_empty.png", tiles = {10, 10, 10, 10}, font = { shadow = true, }, DrawControl = DrawProgressbar, } skin.scrollpanel = { BorderTileImage = ":cl:panel2_border.png", bordertiles = {14, 14, 14, 14}, BackgroundTileImage = ":cl:panel2_bg.png", bkgndtiles = {14, 14, 14, 14}, TileImage = ":cl:tech_scrollbar.png", tiles = {7, 7, 7, 7}, KnobTileImage = ":cl:tech_scrollbar_knob.png", KnobTiles = {6, 8, 6, 8}, HTileImage = ":cl:tech_scrollbar.png", htiles = {7, 7, 7, 7}, HKnobTileImage = ":cl:tech_scrollbar_knob.png", HKnobTiles = {6, 8, 6, 8}, KnobColorSelected = {1, 0.7, 0.1, 0.8}, scrollbarSize = 11, DrawControl = DrawScrollPanel, DrawControlPostChildren = DrawScrollPanelBorder, } skin.trackbar = { TileImage = ":cl:trackbar.png", tiles = {10, 14, 10, 14}, --// tile widths: left, top, right, bottom ThumbImage = ":cl:trackbar_thumb.png", StepImage = ":cl:trackbar_step.png", hitpadding = {4, 4, 5, 4}, DrawControl = DrawTrackbar, } skin.treeview = { --ImageNode = ":cl:node.png", ImageNodeSelected = ":cl:node_selected.png", tiles = {9, 9, 9, 9}, ImageExpanded = ":cl:treeview_node_expanded.png", ImageCollapsed = ":cl:treeview_node_collapsed.png", treeColor = {1, 1, 1, 0.1}, DrawNode = DrawTreeviewNode, DrawNodeTree = DrawTreeviewNodeTree, } skin.window = { TileImage = ":cl:tech_dragwindow.png", --TileImage = ":cl:tech_window.png", --TileImage = ":cl:window_tooltip.png", --tiles = {25, 25, 25, 25}, --// tile widths: left, top, right, bottom tiles = {62, 62, 62, 62}, --// tile widths: left, top, right, bottom padding = {13, 13, 13, 13}, hitpadding = {4, 4, 4, 4}, captionColor = {1, 1, 1, 0.45}, boxes = { resize = {-21, -21, -10, -10}, drag = {0, 0, "100%", 10}, }, NCHitTest = NCHitTestWithPadding, NCMouseDown = WindowNCMouseDown, NCMouseDownPostChildren = WindowNCMouseDownPostChildren, DrawControl = DrawWindow, DrawDragGrip = function() end, DrawResizeGrip = DrawResizeGrip, } skin.control = skin.general --// ============================================================================= --// return skin
gpl-2.0
davidedmonds/darkstar
scripts/globals/spells/diaga_ii.lua
18
1869
----------------------------------------- -- Spell: Diaga II -- Lowers an enemy's defense and gradually deals light elemental damage. ----------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------------- -- OnSpellCast ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) --calculate raw damage local basedmg = caster:getSkillLevel(ENFEEBLING_MAGIC_SKILL) / 4; local dmg = calculateMagicDamage(basedmg,3,caster,spell,target,ENFEEBLING_MAGIC_SKILL,MOD_INT,false); dmg = utils.clamp(dmg, 1, 40); --get resist multiplier (1x if no resist) local resist = applyResistance(caster,spell,target,caster:getStat(MOD_INT)-target:getStat(MOD_INT),ENFEEBLING_MAGIC_SKILL,1.0); --get the resisted damage dmg = dmg*resist; --add on bonuses (staff/day/weather/jas/mab/etc all go in this function) dmg = addBonuses(caster,spell,target,dmg); --add in target adjustment dmg = adjustForTarget(target,dmg,spell:getElement()); --add in final adjustments including the actual damage dealt local final = finalMagicAdjustments(caster,target,spell,dmg); -- Calculate duration. local duration = 120; -- Check for Bio. local bio = target:getStatusEffect(EFFECT_BIO); -- Do it! if (bio == nil or (DIA_OVERWRITE == 0 and bio:getPower() <= 2) or (DIA_OVERWRITE == 1 and bio:getPower() < 2)) then target:addStatusEffect(EFFECT_DIA,2,3,duration,FLAG_ERASABLE, 10); spell:setMsg(2); else spell:setMsg(75); end -- Try to kill same tier Bio if (BIO_OVERWRITE == 1 and bio ~= nil) then if (bio:getPower() <= 2) then target:delStatusEffect(EFFECT_BIO); end end return final; end;
gpl-3.0
waterlgndx/darkstar
scripts/globals/spells/light_carol.lua
2
1569
----------------------------------------- -- Spell: Light Carol -- Increases light 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.LIGHT, 1)) then spell:setMsg(dsp.msg.basic.MAGIC_NO_EFFECT); end return dsp.effect.CAROL; end;
gpl-3.0
kidaa/darkstar
scripts/globals/items/army_biscuit.lua
35
1254
----------------------------------------- -- ID: 5657 -- Item: army_biscuit -- Food Effect: 5Min?, All Races ----------------------------------------- -- HP Recovered While Healing 3 -- MP Recovered While Healing 3 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,300,5657); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_HPHEAL, 3); target:addMod(MOD_MPHEAL, 3); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_HPHEAL, 3); target:delMod(MOD_MPHEAL, 3); end;
gpl-3.0
MonokuroInzanaito/ygopro-777DIY
expansions/script/c80100005.lua
1
5431
--幻想物语 归去月球的辉夜姬 function c80100005.initial_effect(c) c:EnableReviveLimit() --pendulum summon aux.EnablePendulumAttribute(c,false) --spsummon condition local ea=Effect.CreateEffect(c) ea:SetType(EFFECT_TYPE_SINGLE) ea:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) ea:SetCode(EFFECT_SPSUMMON_CONDITION) ea:SetValue(c80100005.splimit) c:RegisterEffect(ea) --spsummon limit local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD) e3:SetRange(LOCATION_MZONE) e3:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e3:SetTargetRange(1,0) e3:SetTarget(c80100005.sumlimit) c:RegisterEffect(e3) -- local eb=Effect.CreateEffect(c) eb:SetType(EFFECT_TYPE_SINGLE) eb:SetCode(EFFECT_UNRELEASABLE_SUM) eb:SetProperty(EFFECT_FLAG_SINGLE_RANGE) eb:SetRange(LOCATION_MZONE) eb:SetValue(1) c:RegisterEffect(eb) --atkup local e8=Effect.CreateEffect(c) e8:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD) e8:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e8:SetCode(EVENT_CHAINING) e8:SetRange(LOCATION_MZONE) e8:SetOperation(aux.chainreg) c:RegisterEffect(e8) --change effect local ec=Effect.CreateEffect(c) ec:SetDescription(aux.Stringid(80100005,1)) ec:SetCategory(CATEGORY_DISABLE) ec:SetType(EFFECT_TYPE_QUICK_O) ec:SetProperty(EFFECT_FLAG_CARD_TARGET) ec:SetCode(EVENT_CHAINING) ec:SetRange(LOCATION_MZONE) ec:SetCountLimit(1,80100005) ec:SetCondition(c80100005.chcon) ec:SetTarget(c80100005.chtg) ec:SetOperation(c80100005.chop) c:RegisterEffect(ec) --to hand local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(80100005,2)) e2:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_DESTROY) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetCode(EVENT_RELEASE) e2:SetCountLimit(1,80100005) e2:SetCost(c80100005.rlcost) e2:SetTarget(c80100005.rltg) e2:SetOperation(c80100005.rlop) c:RegisterEffect(e2) end function c80100005.splimit(e,se,sp,st) return se:GetHandler():IsSetCard(0x3400) or bit.band(st,SUMMON_TYPE_PENDULUM)==SUMMON_TYPE_PENDULUM end function c80100005.sumlimit(e,c,sump,sumtype,sumpos,targetp,se) return c:IsLocation(LOCATION_GRAVE+LOCATION_HAND) end function c80100005.chcon(e,tp,eg,ep,ev,re,r,rp) --[[local rc=re:GetHandler() return rc:GetType()==TYPE_QUICKPLAY and re:IsHasType(EFFECT_TYPE_ACTIVATE)]] local tpe=re:GetActiveType() return re:IsHasType(EFFECT_TYPE_ACTIVATE) and tpe==TYPE_QUICKPLAY+TYPE_SPELL and e:GetHandler():GetFlagEffect(1)>0 end function c80100005.filter(c) return c:IsFaceup() and not c:IsDisabled() end function c80100005.chtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and c80100005.filter(chkc) end if chk==0 then return Duel.IsExistingTarget(c80100005.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectTarget(tp,c80100005.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil) if Duel.GetFieldGroupCount(tp,0,LOCATION_HAND)>0 then Duel.SetOperationInfo(0,CATEGORY_DISABLE,g,1,0,0) end end function c80100005.chop(e,tp,eg,ep,ev,re,r,rp) local hg=Duel.GetFieldGroup(1-tp,LOCATION_HAND,0) if hg:GetCount()>0 and Duel.SelectYesNo(1-tp,aux.Stringid(12152769,2)) then Duel.Hint(HINT_SELECTMSG,1-tp,aux.Stringid(12152769,3)) local sg=hg:Select(1-tp,1,1,nil) Duel.SendtoHand(sg,tp,REASON_EFFECT) if Duel.IsChainDisablable(0) then Duel.NegateEffect(0) return end end local c=e:GetHandler() local tc=Duel.GetFirstTarget() if tc:IsFaceup() and tc:IsRelateToEffect(e) then local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_DISABLE) e2:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) tc:RegisterEffect(e2) local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetCode(EFFECT_DISABLE_EFFECT) e3:SetValue(RESET_TURN_SET) e3:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) tc:RegisterEffect(e3) end end function c80100005.rlcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.CheckLPCost(tp,400) end Duel.PayLPCost(tp,400) end function c80100005.filter8(c,e,tp) return c:IsSetCard(0x3400) and c:IsCanBeSpecialSummoned(e,0,tp,true,false) end function c80100005.rltg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c80100005.filter8,tp,LOCATION_EXTRA,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function c80100005.rlop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c80100005.filter8,tp,LOCATION_EXTRA,0,1,1,nil,e,tp) local tc=g:GetFirst() if tc then Duel.SpecialSummon(tc,0,tp,tp,true,false,POS_FACEUP) tc:CompleteProcedure() Duel.BreakEffect() --Duel.SendtoDeck(tc,nil,2,REASON_EFFECT) Duel.Destroy(tc,REASON_EFFECT) end end
gpl-3.0
kidaa/darkstar
scripts/zones/Gusgen_Mines/npcs/_5gd.lua
34
1341
----------------------------------- -- Area: Gusgen Mines -- NPC: _5gd (Lever F) -- @pos 44 -20.56 143.802 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 F GetNPCByID(Lever-5):setAnimation(9);--close door E GetNPCByID(Lever-4):setAnimation(9);--close door D 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
waterlgndx/darkstar
scripts/zones/The_Garden_of_RuHmet/npcs/_0z0.lua
2
1617
----------------------------------- -- Area: The_Garden_of_RuHmet -- NPC: _0z0 ----------------------------------- package.loaded["scripts/zones/The_Garden_of_RuHmet/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/zones/The_Garden_of_RuHmet/TextIDs"); require("scripts/globals/missions"); require("scripts/globals/keyitems"); require("scripts/globals/bcnm"); function onTrade(player,npc,trade) if (TradeBCNM(player,player:getZoneID(),trade,npc)) then return; end end; function onTrigger(player,npc) --player:addMission(COP, WHEN_ANGELS_FALL); --player:setVar("PromathiaStatus",3); if (player:getCurrentMission(COP) == WHEN_ANGELS_FALL and player:getVar("PromathiaStatus")==3) then player:startEvent(203); elseif (EventTriggerBCNM(player,npc)) then elseif (player:getCurrentMission(COP) == WHEN_ANGELS_FALL and player:getVar("PromathiaStatus")==5) then player:startEvent(205); end return 1; end; function onEventUpdate(player,csid,option) -- printf("onUpdate CSID: %u",csid); -- printf("onUpdate RESULT: %u",option); if (EventUpdateBCNM(player,csid,option)) then return 1; end end; ----------------------------------- -- onEventFinish Action ----------------------------------- function onEventFinish(player,csid,option) -- printf("onFinish CSID: %u",csid); -- printf("onFinish RESULT: %u",option); if ( csid == 203) then player:setVar("PromathiaStatus",4); elseif (EventFinishBCNM(player,csid,option)) then return; end end;
gpl-3.0
waterlgndx/darkstar
scripts/zones/Bastok_Mines/npcs/Gerbaum.lua
2
1857
----------------------------------- -- Area: Bastok Mines -- NPC: Gerbaum -- Starts & Finishes Repeatable Quest: Minesweeper (100%) ----------------------------------- package.loaded["scripts/zones/Bastok_Mines/TextIDs"] = nil; ----------------------------------- require("scripts/globals/titles"); require("scripts/globals/quests"); require("scripts/globals/settings"); require("scripts/zones/Bastok_Mines/TextIDs"); ----------------------------------- function onTrade(player,npc,trade) count = trade:getItemCount(); ZeruhnSoot = trade:hasItemQty(560,3); if (ZeruhnSoot == true and count == 3) then MineSweep = player:getQuestStatus(BASTOK,MINESWEEPER); if (MineSweep >= 1) then player:tradeComplete(); player:startEvent(109); end end end; function onTrigger(player,npc) MineSweep = player:getQuestStatus(BASTOK,MINESWEEPER); if (MineSweep == 0) then player:startEvent(108); else rand = math.random(1,2); if (rand == 1) then player:startEvent(22); else player:startEvent(23); end end end; function onEventUpdate(player,csid,option) -- printf("CSID2: %u",csid); -- printf("RESULT2: %u",option); end; function onEventFinish(player,csid,option) MineSweep = player:getQuestStatus(BASTOK,MINESWEEPER); if (csid == 108) then if (MineSweep == 0) then player:addQuest(BASTOK,MINESWEEPER); end elseif (csid == 109) then if (MineSweep == 1) then player:completeQuest(BASTOK,MINESWEEPER); player:addFame(BASTOK,75); player:addTitle(dsp.title.ZERUHN_SWEEPER); else player:addFame(BASTOK,8); end player:addGil(GIL_RATE*150); player:messageSpecial(GIL_OBTAINED,GIL_RATE*150); end end;
gpl-3.0
DarkWanderer/LuaParser
DW.Lua.UnitTests/Code/Fixtures/tpack.lua
6
10603
-- $Id: tpack.lua,v 1.13 2016/11/07 13:11:28 roberto Exp $ -- See Copyright Notice in file all.lua local pack = string.pack local packsize = string.packsize local unpack = string.unpack print "testing pack/unpack" -- maximum size for integers local NB = 16 local sizeshort = packsize("h") local sizeint = packsize("i") local sizelong = packsize("l") local sizesize_t = packsize("T") local sizeLI = packsize("j") local sizefloat = packsize("f") local sizedouble = packsize("d") local sizenumber = packsize("n") local little = (pack("i2", 1) == "\1\0") local align = packsize("!xXi16") assert(1 <= sizeshort and sizeshort <= sizeint and sizeint <= sizelong and sizefloat <= sizedouble) print("platform:") print(string.format( "\tshort %d, int %d, long %d, size_t %d, float %d, double %d,\n\z \tlua Integer %d, lua Number %d", sizeshort, sizeint, sizelong, sizesize_t, sizefloat, sizedouble, sizeLI, sizenumber)) print("\t" .. (little and "little" or "big") .. " endian") print("\talignment: " .. align) -- check errors in arguments function checkerror (msg, f, ...) local status, err = pcall(f, ...) -- print(status, err, msg) assert(not status and string.find(err, msg)) end -- minimum behavior for integer formats assert(unpack("B", pack("B", 0xff)) == 0xff) assert(unpack("b", pack("b", 0x7f)) == 0x7f) assert(unpack("b", pack("b", -0x80)) == -0x80) assert(unpack("H", pack("H", 0xffff)) == 0xffff) assert(unpack("h", pack("h", 0x7fff)) == 0x7fff) assert(unpack("h", pack("h", -0x8000)) == -0x8000) assert(unpack("L", pack("L", 0xffffffff)) == 0xffffffff) assert(unpack("l", pack("l", 0x7fffffff)) == 0x7fffffff) assert(unpack("l", pack("l", -0x80000000)) == -0x80000000) for i = 1, NB do -- small numbers with signal extension ("\xFF...") local s = string.rep("\xff", i) assert(pack("i" .. i, -1) == s) assert(packsize("i" .. i) == #s) assert(unpack("i" .. i, s) == -1) -- small unsigned number ("\0...\xAA") s = "\xAA" .. string.rep("\0", i - 1) assert(pack("<I" .. i, 0xAA) == s) assert(unpack("<I" .. i, s) == 0xAA) assert(pack(">I" .. i, 0xAA) == s:reverse()) assert(unpack(">I" .. i, s:reverse()) == 0xAA) end do local lnum = 0x13121110090807060504030201 local s = pack("<j", lnum) assert(unpack("<j", s) == lnum) assert(unpack("<i" .. sizeLI + 1, s .. "\0") == lnum) assert(unpack("<i" .. sizeLI + 1, s .. "\0") == lnum) for i = sizeLI + 1, NB do local s = pack("<j", -lnum) assert(unpack("<j", s) == -lnum) -- strings with (correct) extra bytes assert(unpack("<i" .. i, s .. ("\xFF"):rep(i - sizeLI)) == -lnum) assert(unpack(">i" .. i, ("\xFF"):rep(i - sizeLI) .. s:reverse()) == -lnum) assert(unpack("<I" .. i, s .. ("\0"):rep(i - sizeLI)) == -lnum) -- overflows checkerror("does not fit", unpack, "<I" .. i, ("\x00"):rep(i - 1) .. "\1") checkerror("does not fit", unpack, ">i" .. i, "\1" .. ("\x00"):rep(i - 1)) end end for i = 1, sizeLI do local lstr = "\1\2\3\4\5\6\7\8\9\10\11\12\13" local lnum = 0x13121110090807060504030201 local n = lnum & (~(-1 << (i * 8))) local s = string.sub(lstr, 1, i) assert(pack("<i" .. i, n) == s) assert(pack(">i" .. i, n) == s:reverse()) assert(unpack(">i" .. i, s:reverse()) == n) end -- sign extension do local u = 0xf0 for i = 1, sizeLI - 1 do assert(unpack("<i"..i, "\xf0"..("\xff"):rep(i - 1)) == -16) assert(unpack(">I"..i, "\xf0"..("\xff"):rep(i - 1)) == u) u = u * 256 + 0xff end end -- mixed endianness do assert(pack(">i2 <i2", 10, 20) == "\0\10\20\0") local a, b = unpack("<i2 >i2", "\10\0\0\20") assert(a == 10 and b == 20) assert(pack("=i4", 2001) == pack("i4", 2001)) end print("testing invalid formats") checkerror("out of limits", pack, "i0", 0) checkerror("out of limits", pack, "i" .. NB + 1, 0) checkerror("out of limits", pack, "!" .. NB + 1, 0) checkerror("%(17%) out of limits %[1,16%]", pack, "Xi" .. NB + 1) checkerror("invalid format option 'r'", pack, "i3r", 0) checkerror("16%-byte integer", unpack, "i16", string.rep('\3', 16)) checkerror("not power of 2", pack, "!4i3", 0); checkerror("missing size", pack, "c", "") checkerror("variable%-length format", packsize, "s") checkerror("variable%-length format", packsize, "z") -- overflow in option size (error will be in digit after limit) checkerror("invalid format", packsize, "c1" .. string.rep("0", 40)) if packsize("i") == 4 then -- result would be 2^31 (2^3 repetitions of 2^28 strings) local s = string.rep("c268435456", 2^3) checkerror("too large", packsize, s) -- one less is OK s = string.rep("c268435456", 2^3 - 1) .. "c268435455" assert(packsize(s) == 0x7fffffff) end -- overflow in packing for i = 1, sizeLI - 1 do local umax = (1 << (i * 8)) - 1 local max = umax >> 1 local min = ~max checkerror("overflow", pack, "<I" .. i, -1) checkerror("overflow", pack, "<I" .. i, min) checkerror("overflow", pack, ">I" .. i, umax + 1) checkerror("overflow", pack, ">i" .. i, umax) checkerror("overflow", pack, ">i" .. i, max + 1) checkerror("overflow", pack, "<i" .. i, min - 1) assert(unpack(">i" .. i, pack(">i" .. i, max)) == max) assert(unpack("<i" .. i, pack("<i" .. i, min)) == min) assert(unpack(">I" .. i, pack(">I" .. i, umax)) == umax) end -- Lua integer size assert(unpack(">j", pack(">j", math.maxinteger)) == math.maxinteger) assert(unpack("<j", pack("<j", math.mininteger)) == math.mininteger) assert(unpack("<J", pack("<j", -1)) == -1) -- maximum unsigned integer if little then assert(pack("f", 24) == pack("<f", 24)) else assert(pack("f", 24) == pack(">f", 24)) end print "testing pack/unpack of floating-point numbers" for _, n in ipairs{0, -1.1, 1.9, 1/0, -1/0, 1e20, -1e20, 0.1, 2000.7} do assert(unpack("n", pack("n", n)) == n) assert(unpack("<n", pack("<n", n)) == n) assert(unpack(">n", pack(">n", n)) == n) assert(pack("<f", n) == pack(">f", n):reverse()) assert(pack(">d", n) == pack("<d", n):reverse()) end -- for non-native precisions, test only with "round" numbers for _, n in ipairs{0, -1.5, 1/0, -1/0, 1e10, -1e9, 0.5, 2000.25} do assert(unpack("<f", pack("<f", n)) == n) assert(unpack(">f", pack(">f", n)) == n) assert(unpack("<d", pack("<d", n)) == n) assert(unpack(">d", pack(">d", n)) == n) end print "testing pack/unpack of strings" do local s = string.rep("abc", 1000) assert(pack("zB", s, 247) == s .. "\0\xF7") local s1, b = unpack("zB", s .. "\0\xF9") assert(b == 249 and s1 == s) s1 = pack("s", s) assert(unpack("s", s1) == s) checkerror("does not fit", pack, "s1", s) checkerror("contains zeros", pack, "z", "alo\0"); for i = 2, NB do local s1 = pack("s" .. i, s) assert(unpack("s" .. i, s1) == s and #s1 == #s + i) end end do local x = pack("s", "alo") checkerror("too short", unpack, "s", x:sub(1, -2)) checkerror("too short", unpack, "c5", "abcd") checkerror("out of limits", pack, "s100", "alo") end do assert(pack("c0", "") == "") assert(packsize("c0") == 0) assert(unpack("c0", "") == "") assert(pack("<! c3", "abc") == "abc") assert(packsize("<! c3") == 3) assert(pack(">!4 c6", "abcdef") == "abcdef") assert(pack("c3", "123") == "123") assert(pack("c0", "") == "") assert(pack("c8", "123456") == "123456\0\0") assert(pack("c88", "") == string.rep("\0", 88)) assert(pack("c188", "ab") == "ab" .. string.rep("\0", 188 - 2)) local a, b, c = unpack("!4 z c3", "abcdefghi\0xyz") assert(a == "abcdefghi" and b == "xyz" and c == 14) checkerror("longer than", pack, "c3", "1234") end -- testing multiple types and sequence do local x = pack("<b h b f d f n i", 1, 2, 3, 4, 5, 6, 7, 8) assert(#x == packsize("<b h b f d f n i")) local a, b, c, d, e, f, g, h = unpack("<b h b f d f n i", x) assert(a == 1 and b == 2 and c == 3 and d == 4 and e == 5 and f == 6 and g == 7 and h == 8) end print "testing alignment" do assert(pack(" < i1 i2 ", 2, 3) == "\2\3\0") -- no alignment by default local x = pack(">!8 b Xh i4 i8 c1 Xi8", -12, 100, 200, "\xEC") assert(#x == packsize(">!8 b Xh i4 i8 c1 Xi8")) assert(x == "\xf4" .. "\0\0\0" .. "\0\0\0\100" .. "\0\0\0\0\0\0\0\xC8" .. "\xEC" .. "\0\0\0\0\0\0\0") local a, b, c, d, pos = unpack(">!8 c1 Xh i4 i8 b Xi8 XI XH", x) assert(a == "\xF4" and b == 100 and c == 200 and d == -20 and (pos - 1) == #x) x = pack(">!4 c3 c4 c2 z i4 c5 c2 Xi4", "abc", "abcd", "xz", "hello", 5, "world", "xy") assert(x == "abcabcdxzhello\0\0\0\0\0\5worldxy\0") local a, b, c, d, e, f, g, pos = unpack(">!4 c3 c4 c2 z i4 c5 c2 Xh Xi4", x) assert(a == "abc" and b == "abcd" and c == "xz" and d == "hello" and e == 5 and f == "world" and g == "xy" and (pos - 1) % 4 == 0) x = pack(" b b Xd b Xb x", 1, 2, 3) assert(packsize(" b b Xd b Xb x") == 4) assert(x == "\1\2\3\0") a, b, c, pos = unpack("bbXdb", x) assert(a == 1 and b == 2 and c == 3 and pos == #x) -- only alignment assert(packsize("!8 xXi8") == 8) local pos = unpack("!8 xXi8", "0123456701234567"); assert(pos == 9) assert(packsize("!8 xXi2") == 2) local pos = unpack("!8 xXi2", "0123456701234567"); assert(pos == 3) assert(packsize("!2 xXi2") == 2) local pos = unpack("!2 xXi2", "0123456701234567"); assert(pos == 3) assert(packsize("!2 xXi8") == 2) local pos = unpack("!2 xXi8", "0123456701234567"); assert(pos == 3) assert(packsize("!16 xXi16") == 16) local pos = unpack("!16 xXi16", "0123456701234567"); assert(pos == 17) checkerror("invalid next option", pack, "X") checkerror("invalid next option", unpack, "XXi", "") checkerror("invalid next option", unpack, "X i", "") checkerror("invalid next option", pack, "Xc1") end do -- testing initial position local x = pack("i4i4i4i4", 1, 2, 3, 4) for pos = 1, 16, 4 do local i, p = unpack("i4", x, pos) assert(i == pos//4 + 1 and p == pos + 4) end -- with alignment for pos = 0, 12 do -- will always round position to power of 2 local i, p = unpack("!4 i4", x, pos + 1) assert(i == (pos + 3)//4 + 1 and p == i*4 + 1) end -- negative indices local i, p = unpack("!4 i4", x, -4) assert(i == 4 and p == 17) local i, p = unpack("!4 i4", x, -7) assert(i == 4 and p == 17) local i, p = unpack("!4 i4", x, -#x) assert(i == 1 and p == 5) -- limits for i = 1, #x + 1 do assert(unpack("c0", x, i) == "") end checkerror("out of string", unpack, "c0", x, 0) checkerror("out of string", unpack, "c0", x, #x + 2) checkerror("out of string", unpack, "c0", x, -(#x + 1)) end print "OK"
mit
lhog/Zero-K
scripts/striderdante.lua
4
14653
include 'constants.lua' -------------------------------------------------------------------------------- -- pieces -------------------------------------------------------------------------------- local base = piece 'base' local pelvis = piece 'pelvis' local torso = piece 'torso' local tail = piece 'tail' local flagellum = piece 'flagellum' local ruparm = piece 'ruparm' local rarm = piece 'rarm' local rshield = piece 'rshield' local lshield = piece 'lshield' local luparm = piece 'luparm' local larm = piece 'larm' local rupleg = piece 'rupleg' local lupleg = piece 'lupleg' local lleg = piece 'lleg' local rleg = piece 'rleg' local rfoot = piece 'rfoot' local lfoot = piece 'lfoot' local rtoef = piece 'rtoef' local rtoer = piece 'rtoer' local ltoef = piece 'ltoef' local ltoer = piece 'ltoer' local rf1 = piece 'rf1' local rf2 = piece 'rf2' local rf3 = piece 'rf3' local rbak1 = piece 'rbak1' local rbak2 = piece 'rbak2' local lbak1 = piece 'lbak1' local lbak2 = piece 'lbak2' local lf1 = piece 'lf1' local lf2 = piece 'lf2' local lf3 = piece 'lf3' local flame1 = piece 'flame1' local flame2 = piece 'flame2' local jet1 = piece 'jet1' local jet2 = piece 'jet2' local fix = piece 'fix' local smokePiece = {torso, pelvis, flagellum} local weaponPieces = { {aimFrom = torso, query = {rf1, lf1, rf2, lf2, rf3, lf3}, index = 1}, {aimFrom = torso, query = {flame1, flame2}, index = 1}, {aimFrom = torso, query = {rf1, lf1, rf2, lf2, rf3, lf3}, index = 1}, {aimFrom = torso, query = {fix}, index = 1}, } local missileEmits = {{lbak1, lbak2}, {rbak1, rbak2}} -------------------------------------------------------------------------------- -- constants -------------------------------------------------------------------------------- local SIG_WALK = 1 local SIG_AIM = 2 local SIG_AIM_2 = 4 local SIG_AIM_3 = 8 local SIG_AIM_4 = 16 local SIG_RESTORE = 32 local SIG_IDLE = 64 local RELOADTIME = wd and WeaponDefs[wd].reload*30 or 20*30 local SALVO_TIME = 1000 local unitDefID = Spring.GetUnitDefID(unitID) local wd = UnitDefs[unitDefID].weapons[3] and UnitDefs[unitDefID].weapons[3].weaponDef -------------------------------------------------------------------------------- -- vars -------------------------------------------------------------------------------- local dead = false local armsFree = true local dgunning = false local rightArmPitch = 0 -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Arm Animation local function RestorePose() Turn(torso, x_axis, 0, math.rad(100)) Turn(lupleg, x_axis, 0, math.rad(100)) Turn(rupleg, x_axis, 0, math.rad(100)) Turn(lfoot, x_axis, 0, math.rad(100)) Turn(rfoot, x_axis, 0, math.rad(100)) Turn(lleg, x_axis, 0, math.rad(100)) Turn(rleg, x_axis, 0, math.rad(100)) Turn(ltoef, x_axis, 0, math.rad(100)) Turn(ltoer, x_axis, 0, math.rad(100)) Turn(rtoef, x_axis, 0, math.rad(100)) Turn(rtoer, x_axis, 0, math.rad(100)) Turn(pelvis, z_axis, 0, math.rad(100)) Move(pelvis, y_axis, 0, 25) rightArmPitch = 0 end local function IdleAnim() Signal(SIG_IDLE) SetSignalMask(SIG_IDLE) Sleep(12000) while true do Turn(torso, y_axis, math.rad(15), math.rad(60)) --Turn(larm, y_axis, math.rad(15), math.rad(60)) --Turn(rarm, y_axis, math.rad(-10), math.rad(60)) Turn(luparm, x_axis, math.rad(-40), math.rad(120)) Turn(ruparm, x_axis, 0, math.rad(120)) Sleep(1500) Turn(torso, y_axis, math.rad(-15), math.rad(90)) --Turn(larm, y_axis, math.rad(10), math.rad(60)) --Turn(rarm, y_axis, math.rad(-15), math.rad(60)) Turn(luparm, x_axis, 0, math.rad(120)) Turn(ruparm, x_axis, math.rad(-40), math.rad(120)) Sleep(1500) Turn(torso, y_axis, 0, math.rad(60)) --Turn(larm, y_axis, 0, math.rad(60)) --Turn(rarm, y_axis, 0, math.rad(60)) Turn(luparm, x_axis, 0, math.rad(120)) Turn(ruparm, x_axis, 0, math.rad(120)) Sleep(7000) end end local function RestoreAfterDelay() Signal(SIG_RESTORE) SetSignalMask(SIG_RESTORE) Sleep(8000) --torso if not dead then Turn(torso, y_axis, 0, math.rad(100)) Turn(ruparm, x_axis, 0, math.rad(250)) Turn(ruparm, y_axis, 0, math.rad(250)) Turn(ruparm, z_axis, math.rad(-(0)), math.rad(250)) Turn(rarm, x_axis, 0, math.rad(250)) --up 2 Turn(rarm, y_axis, 0, math.rad(250)) Turn(rarm, z_axis, math.rad(-(0)), math.rad(250)) --up -12 Turn(flagellum, x_axis, 0, math.rad(90)) Turn(luparm, x_axis, 0, math.rad(250)) --up -9 Turn(luparm, y_axis, 0, math.rad(250)) Turn(luparm, z_axis, math.rad(-(0)), math.rad(250)) Turn(larm, x_axis, 0, math.rad(250)) --up 5 Turn(larm, y_axis, 0, math.rad(250)) --up -3 Turn(larm, z_axis, math.rad(-(0)), math.rad(250)) --up 22 RestorePose() end StartThread(IdleAnim) armsFree = true end -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Walking local PACE = 3.9 local SLEEP_TIME = 1080/PACE local walkCycle = 1 -- Alternate between 1 and 2 local tempSpeed = 40 local walkAngle = { { -- Moving forwards { hip = {math.rad(0), math.rad(20) * PACE}, leg = {math.rad(-20), math.rad(40) * PACE}, foot = {math.rad(15), math.rad(54) * PACE}, toeFront = {math.rad(22), math.rad(45) * PACE}, toeRear = {math.rad(-22), math.rad(45) * PACE}, arm = {math.rad(4), math.rad(12) * PACE}, }, { hip = {math.rad(-35), math.rad(35) * PACE}, leg = {math.rad(0), math.rad(20) * PACE}, foot = {math.rad(-5), math.rad(20) * PACE}, toeFront = {math.rad(22), 0}, toeRear = {math.rad(-6), 10}, }, { hip = {math.rad(-60), math.rad(25) * PACE}, leg = {math.rad(30), math.rad(30) * PACE}, foot = {math.rad(31), math.rad(36) * PACE}, toeFront = {0, math.rad(45) * PACE}, toeRear = {math.rad(10), math.rad(30) * PACE}, }, }, { -- Moving backwards { hip = {math.rad(-35), math.rad(25) * PACE}, leg = {math.rad(20), math.rad(10) * PACE}, foot = {math.rad(15), math.rad(16) * PACE}, toeFront = {0, 0}, toeRear = {0, math.rad(40) * PACE}, arm = {math.rad(4), math.rad(12) * PACE}, }, { hip = {math.rad(-5), math.rad(30) * PACE}, leg = {math.rad(10), math.rad(10) * PACE}, foot = {math.rad(-3), math.rad(18) * PACE}, toeFront = {0, 0}, toeRear = {0, 0}, }, { hip = {math.rad(20), math.rad(25) * PACE}, leg = {math.rad(20), math.rad(10) * PACE}, foot = {math.rad(-39), math.rad(36) * PACE}, toeFront = {0, 0}, toeRear = {0, 0}, }, }, { -- Do each cycle { pelvisMove = {4.6, 2.9 * PACE}, pelvisTurn = {math.rad(0.8), math.rad(1.6) * PACE}, }, { pelvisMove = {3.8, 0.9 * PACE}, pelvisTurn = {math.rad(2), math.rad(1.2) * PACE}, }, { pelvisMove = {1.7, 2.1 * PACE}, pelvisTurn = {math.rad(0.8), math.rad(1.6) * PACE}, }, } } local function Walk() Signal(SIG_WALK) SetSignalMask(SIG_WALK) if armsFree then Turn(torso, y_axis, 0, math.rad(90)) Turn(larm, y_axis, 0, math.rad(120)) Turn(rarm, y_axis, 0, math.rad(120)) Turn(luparm, x_axis, 0, math.rad(240)) Turn(ruparm, x_axis, 0, math.rad(240)) rightArmPitch = 0 end while true do walkCycle = 3 - walkCycle local speedMult = (GG.att_MoveChange[unitID] or 1) local left = walkAngle[walkCycle] local right = walkAngle[3 - walkCycle] local main = walkAngle[3] for i = 1, 3 do Turn(lupleg, x_axis, left[i].hip[1], left[i].hip[2] * speedMult) Turn(lleg, x_axis, left[i].leg[1], left[i].leg[2] * speedMult) Turn(lfoot, x_axis, left[i].foot[1], left[i].foot[2] * speedMult) Turn(ltoef, x_axis, left[i].toeFront[1], left[i].toeFront[2] * speedMult) Turn(ltoer, x_axis, left[i].toeRear[1], left[i].toeRear[2] * speedMult) Turn(rupleg, x_axis, right[i].hip[1], right[i].hip[2] * speedMult) Turn(rleg, x_axis, right[i].leg[1], right[i].leg[2] * speedMult) Turn(rfoot, x_axis, right[i].foot[1], right[i].foot[2] * speedMult) Turn(rtoef, x_axis, right[i].toeFront[1], right[i].toeFront[2] * speedMult) Turn(rtoer, x_axis, right[i].toeRear[1], right[i].toeRear[2] * speedMult) if armsFree and left[i].arm then local parity = 3 - walkCycle*2 Turn(larm, y_axis, left[i].arm[1] * parity, left[i].arm[2] * speedMult) Turn(rarm, y_axis, right[i].arm[1] * parity, right[i].arm[2] * speedMult) Turn(pelvis, z_axis, main[i].pelvisTurn[1] * parity, main[i].pelvisTurn[2] * speedMult) end Move(pelvis, y_axis, main[i].pelvisMove[1], main[i].pelvisMove[2] * speedMult) Sleep(SLEEP_TIME / speedMult) end end end function script.Create() Hide(flame1) Hide(flame2) Hide(rf1) Hide(rf2) Hide(rf3) Hide(lf1) Hide(lf2) Hide(lf3) Hide(jet1) Hide(jet2) StartThread(GG.Script.SmokeUnit, unitID, smokePiece) end local function Stopping() Signal(SIG_WALK) SetSignalMask(SIG_WALK) RestorePose() StartThread(IdleAnim) end function script.StartMoving() StartThread(Walk) Signal(SIG_IDLE) end function script.StopMoving() StartThread(Stopping) end -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Weaponry function script.AimFromWeapon(num) if num > 4 then return torso end return weaponPieces[num].aimFrom end function script.QueryWeapon(num) if num > 4 then return torso end local pieces = weaponPieces[num].query return pieces[weaponPieces[num].index] end function script.AimWeapon(num, heading, pitch) Signal(SIG_IDLE) if num == 1 then if dgunning then return false end Signal(SIG_AIM) SetSignalMask(SIG_AIM) armsFree = false Turn(ruparm, x_axis, -pitch - math.rad(20), math.rad(250)) Turn(luparm, x_axis, -pitch - math.rad(20), math.rad(250)) Turn(torso, y_axis, heading, math.rad(250)) Turn(rarm, x_axis, math.rad(20), math.rad(250)) Turn(larm, x_axis, math.rad(20), math.rad(250)) WaitForTurn(torso, y_axis) WaitForTurn(larm, x_axis) --need to make surenot rightArmPitch = -pitch return true elseif num == 2 then if dgunning then return false end Signal(SIG_AIM_2) SetSignalMask(SIG_AIM_2) Turn(torso, y_axis, heading, math.rad(200)) WaitForTurn(torso, y_axis) StartThread(RestoreAfterDelay) return true elseif num == 3 then dgunning = true Signal(SIG_AIM) Signal(SIG_AIM_2) Signal(SIG_AIM_3) SetSignalMask(SIG_AIM_3) Spring.SetUnitRulesParam(unitID, "selfTurnSpeedChange", 0) GG.UpdateUnitAttributes(unitID) armsFree = false Turn(ruparm, x_axis, -pitch - math.rad(20), math.rad(250)) Turn(luparm, x_axis, -pitch - math.rad(20), math.rad(250)) Turn(torso, y_axis, heading, math.rad(250)) Turn(rarm, x_axis, math.rad(20), math.rad(250)) Turn(larm, x_axis, math.rad(20), math.rad(250)) WaitForTurn(torso, y_axis) WaitForTurn(larm, x_axis) StartThread(RestoreAfterDelay) Signal(SIG_AIM) Signal(SIG_AIM_2) Spring.SetUnitRulesParam(unitID, "selfTurnSpeedChange", 1) GG.UpdateUnitAttributes(unitID) dgunning = false rightArmPitch = -pitch return true elseif num == 4 then if dgunning then return false end Signal(SIG_AIM_4) SetSignalMask(SIG_AIM_4) Turn(flagellum, x_axis, -pitch - rightArmPitch + 0.45, math.rad(90)) Turn(torso, y_axis, heading, math.rad(250)) WaitForTurn(ruparm, x_axis) WaitForTurn(flagellum, x_axis) WaitForTurn(torso, y_axis) StartThread(RestoreAfterDelay) return true end return true end function script.Shot(num) local weapon = weaponPieces[num] local index = weapon.index if num == 1 or num == 3 then local side = index%2 + 1 EmitSfx(weapon.query[index], 1024) EmitSfx(missileEmits[side][1], 1025) EmitSfx(missileEmits[side][2], 1025) end weapon.index = index + 1 if (index + 1) > #weapon.query then weapon.index = 1 end end function script.BlockShot(num, targetID) if num ~= 1 then return false end local reloadState = Spring.GetUnitWeaponState(unitID, 3, 'reloadState') return not (reloadState and (reloadState < 0 or reloadState < Spring.GetGameFrame())) end function script.FireWeapon(num) if num == 3 then dgunning = true Spring.SetUnitRulesParam(unitID, "selfTurnSpeedChange", 0) GG.UpdateUnitAttributes(unitID) Sleep(SALVO_TIME) dgunning = false Spring.SetUnitRulesParam(unitID, "selfTurnSpeedChange", 1) GG.UpdateUnitAttributes(unitID) end end function OnLoadGame() Spring.SetUnitRulesParam(unitID, "selfTurnSpeedChange", 1) GG.UpdateUnitAttributes(unitID) end function script.Killed(recentDamage, maxHealth) local severity = recentDamage/maxHealth dead = true Turn(torso, y_axis, 0, math.rad(200)) if severity <= 0.5 then Turn(base, x_axis, math.rad(71), math.rad(70)) Turn(torso, x_axis, math.rad(-31), math.rad(50)) Turn(ruparm, x_axis, math.rad(-41), math.rad(50)) Turn(ruparm, y_axis, math.rad(-11), math.rad(50)) Turn(rarm, x_axis, math.rad(-6), math.rad(50)) --was 0 Turn(flagellum, x_axis, math.rad(49), math.rad(50)) Turn(flagellum, y_axis, math.rad(14), math.rad(50)) Turn(luparm, y_axis, math.rad(54), math.rad(50)) Turn(rupleg, x_axis, math.rad(-27), math.rad(50)) Turn(rupleg, y_axis, math.rad(-42), math.rad(50)) Turn(rupleg, z_axis, math.rad(-(-5)), math.rad(50)) Turn(rleg, x_axis, math.rad(13), math.rad(50)) Turn(rleg, y_axis, math.rad(-36), math.rad(50)) Turn(rleg, z_axis, math.rad(-(24)), math.rad(50)) Turn(lupleg, y_axis, math.rad(18), math.rad(50)) Turn(lleg, x_axis, math.rad(20), math.rad(50)) Turn(lleg, y_axis, math.rad(28), math.rad(50)) Turn(lfoot, x_axis, math.rad(23), math.rad(50)) GG.Script.InitializeDeathAnimation(unitID) Sleep(800) --EmitSfx(torso, 1027) --impact --StartThread(burn) --Sleep((1000 * rand (2, 5))) Explode(pelvis, SFX.NONE) Explode(luparm, SFX.NONE) Explode(lleg, SFX.NONE) Explode(lupleg, SFX.NONE) Explode(rarm, SFX.FALL) Explode(rleg, SFX.NONE) Explode(ruparm, SFX.NONE) Explode(rupleg, SFX.NONE) Explode(torso, SFX.NONE) return 1 else Explode(pelvis, SFX.FALL + SFX.FIRE + SFX.SMOKE + SFX.EXPLODE_ON_HIT) Explode(luparm, SFX.FALL + SFX.FIRE + SFX.SMOKE + SFX.EXPLODE_ON_HIT) Explode(lleg, SFX.FALL + SFX.FIRE + SFX.SMOKE + SFX.EXPLODE_ON_HIT) Explode(lupleg, SFX.FALL + SFX.FIRE + SFX.SMOKE + SFX.EXPLODE_ON_HIT) Explode(rarm, SFX.FALL + SFX.FIRE + SFX.SMOKE + SFX.EXPLODE_ON_HIT) Explode(rleg, SFX.FALL + SFX.FIRE + SFX.SMOKE + SFX.EXPLODE_ON_HIT) Explode(ruparm, SFX.FALL + SFX.FIRE + SFX.SMOKE + SFX.EXPLODE_ON_HIT) Explode(rupleg, SFX.FALL + SFX.FIRE + SFX.SMOKE + SFX.EXPLODE_ON_HIT) Explode(torso, SFX.SHATTER + SFX.EXPLODE_ON_HIT) return 2 end end
gpl-2.0
davidedmonds/darkstar
scripts/zones/Port_Windurst/npcs/Kuroido-Moido.lua
17
3895
----------------------------------- -- Area: Port Windurst -- NPC: Kuriodo-Moido -- Involved In Quest: Making Amends, Wonder Wands -- Starts and Finishes: Making Amens! -- Working 100% ----------------------------------- package.loaded["scripts/zones/Port_Windurst/TextIDs"] = nil; ----------------------------------- require("scripts/globals/missions"); require("scripts/globals/quests"); require("scripts/globals/settings"); require("scripts/globals/titles"); require("scripts/globals/keyitems"); require("scripts/zones/Port_Windurst/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) MakingAmends = player:getQuestStatus(WINDURST,MAKING_AMENDS); --First quest in series MakingAmens = player:getQuestStatus(WINDURST,MAKING_AMENS); --Second quest in series WonderWands = player:getQuestStatus(WINDURST,WONDER_WANDS); --Third and final quest in series pfame = player:getFameLevel(WINDURST); needToZone = player:needToZone(); BrokenWand = player:hasKeyItem(128); if (MakingAmends == QUEST_ACCEPTED) then -- MAKING AMENDS: During Quest player:startEvent(0x0114); elseif (MakingAmends == QUEST_COMPLETED and MakingAmens ~= QUEST_COMPLETED and WonderWands ~= QUEST_COMPLETED and needToZone) then -- MAKING AMENDS: After Quest player:startEvent(0x0117); elseif (MakingAmends == QUEST_COMPLETED and MakingAmens == QUEST_AVAILABLE) then if (pfame >=4 and not needToZone) then player:startEvent(0x0118); -- Start Making Amens! if prerequisites are met else player:startEvent(0x0117); -- MAKING AMENDS: After Quest end elseif (MakingAmens == QUEST_ACCEPTED and not BrokenWand) then -- Reminder for Making Amens! player:startEvent(0x011b); elseif (MakingAmens == QUEST_ACCEPTED and BrokenWand) then -- Complete Making Amens! player:startEvent(0x011c,GIL_RATE*6000); elseif (MakingAmens == QUEST_COMPLETED) then if (WonderWands == QUEST_ACCEPTED) then -- During Wonder Wands dialogue player:startEvent(0x0105); elseif (WonderWands == QUEST_COMPLETED) then -- Post Wonder Wands dialogue player:startEvent(0x010a); else player:startEvent(0x011e,0,937); -- Post Making Amens! dialogue (before Wonder Wands) end elseif (player:getCurrentMission(ASA) == THAT_WHICH_CURDLES_BLOOD) then local item = 0; local asaStatus = player:getVar("ASA_Status"); -- TODO: Other Enfeebling Kits if (asaStatus == 0) then item = 2779; else printf("Error: Unknown ASA Status Encountered <%u>", asaStatus); end -- The Parameters are Item IDs for the Recipe player:startEvent(0x035a, item, 1134, 2778, 2778, 4099, 2778); else rand = math.random(1,2); if (rand == 1) then player:startEvent(0x00e1); -- Standard Conversation else player:startEvent(0x00e2); -- Standard Conversation end end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); if (csid == 0x0118) then player:addQuest(WINDURST,MAKING_AMENS); elseif (csid == 0x011c) then player:needToZone(true); player:delKeyItem(BROKEN_WAND); player:addTitle(HAKKURURINKURUS_BENEFACTOR); player:addGil(GIL_RATE*6000); player:messageSpecial(GIL_OBTAINED,GIL_RATE*6000); player:addFame(WINDURST,WIN_FAME*150); player:completeQuest(WINDURST,MAKING_AMENS); end end;
gpl-3.0
lhog/Zero-K
LuaRules/Gadgets/unit_prevent_turret_overshoot.lua
4
4130
if not gadgetHandler:IsSyncedCode() then return end function gadget:GetInfo() return { name = "Prevent turret overshoot", author = "Sprung", date = "3rd April 2017", license = "GNU GPL, v2 or later", layer = 0, enabled = true, } end local fudgeNames = { turretmissile = 45, -- projectile speed is 25 elmo/frame turretheavylaser = 15, turretlaser = 15, } local sphericals = { -- spherical weapons; rest assumed cylindrical "turretheavylaser", "turretlaser", } local isSpherical = {} for i = 1, #sphericals do isSpherical[UnitDefNames[sphericals[i]].id] = true end sphericals = nil local allowedRangeSq = {} for name, fudge in pairs(fudgeNames) do local udid = UnitDefNames[name].id local range = WeaponDefs[UnitDefs[udid].weapons[1].weaponDef].range local allowedRange = range - fudge allowedRangeSq[udid] = allowedRange*allowedRange end fudgeNames = nil include "LuaRules/Configs/customcmds.h.lua" local blockedCmds = { [CMD.ATTACK] = true, [CMD.INSERT] = true, [CMD_UNIT_SET_TARGET] = true, } function gadget:AllowCommand_GetWantedCommand() return blockedCmds end function gadget:AllowCommand_GetWantedUnitDefID() return allowedRangeSq end function gadget:AllowCommand(unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOpts) local paramCount = #cmdParams if cmdID == CMD_INSERT then cmdID = cmdParams[2] for i = 4, paramCount do cmdParams[i - 3] = cmdParams[i] end paramCount = paramCount - 3 end if not blockedCmds[cmdID] then return true end -- 3 is attack ground, 4 is usually attack units in radius but becomes attack ground when R=0 if paramCount ~= 3 and (paramCount ~= 4 or cmdParams[4] ~= 0) then return true end local tx, ty, tz = cmdParams[1], cmdParams[2], cmdParams[3] local ux, uy, uz = Spring.GetUnitPosition(unitID) local dx, dy, dz = ux-tx, uy-ty, uz-tz local distSq = dx*dx + dz*dz if isSpherical[unitDefID] then distSq = distSq + dy*dy end if distSq < allowedRangeSq[unitDefID] then return true end return false end ------------------------------------------------------------------------------- -- Unused local trackedWeaponDefNames = {} -- {"turretgauss_gauss"} local trackedWeaponDefIDs = {} for i = 1, #trackedWeaponDefNames do local wd = WeaponDefNames[trackedWeaponDefNames[i]] trackedWeaponDefIDs[wd.id] = wd.range * wd.range end trackedWeaponDefNames = nil local projectiles = {} local projectileByID = {} local projCount = 0 function gadget:ProjectileCreated(proID, unitID, weaponID) if not unitID then return end local rangeSq = trackedWeaponDefIDs[weaponID] if not rangeSq then return end if projCount == 0 then gadgetHandler:UpdateCallIn("GameFrame") end local x, y, z = Spring.GetUnitPosition(unitID) if z then projCount = projCount + 1 projectiles[projCount] = {proID, rangeSq, x, y, z} projectileByID[proID] = projCount end end function gadget:ProjectileDestroyed(proID) if not projectileByID[proID] then return end local index = projectileByID[proID] local lastData = projectiles[projCount] projectiles[index] = lastData projectiles[projCount] = nil local lastProID = lastData[1] projectileByID[lastProID] = index projectileByID[proID] = nil projCount = projCount - 1 if projCount == 0 then gadgetHandler:RemoveCallIn("GameFrame") end end local spGetProjectilePosition = Spring.GetProjectilePosition local spDeleteProjectile = Spring.DeleteProjectile function gadget:GameFrame() local i = 0 while i < projCount do i = i + 1 local projData = projectiles[i] local proID, rangeSq = projData[1], projData[2] local ux, uy, uz = projData[3], projData[4], projData[5] local tx, ty, tz = spGetProjectilePosition(proID) if tx then local dx, dy, dz = ux-tx, uy-ty, uz-tz local distSq = dx*dx + dy*dy + dz*dz if distSq > rangeSq then local prc = projCount spDeleteProjectile(proID) if prc == projCount then gadget:ProjectileDestroyed(proID) end -- ugly workaround because it isnt always called i = i - 1 end end end end function gadget:Initialize() if projCount == 0 then gadgetHandler:RemoveCallIn("GameFrame") end end
gpl-2.0
davidedmonds/darkstar
scripts/zones/Altar_Room/npcs/Hooknox.lua
38
1033
----------------------------------- -- Area: Altar Room -- NPC: Hooknox -- Type: Standard NPC -- @zone: 152 -- @pos -265.248 11.693 -102.547 -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/Altar_Room/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x002e); 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/Sealions_Den/npcs/Jovial_Rat.lua
38
1034
----------------------------------- -- Area: Northern San d'Oria -- NPC: Jovial Rat -- Type: Past Event Watcher -- @zone: 32 -- @pos -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x0004); 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/Sealions_Den/npcs/Jovial_Rat.lua
38
1034
----------------------------------- -- Area: Northern San d'Oria -- NPC: Jovial Rat -- Type: Past Event Watcher -- @zone: 32 -- @pos -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x0004); 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/Tahrongi_Canyon/npcs/Telepoint.lua
17
1649
----------------------------------- -- Area: Tahrongi Canyon -- NPC: Telepoint -- @pos 100.000 35.150 340.000 117 ----------------------------------- package.loaded["scripts/zones/Tahrongi_Canyon/TextIDs"] = nil; ----------------------------------- require("scripts/globals/keyitems"); require("scripts/zones/Tahrongi_Canyon/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) item = trade:getItem(); if(trade:getItemCount() == 1 and item > 4095 and item < 4104) then if(player:getFreeSlotsCount() > 0 and player:hasItem(613) == false) then player:tradeComplete(); player:addItem(613); player:messageSpecial(ITEM_OBTAINED,613); -- Faded Crystal else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,613); -- Faded Crystal end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if(player:hasKeyItem(MEA_GATE_CRYSTAL) == false) then player:addKeyItem(MEA_GATE_CRYSTAL); player:messageSpecial(KEYITEM_OBTAINED,MEA_GATE_CRYSTAL); else player:messageSpecial(ALREADY_OBTAINED_TELE); 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
kidaa/darkstar
scripts/zones/Tahrongi_Canyon/npcs/Telepoint.lua
17
1649
----------------------------------- -- Area: Tahrongi Canyon -- NPC: Telepoint -- @pos 100.000 35.150 340.000 117 ----------------------------------- package.loaded["scripts/zones/Tahrongi_Canyon/TextIDs"] = nil; ----------------------------------- require("scripts/globals/keyitems"); require("scripts/zones/Tahrongi_Canyon/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) item = trade:getItem(); if(trade:getItemCount() == 1 and item > 4095 and item < 4104) then if(player:getFreeSlotsCount() > 0 and player:hasItem(613) == false) then player:tradeComplete(); player:addItem(613); player:messageSpecial(ITEM_OBTAINED,613); -- Faded Crystal else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,613); -- Faded Crystal end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if(player:hasKeyItem(MEA_GATE_CRYSTAL) == false) then player:addKeyItem(MEA_GATE_CRYSTAL); player:messageSpecial(KEYITEM_OBTAINED,MEA_GATE_CRYSTAL); else player:messageSpecial(ALREADY_OBTAINED_TELE); 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
waterlgndx/darkstar
scripts/globals/items/holy_maul_+1.lua
2
1096
----------------------------------------- -- ID: 17114 -- Item: Holy Maul +1 -- Additional Effect: Light Damage ----------------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); require("scripts/globals/msg"); ----------------------------------- function onAdditionalEffect(player,target,damage) local chance = 10; if (math.random(0,99) >= chance) then return 0,0,0; else local dmg = math.random(7,21); local params = {}; params.bonusmab = 0; params.includemab = false; dmg = addBonusesAbility(player, dsp.magic.ele.LIGHT, target, dmg, params); dmg = dmg * applyResistanceAddEffect(player,target,dsp.magic.ele.LIGHT,0); dmg = adjustForTarget(target,dmg,dsp.magic.ele.LIGHT); dmg = finalMagicNonSpellAdjustments(player,target,dsp.magic.ele.LIGHT,dmg); local message = dsp.msg.basic.ADD_EFFECT_DMG; if (dmg < 0) then message = dsp.msg.basic.ADD_EFFECT_HEAL; end return dsp.subEffect.LIGHT_DAMAGE,message,dmg; end end;
gpl-3.0
kiarash14/TSbumper
bot/utils.lua
646
23489
URL = require "socket.url" http = require "socket.http" https = require "ssl.https" ltn12 = require "ltn12" serpent = require "serpent" feedparser = require "feedparser" json = (loadfile "./libs/JSON.lua")() mimetype = (loadfile "./libs/mimetype.lua")() redis = (loadfile "./libs/redis.lua")() JSON = (loadfile "./libs/dkjson.lua")() http.TIMEOUT = 10 function get_receiver(msg) if msg.to.type == 'user' then return 'user#id'..msg.from.id end if msg.to.type == 'chat' then return 'chat#id'..msg.to.id end if msg.to.type == 'encr_chat' then return msg.to.print_name end end function is_chat_msg( msg ) if msg.to.type == 'chat' then return true end return false end function string.random(length) local str = ""; for i = 1, length do math.random(97, 122) str = str..string.char(math.random(97, 122)); end return str; end function string:split(sep) local sep, fields = sep or ":", {} local pattern = string.format("([^%s]+)", sep) self:gsub(pattern, function(c) fields[#fields+1] = c end) return fields end -- DEPRECATED function string.trim(s) print("string.trim(s) is DEPRECATED use string:trim() instead") return s:gsub("^%s*(.-)%s*$", "%1") end -- Removes spaces function string:trim() return self:gsub("^%s*(.-)%s*$", "%1") end function get_http_file_name(url, headers) -- Eg: foo.var local file_name = url:match("[^%w]+([%.%w]+)$") -- Any delimited alphanumeric on the url file_name = file_name or url:match("[^%w]+(%w+)[^%w]+$") -- Random name, hope content-type works file_name = file_name or str:random(5) local content_type = headers["content-type"] local extension = nil if content_type then extension = mimetype.get_mime_extension(content_type) end if extension then file_name = file_name.."."..extension end local disposition = headers["content-disposition"] if disposition then -- attachment; filename=CodeCogsEqn.png file_name = disposition:match('filename=([^;]+)') or file_name end return file_name end -- Saves file to /tmp/. If file_name isn't provided, -- will get the text after the last "/" for filename -- and content-type for extension function download_to_file(url, file_name) print("url to download: "..url) local respbody = {} local options = { url = url, sink = ltn12.sink.table(respbody), redirect = true } -- nil, code, headers, status local response = nil if url:starts('https') then options.redirect = false response = {https.request(options)} else response = {http.request(options)} end local code = response[2] local headers = response[3] local status = response[4] if code ~= 200 then return nil end file_name = file_name or get_http_file_name(url, headers) local file_path = "/tmp/"..file_name print("Saved to: "..file_path) file = io.open(file_path, "w+") file:write(table.concat(respbody)) file:close() return file_path end function vardump(value) print(serpent.block(value, {comment=false})) end -- taken from http://stackoverflow.com/a/11130774/3163199 function scandir(directory) local i, t, popen = 0, {}, io.popen for filename in popen('ls -a "'..directory..'"'):lines() do i = i + 1 t[i] = filename end return t end -- http://www.lua.org/manual/5.2/manual.html#pdf-io.popen function run_command(str) local cmd = io.popen(str) local result = cmd:read('*all') cmd:close() return result end -- User has privileges function is_sudo(msg) local var = false -- Check users id in config for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end -- Returns the name of the sender function get_name(msg) local name = msg.from.first_name if name == nil then name = msg.from.id end return name end -- Returns at table of lua files inside plugins function plugins_names( ) local files = {} for k, v in pairs(scandir("plugins")) do -- Ends with .lua if (v:match(".lua$")) then table.insert(files, v) end end return files end -- Function name explains what it does. function file_exists(name) local f = io.open(name,"r") if f ~= nil then io.close(f) return true else return false end end -- Save into file the data serialized for lua. -- Set uglify true to minify the file. function serialize_to_file(data, file, uglify) file = io.open(file, 'w+') local serialized if not uglify then serialized = serpent.block(data, { comment = false, name = '_' }) else serialized = serpent.dump(data) end file:write(serialized) file:close() end -- Returns true if the string is empty function string:isempty() return self == nil or self == '' end -- Returns true if the string is blank function string:isblank() self = self:trim() return self:isempty() end -- DEPRECATED!!!!! function string.starts(String, Start) print("string.starts(String, Start) is DEPRECATED use string:starts(text) instead") return Start == string.sub(String,1,string.len(Start)) end -- Returns true if String starts with Start function string:starts(text) return text == string.sub(self,1,string.len(text)) end -- Send image to user and delete it when finished. -- cb_function and cb_extra are optionals callback function _send_photo(receiver, file_path, cb_function, cb_extra) local cb_extra = { file_path = file_path, cb_function = cb_function, cb_extra = cb_extra } -- Call to remove with optional callback send_photo(receiver, file_path, cb_function, cb_extra) end -- Download the image and send to receiver, it will be deleted. -- cb_function and cb_extra are optionals callback function send_photo_from_url(receiver, url, cb_function, cb_extra) -- If callback not provided cb_function = cb_function or ok_cb cb_extra = cb_extra or false local file_path = download_to_file(url, false) if not file_path then -- Error local text = 'Error downloading the image' send_msg(receiver, text, cb_function, cb_extra) else print("File path: "..file_path) _send_photo(receiver, file_path, cb_function, cb_extra) end end -- Same as send_photo_from_url but as callback function function send_photo_from_url_callback(cb_extra, success, result) local receiver = cb_extra.receiver local url = cb_extra.url local file_path = download_to_file(url, false) if not file_path then -- Error local text = 'Error downloading the image' send_msg(receiver, text, ok_cb, false) else print("File path: "..file_path) _send_photo(receiver, file_path, ok_cb, false) end end -- Send multiple images asynchronous. -- param urls must be a table. function send_photos_from_url(receiver, urls) local cb_extra = { receiver = receiver, urls = urls, remove_path = nil } send_photos_from_url_callback(cb_extra) end -- Use send_photos_from_url. -- This function might be difficult to understand. function send_photos_from_url_callback(cb_extra, success, result) -- cb_extra is a table containing receiver, urls and remove_path local receiver = cb_extra.receiver local urls = cb_extra.urls local remove_path = cb_extra.remove_path -- The previously image to remove if remove_path ~= nil then os.remove(remove_path) print("Deleted: "..remove_path) end -- Nil or empty, exit case (no more urls) if urls == nil or #urls == 0 then return false end -- Take the head and remove from urls table local head = table.remove(urls, 1) local file_path = download_to_file(head, false) local cb_extra = { receiver = receiver, urls = urls, remove_path = file_path } -- Send first and postpone the others as callback send_photo(receiver, file_path, send_photos_from_url_callback, cb_extra) end -- Callback to remove a file function rmtmp_cb(cb_extra, success, result) local file_path = cb_extra.file_path local cb_function = cb_extra.cb_function or ok_cb local cb_extra = cb_extra.cb_extra if file_path ~= nil then os.remove(file_path) print("Deleted: "..file_path) end -- Finally call the callback cb_function(cb_extra, success, result) end -- Send document to user and delete it when finished. -- cb_function and cb_extra are optionals callback function _send_document(receiver, file_path, cb_function, cb_extra) local cb_extra = { file_path = file_path, cb_function = cb_function or ok_cb, cb_extra = cb_extra or false } -- Call to remove with optional callback send_document(receiver, file_path, rmtmp_cb, cb_extra) end -- Download the image and send to receiver, it will be deleted. -- cb_function and cb_extra are optionals callback function send_document_from_url(receiver, url, cb_function, cb_extra) local file_path = download_to_file(url, false) print("File path: "..file_path) _send_document(receiver, file_path, cb_function, cb_extra) end -- Parameters in ?a=1&b=2 style function format_http_params(params, is_get) local str = '' -- If is get add ? to the beginning if is_get then str = '?' end local first = true -- Frist param for k,v in pairs (params) do if v then -- nil value if first then first = false str = str..k.. "="..v else str = str.."&"..k.. "="..v end end end return str end -- Check if user can use the plugin and warns user -- Returns true if user was warned and false if not warned (is allowed) function warns_user_not_allowed(plugin, msg) if not user_allowed(plugin, msg) then local text = 'This plugin requires privileged user' local receiver = get_receiver(msg) send_msg(receiver, text, ok_cb, false) return true else return false end end -- Check if user can use the plugin function user_allowed(plugin, msg) if plugin.privileged and not is_sudo(msg) then return false end return true end function send_order_msg(destination, msgs) local cb_extra = { destination = destination, msgs = msgs } send_order_msg_callback(cb_extra, true) end function send_order_msg_callback(cb_extra, success, result) local destination = cb_extra.destination local msgs = cb_extra.msgs local file_path = cb_extra.file_path if file_path ~= nil then os.remove(file_path) print("Deleted: " .. file_path) end if type(msgs) == 'string' then send_large_msg(destination, msgs) elseif type(msgs) ~= 'table' then return end if #msgs < 1 then return end local msg = table.remove(msgs, 1) local new_cb_extra = { destination = destination, msgs = msgs } if type(msg) == 'string' then send_msg(destination, msg, send_order_msg_callback, new_cb_extra) elseif type(msg) == 'table' then local typ = msg[1] local nmsg = msg[2] new_cb_extra.file_path = nmsg if typ == 'document' then send_document(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'image' or typ == 'photo' then send_photo(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'audio' then send_audio(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'video' then send_video(destination, nmsg, send_order_msg_callback, new_cb_extra) else send_file(destination, nmsg, send_order_msg_callback, new_cb_extra) end end end -- Same as send_large_msg_callback but friendly params function send_large_msg(destination, text) local cb_extra = { destination = destination, text = text } send_large_msg_callback(cb_extra, true) end -- If text is longer than 4096 chars, send multiple msg. -- https://core.telegram.org/method/messages.sendMessage function send_large_msg_callback(cb_extra, success, result) local text_max = 4096 local destination = cb_extra.destination local text = cb_extra.text local text_len = string.len(text) local num_msg = math.ceil(text_len / text_max) if num_msg <= 1 then send_msg(destination, text, ok_cb, false) else local my_text = string.sub(text, 1, 4096) local rest = string.sub(text, 4096, text_len) local cb_extra = { destination = destination, text = rest } send_msg(destination, my_text, send_large_msg_callback, cb_extra) end end -- Returns a table with matches or nil function match_pattern(pattern, text, lower_case) if text then local matches = {} if lower_case then matches = { string.match(text:lower(), pattern) } else matches = { string.match(text, pattern) } end if next(matches) then return matches end end -- nil end -- Function to read data from files function load_from_file(file, default_data) local f = io.open(file, "r+") -- If file doesn't exists if f == nil then -- Create a new empty table default_data = default_data or {} serialize_to_file(default_data, file) print ('Created file', file) else print ('Data loaded from file', file) f:close() end return loadfile (file)() end -- See http://stackoverflow.com/a/14899740 function unescape_html(str) local map = { ["lt"] = "<", ["gt"] = ">", ["amp"] = "&", ["quot"] = '"', ["apos"] = "'" } new = string.gsub(str, '(&(#?x?)([%d%a]+);)', function(orig, n, s) var = map[s] or n == "#" and string.char(s) var = var or n == "#x" and string.char(tonumber(s,16)) var = var or orig return var end) return new end --Check if this chat is realm or not function is_realm(msg) local var = false local realms = 'realms' local data = load_data(_config.moderation.data) local chat = msg.to.id if data[tostring(realms)] then if data[tostring(realms)][tostring(msg.to.id)] then var = true end return var end end --Check if this chat is a group or not function is_group(msg) local var = false local groups = 'groups' local data = load_data(_config.moderation.data) local chat = msg.to.id if data[tostring(groups)] then if data[tostring(groups)][tostring(msg.to.id)] then var = true end return var end end function savelog(group, logtxt) local text = (os.date("[ %c ]=> "..logtxt.."\n \n")) local file = io.open("./groups/logs/"..group.."log.txt", "a") file:write(text) file:close() end 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 --Check if user is the owner of that group or not function is_owner(msg) local var = false local data = load_data(_config.moderation.data) local user = msg.from.id if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['set_owner'] then if data[tostring(msg.to.id)]['set_owner'] == tostring(user) then var = true end end end if data['admins'] then if data['admins'][tostring(user)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end function is_owner2(user_id, group_id) local var = false local data = load_data(_config.moderation.data) if data[tostring(group_id)] then if data[tostring(group_id)]['set_owner'] then if data[tostring(group_id)]['set_owner'] == tostring(user_id) then var = true end end end if data['admins'] then if data['admins'][tostring(user_id)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == user_id then var = true end end return var end --Check if user is admin or not function is_admin(msg) local var = false local data = load_data(_config.moderation.data) local user = msg.from.id local admins = 'admins' if data[tostring(admins)] then if data[tostring(admins)][tostring(user)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end function is_admin2(user_id) local var = false local data = load_data(_config.moderation.data) local user = user_id local admins = 'admins' if data[tostring(admins)] then if data[tostring(admins)][tostring(user)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == user_id then var = true end end return var end --Check if user is the mod of that group or not function is_momod(msg) local var = false local data = load_data(_config.moderation.data) local user = msg.from.id if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['moderators'] then if data[tostring(msg.to.id)]['moderators'][tostring(user)] then var = true end end end if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['set_owner'] then if data[tostring(msg.to.id)]['set_owner'] == tostring(user) then var = true end end end if data['admins'] then if data['admins'][tostring(user)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end function is_momod2(user_id, group_id) local var = false local data = load_data(_config.moderation.data) local usert = user_id if data[tostring(group_id)] then if data[tostring(group_id)]['moderators'] then if data[tostring(group_id)]['moderators'][tostring(usert)] then var = true end end end if data[tostring(group_id)] then if data[tostring(group_id)]['set_owner'] then if data[tostring(group_id)]['set_owner'] == tostring(user_id) then var = true end end end if data['admins'] then if data['admins'][tostring(user_id)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == usert then var = true end end return var end -- Returns the name of the sender function kick_user(user_id, chat_id) if tonumber(user_id) == tonumber(our_id) then -- Ignore bot return end if is_owner2(user_id, chat_id) then -- Ignore admins return end local chat = 'chat#id'..chat_id local user = 'user#id'..user_id chat_del_user(chat, user, ok_cb, true) end -- Ban function ban_user(user_id, chat_id) if tonumber(user_id) == tonumber(our_id) then -- Ignore bot return end if is_admin2(user_id) then -- Ignore admins return end -- Save to redis local hash = 'banned:'..chat_id redis:sadd(hash, user_id) -- Kick from chat kick_user(user_id, chat_id) end -- Global ban function banall_user(user_id) if tonumber(user_id) == tonumber(our_id) then -- Ignore bot return end if is_admin2(user_id) then -- Ignore admins return end -- Save to redis local hash = 'gbanned' redis:sadd(hash, user_id) end -- Global unban function unbanall_user(user_id) --Save on redis local hash = 'gbanned' redis:srem(hash, user_id) end -- Check if user_id is banned in chat_id or not function is_banned(user_id, chat_id) --Save on redis local hash = 'banned:'..chat_id local banned = redis:sismember(hash, user_id) return banned or false end -- Check if user_id is globally banned or not function is_gbanned(user_id) --Save on redis local hash = 'gbanned' local banned = redis:sismember(hash, user_id) return banned or false end -- Returns chat_id ban list function ban_list(chat_id) local hash = 'banned:'..chat_id local list = redis:smembers(hash) local text = "Ban list !\n\n" for k,v in pairs(list) do text = text..k.." - "..v.." \n" end return text end -- Returns globally ban list function banall_list() local hash = 'gbanned' local list = redis:smembers(hash) local text = "global bans !\n\n" for k,v in pairs(list) do text = text..k.." - "..v.." \n" end return text end -- /id by reply function get_message_callback_id(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id send_large_msg(chat, result.from.id) else return 'Use This in Your Groups' end end -- kick by reply for mods and owner function Kick_by_reply(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't kick myself" end if is_momod2(result.from.id, result.to.id) then -- Ignore mods,owner,admin return "you can't kick mods,owner and admins" end chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false) else return 'Use This in Your Groups' end end -- Kick by reply for admins function Kick_by_reply_admins(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't kick myself" end if is_admin2(result.from.id) then -- Ignore admins return end chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false) else return 'Use This in Your Groups' end end --Ban by reply for admins function ban_by_reply(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't ban myself" end if is_momod2(result.from.id, result.to.id) then -- Ignore mods,owner,admin return "you can't kick mods,owner and admins" end ban_user(result.from.id, result.to.id) send_large_msg(chat, "User "..result.from.id.." Banned") else return 'Use This in Your Groups' end end -- Ban by reply for admins function ban_by_reply_admins(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't ban myself" end if is_admin2(result.from.id) then -- Ignore admins return end ban_user(result.from.id, result.to.id) send_large_msg(chat, "User "..result.from.id.." Banned") else return 'Use This in Your Groups' end end -- Unban by reply function unban_by_reply(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't unban myself" end send_large_msg(chat, "User "..result.from.id.." Unbanned") -- Save on redis local hash = 'banned:'..result.to.id redis:srem(hash, result.from.id) else return 'Use This in Your Groups' end end function banall_by_reply(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't banall myself" end if is_admin2(result.from.id) then -- Ignore admins return end local name = user_print_name(result.from) banall_user(result.from.id) chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false) send_large_msg(chat, "User "..name.."["..result.from.id.."] hammered") else return 'Use This in Your Groups' end end
gpl-2.0
mirbot/oldbot
bot/utils.lua
646
23489
URL = require "socket.url" http = require "socket.http" https = require "ssl.https" ltn12 = require "ltn12" serpent = require "serpent" feedparser = require "feedparser" json = (loadfile "./libs/JSON.lua")() mimetype = (loadfile "./libs/mimetype.lua")() redis = (loadfile "./libs/redis.lua")() JSON = (loadfile "./libs/dkjson.lua")() http.TIMEOUT = 10 function get_receiver(msg) if msg.to.type == 'user' then return 'user#id'..msg.from.id end if msg.to.type == 'chat' then return 'chat#id'..msg.to.id end if msg.to.type == 'encr_chat' then return msg.to.print_name end end function is_chat_msg( msg ) if msg.to.type == 'chat' then return true end return false end function string.random(length) local str = ""; for i = 1, length do math.random(97, 122) str = str..string.char(math.random(97, 122)); end return str; end function string:split(sep) local sep, fields = sep or ":", {} local pattern = string.format("([^%s]+)", sep) self:gsub(pattern, function(c) fields[#fields+1] = c end) return fields end -- DEPRECATED function string.trim(s) print("string.trim(s) is DEPRECATED use string:trim() instead") return s:gsub("^%s*(.-)%s*$", "%1") end -- Removes spaces function string:trim() return self:gsub("^%s*(.-)%s*$", "%1") end function get_http_file_name(url, headers) -- Eg: foo.var local file_name = url:match("[^%w]+([%.%w]+)$") -- Any delimited alphanumeric on the url file_name = file_name or url:match("[^%w]+(%w+)[^%w]+$") -- Random name, hope content-type works file_name = file_name or str:random(5) local content_type = headers["content-type"] local extension = nil if content_type then extension = mimetype.get_mime_extension(content_type) end if extension then file_name = file_name.."."..extension end local disposition = headers["content-disposition"] if disposition then -- attachment; filename=CodeCogsEqn.png file_name = disposition:match('filename=([^;]+)') or file_name end return file_name end -- Saves file to /tmp/. If file_name isn't provided, -- will get the text after the last "/" for filename -- and content-type for extension function download_to_file(url, file_name) print("url to download: "..url) local respbody = {} local options = { url = url, sink = ltn12.sink.table(respbody), redirect = true } -- nil, code, headers, status local response = nil if url:starts('https') then options.redirect = false response = {https.request(options)} else response = {http.request(options)} end local code = response[2] local headers = response[3] local status = response[4] if code ~= 200 then return nil end file_name = file_name or get_http_file_name(url, headers) local file_path = "/tmp/"..file_name print("Saved to: "..file_path) file = io.open(file_path, "w+") file:write(table.concat(respbody)) file:close() return file_path end function vardump(value) print(serpent.block(value, {comment=false})) end -- taken from http://stackoverflow.com/a/11130774/3163199 function scandir(directory) local i, t, popen = 0, {}, io.popen for filename in popen('ls -a "'..directory..'"'):lines() do i = i + 1 t[i] = filename end return t end -- http://www.lua.org/manual/5.2/manual.html#pdf-io.popen function run_command(str) local cmd = io.popen(str) local result = cmd:read('*all') cmd:close() return result end -- User has privileges function is_sudo(msg) local var = false -- Check users id in config for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end -- Returns the name of the sender function get_name(msg) local name = msg.from.first_name if name == nil then name = msg.from.id end return name end -- Returns at table of lua files inside plugins function plugins_names( ) local files = {} for k, v in pairs(scandir("plugins")) do -- Ends with .lua if (v:match(".lua$")) then table.insert(files, v) end end return files end -- Function name explains what it does. function file_exists(name) local f = io.open(name,"r") if f ~= nil then io.close(f) return true else return false end end -- Save into file the data serialized for lua. -- Set uglify true to minify the file. function serialize_to_file(data, file, uglify) file = io.open(file, 'w+') local serialized if not uglify then serialized = serpent.block(data, { comment = false, name = '_' }) else serialized = serpent.dump(data) end file:write(serialized) file:close() end -- Returns true if the string is empty function string:isempty() return self == nil or self == '' end -- Returns true if the string is blank function string:isblank() self = self:trim() return self:isempty() end -- DEPRECATED!!!!! function string.starts(String, Start) print("string.starts(String, Start) is DEPRECATED use string:starts(text) instead") return Start == string.sub(String,1,string.len(Start)) end -- Returns true if String starts with Start function string:starts(text) return text == string.sub(self,1,string.len(text)) end -- Send image to user and delete it when finished. -- cb_function and cb_extra are optionals callback function _send_photo(receiver, file_path, cb_function, cb_extra) local cb_extra = { file_path = file_path, cb_function = cb_function, cb_extra = cb_extra } -- Call to remove with optional callback send_photo(receiver, file_path, cb_function, cb_extra) end -- Download the image and send to receiver, it will be deleted. -- cb_function and cb_extra are optionals callback function send_photo_from_url(receiver, url, cb_function, cb_extra) -- If callback not provided cb_function = cb_function or ok_cb cb_extra = cb_extra or false local file_path = download_to_file(url, false) if not file_path then -- Error local text = 'Error downloading the image' send_msg(receiver, text, cb_function, cb_extra) else print("File path: "..file_path) _send_photo(receiver, file_path, cb_function, cb_extra) end end -- Same as send_photo_from_url but as callback function function send_photo_from_url_callback(cb_extra, success, result) local receiver = cb_extra.receiver local url = cb_extra.url local file_path = download_to_file(url, false) if not file_path then -- Error local text = 'Error downloading the image' send_msg(receiver, text, ok_cb, false) else print("File path: "..file_path) _send_photo(receiver, file_path, ok_cb, false) end end -- Send multiple images asynchronous. -- param urls must be a table. function send_photos_from_url(receiver, urls) local cb_extra = { receiver = receiver, urls = urls, remove_path = nil } send_photos_from_url_callback(cb_extra) end -- Use send_photos_from_url. -- This function might be difficult to understand. function send_photos_from_url_callback(cb_extra, success, result) -- cb_extra is a table containing receiver, urls and remove_path local receiver = cb_extra.receiver local urls = cb_extra.urls local remove_path = cb_extra.remove_path -- The previously image to remove if remove_path ~= nil then os.remove(remove_path) print("Deleted: "..remove_path) end -- Nil or empty, exit case (no more urls) if urls == nil or #urls == 0 then return false end -- Take the head and remove from urls table local head = table.remove(urls, 1) local file_path = download_to_file(head, false) local cb_extra = { receiver = receiver, urls = urls, remove_path = file_path } -- Send first and postpone the others as callback send_photo(receiver, file_path, send_photos_from_url_callback, cb_extra) end -- Callback to remove a file function rmtmp_cb(cb_extra, success, result) local file_path = cb_extra.file_path local cb_function = cb_extra.cb_function or ok_cb local cb_extra = cb_extra.cb_extra if file_path ~= nil then os.remove(file_path) print("Deleted: "..file_path) end -- Finally call the callback cb_function(cb_extra, success, result) end -- Send document to user and delete it when finished. -- cb_function and cb_extra are optionals callback function _send_document(receiver, file_path, cb_function, cb_extra) local cb_extra = { file_path = file_path, cb_function = cb_function or ok_cb, cb_extra = cb_extra or false } -- Call to remove with optional callback send_document(receiver, file_path, rmtmp_cb, cb_extra) end -- Download the image and send to receiver, it will be deleted. -- cb_function and cb_extra are optionals callback function send_document_from_url(receiver, url, cb_function, cb_extra) local file_path = download_to_file(url, false) print("File path: "..file_path) _send_document(receiver, file_path, cb_function, cb_extra) end -- Parameters in ?a=1&b=2 style function format_http_params(params, is_get) local str = '' -- If is get add ? to the beginning if is_get then str = '?' end local first = true -- Frist param for k,v in pairs (params) do if v then -- nil value if first then first = false str = str..k.. "="..v else str = str.."&"..k.. "="..v end end end return str end -- Check if user can use the plugin and warns user -- Returns true if user was warned and false if not warned (is allowed) function warns_user_not_allowed(plugin, msg) if not user_allowed(plugin, msg) then local text = 'This plugin requires privileged user' local receiver = get_receiver(msg) send_msg(receiver, text, ok_cb, false) return true else return false end end -- Check if user can use the plugin function user_allowed(plugin, msg) if plugin.privileged and not is_sudo(msg) then return false end return true end function send_order_msg(destination, msgs) local cb_extra = { destination = destination, msgs = msgs } send_order_msg_callback(cb_extra, true) end function send_order_msg_callback(cb_extra, success, result) local destination = cb_extra.destination local msgs = cb_extra.msgs local file_path = cb_extra.file_path if file_path ~= nil then os.remove(file_path) print("Deleted: " .. file_path) end if type(msgs) == 'string' then send_large_msg(destination, msgs) elseif type(msgs) ~= 'table' then return end if #msgs < 1 then return end local msg = table.remove(msgs, 1) local new_cb_extra = { destination = destination, msgs = msgs } if type(msg) == 'string' then send_msg(destination, msg, send_order_msg_callback, new_cb_extra) elseif type(msg) == 'table' then local typ = msg[1] local nmsg = msg[2] new_cb_extra.file_path = nmsg if typ == 'document' then send_document(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'image' or typ == 'photo' then send_photo(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'audio' then send_audio(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'video' then send_video(destination, nmsg, send_order_msg_callback, new_cb_extra) else send_file(destination, nmsg, send_order_msg_callback, new_cb_extra) end end end -- Same as send_large_msg_callback but friendly params function send_large_msg(destination, text) local cb_extra = { destination = destination, text = text } send_large_msg_callback(cb_extra, true) end -- If text is longer than 4096 chars, send multiple msg. -- https://core.telegram.org/method/messages.sendMessage function send_large_msg_callback(cb_extra, success, result) local text_max = 4096 local destination = cb_extra.destination local text = cb_extra.text local text_len = string.len(text) local num_msg = math.ceil(text_len / text_max) if num_msg <= 1 then send_msg(destination, text, ok_cb, false) else local my_text = string.sub(text, 1, 4096) local rest = string.sub(text, 4096, text_len) local cb_extra = { destination = destination, text = rest } send_msg(destination, my_text, send_large_msg_callback, cb_extra) end end -- Returns a table with matches or nil function match_pattern(pattern, text, lower_case) if text then local matches = {} if lower_case then matches = { string.match(text:lower(), pattern) } else matches = { string.match(text, pattern) } end if next(matches) then return matches end end -- nil end -- Function to read data from files function load_from_file(file, default_data) local f = io.open(file, "r+") -- If file doesn't exists if f == nil then -- Create a new empty table default_data = default_data or {} serialize_to_file(default_data, file) print ('Created file', file) else print ('Data loaded from file', file) f:close() end return loadfile (file)() end -- See http://stackoverflow.com/a/14899740 function unescape_html(str) local map = { ["lt"] = "<", ["gt"] = ">", ["amp"] = "&", ["quot"] = '"', ["apos"] = "'" } new = string.gsub(str, '(&(#?x?)([%d%a]+);)', function(orig, n, s) var = map[s] or n == "#" and string.char(s) var = var or n == "#x" and string.char(tonumber(s,16)) var = var or orig return var end) return new end --Check if this chat is realm or not function is_realm(msg) local var = false local realms = 'realms' local data = load_data(_config.moderation.data) local chat = msg.to.id if data[tostring(realms)] then if data[tostring(realms)][tostring(msg.to.id)] then var = true end return var end end --Check if this chat is a group or not function is_group(msg) local var = false local groups = 'groups' local data = load_data(_config.moderation.data) local chat = msg.to.id if data[tostring(groups)] then if data[tostring(groups)][tostring(msg.to.id)] then var = true end return var end end function savelog(group, logtxt) local text = (os.date("[ %c ]=> "..logtxt.."\n \n")) local file = io.open("./groups/logs/"..group.."log.txt", "a") file:write(text) file:close() end 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 --Check if user is the owner of that group or not function is_owner(msg) local var = false local data = load_data(_config.moderation.data) local user = msg.from.id if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['set_owner'] then if data[tostring(msg.to.id)]['set_owner'] == tostring(user) then var = true end end end if data['admins'] then if data['admins'][tostring(user)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end function is_owner2(user_id, group_id) local var = false local data = load_data(_config.moderation.data) if data[tostring(group_id)] then if data[tostring(group_id)]['set_owner'] then if data[tostring(group_id)]['set_owner'] == tostring(user_id) then var = true end end end if data['admins'] then if data['admins'][tostring(user_id)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == user_id then var = true end end return var end --Check if user is admin or not function is_admin(msg) local var = false local data = load_data(_config.moderation.data) local user = msg.from.id local admins = 'admins' if data[tostring(admins)] then if data[tostring(admins)][tostring(user)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end function is_admin2(user_id) local var = false local data = load_data(_config.moderation.data) local user = user_id local admins = 'admins' if data[tostring(admins)] then if data[tostring(admins)][tostring(user)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == user_id then var = true end end return var end --Check if user is the mod of that group or not function is_momod(msg) local var = false local data = load_data(_config.moderation.data) local user = msg.from.id if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['moderators'] then if data[tostring(msg.to.id)]['moderators'][tostring(user)] then var = true end end end if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['set_owner'] then if data[tostring(msg.to.id)]['set_owner'] == tostring(user) then var = true end end end if data['admins'] then if data['admins'][tostring(user)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end function is_momod2(user_id, group_id) local var = false local data = load_data(_config.moderation.data) local usert = user_id if data[tostring(group_id)] then if data[tostring(group_id)]['moderators'] then if data[tostring(group_id)]['moderators'][tostring(usert)] then var = true end end end if data[tostring(group_id)] then if data[tostring(group_id)]['set_owner'] then if data[tostring(group_id)]['set_owner'] == tostring(user_id) then var = true end end end if data['admins'] then if data['admins'][tostring(user_id)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == usert then var = true end end return var end -- Returns the name of the sender function kick_user(user_id, chat_id) if tonumber(user_id) == tonumber(our_id) then -- Ignore bot return end if is_owner2(user_id, chat_id) then -- Ignore admins return end local chat = 'chat#id'..chat_id local user = 'user#id'..user_id chat_del_user(chat, user, ok_cb, true) end -- Ban function ban_user(user_id, chat_id) if tonumber(user_id) == tonumber(our_id) then -- Ignore bot return end if is_admin2(user_id) then -- Ignore admins return end -- Save to redis local hash = 'banned:'..chat_id redis:sadd(hash, user_id) -- Kick from chat kick_user(user_id, chat_id) end -- Global ban function banall_user(user_id) if tonumber(user_id) == tonumber(our_id) then -- Ignore bot return end if is_admin2(user_id) then -- Ignore admins return end -- Save to redis local hash = 'gbanned' redis:sadd(hash, user_id) end -- Global unban function unbanall_user(user_id) --Save on redis local hash = 'gbanned' redis:srem(hash, user_id) end -- Check if user_id is banned in chat_id or not function is_banned(user_id, chat_id) --Save on redis local hash = 'banned:'..chat_id local banned = redis:sismember(hash, user_id) return banned or false end -- Check if user_id is globally banned or not function is_gbanned(user_id) --Save on redis local hash = 'gbanned' local banned = redis:sismember(hash, user_id) return banned or false end -- Returns chat_id ban list function ban_list(chat_id) local hash = 'banned:'..chat_id local list = redis:smembers(hash) local text = "Ban list !\n\n" for k,v in pairs(list) do text = text..k.." - "..v.." \n" end return text end -- Returns globally ban list function banall_list() local hash = 'gbanned' local list = redis:smembers(hash) local text = "global bans !\n\n" for k,v in pairs(list) do text = text..k.." - "..v.." \n" end return text end -- /id by reply function get_message_callback_id(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id send_large_msg(chat, result.from.id) else return 'Use This in Your Groups' end end -- kick by reply for mods and owner function Kick_by_reply(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't kick myself" end if is_momod2(result.from.id, result.to.id) then -- Ignore mods,owner,admin return "you can't kick mods,owner and admins" end chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false) else return 'Use This in Your Groups' end end -- Kick by reply for admins function Kick_by_reply_admins(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't kick myself" end if is_admin2(result.from.id) then -- Ignore admins return end chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false) else return 'Use This in Your Groups' end end --Ban by reply for admins function ban_by_reply(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't ban myself" end if is_momod2(result.from.id, result.to.id) then -- Ignore mods,owner,admin return "you can't kick mods,owner and admins" end ban_user(result.from.id, result.to.id) send_large_msg(chat, "User "..result.from.id.." Banned") else return 'Use This in Your Groups' end end -- Ban by reply for admins function ban_by_reply_admins(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't ban myself" end if is_admin2(result.from.id) then -- Ignore admins return end ban_user(result.from.id, result.to.id) send_large_msg(chat, "User "..result.from.id.." Banned") else return 'Use This in Your Groups' end end -- Unban by reply function unban_by_reply(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't unban myself" end send_large_msg(chat, "User "..result.from.id.." Unbanned") -- Save on redis local hash = 'banned:'..result.to.id redis:srem(hash, result.from.id) else return 'Use This in Your Groups' end end function banall_by_reply(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't banall myself" end if is_admin2(result.from.id) then -- Ignore admins return end local name = user_print_name(result.from) banall_user(result.from.id) chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false) send_large_msg(chat, "User "..name.."["..result.from.id.."] hammered") else return 'Use This in Your Groups' end end
gpl-2.0
will4wachter/Project1
scripts/zones/Middle_Delkfutts_Tower/npcs/Treasure_Chest.lua
1
3322
----------------------------------- -- Area: Middle Delkfutt's Tower -- NPC: Treasure Chest -- Involved In Quest: Wings of Gold -- @zone 157 ----------------------------------- package.loaded["scripts/zones/Middle_Delkfutts_Tower/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/treasure"); require("scripts/globals/quests"); require("scripts/zones/Middle_Delkfutts_Tower/TextIDs"); local TreasureType = "Chest"; local TreasureLvL = 43; local TreasureMinLvL = 33; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- trade:hasItemQty(1036,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(1036,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: WINGS OF GOLD QUEST QUEST ----------- if(player:getQuestStatus(JEUNO,WINGS_OF_GOLD) == QUEST_ACCEPTED and player:hasKeyItem(GUIDING_BELL) == false) then questItemNeeded = 1; 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(GUIDING_BELL); player:messageSpecial(KEYITEM_OBTAINED,GUIDING_BELL); -- Guiding Bell (KI) else local zone = player:getZone(); 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,1036); 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/LaLoff_Amphitheater/bcnms/ark_angels_4.lua
17
3456
----------------------------------- -- Area: LaLoff Amphitheater -- Name: Ark Angels 4 (Elvaan) ----------------------------------- package.loaded["scripts/zones/LaLoff_Amphitheater/TextIDs"] = nil; ----------------------------------- require("scripts/zones/LaLoff_Amphitheater/TextIDs"); require("scripts/globals/missions"); require("scripts/globals/keyitems"); ----------------------------------- -- Death cutscenes: -- player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,0,0); -- Hume -- player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,1,0); -- taru -- player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,2,0); -- mithra -- player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,3,0); -- elvan -- player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,4,0); -- galka -- player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,5,0); -- divine might -- player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,6,0); -- skip ending cs -- After registering the BCNM via bcnmRegister(bcnmid) function onBcnmRegister(player,instance) end; -- Physically entering the BCNM via bcnmEnter(bcnmid) function onBcnmEnter(player,instance) end; -- Leaving the BCNM by every mean possible, given by the LeaveCode -- 1=Select Exit on circle -- 2=Winning the BC -- 3=Disconnected or warped out -- 4=Losing the BC -- via bcnmLeave(1) or bcnmLeave(2). LeaveCodes 3 and 4 are called -- from the core when a player disconnects or the time limit is up, etc function onBcnmLeave(player,instance,leavecode) --print("leave code "..leavecode); if (leavecode == 2) then -- play end CS. Need time and battle id for record keeping + storage if (player:hasCompletedMission(ZILART,ARK_ANGELS)) then player:startEvent(0x7d01,instance:getEntrance(),instance:getFastestTime(),1,instance:getTimeInside(),180,3,1); -- winning CS (allow player to skip) else player:startEvent(0x7d01,instance:getEntrance(),instance:getFastestTime(),1,instance:getTimeInside(),180,3,0); -- winning CS (allow player to skip) end elseif (leavecode == 4) then player:startEvent(0x7d02, 0, 0, 0, 0, 0, instance:getEntrance(), 180); -- player lost end end; function onEventUpdate(player,csid,option) -- print("bc update csid "..csid.." and option "..option); end; function onEventFinish(player,csid,option) -- print("bc finish csid "..csid.." and option "..option); local AAKeyitems = (player:hasKeyItem(SHARD_OF_APATHY) and player:hasKeyItem(SHARD_OF_COWARDICE) and player:hasKeyItem(SHARD_OF_ENVY) and player:hasKeyItem(SHARD_OF_RAGE)); if (csid == 0x7d01) then if (player:getCurrentMission(ZILART) == ARK_ANGELS and player:getVar("ZilartStatus") == 1) then player:addKeyItem(SHARD_OF_ARROGANCE); player:messageSpecial(KEYITEM_OBTAINED,SHARD_OF_ARROGANCE); if (AAKeyitems == true) then player:completeMission(ZILART,ARK_ANGELS); player:addMission(ZILART,THE_SEALED_SHRINE); player:setVar("ZilartStatus",0); end end end local AAKeyitems = (player:hasKeyItem(SHARD_OF_APATHY) and player:hasKeyItem(SHARD_OF_ARROGANCE) and player:hasKeyItem(SHARD_OF_COWARDICE) and player:hasKeyItem(SHARD_OF_ENVY) and player:hasKeyItem(SHARD_OF_RAGE)); if (AAKeyitems == true) then player:completeMission(ZILART,ARK_ANGELS); player:addMission(ZILART,THE_SEALED_SHRINE); player:setVar("ZilartStatus",0); end end;
gpl-3.0
badboyam/telebot
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
Maxsteam/1bot
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
waterlgndx/darkstar
scripts/zones/Dynamis-Qufim/bcnms/dynamis_qufim.lua
5
1215
----------------------------------- -- Area: dynamis_Qufim -- Name: dynamis_Qufim ----------------------------------- -- After registering the BCNM via bcnmRegister(bcnmid) function onBcnmRegister(player,instance) SetServerVariable("[DynaQufim]UniqueID",os.time()); SetServerVariable("[DynaQufim]Boss_Trigger",0); SetServerVariable("[DynaQufim]Already_Received",0); end; -- Physically entering the BCNM via bcnmEnter(bcnmid) function onBcnmEnter(player,instance) player:setVar("DynamisID",GetServerVariable("[DynaQufim]UniqueID")); local realDay = os.time(); if (DYNA_MIDNIGHT_RESET == true) then realDay = getMidnight() - 86400; end local dynaWaitxDay = player:getVar("dynaWaitxDay"); if ((dynaWaitxDay + (BETWEEN_2DYNA_WAIT_TIME * 60 * 60)) < realDay) then player:setVar("dynaWaitxDay",realDay); end end; -- Leaving the Dynamis by every mean possible, given by the LeaveCode -- 3=Disconnected or warped out (if dyna is empty: launch 4 after 3) -- 4=Finish he dynamis function onBcnmLeave(player,instance,leavecode) --print("leave code "..leavecode); if (leavecode == 4) then SetServerVariable("[DynaQufim]UniqueID",0); end end;
gpl-3.0
kidaa/darkstar
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
will4wachter/Project1
scripts/zones/Temenos/mobs/Earth_Elemental.lua
17
1708
----------------------------------- -- Area: Temenos E T -- NPC: Earth_Elemental ----------------------------------- package.loaded["scripts/zones/Temenos/TextIDs"] = nil; ----------------------------------- require("scripts/globals/limbus"); require("scripts/zones/Temenos/TextIDs"); ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) end; ----------------------------------- -- onMobEngaged ----------------------------------- function onMobEngaged(mob,target) end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob,killer) local mobID = mob:getID(); local mobX = mob:getXPos(); local mobY = mob:getYPos(); local mobZ = mob:getZPos(); switch (mobID): caseof { -- 100 a 106 inclut (Temenos -Northern Tower ) [16928867] = function (x) GetNPCByID(16928768+182):setPos(mobX,mobY,mobZ); GetNPCByID(16928768+182):setStatus(STATUS_NORMAL); end , [16928868] = function (x) GetNPCByID(16928768+236):setPos(mobX,mobY,mobZ); GetNPCByID(16928768+236):setStatus(STATUS_NORMAL); end , [16928869] = function (x) GetNPCByID(16928768+360):setPos(mobX,mobY,mobZ); GetNPCByID(16928768+360):setStatus(STATUS_NORMAL); end , [16928870] = function (x) GetNPCByID(16928768+47):setPos(mobX,mobY,mobZ); GetNPCByID(16928768+47):setStatus(STATUS_NORMAL); end , [16929036] = function (x) if(IsMobDead(16929037)==false)then DespawnMob(16929037); SpawnMob(16929043); end end , } end;
gpl-3.0
davidedmonds/darkstar
scripts/zones/Cloister_of_Tides/npcs/Water_Protocrystal.lua
17
1880
----------------------------------- -- Area: Cloister of Tides -- NPC: Water Protocrystal -- Involved in Quests: Trial by Water, Trial Size Trial by Water -- @pos 560 36 560 211 ----------------------------------- package.loaded["scripts/zones/Cloister_of_Tides/TextIDs"] = nil; ------------------------------------- require("scripts/globals/keyitems"); require("scripts/globals/bcnm"); require("scripts/zones/Cloister_of_Tides/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if (TradeBCNM(player,player:getZoneID(),trade,npc)) then return; end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:getCurrentMission(ASA) == SUGAR_COATED_DIRECTIVE and player:getVar("ASA4_Cerulean") == 1) then player:startEvent(0x0002); elseif (EventTriggerBCNM(player,npc)) then return; else player:messageSpecial(PROTOCRYSTAL); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("onUpdate CSID: %u",csid); --printf("onUpdate RESULT: %u",option); if (EventUpdateBCNM(player,csid,option)) then return; end end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("onFinish CSID: %u",csid); --printf("onFinish RESULT: %u",option); if (csid==0x0002) then player:delKeyItem(DOMINAS_CERULEAN_SEAL); player:addKeyItem(CERULEAN_COUNTERSEAL); player:messageSpecial(KEYITEM_OBTAINED,CERULEAN_COUNTERSEAL); player:setVar("ASA4_Cerulean","2"); elseif (EventFinishBCNM(player,csid,option)) then return; end end;
gpl-3.0
davidedmonds/darkstar
scripts/zones/Mhaura/npcs/Blandine.lua
17
2177
----------------------------------- -- Area: Mhaura -- NPC: Blandine -- Start Quest: The Sand Charmz -- @pos 23 -7 41 249 ----------------------------------- package.loaded["scripts/zones/Mhaura/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/quests"); require("scripts/zones/Mhaura/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local X = player:getXPos(); Z = player:getZPos(); local TheSandCharm = player:getQuestStatus(OTHER_AREAS,THE_SAND_CHARM); if (Z <= 29 or Z >= 38 or X <= 16 or X >= 32) then if (player:getFameLevel(WINDURST) >= 4 and TheSandCharm == QUEST_AVAILABLE) then player:startEvent(0x007d); -- Start quest "The Sand Charm" elseif (player:getVar("theSandCharmVar") == 2) then player:startEvent(0x007c); -- During quest "The Sand Charm" - 2nd dialog elseif (TheSandCharm == QUEST_COMPLETED and player:getVar("SmallDialogByBlandine") == 1) then player:startEvent(0x0080); -- Thanks dialog of Bladine after "The Sand Charm" elseif (TheSandCharm == QUEST_COMPLETED) then player:startEvent(0x0081); -- New standard dialog after "The Sand Charm" else player:startEvent(0x007a); -- Standard dialog end end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); if (csid == 0x007d) then player:addQuest(OTHER_AREAS,THE_SAND_CHARM); player:setVar("theSandCharmVar",1); elseif (csid == 0x007c) then player:setVar("theSandCharmVar",3); elseif (csid == 0x0080) then player:setVar("SmallDialogByBlandine",0); end end;
gpl-3.0
lhog/Zero-K
LuaUI/Widgets/gui_attack_aoe.lua
4
25008
-- $Id: gui_attack_aoe.lua 3823 2009-01-19 23:40:49Z evil4zerggin $ -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- local versionNumber = "v3.1" function widget:GetInfo() return { name = "Attack AoE", desc = versionNumber .. " Cursor indicator for area of effect and scatter when giving attack command.", author = "Evil4Zerggin", date = "26 September 2008", license = "GNU LGPL, v2.1 or later", layer = 1, enabled = true -- loaded by default? } end -------------------------------------------------------------------------------- --config -------------------------------------------------------------------------------- local numScatterPoints = 32 local aoeColor = {1, 0, 0, 1} local aoeLineWidthMult = 64 local scatterColor = {1, 1, 0, 1} local scatterLineWidthMult = 1024 local depthColor = {1, 0, 0, 0.5} local depthLineWidth = 1 local circleDivs = 64 local minSpread = 8 --weapons with this spread or less are ignored local numAoECircles = 9 local pointSizeMult = 2048 -------------------------------------------------------------------------------- --vars -------------------------------------------------------------------------------- local aoeDefInfo = {} local dgunInfo = {} local unitAoeDefs = {} local unitDgunDefs = {} local unitHasBeenSetup = {} local aoeUnitInfo local dgunUnitInfo local aoeUnitID local dgunUnitID local selUnitID local circleList local secondPart = 0 local mouseDistance = 1000 local extraDrawRange local sumoSelected = false local detrimentSelected = false local detrimentUnitID = nil -------------------------------------------------------------------------------- --speedups -------------------------------------------------------------------------------- local GetActiveCommand = Spring.GetActiveCommand local GetCameraPosition = Spring.GetCameraPosition local GetFeaturePosition = Spring.GetFeaturePosition local GetGroundHeight = Spring.GetGroundHeight local GetMouseState = Spring.GetMouseState local GetSelectedUnitsSorted = Spring.GetSelectedUnitsSorted local GetUnitPosition = Spring.GetUnitPosition local GetUnitRadius = Spring.GetUnitRadius local TraceScreenRay = Spring.TraceScreenRay local CMD_ATTACK = CMD.ATTACK local CMD_MANUALFIRE = CMD.MANUALFIRE local g = Game.gravity local GAME_SPEED = 30 local g_f = g / GAME_SPEED / GAME_SPEED local glBeginEnd = gl.BeginEnd local glCallList = gl.CallList local glCreateList = gl.CreateList local glColor = gl.Color local glDeleteList = gl.DeleteList local glDepthTest = gl.DepthTest local glDrawGroundCircle = gl.DrawGroundCircle local glLineStipple = gl.LineStipple local glLineWidth = gl.LineWidth local glPointSize = gl.PointSize local glPopMatrix = gl.PopMatrix local glPushMatrix = gl.PushMatrix local glRotate = gl.Rotate local glScale = gl.Scale local glTranslate = gl.Translate local glVertex = gl.Vertex local GL_LINES = GL.LINES local GL_LINE_LOOP = GL.LINE_LOOP local GL_POINTS = GL.POINTS local PI = math.pi local atan = math.atan local cos = math.cos local sin = math.sin local floor = math.floor local max = math.max local min = math.min local sqrt = math.sqrt VFS.Include("LuaRules/Configs/customcmds.h.lua") local sumoDefID = UnitDefNames.jumpsumo.id local sumoAoE = WeaponDefNames.jumpsumo_landing.damageAreaOfEffect local sumoEE = WeaponDefNames.jumpsumo_landing.edgeEffectiveness local detrimentDefID = UnitDefNames.striderdetriment.id local detrimentLandingAoE = WeaponDefNames.striderdetriment_landing.damageAreaOfEffect local detrimentLandingEE = WeaponDefNames.striderdetriment_landing.edgeEffectiveness -------------------------------------------------------------------------------- --utility functions -------------------------------------------------------------------------------- local function ToBool(x) return x and x ~= 0 and x ~= "false" end local function Normalize(x, y, z) local mag = sqrt(x*x + y*y + z*z) if (mag == 0) then return nil else return x/mag, y/mag, z/mag, mag end end local function VertexList(points) for i, point in pairs(points) do glVertex(point) end end local function GetMouseTargetPosition() local mx, my = GetMouseState() local mouseTargetType, mouseTarget = TraceScreenRay(mx, my, false, true, false, true) if (mouseTargetType == "ground") then return mouseTarget[1], mouseTarget[2], mouseTarget[3], true elseif (mouseTargetType == "unit") then return GetUnitPosition(mouseTarget) elseif (mouseTargetType == "feature") then local _, coords = TraceScreenRay(mx, my, true, true, false, true) if coords and coords[3] then return coords[1], coords[2], coords[3], true else return GetFeaturePosition(mouseTarget) end else return nil end end local function GetMouseDistance() local cx, cy, cz = GetCameraPosition() local mx, my, mz = GetMouseTargetPosition() if (not mx) then return nil end local dx = cx - mx local dy = cy - my local dz = cz - mz return sqrt(dx*dx + dy*dy + dz*dz) end local function UnitCircleVertices() for i = 1, circleDivs do local theta = 2 * PI * i / circleDivs glVertex(cos(theta), 0, sin(theta)) end end local function DrawUnitCircle() glBeginEnd(GL_LINE_LOOP, UnitCircleVertices) end local function DrawCircle(x, y, z, radius) glPushMatrix() glTranslate(x, y, z) glScale(radius, radius, radius) glCallList(circleList) glPopMatrix() end local function GetSecondPart(offset) local result = secondPart + (offset or 0) return result - floor(result) end -------------------------------------------------------------------------------- --initialization -------------------------------------------------------------------------------- local function getWeaponInfo(weaponDef, unitDef) local retData local weaponType = weaponDef.type local scatter = weaponDef.accuracy + weaponDef.sprayAngle local aoe = weaponDef.damageAreaOfEffect local cost = unitDef.metalCost local waterWeapon = weaponDef.waterWeapon local ee = weaponDef.edgeEffectiveness if (weaponDef.cylinderTargetting >= 100) then retData = {type = "orbital", scatter = scatter} elseif (weaponType == "Cannon") then retData = { type = "ballistic", scatter = scatter, v = (weaponDef.customParams.weaponvelocity or 0), range = weaponDef.range, mygravity = weaponDef.customParams and weaponDef.customParams.mygravity and weaponDef.customParams.mygravity*800 } elseif (weaponType == "MissileLauncher") then local turnRate = 0 if (weaponDef.tracks) then turnRate = weaponDef.turnRate end if (weaponDef.wobble > turnRate * 1.4) then scatter = (weaponDef.wobble - weaponDef.turnRate) * (weaponDef.customParams.weaponvelocity or 0) * 16 local rangeScatter = (8 * weaponDef.wobble - weaponDef.turnRate) retData = {type = "wobble", scatter = scatter, rangeScatter = rangeScatter, range = weaponDef.range} elseif (weaponDef.wobble > turnRate) then scatter = (weaponDef.wobble - weaponDef.turnRate) * (weaponDef.customParams.weaponvelocity or 0) * 16 retData = {type = "wobble", scatter = scatter} elseif (weaponDef.tracks) then retData = {type = "tracking"} else retData = {type = "direct", scatter = scatter, range = weaponDef.range} end elseif (weaponType == "AircraftBomb") then retData = {type = "dropped", scatter = scatter, v = unitDef.speed, h = unitDef.wantedHeight, salvoSize = weaponDef.salvoSize, salvoDelay = weaponDef.salvoDelay} elseif (weaponType == "StarburstLauncher") then if (weaponDef.tracks) then retData = {type = "tracking", range = weaponDef.range} else retData = {type = "cruise", range = weaponDef.range} end elseif (weaponType == "TorpedoLauncher") then if (weaponDef.tracks) then retData = {type = "tracking"} else retData = {type = "direct", scatter = scatter, range = weaponDef.range} end elseif (weaponType == "Flame" or weaponDef.noExplode) then retData = {type = "noexplode", range = weaponDef.range} else retData = {type = "direct", scatter = scatter, range = weaponDef.range} end if not weaponDef.impactOnly then retData.aoe = aoe else retData.aoe = 0 end retData.cost = cost retData.mobile = not unitDef.isImmobile retData.waterWeapon = waterWeapon retData.ee = ee return retData end local function SetupUnit(unitDef, unitID) if (not unitDef.weapons) then return end local weapon1, weapon2, manualfireWeapon, rangeMult if unitID then weapon1 = Spring.GetUnitRulesParam(unitID, "comm_weapon_num_1") weapon2 = Spring.GetUnitRulesParam(unitID, "comm_weapon_num_2") local manual1 = Spring.GetUnitRulesParam(unitID, "comm_weapon_manual_1") == 1 local manual2 = Spring.GetUnitRulesParam(unitID, "comm_weapon_manual_2") == 1 if manual1 then manualfireWeapon = weapon1 elseif manual2 then manualfireWeapon = weapon2 end rangeMult = Spring.GetUnitRulesParam(unitID, "comm_range_mult") end local retDgunInfo local retAoeInfo local maxSpread = minSpread local maxWeaponDef for num, weapon in ipairs(unitDef.weapons) do if (weapon.weaponDef) and ((not unitID) or num == weapon1 or num == weapon2) then local weaponDef = WeaponDefs[weapon.weaponDef] if (weaponDef) then local aoe = weaponDef.damageAreaOfEffect if (weaponDef.manualFire and unitDef.canManualFire) or num == manualfireWeapon then retDgunInfo = getWeaponInfo(weaponDef, unitDef) if retDgunInfo.range then if weaponDef.customParams.truerange then retDgunInfo.range = tonumber(weaponDef.customParams.truerange) end if weaponDef.customParams.gui_draw_range then retDgunInfo.range = tonumber(weaponDef.customParams.gui_draw_range) end if rangeMult then retDgunInfo.range = retDgunInfo.range * rangeMult end end elseif (not weaponDef.isShield and not ToBool(weaponDef.interceptor) and not ToBool(weaponDef.customParams.hidden) and (aoe > maxSpread or weaponDef.range * (weaponDef.accuracy + weaponDef.sprayAngle) > maxSpread )) then maxSpread = max(aoe, weaponDef.range * (weaponDef.accuracy + weaponDef.sprayAngle)) maxWeaponDef = weaponDef end end end end if (maxWeaponDef) then retAoeInfo = getWeaponInfo(maxWeaponDef, unitDef) if maxWeaponDef.customParams.gui_draw_range then retAoeInfo.range = tonumber(maxWeaponDef.customParams.gui_draw_range) end if retAoeInfo.range and rangeMult then retAoeInfo.range = retAoeInfo.range * rangeMult end end return retAoeInfo, retDgunInfo end local function SetupDisplayLists() circleList = glCreateList(DrawUnitCircle) end local function DeleteDisplayLists() glDeleteList(circleList) end -------------------------------------------------------------------------------- --updates -------------------------------------------------------------------------------- local function UpdateSelection() local sel = GetSelectedUnitsSorted() local maxCost = 0 dgunUnitInfo = nil aoeUnitInfo = nil dgunUnitID = nil aoeUnitID = nil sumoSelected = false detrimentSelected = false detrimentUnitID = nil for unitDefID, unitIDs in pairs(sel) do if unitDefID ~= "n" then local unitID = unitIDs[1] if unitDefID == sumoDefID then sumoSelected = true end if unitDefID == detrimentDefID then detrimentSelected = true detrimentUnitID = unitID end local dynamicComm = Spring.GetUnitRulesParam(unitID, "comm_level") if dynamicComm and not unitHasBeenSetup[unitID] then unitAoeDefs[unitID], unitDgunDefs[unitID] = SetupUnit(UnitDefs[unitDefID], unitID) unitHasBeenSetup[unitID] = true end if (dgunInfo[unitDefID]) then dgunUnitInfo = unitDgunDefs[unitID] or ((not dynamicComm) and dgunInfo[unitDefID]) dgunUnitID = unitID end if (aoeDefInfo[unitDefID]) then local currCost = UnitDefs[unitDefID].metalCost * #unitIDs if (currCost > maxCost) then maxCost = currCost aoeUnitInfo = unitAoeDefs[unitID] or ((not dynamicComm) and aoeDefInfo[unitDefID]) aoeUnitID = unitID end end local extraDrawParam = Spring.GetUnitRulesParam(unitID, "secondary_range") if extraDrawParam then extraDrawRange = extraDrawParam else extraDrawRange = UnitDefs[unitDefID] and UnitDefs[unitDefID].customParams and UnitDefs[unitDefID].customParams.extradrawrange end if extraDrawRange then selUnitID = unitID end end end end -------------------------------------------------------------------------------- --aoe -------------------------------------------------------------------------------- local function DrawAoE(tx, ty, tz, aoe, ee, alphaMult, offset) glLineWidth(math.max(0.05, aoeLineWidthMult * aoe / mouseDistance)) for i = 1, numAoECircles do local proportion = i / (numAoECircles + 1) local radius = aoe * proportion local alpha = aoeColor[4] * (1 - proportion) / (1 - proportion * ee) * (1 - GetSecondPart(offset or 0)) * (alphaMult or 1) glColor(aoeColor[1], aoeColor[2], aoeColor[3], alpha) DrawCircle(tx, ty, tz, radius) end glColor(1,1,1,1) glLineWidth(1) end -------------------------------------------------------------------------------- --dgun/noexplode -------------------------------------------------------------------------------- local function DrawNoExplode(aoe, fx, fy, fz, tx, ty, tz, range) local dx = tx - fx local dy = ty - fy local dz = tz - fz local bx, by, bz, dist = Normalize(dx, dy, dz) if (not bx or dist > range) then return end local br = sqrt(bx*bx + bz*bz) local wx = -aoe * bz / br local wz = aoe * bx / br local ex = range * bx / br local ez = range * bz / br local vertices = {{fx + wx, fy, fz + wz}, {fx + ex + wx, ty, fz + ez + wz}, {fx - wx, fy, fz - wz}, {fx + ex - wx, ty, fz + ez - wz}} local alpha = (1 - GetSecondPart()) * aoeColor[4] glColor(aoeColor[1], aoeColor[2], aoeColor[3], alpha) glLineWidth(scatterLineWidthMult / mouseDistance) glBeginEnd(GL_LINES, VertexList, vertices) glColor(1,1,1,1) glLineWidth(1) end -------------------------------------------------------------------------------- --ballistics -------------------------------------------------------------------------------- local function GetBallisticVector(v, mg, dx, dy, dz, trajectory, range) local dr_sq = dx*dx + dz*dz local dr = sqrt(dr_sq) if (dr > range) then return nil end local d_sq = dr_sq + dy*dy if (d_sq == 0) then return 0, v * trajectory, 0 end local root1 = v*v*v*v - 2*v*v*mg*dy - mg*mg*dr_sq if (root1 < 0) then return nil end local root2 = 2*dr_sq*d_sq*(v*v - mg*dy - trajectory*sqrt(root1)) if (root2 < 0) then return nil end local vr = sqrt(root2)/(2*d_sq) local vy if (r == 0 or vr == 0) then vy = v else vy = vr*dy/dr + dr*mg/(2*vr) end local bx = dx*vr/dr local bz = dz*vr/dr local by = vy return Normalize(bx, by, bz) end local function GetBallisticImpactPoint(v, mg_f, fx, fy, fz, bx, by, bz) local v_f = v / GAME_SPEED local vx_f = bx * v_f local vy_f = by * v_f local vz_f = bz * v_f local px = fx local py = fy local pz = fz local ttl = 4 * v_f / mg_f for i = 1, ttl do px = px + vx_f py = py + vy_f pz = pz + vz_f vy_f = vy_f - mg_f local gwh = max(GetGroundHeight(px, pz), 0) if (py < gwh) then local interpolate = min((py - gwh) / vy_f, 1) local x = px - interpolate * vx_f local z = pz - interpolate * vz_f return {x, max(GetGroundHeight(x, z), 0), z} end end return {px, py, pz} end --v: weaponvelocity --trajectory: +1 for high, -1 for low local function DrawBallisticScatter(scatter, v, mygravity ,fx, fy, fz, tx, ty, tz, trajectory, range) if (scatter == 0) then return end local dx = tx - fx local dy = ty - fy local dz = tz - fz if (dx == 0 and dz == 0) then return end local mg = mygravity or g local bx, by, bz = GetBallisticVector(v, mg, dx, dy, dz, trajectory, range) --don't draw anything if out of range if (not bx) then return end local br = sqrt(bx*bx + bz*bz) --bars local rx = dx / br local rz = dz / br local wx = -scatter * rz local wz = scatter * rx local barLength = sqrt(wx*wx + wz*wz) --length of bars local barX = 0.5 * barLength * bx / br local barZ = 0.5 * barLength * bz / br local sx = tx - barX local sz = tz - barZ local lx = tx + barX local lz = tz + barZ local wsx = -scatter * (rz - barZ) local wsz = scatter * (rx - barX) local wlx = -scatter * (rz + barZ) local wlz = scatter * (rx + barX) local bars = {{tx + wx, ty, tz + wz}, {tx - wx, ty, tz - wz}, {sx + wsx, ty, sz + wsz}, {lx + wlx, ty, lz + wlz}, {sx - wsx, ty, sz - wsz}, {lx - wlx, ty, lz - wlz}} local scatterDiv = scatter / numScatterPoints local vertices = {} local mg_f = mg / GAME_SPEED / GAME_SPEED --trace impact points for i = -numScatterPoints, numScatterPoints do local currScatter = i * scatterDiv local currScatterCos = sqrt(1 - currScatter * currScatter) local rMult = currScatterCos - by * currScatter / br local bx_c = bx * rMult local by_c = by * currScatterCos + br * currScatter local bz_c = bz * rMult vertices[i+numScatterPoints+1] = GetBallisticImpactPoint(v, mg_f, fx, fy, fz, bx_c, by_c, bz_c) end glLineWidth(scatterLineWidthMult / mouseDistance) -- FIXME ATIBUG glPointSize(pointSizeMult / mouseDistance) glColor(scatterColor) glDepthTest(false) glBeginEnd(GL_LINES, VertexList, bars) glBeginEnd(GL_POINTS, VertexList, vertices) glDepthTest(true) glColor(1,1,1,1) -- FIXME ATIBUG glPointSize(1) glLineWidth(1) end -------------------------------------------------------------------------------- --wobble -------------------------------------------------------------------------------- local function DrawWobbleScatter(scatter, fx, fy, fz, tx, ty, tz, rangeScatter, range) local dx = tx - fx local dy = ty - fy local dz = tz - fz local bx, by, bz, d = Normalize(dx, dy, dz) glColor(scatterColor) glLineWidth(scatterLineWidthMult / mouseDistance) if d and range then if d <= range then DrawCircle(tx, ty, tz, rangeScatter * d + scatter) end else DrawCircle(tx, ty, tz, scatter) end glColor(1,1,1,1) glLineWidth(1) end -------------------------------------------------------------------------------- --direct -------------------------------------------------------------------------------- local function DrawDirectScatter(scatter, fx, fy, fz, tx, ty, tz, range, unitRadius) local dx = tx - fx local dy = ty - fy local dz = tz - fz local bx, by, bz, d = Normalize(dx, dy, dz) if (not bx or d == 0 or d > range) then return end local ux = bx * unitRadius / sqrt(1 - by*by) local uz = bz * unitRadius / sqrt(1 - by*by) local cx = -scatter * uz local cz = scatter * ux local wx = -scatter * dz / sqrt(1 - by*by) local wz = scatter * dx / sqrt(1 - by*by) local vertices = {{fx + ux + cx, fy, fz + uz + cz}, {tx + wx, ty, tz + wz}, {fx + ux - cx, fy, fz + uz - cz}, {tx - wx, ty, tz - wz}} glColor(scatterColor) glLineWidth(scatterLineWidthMult / mouseDistance) glBeginEnd(GL_LINES, VertexList, vertices) glColor(1,1,1,1) glLineWidth(1) end -------------------------------------------------------------------------------- --dropped -------------------------------------------------------------------------------- local function DrawDroppedScatter(aoe, ee, scatter, v, fx, fy, fz, tx, ty, tz, salvoSize, salvoDelay) local dx = tx - fx local dz = tz - fz local bx, _, bz = Normalize(dx, 0, dz) if (not bx) then return end local vertices = {} local currScatter = scatter * v * sqrt(2*fy/g) local alphaMult = min(v * salvoDelay / aoe, 1) for i=1,salvoSize do local delay = salvoDelay * (i - (salvoSize + 1) / 2) local dist = v * delay local px_c = dist * bx + tx local pz_c = dist * bz + tz local py_c = max(GetGroundHeight(px_c, pz_c), 0) DrawAoE(px_c, py_c, pz_c, aoe, ee, alphaMult, -delay) glColor(scatterColor[1], scatterColor[2], scatterColor[3], scatterColor[4] * alphaMult) glLineWidth(scatterLineWidthMult / mouseDistance) DrawCircle(px_c, py_c, pz_c, currScatter) end glColor(1,1,1,1) glLineWidth(1) end -------------------------------------------------------------------------------- --orbital -------------------------------------------------------------------------------- local function DrawOrbitalScatter(scatter, tx, ty, tz) glColor(scatterColor) glLineWidth(scatterLineWidthMult / mouseDistance) DrawCircle(tx, ty, tz, scatter) glColor(1,1,1,1) glLineWidth(1) end -------------------------------------------------------------------------------- --underwater -------------------------------------------------------------------------------- local function DrawWaterDepth(tx, ty, tz) glColor(depthColor) glLineWidth(depthLineWidth) glLineStipple(1, 255) glBeginEnd(GL_LINES, VertexList, {{tx,0,tz},{tx,ty,tz}}) glLineStipple(false) glColor(1,1,1,1) glLineWidth(1) end -------------------------------------------------------------------------------- --callins -------------------------------------------------------------------------------- function widget:Initialize() for unitDefID, unitDef in pairs(UnitDefs) do aoeDefInfo[unitDefID], dgunInfo[unitDefID] = SetupUnit(unitDef) end SetupDisplayLists() end function widget:Shutdown() DeleteDisplayLists() end function widget:DrawWorld() mouseDistance = GetMouseDistance() or 1000 local tx, ty, tz, targetIsGround = GetMouseTargetPosition() if (not tx) then return end local _, cmd, _ = GetActiveCommand() local info, unitID if extraDrawRange and selUnitID and cmd == CMD_ATTACK then local _,_,_,fx, fy, fz = GetUnitPosition(selUnitID, true) if fx then glColor(1, 0.35, 0.35, 0.75) glLineWidth(1) glDrawGroundCircle(fx, fy, fz, extraDrawRange, 50) glColor(1,1,1,1) end end if (cmd == CMD_ATTACK and aoeUnitInfo) then info = aoeUnitInfo unitID = aoeUnitID elseif (cmd == CMD_MANUALFIRE and dgunUnitInfo) then info = dgunUnitInfo local extraDrawParam = Spring.GetUnitRulesParam(dgunUnitID, "secondary_range") if extraDrawParam then info.range = extraDrawParam end unitID = dgunUnitID elseif (cmd == CMD_JUMP and sumoSelected) then DrawAoE(tx, ty, tz, sumoAoE, sumoEE) return elseif (cmd == CMD_JUMP and detrimentSelected) then local _,_,_,fx, fy, fz = GetUnitPosition(detrimentUnitID, true) DrawAoE(tx, ty, tz, detrimentLandingAoE, detrimentLandingEE) return else return end local _,_,_,fx, fy, fz = GetUnitPosition(unitID, true) if (not fx) then return end if (not info.mobile) then fy = fy + GetUnitRadius(unitID) end if ty < 0 and targetIsGround then DrawWaterDepth(tx, ty, tz) end if (not info.waterWeapon) then ty = max(0, ty) end local weaponType = info.type if (weaponType == "noexplode") then DrawNoExplode(info.aoe, fx, fy, fz, tx, ty, tz, info.range) elseif (weaponType == "ballistic") then local trajectory = Spring.Utilities.GetUnitTrajectoryState(unitID) if trajectory then trajectory = 1 else trajectory = -1 end DrawAoE(tx, ty, tz, info.aoe, info.ee) DrawBallisticScatter(info.scatter, info.v, info.mygravity, fx, fy, fz, tx, ty, tz, trajectory, info.range) elseif (weaponType == "tracking") then DrawAoE(tx, ty, tz, info.aoe, info.ee) elseif (weaponType == "direct") then DrawAoE(tx, ty, tz, info.aoe, info.ee) DrawDirectScatter(info.scatter, fx, fy, fz, tx, ty, tz, info.range, GetUnitRadius(unitID)) elseif (weaponType == "dropped") then DrawDroppedScatter(info.aoe, info.ee, info.scatter, info.v, fx, info.h, fz, tx, ty, tz, info.salvoSize, info.salvoDelay) elseif (weaponType == "wobble") then DrawAoE(tx, ty, tz, info.aoe, info.ee) DrawWobbleScatter(info.scatter, fx, fy, fz, tx, ty, tz, info.rangeScatter, info.range) elseif (weaponType == "orbital") then DrawAoE(tx, ty, tz, info.aoe, info.ee) DrawOrbitalScatter(info.scatter, tx, ty, tz) elseif (weaponType ~= "dontdraw") then DrawAoE(tx, ty, tz, info.aoe, info.ee) end if (cmd == CMD_MANUALFIRE) and info.range then glColor(1, 0, 0, 0.75) glLineWidth(1) glDrawGroundCircle(fx, fy, fz, info.range, circleDivs) glColor(1,1,1,1) end end function widget:UnitDestroyed(unitID) unitAoeDefs[unitID] = nil unitDgunDefs[unitID] = nil unitHasBeenSetup[unitID] = nil end function widget:SelectionChanged(sel) UpdateSelection() end function widget:Update(dt) secondPart = secondPart + dt secondPart = secondPart - floor(secondPart) end
gpl-2.0
kidaa/darkstar
scripts/globals/spells/paralyze.lua
11
1994
----------------------------------------- -- Spell: Paralyze -- Spell accuracy is most highly affected by Enfeebling Magic Skill, Magic Accuracy, and MND. ----------------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------------- -- OnSpellCast ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) if(target:hasStatusEffect(EFFECT_PARALYSIS)) then --effect already on, do nothing spell:setMsg(75); else -- Calculate duration. local duration = math.random(20,120); if (caster:hasStatusEffect(EFFECT_SABOTEUR)) then duration = duration * 2; end -- Grabbing variables for paralyze potency local pMND = caster:getStat(MOD_MND); local mMND = target:getStat(MOD_MND); local dMND = (pMND - mMND); -- Calculate potency. local potency = (pMND + dMND)/5; --simplified from (2 * (pMND + dMND)) / 10 if potency > 25 then potency = 25; end if (caster:hasStatusEffect(EFFECT_SABOTEUR)) then potency = potency * 2; end caster:delStatusEffect(EFFECT_SABOTEUR); --printf("Duration : %u",duration); --printf("Potency : %u",potency); local resist = applyResistanceEffect(caster,spell,target,dMND,35,0,EFFECT_PARALYSIS); if(resist >= 0.5) then --there are no quarter or less hits, if target resists more than .5 spell is resisted completely if(target:addStatusEffect(EFFECT_PARALYSIS,potency,0,duration*resist)) then spell:setMsg(236); else -- no effect spell:setMsg(75); end else -- resist spell:setMsg(85); end end return EFFECT_PARALYSIS; end;
gpl-3.0
waterlgndx/darkstar
scripts/zones/Cloister_of_Frost/bcnms/trial_by_ice.lua
2
1946
----------------------------------- -- Area: Cloister of Frost -- BCNM: Trial by Ice -- !pos 558 0.1 596 203 ----------------------------------- package.loaded["scripts/zones/Cloister_of_Frost/TextIDs"] = nil; ------------------------------------- require("scripts/globals/keyitems"); require("scripts/globals/quests"); require("scripts/globals/titles"); require("scripts/zones/Cloister_of_Frost/TextIDs"); ----------------------------------- -- After registering the BCNM via bcnmRegister(bcnmid) function onBcnmRegister(player,instance) end; -- Physically entering the BCNM via bcnmEnter(bcnmid) function onBcnmEnter(player,instance) end; -- Leaving the BCNM by every mean possible, given by the LeaveCode -- 1=Select Exit on circle -- 2=Winning the BC -- 3=Disconnected or warped out -- 4=Losing the BC -- via bcnmLeave(1) or bcnmLeave(2). LeaveCodes 3 and 4 are called -- from the core when a player disconnects or the time limit is up, etc function onBcnmLeave(player,instance,leavecode) -- print("leave code "..leavecode); if (leavecode == 2) then -- play end CS. Need time and battle id for record keeping + storage if (player:hasCompletedQuest(SANDORIA,TRIAL_BY_ICE)) then player:startEvent(32001,1,1,1,instance:getTimeInside(),1,0,1); else player:startEvent(32001,1,1,1,instance:getTimeInside(),1,0,0); end elseif (leavecode == 4) then player:startEvent(32002); end end; function onEventUpdate(player,csid,option) -- print("bc update csid "..csid.." and option "..option); end; function onEventFinish(player,csid,option) -- print("bc finish csid "..csid.." and option "..option); if (csid == 32001) then player:delKeyItem(dsp.ki.TUNING_FORK_OF_ICE); player:addKeyItem(dsp.ki.WHISPER_OF_FROST); player:addTitle(dsp.title.HEIR_OF_THE_GREAT_ICE); player:messageSpecial(KEYITEM_OBTAINED,dsp.ki.WHISPER_OF_FROST); end end;
gpl-3.0
waterlgndx/darkstar
scripts/zones/Abyssea-Uleguerand/MobIDs.lua
2
2847
require("scripts/globals/keyitems"); -- [QM] = {'name', {list of required trades}, {list of required KIs}, nmID} -- uncomment lines as NMs are implemented NM_POPS = { -- [17813949] = { 'qm1', {3245,3251}, {}, 17813925}, -- Ironclad Triturator -- [17813950] = { 'qm2', {3246,3247,3253}, {}, 17813927}, -- Dhorme Khimaira -- [17813951] = { 'qm3', {3248,3257}, {}, 17813930}, -- Blanga -- [17813952] = { 'qm4', {3249,3259}, {}, 17813931}, -- Yaguarogui -- [17813953] = { 'qm5', {3250}, {}, 17813933}, -- Koghatu -- [17813954] = { 'qm6', {3252}, {}, 17813935}, -- Upas-Kamuy -- [17813955] = { 'qm7', {3254}, {}, 17813937}, -- Veri Selen -- [17813956] = { 'qm8', {3255}, {}, 17813938}, -- Anemic Aloysius -- [17813957] = { 'qm9', {3256}, {}, 17813939}, -- Chillwing Hwitti -- [17813958] = {'qm10', {3258}, {}, 17813940}, -- Audumbla -- [17813959] = {'qm11', {}, {dsp.ki.WARPED_IRON_GIANT_NAIL,dsp.ki.DENTED_CHARIOT_SHIELD}, 17813910}, -- Pantokrator -- [17813960] = {'qm12', {}, {dsp.ki.TORN_KHIMAIRA_WING}, 17813911}, -- Apademak -- [17813961] = {'qm13', {}, {dsp.ki.BEGRIMED_DRAGON_HIDE}, 17813912}, -- Isgebind -- [17813962] = {'qm14', {}, {dsp.ki.DECAYING_DIREMITE_FANG}, 17813913}, -- Resheph -- [17813963] = {'qm15', {}, {dsp.ki.WARPED_IRON_GIANT_NAIL,dsp.ki.DENTED_CHARIOT_SHIELD}, 17813914}, -- Pantokrator -- [17813964] = {'qm16', {}, {dsp.ki.TORN_KHIMAIRA_WING}, 17813915}, -- Apademak -- [17813965] = {'qm17', {}, {dsp.ki.BEGRIMED_DRAGON_HIDE}, 17813916}, -- Isgebind -- [17813966] = {'qm18', {}, {dsp.ki.DECAYING_DIREMITE_FANG}, 17813917}, -- Resheph -- [17813967] = {'qm19', {}, {dsp.ki.WARPED_IRON_GIANT_NAIL,dsp.ki.DENTED_CHARIOT_SHIELD}, 17813918}, -- Pantokrator -- [17813968] = {'qm20', {}, {dsp.ki.TORN_KHIMAIRA_WING}, 17813919}, -- Apademak -- [17813969] = {'qm21', {}, {dsp.ki.BEGRIMED_DRAGON_HIDE}, 17813920}, -- Isgebind -- [17813970] = {'qm22', {}, {dsp.ki.DECAYING_DIREMITE_FANG}, 17813921}, -- Resheph }
gpl-3.0
kidaa/darkstar
scripts/zones/Windurst_Woods/npcs/Pew_Sahbaraef.lua
38
1038
---------------------------------- -- Area: Windurst Woods -- NPC: Pew Sahbaraef -- Type: Item Deliverer -- @zone: 241 -- @pos 61.899 -2.5 -112.956 -- ----------------------------------- package.loaded["scripts/zones/Windurst_Woods/TextIDs"] = nil; require("scripts/zones/Windurst_Woods/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc, ITEM_DELIVERY_DIALOG); player:openSendBox(); 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/globals/spells/dia.lua
2
2460
----------------------------------------- -- Spell: Dia -- Lowers an enemy's defense and gradually deals light elemental damage. ----------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/magic"); require("scripts/globals/msg"); ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) -- calculate raw damage local basedmg = caster:getSkillLevel(dsp.skill.ENFEEBLING_MAGIC) / 4; local params = {}; params.dmg = basedmg; params.multiplier = 1; params.skillType = dsp.skill.ENFEEBLING_MAGIC; params.attribute = dsp.mod.INT; params.hasMultipleTargetReduction = false; local dmg = calculateMagicDamage(caster, target, spell, params); -- Softcaps at 2, should always do at least 1 dmg = utils.clamp(dmg, 1, 2); -- get resist multiplier (1x if no resist) local params = {}; params.diff = caster:getStat(dsp.mod.INT)-target:getStat(dsp.mod.INT); params.attribute = dsp.mod.INT; params.skillType = dsp.skill.ENFEEBLING_MAGIC; params.bonus = 1.0; local resist = applyResistance(caster, target, spell, params); -- get the resisted damage dmg = dmg*resist; -- add on bonuses (staff/day/weather/jas/mab/etc all go in this function) dmg = addBonuses(caster,spell,target,dmg); -- add in target adjustment dmg = adjustForTarget(target,dmg,spell:getElement()); -- add in final adjustments including the actual damage dealt local final = finalMagicAdjustments(caster,target,spell,dmg); -- Calculate duration and bonus. local duration = 60; local dotBonus = caster:getMod(dsp.mod.DIA_DOT); -- Dia Wand if (caster:hasStatusEffect(dsp.effect.SABOTEUR)) then duration = duration * 2; caster:delStatusEffect(dsp.effect.SABOTEUR); end -- Check for Bio. local bio = target:getStatusEffect(dsp.effect.BIO); -- Do it! if (target:addStatusEffect(dsp.effect.DIA,1+dotBonus,3,duration,FLAG_ERASABLE,5,1)) then spell:setMsg(dsp.msg.basic.MAGIC_DMG); else spell:setMsg(dsp.msg.basic.MAGIC_NO_EFFECT); end -- Try to kill same tier Bio if (BIO_OVERWRITE == 1 and bio ~= nil) then if (bio:getPower() == 1) then target:delStatusEffect(dsp.effect.BIO); end end return final; end;
gpl-3.0
davidedmonds/darkstar
scripts/zones/Bastok_Mines/npcs/Crying_Wind_IM.lua
28
4888
----------------------------------- -- Area: Bastok Mines -- NPC: Crying Wind, I.M. -- X Grant Signet -- X Recharge Emperor Band, Empress Band, or Chariot Band -- X Accepts traded Crystals to fill up the Rank bar to open new Missions. -- X Sells items in exchange for Conquest Points -- X Start Supply Run Missions and offers a list of already-delivered supplies. -- Start an Expeditionary Force by giving an E.F. region insignia to you. ------------------------------------- package.loaded["scripts/zones/Bastok_Mines/TextIDs"] = nil; ------------------------------------- require("scripts/globals/conquest"); require("scripts/globals/common"); require("scripts/zones/Bastok_Mines/TextIDs"); local guardnation = BASTOK; -- SANDORIA, BASTOK, WINDURST, JEUNO local guardtype = 1; -- 1: city, 2: foreign, 3: outpost, 4: border local size = table.getn(BastInv); local inventory = BastInv; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) tradeConquestGuard(player,npc,trade,guardnation,guardtype); end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:getNation() == guardnation and player:getVar("supplyQuest_started") > 0 and supplyRunFresh(player) == 0) then player:showText(npc,CONQUEST + 40); -- "We will dispose of those unusable supplies." local region = player:getVar("supplyQuest_region"); player:delKeyItem(getSupplyKey(region)); player:messageSpecial(KEYITEM_OBTAINED + 1,getSupplyKey(region)); player:setVar("supplyQuest_started",0); player:setVar("supplyQuest_region",0); player:setVar("supplyQuest_fresh",0); else local Menu1 = getArg1(guardnation,player); local Menu2 = getExForceAvailable(guardnation,player); local Menu3 = conquestRanking(); local Menu4 = getSupplyAvailable(guardnation,player); local Menu5 = player:getNationTeleport(guardnation); local Menu6 = getArg6(player); local Menu7 = player:getCP(); local Menu8 = getRewardExForce(guardnation,player); player:startEvent(0x7ff9,Menu1,Menu2,Menu3,Menu4,Menu5,Menu6,Menu7,Menu8); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("onUpdateCSID: %u",csid); -- printf("onUpdateOPTION: %u",option); if (option >= 32768 and option <= 32944) then for Item = 1,size,3 do if (option == inventory[Item]) then CPVerify = 1; if (player:getCP() >= inventory[Item + 1]) then CPVerify = 0; end; player:updateEvent(2,CPVerify,inventory[Item + 2]); break; end; end; end; end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("onFinishCSID: %u",csid); -- printf("onFinishOPTION: %u",option); if (option == 1) then local duration = (player:getRank() + getNationRank(player:getNation()) + 3) * 3600; player:delStatusEffect(EFFECT_SIGIL); player:delStatusEffect(EFFECT_SANCTION); player:delStatusEffect(EFFECT_SIGNET); player:addStatusEffect(EFFECT_SIGNET,0,0,duration); -- Grant Signet elseif (option >= 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 if (player:getNation() == guardnation) 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) 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;
gpl-3.0
MonokuroInzanaito/ygopro-777DIY
expansions/script/c20323008.lua
1
2376
--美丽硬仆骨舌鱼 function c20323008.initial_effect(c) --spsummon local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_HAND) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetCountLimit(1,20323008) e1:SetTarget(c20323008.sptg) e1:SetOperation(c20323008.spop) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(20323008,1)) e2:SetCategory(CATEGORY_ATKCHANGE) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetRange(LOCATION_MZONE) e2:SetCode(EVENT_BECOME_TARGET) e2:SetCondition(c20323008.spcon) e2:SetOperation(c20323008.op) c:RegisterEffect(e2) end function c20323008.cfilter(c) return c:IsFaceup() and c:IsRace(RACE_FISH) and c:IsLevelAbove(1) end function c20323008.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c20323008.cfilter(chkc) end if chk==0 then return Duel.IsExistingTarget(c20323008.cfilter,tp,LOCATION_MZONE,0,1,nil) and Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET) local g=Duel.SelectTarget(tp,c20323008.cfilter,tp,LOCATION_MZONE,0,1,1,nil) local tc=g:GetFirst() Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function c20323008.spop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() if tc:IsFacedown() or not tc:IsRelateToEffect(e) then return end if c:IsRelateToEffect(e) then if Duel.GetLocationCount(tp,LOCATION_MZONE)>0 then if Duel.SpecialSummonStep(c,0,tp,tp,false,false,POS_FACEUP) then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_CHANGE_LEVEL) e1:SetValue(tc:GetLevel()) e1:SetReset(RESET_EVENT+0x1fe0000) c:RegisterEffect(e1) Duel.SpecialSummonComplete() end else Duel.SendtoGrave(c,REASON_RULE) end end end function c20323008.spcon(e,tp,eg,ep,ev,re,r,rp) return eg:IsContains(e:GetHandler()) end function c20323008.op(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and c:IsFaceup() then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetValue(1000) e1:SetReset(RESET_EVENT+0x1ff0000) c:RegisterEffect(e1) end end
gpl-3.0
waterlgndx/darkstar
scripts/globals/items/naval_rice_ball.lua
2
1153
----------------------------------------- -- ID: 4605 -- Item: Naval Rice Ball -- Food Effect: 30Min, All Races ----------------------------------------- -- HP +12 -- Dex +3 -- Vit +3 -- hHP +2 -- Effect with enhancing equipment (Note: these are latents on gear with the effect) -- Atk +40 -- Def +40 -- Arcana Killer (guesstimated 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,1800,4605); end; function onEffectGain(target, effect) target:addMod(dsp.mod.HP, 12); target:addMod(dsp.mod.DEX, 3); target:addMod(dsp.mod.VIT, 3); target:addMod(dsp.mod.HPHEAL, 2); end; function onEffectLose(target, effect) target:delMod(dsp.mod.HP, 12); target:delMod(dsp.mod.DEX, 3); target:delMod(dsp.mod.VIT, 3); target:delMod(dsp.mod.HPHEAL, 2); end;
gpl-3.0
davidedmonds/darkstar
scripts/globals/items/smoldering_salisbury_steak.lua
36
1686
----------------------------------------- -- ID: 5924 -- Item: Smoldering Salisbury Steak -- Food Effect: 180 Min, All Races ----------------------------------------- -- HP +30 -- Strength +7 -- Intelligence -5 -- Attack % 20 Cap 160 -- Ranged Attack %20 Cap 160 -- Dragon Killer +5 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,10800,5924); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_HP, 30); target:addMod(MOD_STR, 7); target:addMod(MOD_INT, -5); target:addMod(MOD_FOOD_ATTP, 20); target:addMod(MOD_FOOD_ATT_CAP, 160); target:addMod(MOD_FOOD_RATTP, 20); target:addMod(MOD_FOOD_RATT_CAP, 160); target:addMod(MOD_DRAGON_KILLER, 5); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_HP, 30); target:delMod(MOD_STR, 7); target:delMod(MOD_INT, -5); target:delMod(MOD_FOOD_ATTP, 20); target:delMod(MOD_FOOD_ATT_CAP, 160); target:delMod(MOD_FOOD_RATTP, 20); target:delMod(MOD_FOOD_RATT_CAP, 160); target:delMod(MOD_DRAGON_KILLER, 5); end;
gpl-3.0
davidedmonds/darkstar
scripts/zones/Valkurm_Dunes/npcs/Nyata-Mobuta_WW.lua
30
3056
----------------------------------- -- Area: Valkurm Dunes -- NPC: Nyata-Mobuta, W.W. -- Type: Outpost Conquest Guards -- @pos 139.394 -7.885 100.384 103 ----------------------------------- package.loaded["scripts/zones/Valkurm_Dunes/TextIDs"] = nil; ----------------------------------- require("scripts/globals/conquest"); require("scripts/zones/Valkurm_Dunes/TextIDs"); local guardnation = WINDURST; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno local guardtype = 3; -- 1: city, 2: foreign, 3: outpost, 4: border local region = ZULKHEIM; local csid = 0x7ff7; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) tradeConquestGuard(player,npc,trade,guardnation,guardtype); end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:hasKeyItem(getSupplyKey(region)) and player:getNation() == guardnation) then if (supplyRunFresh(player) == 1) then player:startEvent(csid,16,0,0,0,1,0,0,255); -- you have brought us supplies ! else player:showText(npc, CONQUEST - 1); -- "Hmm... These supplies you have brought us are too old to be of any use." player:delKeyItem(getSupplyKey(region)); player:messageSpecial(KEYITEM_OBTAINED + 1, getSupplyKey(region)); player:setVar("supplyQuest_region",0); end else local arg1 = getArg1(guardnation, player) - 1; if (arg1 >= 1792) then -- foreign, non-allied player:startEvent(csid,1808,0,0,0,0,player:getRank(),0,0); else -- citizen or allied player:startEvent(csid,arg1,0,0x3F0000,0,0,getArg6(player),0,0); end end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("OPTION: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("OPTION: %u",option); if (option == 1) then local duration = (player:getRank() + getNationRank(player:getNation()) + 3) * 3600; player:delStatusEffect(EFFECT_SIGIL); player:delStatusEffect(EFFECT_SANCTION); player:delStatusEffect(EFFECT_SIGNET); player:addStatusEffect(EFFECT_SIGNET,0,0,duration); -- Grant Signet elseif (option == 2) then player:delKeyItem(getSupplyKey(region)); player:addCP(supplyReward[region + 1]) player:messageSpecial(CONQUEST); -- "You've earned conquest points!" if (hasOutpost(player, region+5) == 0) then local supply_quests = 2^(region+5); player:addNationTeleport(guardnation,supply_quests); player:setVar("supplyQuest_region",0); end elseif (option == 4) then if (player:delGil(giltosetHP(guardnation,player))) then player:setHomePoint(); player:messageSpecial(CONQUEST + 94); -- "Your home point has been set." else player:messageSpecial(CONQUEST + 95); -- "You do not have enough gil to set your home point here." end end end;
gpl-3.0
davidedmonds/darkstar
scripts/globals/items/bowl_of_seafood_stew.lua
35
1467
----------------------------------------- -- ID: 4561 -- Item: Bowl of Seafood Stew -- Food Effect: 180Min, All Races ----------------------------------------- -- Health 20 -- Dexterity 1 -- Vitality 5 -- Defense % 25 -- Defense Cap 120 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,10800,4561); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_HP, 20); target:addMod(MOD_DEX, 1); target:addMod(MOD_VIT, 5); target:addMod(MOD_FOOD_DEFP, 25); target:addMod(MOD_FOOD_DEF_CAP, 120); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_HP, 20); target:delMod(MOD_DEX, 1); target:delMod(MOD_VIT, 5); target:delMod(MOD_FOOD_DEFP, 25); target:delMod(MOD_FOOD_DEF_CAP, 120); end;
gpl-3.0
waterlgndx/darkstar
scripts/globals/items/deep-fried_shrimp.lua
2
1493
----------------------------------------- -- ID: 6276 -- Item: deep-fried_shrimp -- Food Effect: 30Min, All Races ----------------------------------------- -- VIT +3 -- Fire resistance +20 -- Accuracy +20% (cap 70) -- Ranged Accuracy +20% (cap 70) -- Subtle Blow +8 ----------------------------------------- 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,1800,6276); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(dsp.mod.VIT, 3); target:addMod(dsp.mod.FIRERES, 20); target:addMod(dsp.mod.FOOD_ACCP, 20); target:addMod(dsp.mod.FOOD_ACC_CAP, 70); target:addMod(dsp.mod.FOOD_RACCP, 20); target:addMod(dsp.mod.FOOD_RACC_CAP, 70); target:addMod(dsp.mod.SUBTLE_BLOW, 8); end; function onEffectLose(target, effect) target:delMod(dsp.mod.VIT, 3); target:delMod(dsp.mod.FIRERES, 20); target:delMod(dsp.mod.FOOD_ACCP, 20); target:delMod(dsp.mod.FOOD_ACC_CAP, 70); target:delMod(dsp.mod.FOOD_RACCP, 20); target:delMod(dsp.mod.FOOD_RACC_CAP, 70); target:delMod(dsp.mod.SUBTLE_BLOW, 8); end;
gpl-3.0
davidedmonds/darkstar
scripts/zones/Kuftal_Tunnel/MobIDs.lua
36
2913
----------------------------------- -- Area: Kuftal Tunnel -- Comments: -- posX, posY, posZ --(Taken from 'mob_spawn_points' table) ----------------------------------- -- Amemet Amemet=17490016; Amemet_PH={ [17490000] = '1', -- 123.046, 0.250, 18.642 [17489994] = '1', -- 112.135, -0.278, 38.281 [17490001] = '1', -- 112.008, -0.530, 50.994 [17490003] = '1', -- 122.654, -0.491, 0.840 [17490008] = '1', -- 123.186, 0.213, -24.716 [17490005] = '1', -- 118.633, -0.470, -43.282 [17490010] = '1', -- 109.000, -0.010, -48.000 [17490004] = '1', -- 96.365, -0.269, -7.619 [17490002] = '1', -- 89.590, -0.321, -9.390 [17489933] = '1', -- 68.454, -0.417, -0.413 [17489932] = '1', -- 74.662, -0.513, 3.685 [17490009] = '1', -- 67.998, -0.500, 12.000 [17489934] = '1', -- 92.000, -0.396, 14.000 }; -- Arachne Arachne=17490217; Arachne_PH={ [17490222] = '1', -- 19.000, 20.000, 37.000 [17490221] = '1', -- -10.000, 20.000, 14.000 [17490219] = '1', -- -20.000, 20.000, 38.000 [17490220] = '1', -- -20.000, 21.000, 1.000 }; -- Bloodthirster Madkix Bloodthirster_Madkix=17490159; Bloodthirster_Madkix_PH={ [17490173] = '1', -- 265.000, 9.000, 30.000 [17490182] = '1', -- 256.000, 10.000, 34.000 }; -- Cancer Cancer=17490231; -- Pelican Pelican=17490101; Pelican_PH={ [17490097] = '1', -- 178.857, 20.256, -44.151 [17490094] = '1', -- 180.000, 21.000, -39.000 [17490098] = '1', -- 179.394, 20.061, -34.062 }; -- Dervo's Ghost Dervo_s_Ghost=17489927; -- Gizerl's Ghost Gizerl_s_Ghost=17489928; -- Gordov's Ghost Gordov_s_Ghost=17489926; -- Phantom Worm Phantom_Worm=17490233; -- Sabotender_Mariachi Sabotender_Mariachi=17489980; Sabotender_Mariachi_PH={ [17489987] = '1', -- -23.543, -0.396, 59.578 [17489983] = '1', -- -45.000, -0.115, 39.000 [17489985] = '1', -- -34.263, -0.512, 30.437 [17489984] = '1', -- -38.791, 0.230, 26.579 [17489977] = '1', -- -41.000, 0.088, -3.000 [17489978] = '1', -- -54.912, 0.347, -1.681 [17489979] = '1', -- -58.807, -0.327, -8.531 [17489981] = '1', -- -82.074, -0.450, -0.738 [17489982] = '1', -- -84.721, -0.325, -2.861 [17489974] = '1', -- -41.000, -0.488, -31.000 [17489975] = '1', -- -33.717, -0.448, -43.478 [17489971] = '1', -- -17.217, -0.956, -57.647 }; -- Yowie Yowie=17490204; Yowie_PH={ [17490175] = '1', -- 27.000, 19.000, 132.000 [17490174] = '1', -- 20.000, 20.000, 118.000 [17490168] = '1', -- 19.000, 18.000, 100.000 [17490167] = '1', -- 18.000, 21.000, 82.000 [17490161] = '1', -- 23.000, 20.000, 75.000 [17490176] = '1', -- 19.000, 19.000, 55.000 [17490160] = '1', -- 34.000, 21.000, 59.000 [17490146] = '1', -- 59.000, 21.000, 65.000 [17490148] = '1', -- 58.000, 21.000, 57.000 [17490144] = '1', -- 72.000, 21.000, 63.000 [17490141] = '1', -- 87.000, 21.000, 59.000 };
gpl-3.0
lhog/Zero-K
LuaUI/Widgets/api_win_counter.lua
8
10334
-- Standalone win counter designed to be used through WG. -- This will increment winner scores on game end on a per-player basis, and preserve them from game to game if the player's retain their allies. -- The actual allyTeam and player ids don't matter, just the player groups. -- If players on the same allyTeam are on different teams (i.e. all controlling the same units) between games, the scores will still be preserved, -- as the players in question are still working on the same side between games. function widget:GetInfo() return { name = "Win Counter", desc = "Local win counter, used with a playerlist", author = "Shadowfury333", date = "2014-08-30", license = "GNU GPL, v2 or later", layer = -1, api = true, alwaysStart = true, enabled = true, } --Declares WG.WinCounter_currentWinTable: Table, {string playerName, {"team" = number allyTeam, "wins" = number wins, "wonLastGame" = boolean won previous game}} -- | Table, {"hasWins = boolean somePlayerHasWins} -- WG.WinCounter_Increment: Function, (number allyTeam) -> nil, Increments win counter for selected allyTeam -- WG.WinCounter_Reset: Function, () -> nil, Resets the win count table -- WG.WinCounter_Set: Function, (string playerName | number playerID, number winCount, boolean forAllyTeam (, boolean wonLastGame)) -> nil, -- Sets win count for given player and optionally all players on their allyTeam end local lastWinTable = {} local currentWinTable = {} --NB: This is constructed with info for all non-spec players in the current game at game start local loadedFromConfig = false local function Set(player, winCount, forAllyTeam, wonLastGame) local name = "" if type(player) == "number" then name = Spring.GetPlayerInfo(player, false) elseif type(player) == "string" then name = player end if wonLastGame ~= nil then local allyTeams = Spring.GetAllyTeamList() for i=1, #allyTeams do local playerTeams = Spring.GetTeamList(allyTeams[i]) for j=1, #playerTeams do local players = Spring.GetPlayerList(playerTeams[j]) for k=1, #players do local playerName = Spring.GetPlayerInfo(players[k], false) if playerName ~= nil and currentWinTable[playerName] ~= nil then currentWinTable[playerName].wonLastGame = false end end end end end if type(winCount) == "number" and winCount >= 0 and name ~= nil and currentWinTable[name] ~= nil and type(currentWinTable[name]) == "table" then if forAllyTeam then local alliedTeams = Spring.GetTeamList(currentWinTable[name].allyTeam) for i=1, #alliedTeams do local players = Spring.GetPlayerList(alliedTeams[i]) for j=1, #players do local playerName = Spring.GetPlayerInfo(players[j], false) if currentWinTable[playerName] ~= nil then currentWinTable[playerName].wins = winCount if wonLastGame ~= nil then currentWinTable[playerName].wonLastGame = wonLastGame end end end end else currentWinTable[name].wins = winCount if wonLastGame ~= nil then currentWinTable[name].wonLastGame = wonLastGame end end if winCount > 0 then currentWinTable.hasWins = true else currentWinTable.hasWins = false for k,v in pairs(currentWinTable) do if type(v) == "table" then if v.wins > 0 then currentWinTable.hasWins = true; break end end end end WG.WinCounter_currentWinTable = currentWinTable --Set at end rather than modified throughout to remove contention risks end end local function IncrementAllyTeamWins(allyTeamNumber) --We need to figure out playerName to get current wins for allyTeam local playerName = nil playerTeams = Spring.GetTeamList(allyTeamNumber) if playerTeams ~= nil and #playerTeams >= 1 then players = Spring.GetPlayerList(playerTeams[1]) for i=1, #players do local name,_,isSpec = Spring.GetPlayerInfo(players[i], false) if not isSpec then playerName = name break end end end if playerName ~= nil and currentWinTable[playerName] ~= nil then local wins = currentWinTable[playerName].wins or 0 Set(playerName, wins + 1, true, true) end end local function Reset() Spring.Echo("Resetting win data") -- local players = Spring.GetPlayerList() local allyTeams = Spring.GetAllyTeamList() local allyTeamCount = 0 local playerCount = 0 currentWinTable = {} -- Spring.Echo("#allyTeams: "..#allyTeams) for i=1, #allyTeams do local playerTeams = Spring.GetTeamList(allyTeams[i]) -- Spring.Echo("#playerTeams on allyTeam "..allyTeams[i]..": "..#playerTeams) if #playerTeams > 0 then --Spring counts all startboxes as ally teams, even if they are not used by any players. allyTeamCount = allyTeamCount + 1 --This needs to be worked around, as maps may be set up with more startboxes than necessary. end for j=1, #playerTeams do -- Drill down to player level, in case there are multiple non-spec players on one team, they should all be noted local players = Spring.GetPlayerList(playerTeams[j]) -- Spring.Echo("#players on team "..playerTeams[j]..": "..#players) for k=1, #players do local name,_,isSpec = Spring.GetPlayerInfo(players[k], false) if playerTeams[j] ~= 0 or (playerTeams[j] == 0 and not isSpec) then --Logic taken from Deluxe Player List, though adapted to one line -- Spring.Echo("Resetting: "..name) playerCount = playerCount + 1 currentWinTable[name] = {allyTeam = allyTeams[i], wonLastGame = false, wins = 0} end end end end currentWinTable.count = playerCount currentWinTable.allyTeamCount = allyTeamCount currentWinTable.hasWins = false WG.WinCounter_currentWinTable = currentWinTable --Set at end rather than modified throughout to remove contention risks end function widget:Initialize() WG.WinCounter_Set = Set WG.WinCounter_Reset = Reset WG.WinCounter_Increment = IncrementAllyTeamWins if not loadedFromConfig then Reset() end end function widget:Shutdown() WG.WinCounter_Set = nil WG.WinCounter_Reset = nil WG.WinCounter_Increment = nil end function widget:GameOver(winningAllyTeams) -- Don't do anything if the game was exited if #winningAllyTeams == 0 then return end -- Reset who won last game local players = Spring.GetPlayerList() for i=1, #players do local playerName = Spring.GetPlayerInfo(players[i], false) if currentWinTable[playerName] ~= nil then currentWinTable[playerName].wonLastGame = false end end for i=1, #winningAllyTeams do local winningAllyTeam = winningAllyTeams[i] local winningPlayerTeams = Spring.GetTeamList(winningAllyTeam) for i=1, #winningPlayerTeams do local players = Spring.GetPlayerList(winningPlayerTeams[i]) for j=1, #players do local playerName = Spring.GetPlayerInfo(players[j], false) if currentWinTable[playerName] ~= nil then currentWinTable[playerName].wins = (currentWinTable[playerName].wins or 0) + 1 currentWinTable[playerName].wonLastGame = true end end end currentWinTable.hasWins = true WG.WinCounter_currentWinTable = currentWinTable --Set at end rather than modified throughout to remove contention risks end end function widget:GetConfigData() Spring.Echo("Writing last game win data") return currentWinTable end function widget:SetConfigData(data) loadedFromConfig = true local teamPlayerMatch = true Spring.Echo("Loading last game win data") lastWinTable = data Reset() --Pre-emptively resetting scores, in case last game and this game have different allyTeams Spring.Echo("Last game player count: "..(lastWinTable.count or 0)..", This game player count: "..currentWinTable.count ) Spring.Echo("Last game allyTeam count: "..(lastWinTable.allyTeamCount or 0)..", This game allyTeam count: "..currentWinTable.allyTeamCount ) --If the player or allyTeam count changed, or this widget has broken config data, reset scores if lastWinTable ~= nil and next(lastWinTable) ~= nil and lastWinTable.count == currentWinTable.count and lastWinTable.allyTeamCount == currentWinTable.allyTeamCount then Spring.Echo("Player and team counts match, continuing") --Table for verifying what allyTeams from last game map to this game, if all players remained the same. Assumes allyTeam and player counts remained the same local lastToCurrentTeamMap = {} for lastGamePlayerName,lastGameTeamAndWins in pairs(lastWinTable) do --Check if all players are still on the same allyTeams if type(lastGameTeamAndWins) == "table" then if currentWinTable[lastGamePlayerName] == nil then --If a player from last game isn't here, then allyTeams have changed. Reset scores Spring.Echo(lastGamePlayerName.." was in last game but is now absent, resetting scores") teamPlayerMatch = false break elseif lastGameTeamAndWins ~= nil then local lastGameTeam = lastGameTeamAndWins.allyTeam if lastToCurrentTeamMap[lastGameTeam] == nil then --If this player's allyTeam is not in the map, add it. Otherwise, check that the allyTeam map is consistent lastToCurrentTeamMap[lastGameTeam] = currentWinTable[lastGamePlayerName].allyTeam Spring.Echo("Testing last game's team "..lastGameTeam.." mapped to this game's team "..(currentWinTable[lastGamePlayerName].allyTeam)) elseif lastToCurrentTeamMap[lastGameTeam] ~= currentWinTable[lastGamePlayerName].allyTeam then Spring.Echo(lastGamePlayerName.." changed team since last game, resetting scores") teamPlayerMatch = false break --If a player from last game changed who their allyTeammates are, this check will fail. Reset scores end else Spring.Echo(lastGamePlayerName.." has no win record, this shouldn't happen") teamPlayerMatch = false break end end end if teamPlayerMatch then Spring.Echo("All players and teams match from last game, using last game's scores as base") for name,v in pairs(currentWinTable) do if type(v) == "table" then v.wins = lastWinTable[name].wins v.wonLastGame = lastWinTable[name].wonLastGame -- Spring.Echo(k.." has "..v.wins.." wins for team ", v.allyTeam) -- else -- Spring.Echo(k..": "..v) end currentWinTable.hasWins = lastWinTable.hasWins --This gets updated on GameOver end end end WG.WinCounter_currentWinTable = currentWinTable --Set at end rather than modified throughout to remove contention risks end
gpl-2.0
kidaa/darkstar
scripts/zones/Abyssea-Uleguerand/Zone.lua
32
1548
----------------------------------- -- -- Zone: Abyssea - Uleguerand -- ----------------------------------- package.loaded["scripts/zones/Abyssea-Uleguerand/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/quests"); require("scripts/zones/Abyssea-Uleguerand/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) local cs = -1; if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then player:setPos(-238, -40, -520.5, 0); end if (player:getQuestStatus(ABYSSEA, THE_TRUTH_BECKONS) == QUEST_ACCEPTED and player:getVar("1stTimeAyssea") == 0) then player:setVar("1stTimeAyssea",1); end return cs; end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
gpl-3.0
kidaa/darkstar
scripts/globals/spells/bluemagic/bad_breath.lua
9
3501
----------------------------------------- -- Spell: Bad Breath -- Deals earth damage that inflicts multiple status ailments on enemies within a fan-shaped area originating from the caster -- Spell cost: 212 MP -- Monster Type: Plantoids -- Spell Type: Magical (Earth) -- Blue Magic Points: 5 -- Stat Bonus: INT+2, MND+2 -- Level: 61 -- Casting Time: 8.75 seconds -- Recast Time: 120 seconds -- Magic Bursts on: Scission, Gravitation, Darkness -- Combos: Fast Cast ----------------------------------------- require("scripts/globals/magic"); require("scripts/globals/status"); require("scripts/globals/bluemagic"); ----------------------------------------- -- OnMagicCastingCheck ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; ----------------------------------------- -- OnSpellCast ----------------------------------------- function onSpellCast(caster,target,spell) local params = {}; -- This data should match information on http://wiki.ffxiclopedia.org/wiki/Calculating_Blue_Magic_Damage local multi = 2.08; if(caster:hasStatusEffect(EFFECT_AZURE_LORE)) then multi = multi + 0.50; end params.multiplier = multi; params.tMultiplier = 1.5; params.duppercap = 69; params.str_wsc = 0.0; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.3; params.chr_wsc = 0.0; damage = BlueMagicalSpell(caster, target, spell, params, MND_BASED); damage = BlueFinalAdjustments(caster, target, spell, damage, params); local resist = applyResistance(caster,spell,target,caster:getStat(MOD_INT) - target:getStat(MOD_INT),BLUE_SKILL,1.0); if(damage > 0 and resist > 0.3) then local typeEffect = EFFECT_PARALYSIS; target:delStatusEffect(typeEffect); target:addStatusEffect(typeEffect,25,0,getBlueEffectDuration(caster,resist,typeEffect)); end if(damage > 0 and resist > 0.3) then local typeEffect = EFFECT_WEIGHT; target:delStatusEffect(typeEffect); target:addStatusEffect(typeEffect,25,0,getBlueEffectDuration(caster,resist,typeEffect)); end if(damage > 0 and resist > 0.3) then local typeEffect = EFFECT_POISON; target:delStatusEffect(typeEffect); target:addStatusEffect(typeEffect,4,0,getBlueEffectDuration(caster,resist,typeEffect)); end if(damage > 0 and resist > 0.3) then local typeEffect = EFFECT_SLOW; target:delStatusEffect(typeEffect); target:addStatusEffect(typeEffect,25,0,getBlueEffectDuration(caster,resist,typeEffect)); end if(damage > 0 and resist > 0.3) then local typeEffect = EFFECT_SILENCE; target:delStatusEffect(typeEffect); target:addStatusEffect(typeEffect,25,0,getBlueEffectDuration(caster,resist,typeEffect)); end if(damage > 0 and resist > 0.3) then local typeEffect = EFFECT_BIND; target:delStatusEffect(typeEffect); target:addStatusEffect(typeEffect,1,0,getBlueEffectDuration(caster,resist,typeEffect)); end if(damage > 0 and resist > 0.3) then local typeEffect = EFFECT_BLINDNESS; target:delStatusEffect(typeEffect); target:addStatusEffect(typeEffect,25,0,getBlueEffectDuration(caster,resist,typeEffect)); end return damage; end;
gpl-3.0
davidedmonds/darkstar
scripts/globals/spells/dark_carol.lua
18
1502
----------------------------------------- -- Spell: Dark Carol -- Increases dark resistance for party members within the area of effect. ----------------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------------- -- 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 = 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(MOD_CAROL_EFFECT) + caster:getMod(MOD_ALL_SONGS_EFFECT); power = power + iBoost*5; 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_CAROL,power,0,duration,caster:getID(), ELE_DARK, 1)) then spell:setMsg(75); end return EFFECT_CAROL; end;
gpl-3.0
will4wachter/Project1
scripts/globals/items/crescent_fish.lua
17
1332
----------------------------------------- -- ID: 4473 -- Item: crescent_fish -- Food Effect: 5Min, Mithra only ----------------------------------------- -- Dexterity 3 -- Mind -5 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:getRace() ~= 7) then result = 247; end if(target:getMod(MOD_EAT_RAW_FISH) == 1) then result = 0; end if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,300,4473); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_DEX, 3); target:addMod(MOD_MND,-5); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_DEX, 3); target:delMod(MOD_MND,-5); end;
gpl-3.0
negati-ve/openshift-mediawiki
php/extensions/Scribunto/tests/engines/LuaStandalone/StandaloneTests.lua
9
1406
local testframework = require( 'Module:TestFramework' ) local function setfenv1() local ok, err = pcall( function() setfenv( 2, {} ) end ) if not ok then err = string.gsub( err, '^%S+:%d+: ', '' ) error( err ) end end local function getfenv1() local env pcall( function() env = getfenv( 2 ) end ) return env end return testframework.getTestProvider( { { name = 'setfenv on a C function', func = setfenv1, expect = "'setfenv' cannot set the requested environment, it is protected", }, { name = 'getfenv on a C function', func = getfenv1, expect = { nil }, }, { name = 'Invalid array key (table)', func = mw.var_export, args = { { [{}] = 1 } }, expect = 'Cannot use table as an array key when passing data from Lua to PHP', }, { name = 'Invalid array key (boolean)', func = mw.var_export, args = { { [true] = 1 } }, expect = 'Cannot use boolean as an array key when passing data from Lua to PHP', }, { name = 'Invalid array key (function)', func = mw.var_export, args = { { [tostring] = 1 } }, expect = 'Cannot use function as an array key when passing data from Lua to PHP', }, { name = 'Unusual array key (float)', func = mw.var_export, args = { { [1.5] = 1 } }, expect = { "array ( '1.5' => 1, )" } }, { name = 'Unusual array key (inf)', func = mw.var_export, args = { { [math.huge] = 1 } }, expect = { "array ( 'inf' => 1, )" } }, } )
gpl-2.0
will4wachter/Project1
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
dmzgroup/lmk
scripts/src/obj.lua
2
5343
require "lmkbuild" local append = lmkbuild.append_local local exec = lmkbuild.exec local file_newer = lmkbuild.file_newer local function gset (name, value) lmkbuild.set_global (name, value, true) end local lset = lmk.set_local local get_var = lmkbuild.get_var local ipairs = ipairs local is_valid = lmkbuild.is_valid local print = print local resolve = lmkbuild.resolve local rm = lmkbuild.rm local set = lmkbuild.set_local local sys = lmkbuild.system () local table = table if sys == "win32" then gset ("lmk.link", { "$(lmk.$(type).linker.$(lmk.buildMode))", "$(lmk.$(type).linkerFlags)", "$(lmk.$(lmk.buildMode).linkerFlags)", "$(localLibPaths)", "$(lmk.libPaths)", "$(localLibs)", "$(objList)", "$(lmk.$(type).extraFiles)", "/out:$(localBinTarget)", }) gset ("lmk.libPathFlag", "/LIBPATH:") gset ("lmk.libSuffix", ".lib") gset ("lmk.shared.prefix", "") gset ("lmk.shared.ext", ".dll") gset ("lmk.plugin.ext", ".dll") gset ("lmk.exe.ext", ".exe") local linker = "link.exe" local bclinker = "nmlink.exe bcinterf.lib" gset ("lmk.exe.linker.opt", linker) gset ("lmk.exe.linker.debug", linker) gset ("lmk.exe.linker.bc", bclinker) gset ("lmk.exe.linkerFlags", "/nologo") gset ("lmk.shared.linker.opt", linker) gset ("lmk.shared.linker.debug", linker) gset ("lmk.shared.linker.bc", bclinker) gset ("lmk.shared.linkerFlags", "/nologo /DLL") gset ("lmk.shared.extraFiles", "/IMPLIB:$(lmk.libDir)$(name)$(lmk.libSuffix)") gset ("lmk.plugin.linker.opt", linker) gset ("lmk.plugin.linker.debug", linker) gset ("lmk.plugin.linker.bc", bclinker) gset ("lmk.plugin.linkerFlags", "/nologo /DLL") gset ("lmk.debug.linkerFlags", "/DEBUG /INCREMENTAL:no /FIXED:no") gset ("lmk.bc.linkerFlags", "/DEBUG /INCREMENTAL:no /FIXED:no") gset ("lmk.bc.testExec", "bc.exe /NOLOGO /W $(localPwd) ") else -- unix gset ("lmk.link", { "$(lmk.$(type).linker)", "$(lmk.$(type).linkerFlags)", "$(localLibPaths)", "$(lmk.libPaths)", "$(localLibs)", "$(objList)", "-o $(localBinTarget)", }) gset ("lmk.libPathFlag", "-L") gset ("lmk.libPrefix", "-l") gset ("lmk.shared.prefix", "lib") gset ("lmk.shared.ext", ".so") gset ("lmk.plugin.ext", ".plugin") if sys == "macos" then local linker = "g++ -m32 -header_pad_max_install_names" --if is_valid ("/usr/bin/llvm-g++") then linker = "llvm-" .. linker end local outFlag = "-o " gset ("lmk.exe.linker", linker) gset ("lmk.shared.linker", linker) gset ( "lmk.shared.linkerFlags", "-dynamiclib " .. "-install_name @executable_path/../Frameworks/$(localBinName)") gset ("lmk.shared.ext", ".dylib") gset ("lmk.plugin.linker", linker) gset ("lmk.plugin.linkerFlags", "-bundle") elseif sys == "linux" then local linker = "g++" local outFlag = "-o " gset ("lmk.exe.linker", linker) gset ("lmk.shared.linker", linker) gset ( "lmk.shared.linkerFlags", "-shared -Xlinker -E -Xlinker -rpath-link -Xlinker $(lmk.binDir)") gset ("lmk.plugin.linker", linker) gset ( "lmk.plugin.linkerFlags", "-shared -Xlinker -E -Xlinker -rpath-link -Xlinker $(lmk.binDir)") gset ( "lmk.exe.linkerFlags", "-Xlinker -rpath-link -Xlinker $(lmk.binDir)") end end module (...) function main (files) local binName = resolve ("$(lmk.$(type).prefix)$(name)$(lmk.$(type).ext)") set ("localBinName", binName) local binTarget = resolve ("$(lmk.binDir)" .. binName) set ("localBinTarget", binTarget) local build = false if not is_valid (binTarget) then build = true else local objFiles = {} local tmpDir = resolve "$(localTmpDir)" for index, item in ipairs (files) do objFiles[index] = tmpDir .. item end if file_newer (objFiles, binTarget) then build = true end end if build then if sys == "win32" then append ("localLibPaths", "$(lmk.libPathFlag)$(localTmpDir)") set ("objList", files) else local objList = {} for ix, item in ipairs (files) do objList[#objList + 1] = "$(localTmpDir)" .. item end set ("objList", objList) end local libs = get_var ("libs") if libs then local libList = {} for index, item in ipairs (libs) do libList[index] = "$(lmk.libPrefix)" .. item .. "$(lmk.libSuffix)" end append ("localLibs", libList) end exec ("$(lmk.link)") if (sys == "win32") and is_valid (binTarget .. ".manifest") then local mt = "mt.exe -nologo -manifest " .. binTarget .. ".manifest -outputresource:" .. binTarget .. ";" if resolve ("$(type)") == "exe" then mt = mt .. "1" else mt = mt .. "2" end exec (mt) end end end function test (files) main (files) local testDefined = resolve ("$(test)") if testDefined ~= "" then exec ("$(lmk.$(lmk.buildMode).testExec)$(test)") end end function clobber (files) local binTarget = resolve ("$(lmk.binDir)$(lmk.$(type).prefix)$(name)$(lmk.$(type).ext)") rm (binTarget) -- will need to remove windows specific files here end
mit
davidedmonds/darkstar
scripts/globals/items/plate_of_royal_sautee.lua
35
1749
----------------------------------------- -- ID: 4295 -- Item: plate_of_royal_sautee -- Food Effect: 240Min, All Races ----------------------------------------- -- Strength 5 -- Agility 1 -- Intelligence -2 -- Attack % 20 -- Attack Cap 80 -- Ranged ATT % 20 -- Ranged ATT Cap 80 -- Stun Resist 5 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,14400,4295); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_STR, 5); target:addMod(MOD_AGI, 1); target:addMod(MOD_INT, -2); target:addMod(MOD_FOOD_ATTP, 20); target:addMod(MOD_FOOD_ATT_CAP, 80); target:addMod(MOD_FOOD_RATTP, 20); target:addMod(MOD_FOOD_RATT_CAP, 80); target:addMod(MOD_STUNRES, 5); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_STR, 5); target:delMod(MOD_AGI, 1); target:delMod(MOD_INT, -2); target:delMod(MOD_FOOD_ATTP, 20); target:delMod(MOD_FOOD_ATT_CAP, 80); target:delMod(MOD_FOOD_RATTP, 20); target:delMod(MOD_FOOD_RATT_CAP, 80); target:delMod(MOD_STUNRES, 5); end;
gpl-3.0
will4wachter/Project1
scripts/globals/items/plate_of_royal_sautee.lua
35
1749
----------------------------------------- -- ID: 4295 -- Item: plate_of_royal_sautee -- Food Effect: 240Min, All Races ----------------------------------------- -- Strength 5 -- Agility 1 -- Intelligence -2 -- Attack % 20 -- Attack Cap 80 -- Ranged ATT % 20 -- Ranged ATT Cap 80 -- Stun Resist 5 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,14400,4295); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_STR, 5); target:addMod(MOD_AGI, 1); target:addMod(MOD_INT, -2); target:addMod(MOD_FOOD_ATTP, 20); target:addMod(MOD_FOOD_ATT_CAP, 80); target:addMod(MOD_FOOD_RATTP, 20); target:addMod(MOD_FOOD_RATT_CAP, 80); target:addMod(MOD_STUNRES, 5); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_STR, 5); target:delMod(MOD_AGI, 1); target:delMod(MOD_INT, -2); target:delMod(MOD_FOOD_ATTP, 20); target:delMod(MOD_FOOD_ATT_CAP, 80); target:delMod(MOD_FOOD_RATTP, 20); target:delMod(MOD_FOOD_RATT_CAP, 80); target:delMod(MOD_STUNRES, 5); end;
gpl-3.0
davidedmonds/darkstar
scripts/zones/Temenos/mobs/Beli.lua
16
1188
----------------------------------- -- Area: Temenos N T -- NPC: Beli ----------------------------------- package.loaded["scripts/zones/Temenos/TextIDs"] = nil; ----------------------------------- require("scripts/globals/limbus"); require("scripts/zones/Temenos/TextIDs"); ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) end; ----------------------------------- -- onMobEngaged ----------------------------------- function onMobEngaged(mob,target) GetMobByID(16928781):updateEnmity(target); GetMobByID(16928782):updateEnmity(target); end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob,killer) if (IsMobDead(16928781)==true and IsMobDead(16928782)==true and IsMobDead(16928783)==true ) then GetNPCByID(16928768+19):setPos(200,-82,495); GetNPCByID(16928768+19):setStatus(STATUS_NORMAL); GetNPCByID(16928768+153):setPos(206,-82,495); GetNPCByID(16928768+153):setStatus(STATUS_NORMAL); GetNPCByID(16928768+210):setPos(196,-82,495); GetNPCByID(16928768+210):setStatus(STATUS_NORMAL); end end;
gpl-3.0
MonokuroInzanaito/ygopro-777DIY
expansions/script/c114001133.lua
1
2950
--★魔法少女ファンキーコニー function c114001133.initial_effect(c) --special summon local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_SPSUMMON_PROC) e1:SetProperty(EFFECT_FLAG_UNCOPYABLE) e1:SetRange(LOCATION_HAND) e1:SetCondition(c114001133.spcon) e1:SetOperation(c114001133.spop) c:RegisterEffect(e1) --spsummon local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_TO_GRAVE) e2:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e2:SetCountLimit(1,114001133) e2:SetTarget(c114001133.sptg2) e2:SetOperation(c114001133.spop2) c:RegisterEffect(e2) end function c114001133.spfilter(c) return c:IsType(TYPE_MONSTER) and ( c:IsSetCard(0x223) or c:IsSetCard(0x224) or c:IsSetCard(0xcabb) or c:IsCode(36405256) or c:IsCode(54360049) or c:IsCode(37160778) or c:IsCode(27491571) or c:IsCode(80741828) or c:IsCode(90330453) --0x223 or c:IsCode(32751480) or c:IsCode(78010363) or c:IsCode(39432962) or c:IsCode(67511500) or c:IsCode(62379337) or c:IsCode(23087070) or c:IsCode(17720747) or c:IsCode(98358303) or c:IsCode(91584698) ) --0x224 end function c114001133.spcon(e,c) if c==nil then return true end local tp=c:GetControler() return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c114001133.spfilter,tp,LOCATION_HAND,0,1,c) end function c114001133.spop(e,tp,eg,ep,ev,re,r,rp,c) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DISCARD) local g=Duel.SelectMatchingCard(tp,c114001133.spfilter,tp,LOCATION_HAND,0,1,1,c) Duel.SendtoGrave(g,REASON_COST+REASON_DISCARD) end function c114001133.spfilter2(c,e,tp) return c:IsCanBeSpecialSummoned(e,0,tp,false,false) and not c:IsCode(114001133) and c:IsLevelBelow(6) and ( c:IsSetCard(0x223) or c:IsSetCard(0x224) or c:IsSetCard(0xcabb) or c:IsCode(36405256) or c:IsCode(54360049) or c:IsCode(37160778) or c:IsCode(27491571) or c:IsCode(80741828) or c:IsCode(90330453) --0x223 or c:IsCode(32751480) or c:IsCode(78010363) or c:IsCode(39432962) or c:IsCode(67511500) or c:IsCode(62379337) or c:IsCode(23087070) or c:IsCode(17720747) or c:IsCode(98358303) or c:IsCode(91584698) ) --0x224 end function c114001133.sptg2(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c114001133.spfilter2(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingTarget(c114001133.spfilter2,tp,LOCATION_GRAVE,0,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectTarget(tp,c114001133.spfilter2,tp,LOCATION_GRAVE,0,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0) end function c114001133.spop2(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.SpecialSummon(tc,206,tp,tp,false,false,POS_FACEUP) end end
gpl-3.0
ii02ii/Dev_Saqt
plugins/leave.lua
1
1827
--[[ ▀▄ ▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀ ▀▄ ▄▀ ▀▄ ▄▀ ▀▄ ▄▀ BY Memo ▀▄ ▄▀ ▀▄ ▄▀ BY Memo (@ii02iI) ▀▄ ▄▀ ▀▄ ▄▀ Making the file by Memo ▀▄ ▄▀ ▀▄ ▄▀ kikebot : طرد البوت ▀▄ ▄▀ ▀▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀ --]] do -- هل ملف شغلة يطرد البوت اذا ضافوه غير المطورين local function Ch_Dev(msg, Mushakil) local bot_id = our_id local receiver = get_receiver(msg) if Mushakil[1] == 'طرد البوت' and is_admin1(msg) then chat_del_user("chat#id"..msg.to.id, 'user#id'..bot_id, ok_cb, false) leave_channel(receiver, ok_cb, false) elseif msg.service and msg.action.type == "chat_add_user" and msg.action.user.id == tonumber(bot_id) and not is_admin1(msg) then send_large_msg(receiver, 'حہۧبہيہۧبہہۧيے 🌞✨ \n مہۧآحہۧتہۧرمكہۧ لہۧتہضہۧيہفہۧنہيے بہۧعہۧد 🌚😹 \n آلہۧمہۧطہۧور 🌚🍷 \n @ii02ii \n بہۧوتہ آلہۧتہۧوآصہۧل 🐸🍷 \n @ii02ii_bot \n قہۧنہۧآہۧ آلہۧمہۧطہۧور 🙃🚶🏻 \n خاصة للي يريد يصير مطور 🌞✨ \n #Ch_Dev ', ok_cb, false) chat_del_user(receiver, 'user#id'..bot_id, ok_cb, false) leave_channel(receiver, ok_cb, false) end end return { patterns = { "^(طرد البوت)$", "^!!tgservice (.+)$", }, run = Ch_Dev } end
gpl-2.0
waterlgndx/darkstar
scripts/globals/items/serving_of_icecap_rolanberry.lua
2
1081
----------------------------------------- -- ID: 4556 -- Item: serving_of_icecap_rolanberry -- Food Effect: 180Min, All Races ----------------------------------------- -- Magic % 19 -- Magic Cap 55 -- Intelligence 2 -- Wind Res 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,4556); end; function onEffectGain(target, effect) target:addMod(dsp.mod.FOOD_MPP, 19); target:addMod(dsp.mod.FOOD_MP_CAP, 55); target:addMod(dsp.mod.INT, 2); target:addMod(dsp.mod.WINDRES, 5); end; function onEffectLose(target, effect) target:delMod(dsp.mod.FOOD_MPP, 19); target:delMod(dsp.mod.FOOD_MP_CAP, 55); target:delMod(dsp.mod.INT, 2); target:delMod(dsp.mod.WINDRES, 5); end;
gpl-3.0
ryanli/vlc
share/lua/playlist/mpora.lua
97
2565
--[[ $Id$ Copyright © 2009 the VideoLAN team Authors: Konstantin Pavlov (thresh@videolan.org) 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. --]] -- Probe function. function probe() return vlc.access == "http" and string.match( vlc.path, "video%.mpora%.com/watch/" ) end -- Parse function. function parse() p = {} while true do -- Try to find the video's title line = vlc.readline() if not line then break end if string.match( line, "meta name=\"title\"" ) then _,_,name = string.find( line, "content=\"(.*)\" />" ) end if string.match( line, "image_src" ) then _,_,arturl = string.find( line, "image_src\" href=\"(.*)\" />" ) end if string.match( line, "video_src" ) then _,_,video = string.find( line, 'href="http://video%.mpora%.com/ep/(.*)%.swf" />' ) end end if not name or not arturl or not video then return nil end -- Try and get URL for SD video. sd = vlc.stream("http://api.mpora.com/tv/player/playlist/vid/"..video.."/") if not sd then return nil end page = sd:read( 65653 ) sdurl = string.match( page, "url=\"(.*)\" />") page = nil table.insert( p, { path = sdurl; name = name; arturl = arturl; } ) -- Try and check if HD video is available. checkhd = vlc.stream("http://api.mpora.com/tv/player/load/vid/"..video.."/platform/video/domain/video.mpora.com/" ) if not checkhd then return nil end page = checkhd:read( 65653 ) hashd = tonumber( string.match( page, "<has_hd>(%d)</has_hd>" ) ) page = nil if hashd then hd = vlc.stream("http://api.mpora.com/tv/player/playlist/vid/"..video.."/hd/true/") page = hd:read( 65653 ) hdurl = string.match( page, "url=\"(.*)\" />") table.insert( p, { path = hdurl; name = name.." (HD)"; arturl = arturl; } ) end return p end
gpl-2.0
will4wachter/Project1
scripts/zones/Port_Bastok/npcs/Romilda.lua
36
2365
----------------------------------- -- Area: Port Bastok -- NPC: Romilda -- Involved in Quest: Forever to Hold -- Starts & Ends Quest: Till Death Do Us Part ----------------------------------- package.loaded["scripts/zones/Port_Bastok/TextIDs"] = nil; ----------------------------------- require("scripts/globals/titles"); require("scripts/globals/quests"); require("scripts/zones/Port_Bastok/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if (trade:hasItemQty(12497,1) and trade:getItemCount() == 1) then -- Trade Brass Hairpin if (player:getVar("ForevertoHold_Event") == 2) then player:tradeComplete(); player:startEvent(0x7D); player:setVar("ForevertoHold_Event",3); end elseif (trade:hasItemQty(12721,1) and trade:getItemCount() == 1) then -- Trade Cotton Gloves if (player:getVar("ForevertoHold_Event") == 3) then player:tradeComplete(); player:startEvent(0x81); player:setVar("ForevertoHold_Event",4); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) pFame = player:getFameLevel(BASTOK); ForevertoHold = player:getQuestStatus(BASTOK,FOREVER_TO_HOLD); TilldeathdousPart = player:getQuestStatus(BASTOK,TILL_DEATH_DO_US_PART); if (pFame >= 3 and ForevertoHold == QUEST_COMPLETED and TilldeathdousPart == QUEST_AVAILABLE and player:getVar("ForevertoHold_Event") == 3) then player:startEvent(0x80); else player:startEvent(0x22); 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 == 0x80) then player:addQuest(BASTOK,TILL_DEATH_DO_US_PART); elseif (csid == 0x81) then player:addTitle(QIJIS_RIVAL); player:addGil(GIL_RATE*2000); player:messageSpecial(GIL_OBTAINED,GIL_RATE*2000); player:addFame(BASTOK,BAS_FAME*160); player:completeQuest(BASTOK,TILL_DEATH_DO_US_PART); end end;
gpl-3.0
lhog/Zero-K
scripts/vehscout.lua
2
2891
include "constants.lua" local base, body, turret, gun, barrel, bwheel, fwheel, firepoint = piece('base', 'body', 'turret', 'gun', 'barrel', 'bwheel', 'fwheel', 'firepoint') -- tweakables local AIM_SPEED = math.rad(200) local LEAN_SPEED = math.rad(100) local LEAN_MAX = math.rad(50) local LEAN_UPDATE_RATE = 2 -- frames -- derivatives local WHEEL_SPIN_SPEED, WHEEL_SPIN_ACCEL, WHEEL_SPIN_DECEL, LEAN_PER_HEADING_UNIT, SLEEP_TIME do local ud = UnitDefs[unitDefID] local speedInFrames = ud.speed / Game.gameSpeed local WHEEL_DIAMETER = 12.4 -- measured WHEEL_SPIN_SPEED = ud.speed / (WHEEL_DIAMETER * math.pi) WHEEL_SPIN_ACCEL = WHEEL_SPIN_SPEED * ud.maxAcc / speedInFrames WHEEL_SPIN_DECEL = WHEEL_SPIN_SPEED * ud.maxDec / speedInFrames LEAN_PER_HEADING_UNIT = LEAN_MAX / (ud.turnRate * LEAN_UPDATE_RATE) SLEEP_TIME = (1000 * LEAN_UPDATE_RATE) / Game.gameSpeed end local SIG_MOVE = 1 local SIG_AIM = 2 local spGetUnitHeading = Spring.GetUnitHeading local function Lean() SetSignalMask (SIG_MOVE) local lastHeading = spGetUnitHeading (unitID) while true do local currHeading = spGetUnitHeading (unitID) local diffHeading = lastHeading - currHeading if diffHeading >= 32768 then diffHeading = diffHeading - 65536 end if diffHeading < -32768 then diffHeading = diffHeading + 65536 end lastHeading = currHeading local leanAngle = diffHeading * LEAN_PER_HEADING_UNIT Turn (body, z_axis, leanAngle, LEAN_SPEED) Sleep (SLEEP_TIME) end end function script.StartMoving() Signal (SIG_MOVE) Spin (fwheel, x_axis, WHEEL_SPIN_SPEED, WHEEL_SPIN_ACCEL) Spin (bwheel, x_axis, WHEEL_SPIN_SPEED, WHEEL_SPIN_ACCEL) StartThread (Lean) end function script.StopMoving() Signal (SIG_MOVE) StopSpin (fwheel, x_axis, WHEEL_SPIN_DECEL) StopSpin (bwheel, x_axis, WHEEL_SPIN_DECEL) Turn (body, z_axis, 0, LEAN_SPEED) end function script.Create() StartThread(GG.Script.SmokeUnit, unitID, {bwheel, fwheel}) end local function RestoreAfterDelay() Sleep (5000) Turn (turret, y_axis, 0, math.rad(10)) Turn (gun, x_axis, 0, math.rad(10)) end function script.AimWeapon(num, heading, pitch) Signal (SIG_AIM) SetSignalMask (SIG_AIM) Turn (turret, y_axis, heading, AIM_SPEED) Turn (gun, x_axis, -pitch, AIM_SPEED) WaitForTurn (turret, y_axis) WaitForTurn (gun, x_axis) StartThread (RestoreAfterDelay) return true end function script.AimFromWeapon(num) return turret end function script.QueryWeapon(num) return firepoint end local explodables = {barrel, bwheel, fwheel, turret, gun} function script.Killed(recentDamage, maxHealth) local severity = recentDamage / maxHealth local brutal = (severity > 0.5) for i = 1, #explodables do if math.random() < severity then Explode (explodables[i], SFX.FALL + (brutal and (SFX.SMOKE + SFX.FIRE) or 0)) end end if not brutal then return 1 else Explode (base, SFX.SHATTER) return 2 end end
gpl-2.0
davidedmonds/darkstar
scripts/zones/Monarch_Linn/npcs/Spatial_Displacement.lua
19
2455
----------------------------------- -- Area: Monarch_Linn -- NPC: Spatial Displacement -- @pos -35 -1 -539 31 ----------------------------------- package.loaded["scripts/zones/Monarch_LinnTextIDs"] = nil; ----------------------------------- require("scripts/globals/bcnm"); require("scripts/globals/quests"); require("scripts/globals/missions"); require("scripts/zones/Monarch_Linn/TextIDs"); ----------------------------------- -- onTrade ----------------------------------- function onTrade(player,npc,trade) if (TradeBCNM(player,player:getZoneID(),trade,npc)) then return; end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) --printf("npcID : %u",npcID); local npcID = npc:getID(); local X = player:getXPos(); local Z = player:getZPos(); if (X > 12.934 and X < 24.934) then if (player:getPreviousZone() == 30) then player:startEvent(0x0B); -- To Riv Site A elseif (player:getPreviousZone() == 29) then player:startEvent(0x0A); -- To Riv Site B end elseif ((X > -524.521 and X < -512.521) or (X > 75.524 and X < 87.524) or (X > 675.271 and X < 687.271)) then player:startEvent(0x7d03); -- leave the battlefield elseif (X > -25.684 and X < -13.684) then -- post-battlefield exit player:startEvent(0x0007); elseif (EventTriggerBCNM(player,npc)) then -- enter the battlefield return 1; else player:messageSpecial(GLOWING_MIST); -- needs confirmation end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("onUpdate CSID: %u",csid); --printf("onUpdate RESULT: %u",option); if (EventUpdateBCNM(player,csid,option)) then return; end end; ----------------------------------- -- onEventFinish Action ----------------------------------- function onEventFinish(player,csid,option) --printf("onFinish CSID: %u",csid); --printf("onFinish RESULT: %u",option); if (csid == 0x0B and option == 1) then player:setPos(-508.582,-8.471,-387.670,92,30); -- To Riv Site A (Retail confirmed) elseif (csid == 0x0A and option == 1) then player:setPos(-533.690,-20.5,503.656,224,29); -- To Riv Site B (Retail confirmed) elseif (csid == 0x0007 and option ==1) then player:setPos(-538.526,-29.5,359.219,255,25); -- back to Misareaux Coast (Retail confirmed) elseif (EventFinishBCNM(player,csid,option)) then return; end end;
gpl-3.0
lhog/Zero-K
LuaUI/Configs/lupsFXs.lua
6
14395
VFS.Include("LuaRules/Utilities/tablefunctions.lua") ---------------------------------------------------------------------------- -- GROUNDFLASHES ----------------------------------------------------------- ---------------------------------------------------------------------------- groundFlash = { life = 40, size = 30, sizeGrowth = 7, colormap = { {1, 1, 0.5, 0.3},{1, 1, 0, 0.04},{1, 0.3, 0, 0} } } groundFlashRed = { life = 20, size = 100, texture = "bitmaps/GPL/Lups/groundflash.png", colormap = { {1, 0.2, 0.2, 0.3},{1, 0.2, 0.2, 0.4},{1, 0.2, 0.2, 0.4},{1, 0.2, 0.2, 0.3}, }, repeatEffect = true, } groundFlashOrange = { life = 20, size = 100, texture = "bitmaps/GPL/Lups/groundflash.png", colormap = { {0.85, 0.5, 0.25, 0.3},{0.85, 0.5, 0.25, 0.4},{0.85, 0.5, 0.25, 0.4},{0.85, 0.5, 0.25, 0.3}, }, repeatEffect = true, quality = 1, -- Low } groundFlashGreen = { life = 20, size = 100, texture = "bitmaps/GPL/Lups/groundflash.png", colormap = { {0.3, 1.0, 0.3, 0.3},{0.3, 1.0, 0.3, 0.4},{0.3, 1.0, 0.3, 0.4},{0.3, 1.0, 0.3, 0.3}, }, repeatEffect = true, } groundFlashBlue = { life = 20, size = 100, texture = "bitmaps/GPL/Lups/groundflash.png", colormap = { {0.5, 0.5, 1.0, 0.3},{0.5, 0.5, 1.0, 0.4},{0.5, 0.5, 1.0, 0.4},{0.5, 0.5, 1.0, 0.3}, }, repeatEffect = true, } groundFlashViolet = { life = 50, size = 80, texture = "bitmaps/GPL/Lups/groundflash.png", colormap = { {0.9, 0.1, 0.9, 0.1},{0.9, 0.1, 0.9, 0.2},{0.9, 0.1, 0.9, 0.2},{0.9, 0.1, 0.9, 0.1}, }, repeatEffect = true, } groundFlashShield = { life = 50, size = 360, texture = "bitmaps/GPL/Lups/groundringBW.png", colormap = { {0.9, 0.1, 0.9, 0.2},{0.9, 0.1, 0.9, 0.3},{0.9, 0.1, 0.9, 0.2},{0.9, 0.1, 0.9, 0.2}, }, repeatEffect = true, } groundFlashenergypylon = { life = 50, size = 80, texture = "bitmaps/GPL/Lups/gf_energypylon.png", colormap = { {0.9, 0.9, 0.0, 0.2},{0.9, 0.9, 0.0, 0.3},{0.9, 0.9, 0.0, 0.3},{0.9, 0.9, 0.0, 0.2}, }, repeatEffect = true, quality = 1, -- Low } ---------------------------------------------------------------------------- -- BURSTS ------------------------------------------------------------------ ---------------------------------------------------------------------------- energysinguBursts = { life = math.huge, pos = {0,58,-5}, rotSpeed = 0.5, rotSpread = 1, arc = 90, arcSpread = 0, size = 35, sizeSpread = 10, colormap = { {1.0, 0.7, 0.5, 0.3} }, directional= true, repeatEffect = true, noIconDraw = true, count = 20, quality = 4, -- Ultra settings } staticshieldBursts = { layer = -35, life = math.huge, piece = "glow", rotSpeed = 0.7, rotSpread = 0, arc = 50, arcSpread = 0, size = 14, sizeSpread = 10, texture = "bitmaps/GPL/Lups/shieldbursts5.png", --colormap = { {1, 0.6, 1, 0.8} }, colormap = { {1, 0.3, 1, 0.8} }, directional= true, repeatEffect = true, noIconDraw = true, count = 8, quality = 3, -- High } staticshieldBall = { piece = "glow", life = math.huge, size = 11, colormap1 = {{0.95, 0.1, 0.95, 0.9}}, repeatEffect = true, noIconDraw = true, quality = 3, -- High } staticshieldBurstsBig = { layer = -35, life = math.huge, piece = "glow", rotSpeed = 0.7, rotSpread = 0, arc = 50, arcSpread = 0, size = 22, sizeSpread = 10, texture = "bitmaps/GPL/Lups/shieldbursts5.png", --colormap = { {1, 0.6, 1, 0.8} }, colormap = { {1, 0.3, 1, 0.8} }, directional= true, repeatEffect = true, noIconDraw = true, count = 8, quality = 3, -- High } ---------------------------------------------------------------------------- -- COLORSPHERES ------------------------------------------------------------ ---------------------------------------------------------------------------- energysinguShieldSphere = { layer=-35, life=20, pos={0,58.9,-4.5}, size=24, colormap1 = { {0.9, 0.9, 1, 0.75},{0.9, 0.9, 1, 1.0},{0.9, 0.9, 1, 1.0},{0.9, 0.9, 1, 0.75} }, colormap2 = { {0.2, 0.2, 1, 0.7},{0.2, 0.2, 1, 0.75},{0.2, 0.2, 1, 0.75},{0.2, 0.2, 1, 0.7} }, repeatEffect=true, quality = 2, -- Medium } corfusShieldSphere = { layer=-35, life=20, pos={0,40.5,0}, size=21.5, colormap1 = { {0.9, 0.9, 1, 0.75},{0.9, 0.9, 1, 1.0},{0.9, 0.9, 1, 1.0},{0.9, 0.9, 1, 0.75} }, colormap2 = { {0.05, 0.35, .44, 0.7},{0.05, 0.35, .44, 0.75},{0.05, 0.35, .44, 0.75},{0.05, 0.35, .44, 0.7} }, repeatEffect=true } teleShieldSphere = { life=20, pos={0,0,0}, size=9, colormap1 = { {0.9, 0.9, 1, 0.75},{0.9, 0.9, 1, 1.0},{0.9, 0.9, 1, 1.0},{0.9, 0.9, 1, 0.75} }, colormap2 = { {0.2, 0.2, 1, 0.7},{0.2, 0.2, 1, 0.75},{0.2, 0.2, 1, 0.75},{0.2, 0.2, 1, 0.7} }, repeatEffect=true, noIconDraw = true, quality = 3, -- High } throwShieldSphere = { life=20, pos={0,0,0}, size=9, colormap1 = { {0.9, 1, 0.9, 0.75},{0.9, 1, 0.9, 1.0}, {0.9, 1, 0.9, 1.0}, {0.9, 1, 0.9, 0.75} }, colormap2 = { {0.2, 1, 0.2, 0.7 },{0.2, 1, 0.2, 0.75},{0.2, 1, 0.2, 0.75},{0.2, 1, 0.2, 0.7} }, repeatEffect=true, noIconDraw = true, quality = 3, -- High } throwCorona = { pos = {0,0,0}, life = math.huge, lifeSpread = 0, size = 35, sizeGrowth = 0, colormap = { {0, 0.75, 0.15, 0.01} }, texture = 'bitmaps/GPL/groundflash.tga', count = 1, quality = 1, -- Low repeatEffect = true, noIconDraw = true, } valkShieldSphere = { life=20, pos={0,0,0}, size=4, colormap1 = { {0.9, 0.9, 1, 0.75},{0.9, 0.9, 1, 1.0},{0.9, 0.9, 1, 1.0},{0.9, 0.9, 1, 0.75} }, colormap2 = { {0.2, 0.2, 1, 0.7},{0.2, 0.2, 1, 0.75},{0.2, 0.2, 1, 0.75},{0.2, 0.2, 1, 0.7} }, repeatEffect=true, noIconDraw = true, quality = 3, -- High } commandShieldSphere = { life = math.huge, heightFactor = 0.75, radiusFactor = 1.75, repeatEffect = true, } shieldBursts350 = { layer = -35, life = math.huge, piece = "base", rotSpeed = 0.50, rotSpread = 0, arc = 50, arcSpread = 0, size = 325, radius = 300, sizeSpread = 50, texture = "bitmaps/GPL/Lups/shieldbursts5.png", --colormap = { {1, 0.6, 1, 0.8} }, colormap = { {1, 1, 1, 0.1} }, directional= true, repeatEffect = true, count = 10, } ---------------------------------------------------------------------------- -- LIGHT ------------------------------------------------------------------- ---------------------------------------------------------------------------- energysinguCorona = { pos = {0,66,0}, life = math.huge, lifeSpread = 0, size = 110, sizeGrowth = 0, --colormap = { {0.7, 0.6, 0.5, 0.01} }, colormap = { {0.9, 0.4, 0.2, 0.01} }, texture = 'bitmaps/GPL/groundflash.tga', count = 1, repeatEffect = true, } radarBlink = { piece = "head_3", onActive = true, pos = {0.5,31,1.2}, life = 120, size = 5, sizeGrowth = 2, colormap = { {0.3, 1, 1, 0.005}, {0, 0, 0, 0.005},{0, 0, 0, 0.005},{0, 0, 0, 0.005},{0, 0, 0, 0.005},{0, 0, 0, 0.005},{0, 0, 0, 0.005},{0, 0, 0, 0.005},{0, 0, 0, 0.005},{0, 0, 0, 0.005},{0, 0, 0, 0.005},{0, 0, 0, 0.005} }, texture = 'bitmaps/GPL/smallflare.tga', count = 1, quality = 1, -- Low repeatEffect= true, noIconDraw = true, } warpgateCorona = { pos = {0,58.9,0}, life = math.huge, lifeSpread = 0, size = 210, sizeGrowth = 0, --colormap = { {0.7, 0.6, 0.5, 0.01} }, colormap = { {0.1, 0.3, 0.8, 0.01} }, texture = 'bitmaps/GPL/groundflash.tga', count = 1, quality = 2, -- Medium repeatEffect = true, } warpgateCoronaAlt = { pos = {0,58.9,0}, life = math.huge, lifeSpread = 0, size = 210, sizeGrowth = 0, colormap = { {0.1, 0.2, 0.5, 0.01} }, texture = 'bitmaps/GPL/groundflash.tga', count = 1, quality = 2, -- Medium repeatEffect = true, } zenithCorona = { pos = {0,130,0}, life = math.huge, lifeSpread = 0, size = 160, sizeGrowth = 0, colormap = { {0.4, 0.2, 0.9, 0.01} }, texture = 'bitmaps/GPL/groundflash.tga', count = 1, quality = 2, -- Medium repeatEffect = true, } teleCorona = { pos = {0,0,0}, life = math.huge, lifeSpread = 0, size = 50, sizeGrowth = 0, colormap = { {0, 0.4, 1, 0.01} }, texture = 'bitmaps/GPL/groundflash.tga', count = 1, quality = 1, -- Low repeatEffect = true, noIconDraw = true, } valkCorona = { pos = {0,0,0}, life = math.huge, lifeSpread = 0, size = 30, sizeGrowth = 0, colormap = { {0, 0.4, 1, 0.01} }, texture = 'bitmaps/GPL/groundflash.tga', count = 1, repeatEffect = true, quality = 1, -- Low noIconDraw = true, } commandCoronaWhite = { heightFactor = 0.75, life = 60, lifeSpread = 0, radiusFactor = 8, sizeGrowth = 0, colormap = { {1, 1, 1, 0.01}, {0.8, 0.8, 0.8, 0.01}, {1, 1, 1, 0.01}, }, texture = 'bitmaps/GPL/groundflash.tga', count = 1, repeatEffect = true, } local commandCoronaColors = { Red = { {0.6, 0.05, 0.05, 0.01}, {0.48, 0.04, 0.04, 0.01}, {0.6, 0.05, 0.05, 0.01}, }, Blue = { {0.05, 0.05, 0.6, 0.01}, {0.04, 0.04, 0.48, 0.01}, {0.05, 0.05, 0.6, 0.01}, }, Green = { {0.05, 0.5, 0.05, 0.01}, {0.04, 0.4, 0.04, 0.01}, {0.05, 0.5, 0.05, 0.01}, }, Orange = { {0.4, 0.15, 0.05, 0.01}, {0.32, 0.12, 0.04, 0.01}, {0.4, 0.15, 0.05, 0.01}, }, } local function InterpolateColors(startColor, endColor, steps) local output = { startColor } local alpha = startColor[4] for i=1,steps do output[i+1] = {} for j=1,3 do local stepSize = (endColor[j] - startColor[j])/steps output[i+1][j] = output[i][j] + stepSize end output[i+1][4] = alpha end output[#output+1] = endColor return output end --commandCoronaWhite.colorMap = InterpolateColors(commandCoronaWhite.colormap[1], commandCoronaWhite.colormap[2], 3) for name, color in pairs(commandCoronaColors) do --color = InterpolateColors(color[1], color[2], 5) local key = "commandCorona"..name widget[key] = Spring.Utilities.CopyTable(commandCoronaWhite, true) widget[key]["colormap"] = color end jackGlow = { life = 60, lifeSpread = 0, size = 60, sizeSpread = 5, colormap = { {1.0, 0.6, 0.2, 0.02}, {0.66, 0.4, 0.133, 0.02}, {1.0, 0.6, 0.2, 0.02} }, texture = 'bitmaps/GPL/smallflare.tga', count = 1, repeatEffect = true, } blinkyLightWhite = { life = 60, lifeSpread = 0, size = 20, sizeSpread = 0, colormap = { {1, 1, 1, 0.02}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} }, texture = 'bitmaps/GPL/smallflare.tga', count = 1, quality = 1, -- Low repeatEffect = true, noIconDraw = true, } local blinkyLightColors = { Red = {1, 0.1, 0.1, 0.02}, Blue = {0.1, 0.1, 1, 0.02}, Green = {0, 1, 0.2, 0.02}, Orange = {0.8, 0.2, 0., 0.02}, Violet = {0.5, 0, 0.6, 0.02}, } for name, color in pairs(blinkyLightColors) do local key = "blinkyLight"..name widget[key] = Spring.Utilities.CopyTable(blinkyLightWhite, true) widget[key]["colormap"][1] = color end ---------------------------------------------------------------------------- -- OverDrive FXs ----------------------------------------------------------- ---------------------------------------------------------------------------- staticmexGlow = { layer = -5, delay = 0, pos = {0,0,0}, piece = "furnace", partpos = "x,y,z|".. "y = ((i>3) and 5) or -5,".. "local i = i%4,".. "local d = 5,".. "x = ((i>1) and -d) or d,".. "z = (((i==0)or(i==3)) and -d) or d", life = math.huge, lifeSpread = 0, sizeGrowth = 0, size = 11, size1 = 11, size2 = 13, colormap = { {0.13, 0.1, 0.001, 0.002}, }, color1 = {0.1, 0.1, 0.001, 0.002}, color2 = {0.9, 0.4, 0.005, 0.005}, texture = 'bitmaps/GPL/groundflash.tga', count = 8, repeatEffect= true, onActive = true, } ---------------------------------------------------------------------------- -- SimpleParticles --------------------------------------------------------- ---------------------------------------------------------------------------- roostDirt = { layer = 10, speed = 0, speedSpread = 0.45, life = 170, lifeSpread = 10, partpos = "x,0,z | alpha=(i/6)*pi*2, r=5+rand()*10, x=r*cos(alpha),z=r*sin(alpha)", colormap = { {0, 0, 0, 0.02}, {0.28, 0.30, 0.30, 0.5}, {0.25, 0.25, 0.30, 0.5}, {0, 0, 0, 0.02} }, rotSpeed = 0.3, rotFactor = 1.0, rotFactorSpread = -2.0, rotairdrag = 0.99, rotSpread = 360, size = 30, sizeSpread = 10, sizeGrowth = 0.08, emitVector = {0,1,0}, emitRotSpread = 70, texture = 'bitmaps/GPL/smoke_orange.png', count = 5, repeatEffect = true, } sparks = { speed = 0, speedSpread = 0, life = 90, lifeSpread = 10, partpos = "x,0,0 | if(rand()*2>1) then x=0 else x=20 end", colormap = { {0.8, 0.8, 0.8, 0.01}, {0, 0, 0, 0.0}, {0, 0, 0, 0.0}, {0, 0, 0, 0.0}, {0, 0, 0, 0.0}, {0, 0, 0, 0.0}, {0, 0, 0, 0.0}, {0, 0, 0, 0.0}, }, rotSpeed = 0.1, rotFactor = 1.0, rotFactorSpread = -2.0, rotairdrag = 0.99, rotSpread = 360, size = 10, sizeSpread = 12, sizeGrowth = 0.4, emitVector = {0,0,0}, emitRotSpread = 70, texture = 'bitmaps/PD/Lightningball.TGA', count = 6, repeatEffect = true, } sparks1 = { speed = 0, speedSpread = 0, life = 20, lifeSpread = 20, partpos = "5-rand()*10, 5-rand()*10, 5-rand()*10 ", --partpos = "0,0,0", colormap = { {0.8, 0.8, 0.2, 0.01}, {0, 0, 0, 0.0}, {0, 0, 0, 0.0}, {0, 0, 0, 0.0}, {0, 0, 0, 0.0}, {0, 0, 0, 0.0}, {0, 0, 0, 0.0}, {0, 0, 0, 0.0}, }, rotSpeed = 0.1, rotFactor = 1.0, rotFactorSpread = -2.0, rotairdrag = 0.99, rotSpread = 360, size = 10, sizeSpread = 12, sizeGrowth = 0.4, emitVector = {0,0,0}, emitRotSpread = 70, texture = 'bitmaps/PD/Lightningball.TGA', count = 6, repeatEffect = true, } ---------------------------------------------------------------------------- -- Ribbons ---------------------------------------------------------------------------- --commandTrailRed = {color={1,0.1,0.1,1}, width=10, piece="torso"}
gpl-2.0
Thonik/FritoMod
fritomod/Media-Backdrop.lua
1
3792
if nil ~= require then require "fritomod/Tables"; require "fritomod/Media"; require "fritomod/Media-Texture"; require "fritomod/Frames"; require "wow/Frame-Container"; require "wow/Frame-Backdrop"; end; local FRITOMOD="Interface/AddOns/FritoMod/media/"; local insets=setmetatable({ dialog = { left = 11, right = 10, top = 11, bottom = 10 }, slider = { left = 2, right = 2, top = 6, bottom = 6 }, }, { __index=function(self, k) if type(k)=="number" then self[k]={ left=k, right=k, top=k, bottom=k }; return self[k]; end; end }); local backdrops=setmetatable({}, { __newindex=function(self, name, backdrop) -- Unix-style slashes work for Blizzard's textures, but not for -- custom addons. I like not having to type two characters, so -- we do the conversion here. backdrop.edgeFile=backdrop.edgeFile:gsub("/", "\\"); if backdrop.bgFile then backdrop.bgFile=backdrop.bgFile:gsub("/", "\\"); end; rawset(self, name, backdrop); end }); backdrops.goldDialog={ edgeFile="Interface/DialogFrame/UI-DialogBox-Gold-Border", bgFile ="Interface/DialogFrame/UI-DialogBox-Gold-Background", edgeSize = 32, tile=true, tileSize=8, insets = insets.dialog }; backdrops.gold=backdrops.goldDialog; backdrops.blackdialog={ edgeFile="Interface/DialogFrame/UI-DialogBox-Border", bgFile ="Interface/DialogFrame/UI-DialogBox-Background", edgeSize = 32, tile=true, tileSize=8, insets = insets.dialog }; backdrops.dialog=backdrops.blackdialog; backdrops.black=backdrops.blackdialog; backdrops.chatbubble={ edgeFile="Interface/Tooltips/ChatBubble-Backdrop", bgFile ="Interface/Tooltips/ChatBubble-Background", edgeSize = 32, tile=true, tileSize=8, insets = insets[32] }; backdrops.chat=backdrops.chatbubble; backdrops.tooltip={ edgeFile="Interface/Tooltips/UI-Tooltip-Border", bgFile ="Interface/Tooltips/UI-Tooltip-Background", edgeSize = 16, tile=true, tileSize=8, insets = insets[4] }; backdrops.default=backdrops.tooltip; backdrops.slider={ edgeFile="Interface/Buttons/UI-SliderBar-Border", bgFile ="Interface/Buttons/UI-SliderBar-Background", edgeSize=8, tile=true, tileSize=8, insets = insets.slider }; backdrops.small=backdrops.slider; backdrops.test={ edgeFile=FRITOMOD.."Test-16-Border", bgFile ="Interface/Buttons/UI-SliderBar-Background", edgeSize = 16, tile=true, tileSize=16, insets = insets[16] }; backdrops.solid={ edgeFile=FRITOMOD.."Solid-Border", bgFile ="Interface/Buttons/UI-SliderBar-Background", edgeSize = 2, tile=true, tileSize=16, insets = insets[1] }; do local sizes = {}; Media.backdrop(function(size) if tonumber(size) then size=tonumber(size); if not sizes[size] then sizes[size]=Tables.Clone(backdrops.solid); sizes[size].edgeSize = size; end; return sizes[size]; end; end); end; Media.backdrop(backdrops); Media.SetAlias("backdrops", "border", "borders", "edge", "edges"); Frames=Frames or {}; function Frames.Backdrop(f, backdrop, bg) if type(backdrop)~="table" or not backdrop.edgeFile then backdrop=Media.backdrop[backdrop]; end; if bg then local usedBackdrop=Tables.Clone(backdrop); usedBackdrop.bgFile=Media.texture[bg].name; backdrop=usedBackdrop; end; f=Frames.AsRegion(f); assert(f and f.SetBackdrop, "Provided object does not support backdrops"); local insettedRegions = {}; local oldInsets = Frames.Insets(f); do local regions = {f:GetRegions()}; Lists.InsertAll(regions, f:GetChildren()); for _, region in ipairs(regions) do if Frames.IsInsetted(region, f) then trace("Found insetted region!"); table.insert(insettedRegions, region); end; end; end; f:SetBackdrop(backdrop); Lists.Each(insettedRegions, Headless(Frames.AdjustInsets, f, oldInsets)); return f; end; -- vim: set noet :
mit
MonokuroInzanaito/ygopro-777DIY
expansions/script/c37564225.lua
1
2957
--Sawawa-Border of Life local m=37564225 local cm=_G["c"..m] xpcall(function() require("expansions/script/c37564765") end,function() require("script/c37564765") end) cm.Senya_name_with_sawawa=true function cm.initial_effect(c) --Senya.setreg(c,m,37564299) c:EnableReviveLimit() --tg local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(37564225,0)) e1:SetCategory(CATEGORY_TOGRAVE) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_QUICK_F) e1:SetCode(EVENT_CHAINING) e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL) e1:SetRange(LOCATION_MZONE) e1:SetCountLimit(7,m) e1:SetCondition(cm.discon) e1:SetTarget(cm.distg) e1:SetOperation(cm.disop) c:RegisterEffect(e1) --ss local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(37564225,1)) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY+EFFECT_FLAG_CARD_TARGET) e3:SetCode(EVENT_TO_GRAVE) e3:SetCountLimit(1,m-4000) e3:SetCondition(cm.spcon) e3:SetTarget(cm.sptg) e3:SetOperation(cm.spop) c:RegisterEffect(e3) end function cm.discon(e,tp,eg,ep,ev,re,r,rp) return re:IsActiveType(TYPE_MONSTER) and re:GetHandler()~=e:GetHandler() and ep~=tp and Senya.CheckNoExtra(e,tp) end function cm.distg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(Card.IsAbleToGrave,tp,0,LOCATION_EXTRA,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,1-tp,LOCATION_EXTRA) end function cm.disop(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(Card.IsAbleToGrave,tp,0,LOCATION_EXTRA,nil) if g:GetCount()>0 then Duel.Hint(HINT_SELECTMSG,1-tp,HINTMSG_TOGRAVE) sg=g:Select(1-tp,1,1,nil) Duel.SendtoGrave(sg,REASON_EFFECT) local og=Duel.GetOperatedGroup() if og:GetCount()>0 then local tc=og:GetFirst() if tc:IsLocation(LOCATION_GRAVE) then tc:RegisterFlagEffect(37564225,RESET_EVENT+0x1fe0000,0,1) end end end end function cm.spcon(e,tp,eg,ep,ev,re,r,rp) return rp~=tp and e:GetHandler():GetPreviousControler()==tp and e:GetHandler():IsReason(REASON_DESTROY) end function cm.filter(c,e,tp) return c:GetFlagEffect(37564225)>0 and c:IsCanBeSpecialSummoned(e,0,tp,true,true) end function cm.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and cm.filter(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingTarget(cm.filter,tp,0,LOCATION_GRAVE,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectTarget(tp,cm.filter,tp,0,LOCATION_GRAVE,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0) end function cm.spop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then for i=2,11 do Duel.Hint(HINT_OPSELECTED,1-tp,aux.Stringid(37564225,i)) end local oc=Duel.SpecialSummon(tc,0,tp,tp,true,true,POS_FACEUP) tc:CompleteProcedure() end end
gpl-3.0
will4wachter/Project1
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
davidedmonds/darkstar
scripts/zones/Southern_San_dOria/npcs/Aravoge_TK.lua
28
4900
----------------------------------- -- Area: Southern San d'Oria -- NPC: Aravoge, T.K. -- X Grant Signet -- X Recharge Emperor Band, Empress Band, or Chariot Band -- X Accepts traded Crystals to fill up the Rank bar to open new Missions. -- X Sells items in exchange for Conquest Points -- X Start Supply Run Missions and offers a list of already-delivered supplies. -- Start an Expeditionary Force by giving an E.F. region insignia to you. ------------------------------------- package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil; ------------------------------------- require("scripts/globals/conquest"); require("scripts/globals/common"); require("scripts/zones/Southern_San_dOria/TextIDs"); local guardnation = SANDORIA; -- SANDORIA, BASTOK, WINDURST, JEUNO local guardtype = 1; -- 1: city, 2: foreign, 3: outpost, 4: border local size = table.getn(SandInv); local inventory = SandInv; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) tradeConquestGuard(player,npc,trade,guardnation,guardtype); end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:getNation() == guardnation and player:getVar("supplyQuest_started") > 0 and supplyRunFresh(player) == 0) then player:showText(npc,CONQUEST + 40); -- "We will dispose of those unusable supplies." local region = player:getVar("supplyQuest_region"); player:delKeyItem(getSupplyKey(region)); player:messageSpecial(KEYITEM_OBTAINED + 1,getSupplyKey(region)); player:setVar("supplyQuest_started",0); player:setVar("supplyQuest_region",0); player:setVar("supplyQuest_fresh",0); else local Menu1 = getArg1(guardnation,player); local Menu2 = getExForceAvailable(guardnation,player); local Menu3 = conquestRanking(); local Menu4 = getSupplyAvailable(guardnation,player); local Menu5 = player:getNationTeleport(guardnation); local Menu6 = getArg6(player); local Menu7 = player:getCP(); local Menu8 = getRewardExForce(guardnation,player); player:startEvent(0x7ffa,Menu1,Menu2,Menu3,Menu4,Menu5,Menu6,Menu7,Menu8); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("onUpdateCSID: %u",csid); -- printf("onUpdateOPTION: %u",option); if (option >= 32768 and option <= 32944) then for Item = 1,size,3 do if (option == inventory[Item]) then CPVerify = 1; if (player:getCP() >= inventory[Item + 1]) then CPVerify = 0; end; player:updateEvent(2,CPVerify,inventory[Item + 2]); break; end; end; end; end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("onFinishCSID: %u",csid); -- printf("onFinishOPTION: %u",option); if (option == 1) then duration = (player:getRank() + getNationRank(player:getNation()) + 3) * 3600; player:delStatusEffect(EFFECT_SIGIL); player:delStatusEffect(EFFECT_SANCTION); player:delStatusEffect(EFFECT_SIGNET); player:addStatusEffect(EFFECT_SIGNET,0,0,duration); -- Grant Signet elseif (option >= 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 if (player:getNation() == guardnation) 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) 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;
gpl-3.0
davidedmonds/darkstar
scripts/zones/Garlaige_Citadel/npcs/qm9.lua
34
1385
----------------------------------- -- Area: Garlaige Citadel -- NPC: qm9 (???) -- Involved in Quest: Hitting the Marquisate (THF AF3) -- @pos -140.039 -5.500 285.999 200 ----------------------------------- package.loaded["scripts/zones/Garlaige_Citadel/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/zones/Garlaige_Citadel/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local hittingTheMarquisateHagainCS = player:getVar("hittingTheMarquisateHagainCS"); if (hittingTheMarquisateHagainCS == 7) then player:messageSpecial(PRESENCE_FROM_CEILING); player:setVar("hittingTheMarquisateHagainCS",8); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID2: %u",csid); --printf("RESULT2: %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/Southern_San_dOria/npcs/Chanpau.lua
2
1654
----------------------------------- -- Area: Southern San d'Oria -- NPC: Chanpau -- Optional Involvement in Quest: A Squire's Test II -- @zone 230 -- !pos -152 -2 55 ------------------------------------- package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Southern_San_dOria/TextIDs"); require("scripts/globals/settings"); require("scripts/globals/quests"); ----------------------------------- function onTrade(player,npc,trade) -- "Flyers for Regine" conditional script local FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE); if (FlyerForRegine == 1) then local count = trade:getItemCount(); local MagicFlyer = trade:hasItemQty(532,1); if (MagicFlyer == true and count == 1) then player:messageSpecial(FLYER_REFUSED); end end end; function onTrigger(player,npc) if (player:getQuestStatus(SANDORIA,A_SQUIRE_S_TEST_II) == QUEST_ACCEPTED) then player:startEvent(629); elseif (player:getQuestStatus(SANDORIA, THE_BRUGAIRE_CONSORTIUM) == QUEST_COMPLETED) then Fired = player:getVar("Fired") if Fired == 1 then player:startEvent(567) -- i got fired in a day else player:startEvent(505) -- theres work ill go check it out end else player:startEvent(566); end end; function onEventUpdate(player,csid,option) end; function onEventFinish(player,csid,option) if (csid == 505) then player:setVar("Fired", 1) end end; -------for future use -- player:startEvent(32691) -- starlight celebration
gpl-3.0
davidedmonds/darkstar
scripts/zones/LaLoff_Amphitheater/mobs/Ark_Angel_EV.lua
27
1471
----------------------------------- -- Area: LaLoff Amphitheater -- NPC: Ark Angel EV ----------------------------------- require("scripts/globals/status"); require("scripts/zones/LaLoff_Amphitheater/TextIDs"); function onMobInitialize(mob) mob:addMod(MOD_REGAIN, 50); end; ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) end; ----------------------------------- -- onMobEngaged ----------------------------------- function onMobEngaged(mob,target) local mobid = mob:getID() for member = mobid-4, mobid+3 do if (GetMobAction(member) == 16) then GetMobByID(member):updateEnmity(target); end end local hp = math.random(40,60) mob:setLocalVar("Benediction", hp); end; ----------------------------------- -- onMobFight Action ----------------------------------- function onMobFight(mob,target) local battletime = mob:getBattleTime(); local invtime = mob:getLocalVar("Invincible"); local bhp = mob:getLocalVar("Benediction"); if (battletime > invtime + 150) then mob:useMobAbility(438); mob:setLocalVar("Invincible", battletime); elseif (mob:getHPP() < bhp) then mob:useMobAbility(433); mob:setLocalVar("Benediction", 0); end end; ----------------------------------- -- onMobDeath Action ----------------------------------- function onMobDeath(mob,killer) end;
gpl-3.0
MonokuroInzanaito/ygopro-777DIY
expansions/script/c66612327.lua
1
3045
--AIW·扑克魔术的影爱丽丝 function c66612327.initial_effect(c) --cannot special summon local e1=Effect.CreateEffect(c) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_SPSUMMON_CONDITION) c:RegisterEffect(e1) --spsummon local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(66612327,0)) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_HAND) e2:SetTarget(c66612327.target) e2:SetOperation(c66612327.operation) c:RegisterEffect(e2) --recover local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(66612327,1)) e4:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e4:SetType(EFFECT_TYPE_IGNITION) e4:SetRange(LOCATION_GRAVE) e4:SetCost(c66612327.recost) e4:SetTarget(c66612327.rectg) e4:SetOperation(c66612327.recop) c:RegisterEffect(e4) end function c66612327.filter(c) return c:IsFaceup() and (c:IsSetCard(0x660) or c:IsSetCard(0x666)) and c:GetLevel()>1 end function c66612327.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c66612327.filter(chkc) end local c=e:GetHandler() if chk==0 then return Duel.IsExistingTarget(c66612327.filter,tp,LOCATION_MZONE,0,1,nil) and Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and c:IsCanBeSpecialSummoned(e,0,tp,true,true) end Duel.SelectTarget(tp,c66612327.filter,tp,LOCATION_MZONE,0,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,c,1,0,0) end function c66612327.operation(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsFacedown() or not tc:IsRelateToEffect(e) or tc:IsImmuneToEffect(e) then return end local c=e:GetHandler() local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_LEVEL) e1:SetReset(RESET_EVENT+0x1fe0000) e1:SetValue(-1) tc:RegisterEffect(e1) if c:IsRelateToEffect(e) then Duel.SpecialSummonStep(c,0,tp,tp,true,true,POS_FACEUP) local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetCode(EFFECT_CANNOT_BE_SYNCHRO_MATERIAL) e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e3:SetValue(c66612327.splimit) e3:SetReset(RESET_EVENT+0x1fe0000) tc:RegisterEffect(e3) Duel.SpecialSummonComplete() end end function c66612327.recost(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return c:IsAbleToDeckAsCost() end Duel.SendtoDeck(c,nil,2,REASON_COST) end function c66612327.filter2(c) return c:IsCode(66612323) and c:IsAbleToHand() end function c66612327.rectg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chk==0 then return Duel.IsExistingMatchingCard(c66612327.filter2,tp,LOCATION_GRAVE,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_GRAVE) end function c66612327.recop(e,tp,eg,ep,ev,re,r,rp,chk) local tc=Duel.GetFirstMatchingCard(c66612327.filter2,tp,LOCATION_GRAVE,0,nil) if tc then Duel.SendtoHand(tc,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,tc) end end
gpl-3.0
kidaa/darkstar
scripts/zones/Provenance/Zone.lua
17
1255
----------------------------------- -- -- Zone: Provenance (222) -- ----------------------------------- package.loaded["scripts/zones/Provenance/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Provenance/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn( player, prevZone) cs = -1; if( player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then player:setPos(-640,-20,-519.999,192); end return cs; end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
NewbProgrammer101/Lord-of-the-Test
mods/lottachievements/init.lua
2
16426
-- AWARDS -- -- Copyright (C) 2013-2015 rubenwardy -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published by -- the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. -- You should have received a copy of the GNU Lesser 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. -- -- The global award namespace lottachievements = { show_mode = "hud" } -- Internationalization support. local S, NS = dofile(minetest.get_modpath("lottachievements").."/intllib.lua") lottachievements.gettext, lottachievements.ngettext = S, NS dofile(minetest.get_modpath("lottachievements").."/api.lua") dofile(minetest.get_modpath("lottachievements").."/chat_commands.lua") dofile(minetest.get_modpath("lottachievements").."/triggers.lua") -- To add achievements in the middle of ids (e.g. between 29 and 30), -- use the script at the bottom of the file, changing the variables as needed. minetest.register_craftitem("lottachievements:achievement_book", { description = "Achievement Book", inventory_image = "lottachievements_achievement_book.png", groups = {book=1}, on_place = function(_, player) local name = player:get_player_name() lottachievements.show_to(name, name) end, on_use = function(_, player) local name = player:get_player_name() lottachievements.show_to(name, name) end, }) -- Random Achievements! lottachievements.register_achievement("smoke_rings", { title = "Smoke Rings", description = "Blow a smoke ring with a pipe", icon = "lottfarming_smoke_ring.png", id = 1, }) lottachievements.register_achievement("a_long_path_to_mushrooms", { title = "A Long Path to Mushrooms", description = "Show a hobbitish love of mushrooms by eating 99!", icon = "lottplants_mushroom_wild.png", id = 2, trigger = { type = "eat", item = "lottfarming:brown_mushroom", target = 99 } }) lottachievements.register_achievement("tasty_taters", { title = "Tasty Taters", description = "Fill your belly with the good ballast of 9 potatoes", icon = "lottfarming_potato_cooked.png", id = 3, trigger = { type = "eat", item = "lottfarming:potato_cooked", target = 9 } }) lottachievements.register_achievement("thief", { title = "Thief!", description = "Use a lockpick to break into a chest of a different race", icon = "lottblocks_steel_lockpick.png", id = 4, }) lottachievements.register_achievement("rope_is_useful", { title = "Rope is useful!", description = "Craft 100 meters of elven rope", icon = "lottblocks_elven_rope.png", id = 5, trigger = { type = "craft", item = "lottblocks:elven_rope", target = 100, } }) lottachievements.register_achievement("silver_stringed_music", { title = "Silver Stringed Music", description = "Craft a dwarvern harp", icon = "lottblocks_harp_strings.png", id = 6, trigger = { type = "craft", item = "lottblocks:dwarf_harp", target = 1, } }) lottachievements.register_achievement("dungeons_deep_and_caverns_old", { title = "Dungeons Deep and Caverns Old", description = "Find an underground dungeon", icon = "default_mossycobble.png", id = 7, trigger = { type = "dig", node = "default:mossycobble", target = 1, } }) lottachievements.register_achievement("dwarvern_tomb", { title = "Dwarvern Tomb", description = "Find (and loot!) a dwarvern tomb, deep underground...", icon = "lottblocks_dh_top.png", id = 8, trigger = { type = "dig", node = "lottblocks:dwarf_tomb_top", target = 1, } }) lottachievements.register_achievement("express_miner", { title = "Express Miner", description = "Craft a mithril pickaxe", icon = "lottores_mithrilpick.png", id = 9, trigger = { type = "craft", item = "lottores:mithrilpick", target = 1, } }) lottachievements.register_achievement("elf_and_dwarf_cooperation", { title = "Elf and Dwarf Cooperation", description = "Place at least 6 ithildin stone", icon = "default_stone.png^ithildin_1.png", id = 10, trigger = { type = "place", node = "lottores:ithildin_stone_1", target = 6, } }) lottachievements.register_achievement("chains_of_melkor", { title = "Chains of Melkor", description = "Craft a tilkal ingot", icon = "lottores_tilkal_ingot.png", id = 11, trigger = { type = "craft", item = "lottores:tilkal_ingot", target = 1 } }) lottachievements.register_achievement("master_craftsman", { title = "Master Craftsman", description = "Craft a Master Book of Crafts", icon = "lottinventory_master_book.png", id = 12, trigger = { type = "craft", item = "lottinventory:master_book", target = 1, } }) -- Mithril Achievements lottachievements.register_achievement("first_truesilver", { title = "First Truesilver", description = "Mine 1 mithril ore", icon = "default_stone.png^lottores_mithril_ore.png^lottachievements_level1.png", id = 32, trigger = { type = "dig", node = "lottores:mithril_ore", target = 1 } }) lottachievements.register_achievement("dwarvern_miner", { title = "Dwarven Miner", description = "Mine 99 mithril ore", icon = "default_stone.png^lottores_mithril_ore.png^lottachievements_level2.png", requires = "first_truesilver", id = 33, trigger = { type = "dig", node = "lottores:mithril_ore", target = 99 } }) lottachievements.register_achievement("ammassing_fortune", { title = "Amassing Fortune", description = "Mine 500 mithril ore", icon = "default_stone.png^lottores_mithril_ore.png^lottachievements_level3.png", requires = "dwarvern_miner", id = 34, trigger = { type = "dig", node = "lottores:mithril_ore", target = 500 } }) lottachievements.register_achievement("truly_rich", { title = "Truly Rich", description = "Mine 1000 mithril ore", icon = "default_stone.png^lottores_mithril_ore.png^lottachievements_level4.png", requires = "ammassing_fortune", id = 35, trigger = { type = "dig", node = "lottores:mithril_ore", target = 1000 } }) lottachievements.register_achievement("lord_of_moria", { title = "Lord of Moria", description = "Mine 5000 mithril ore", icon = "default_stone.png^lottores_mithril_ore.png^lottachievements_level5.png", requires = "truly_rich", id = 36, trigger = { type = "dig", node = "lottores:mithril_ore", target = 5000 } }) -- Armour Achievements lottachievements.register_achievement("foot_soldier", { title = "Foot Soldier", description = "Equip a full set of steel armor", icon = "lottarmor_inv_chestplate_steel.png", id = 30, trigger = { type = "equip", item = "lottarmor:chestplate_steel", } }) lottachievements.register_achievement("dwarvern_lord", { title = "Dwarven Lord", description = "Equip a full set of mithril armor", icon = "lottarmor_inv_chestplate_mithril.png", id = 31, trigger = { type = "equip", item = "lottarmor:chestplate_mithril", } }) lottachievements.register_achievement("elven_lord", { title = "Elven Lord", description = "Equip a full set of galvorn armor", icon = "lottarmor_inv_chestplate_galvorn.png", id = 29, trigger = { type = "equip", item = "lottarmor:chestplate_galvorn", } }) lottachievements.register_achievement("rohirric_king", { title = "Rohirric King", description = "Equip a full set of gold armor", icon = "lottarmor_inv_chestplate_gold.png", id = 28, trigger = { type = "equip", item = "lottarmor:chestplate_gold", } }) -- Various biome awards lottachievements.register_achievement("in_the_land_of_mordor", { title = "In the Land of Mordor...", description = "Visit Mordor and mine some Mordor Stone as proof", icon = "lottmapgen_mordor_stone.png", id = 13, trigger = { type = "dig", node = "lottmapgen:mordor_stone", target = 1, } }) lottachievements.register_achievement("the_frozen_wastes", { title = "The Frozen Wastes", description = "Visit a frozen biome, and collect some snow", icon = "default_snow.png", id = 14, trigger = { type = "dig", node = "default:snowblock", target = 1, } }) lottachievements.register_achievement("iron_galore", { title = "Iron Galore", description = "Visit the Iron Hills and start a mine there", icon = "default_stone.png^default_mineral_iron.png", id = 15, trigger = { type = "dig", node = "lottmapgen:ironhill_grass", target = 1, } }) lottachievements.register_achievement("the_merry_shire", { title = "The Merry Shire", description = "Visit the Shire, and examine its soil", icon = "lottplants_plum.png", id = 16, trigger = { type = "dig", node = "lottmapgen:shire_grass", target = 1, } }) lottachievements.register_achievement("lorien_the_golden", { title = "Lorien the Golden", description = "Visit the golden forest of Lorien", icon = "lottplants_mallornleaf.png", id = 17, trigger = { type = "dig", node = "lottmapgen:lorien_grass", target = 1, } }) lottachievements.register_achievement("a_small_patch_of_lorien", { title = "A Small Patch of Lorien", description = "Place 7 Mallorn Saplings", icon = "lottplants_mallornsapling.png", id = 19, trigger = { type = "place", node = "lottplants:mallornsapling", target = 7 } }) lottachievements.register_achievement("the_corrupted_greenwood", { title = "The Corrupted Greenwood", description = "Chop down a tree in Mirkwood", icon = "lottplants_mirkleaf.png", id = 18, trigger = { type = "dig", node = "default:jungletree", target = 1, } }) -- Mob Killings! lottachievements.register_achievement("his_arm_has_grown_long", { title = "His arm has grown long indeed", description = "Craft a mithril spear", icon = "lottweapons_mithril_spear.png", id = 20, trigger = { type = "craft", item = "lottweapons:mithril_spear", target = 1 } }) lottachievements.register_achievement("marksman_of_lorien", { title = "Marksman of Lorien", description = "Craft a mallorn bow", icon = "lottthrowing_bow_wood_mallorn.png", id = 21, trigger = { type = "craft", item = "lottthrowing:bow_wood_mallorn", target = 1 } }) lottachievements.register_achievement("durins_bane", { title = "Durin's Bane", description = "Kill a Balrog", icon = "fire_basic_flame.png", id = 27, trigger = { type = "kill", mob = "lottmobs:balrog", target = 1, } }) lottachievements.register_achievement("begone_foul_dwimmerlaik", { title = "Begone, foul dwimmerlaik", description = "Kill the king of the Nazgul", icon = "lottachievements_witch_king.png", id = 26, trigger = { type = "kill", mob = "lottmobs:witch_king", target = 1, } }) lottachievements.register_achievement("living_wood", { title = "Living Wood", description = "Kill an ent", icon = "default_jungletree.png", id = 25, trigger = { type = "kill", mob = "lottmobs:ent", target = 1, } }) lottachievements.register_achievement("elven_champion", { title = "Elven Champion", description = "Kill 25 Mordor orcs", icon = "lottweapons_elven_sword.png", id = 22, trigger = { type = "kill", mob = "lottmobs:orc", target = 25, } }) lottachievements.register_achievement("orcish_warlord", { title = "Orcish Warlord", description = "Kill 25 elves", icon = "lottweapons_orc_sword.png", id = 23, trigger = { type = "kill", mob = "lottmobs:elf", target = 25, } }) lottachievements.register_achievement("spider_hunter", { title = "Spider Hunter", description = "Kill 25 spiders", icon = "lottplants_mirkleaf.png", id = 24, trigger = { type = "kill", mob = "lottmobs:spider", target = 25, } }) -- Advanced Achievements lottachievements.register_achievement("abandoned_workshop", { title = "Abandoned Workshop", description = "Discover a secret Elven Workshop underground", icon = "default_cracked_stone_brick.png", id = 37, trigger = { type = "dig", node = "default:cracked_stonebrick", target = 1 } }) lottachievements.register_achievement("ringsilver_crafter", { title = "Ringsilver crafter", description = "Form your first ingot of ringsilver!", icon = "lottother_ringsilver_ingot.png", requires = "abandoned_workshop", id = 38, }) lottachievements.register_achievement("the_ring_is_prepared", { title = "The Ring is Prepared...", description = "Make a ring ready to have a gem fitted to it", icon = "lottother_prepared_ring.png", requires = "ringsilver_crafter", id = 39, trigger = { type = "craft", item = "lottother:prepared_ring", target = 1, } }) lottachievements.register_achievement("a_pickaxe_fit_for_a_king", { title = "A pickaxe fit for a king", description = "Craft a gem pickaxe", icon = "lottother_gempick.png", requires = "abandoned_workshop", id = 40, trigger = { type = "craft", item = "lottother:gem_pick", target = 1, } }) lottachievements.register_achievement("polisher", { title = "Polisher", description = "Polish a gem", icon = "lottother_redgem.png", requires = "a_pickaxe_fit_for_a_king", id = 41, }) lottachievements.register_achievement("ring_smith", { title = "Ring Smith", description = "Forge a ring of power", requires = "polisher", icon = "lottother_narya.png", id = 42, }) lottachievements.register_achievement("supersonic_speed", { title = "Supersonic Speed", description = "Craft a palantir", icon = "default_obsidian.png", secret = true, id = 43, trigger = { type = "craft", item = "lottblocks:palantir", target = 1, } }) --Death awards :P lottachievements.register_achievement("first_time_for_everything", { title = "First Time for Everything", description = "Die once!", id = 44, icon = "lottachievements_skull.png^lottachievements_level1.png", trigger = { type = "death", target = 1, } }) lottachievements.register_achievement("not_again", { title = "Not Again!", description = "Die a second time", icon = "lottachievements_skull.png^lottachievements_level2.png", requires = "first_time_for_everything", id = 45, trigger = { type = "death", target = 2, } }) lottachievements.register_achievement("this_is_becoming_a_habit", { title = "This is becoming a habit...", description = "Die 10 times!", icon = "lottachievements_skull.png^lottachievements_level3.png", requires = "not_again", id = 46, trigger = { type = "death", target = 10, } }) lottachievements.register_achievement("im_getting_good_at_this", { title = "I'm getting good at this!", description = "Die 20 times, then 5 more.", icon = "lottachievements_skull.png^lottachievements_level4.png", requires = "this_is_becoming_a_habit", id = 47, trigger = { type = "death", target = 25, } }) lottachievements.register_achievement("this_is_really_too_much", { title = "This is really too much...", description = "Die a grand total of 100 times!", icon = "lottachievements_skull.png^lottachievements_level5.png", requires = "im_getting_good_at_this", id = 48, trigger = { type = "death", target = 100, } }) lottachievements.register_achievement("king_of_dying", { title = "King of Dying", description = "Have 500 deaths to your name!", icon = "lottachievements_crowned_skull.png^lottachievements_level6.png", requires = "this_is_really_too_much", id = 49, trigger = { type = "death", target = 500, } }) lottachievements.register_achievement("so_dead_im_immortal", { title = "So dead, I'm immortal!", description = "1000 deaths. Yes, 1000.", icon = "lottachievements_skull.png^lottachievements_level7.png", requires = "king_of_dying", id = 50, trigger = { type = "death", target = 1000, } }) --[[ --Code to increase award numbers: local file = io.open("init.lua") local string = "" local increase_from = 5 -- The number you want the new award to be. local increase_amount = 1 -- How many awards you want to add. for i in file:lines() do if i:find("id = %d+,") then local pos1, pos2 = i:find("id = %d+,") local d = tonumber(i:sub(pos1 + 5, pos2 - 1)) if d >= increase_from then d = d + increase_amount i = i:gsub("id = %d+,", "id = " .. d .. ",") end end string = string .. i .. "\n" end file:close() file = io.open("init.lua", "w+") file:write(string) file:close() --Yes, this should be done with sed or awk, but I have no idea how to use them! ]]--
lgpl-2.1
davidedmonds/darkstar
scripts/globals/abilities/pets/blizzard_iv.lua
20
1156
--------------------------------------------------- -- Aero 2 --------------------------------------------------- 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 spell = getSpell(152); --calculate raw damage local dmg = calculateMagicDamage(506,2,pet,spell,target,ELEMENTAL_MAGIC_SKILL,MOD_INT,false); --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_ICE); --get the resisted damage dmg = dmg*resist; --add on bonuses (staff/day/weather/jas/mab/etc all go in this function) dmg = mobAddBonuses(pet,spell,target,dmg, 5); --add on TP bonuses local tp = skill:getTP(); if tp < 100 then tp = 100; end dmg = dmg * tp / 100; --add in final adjustments dmg = finalMagicAdjustments(pet,target,spell,dmg); return dmg; end
gpl-3.0
will4wachter/Project1
scripts/globals/treasure.lua
6
19448
------------------------------------------------- -- Author: Almendro, Ezekyel -- Treasure functions -- Info from: -- http://wiki.ffxiclopedia.org/wiki/Picking_your_Coffers_and_Chests -- http://ffxi.allakhazam.com/db/jobs.html?fjob=10&mid=1086187627165365190&num=150 ------------------------------------------------- require("scripts/globals/settings"); ------------------------------------------------- -- THF tools/keys & their chance increment ------------------------------------------------- skeletonKey = 0x45B; -- 1115 livingKey = 0x3FF; -- 1023 thftools = 0x3FE; -- 1022 SK_SUCCESS_INCREMENT = 0.2 LK_SUCCESS_INCREMENT = 0.15 TTK_SUCCESS_INCREMENT = 0.1 --------------------------------------- -- Spawn Mimic --------------------------------------- function spawnMimic(zone,npc,player) -- zone,mobid mimic = {147,17379783, 153,17404338, 151,17396144, 161,17436965, 197,17584426, 160,17432583, 195,17576271, 200,17596728, 205,17617157, 174,17490230, 150,17391805, 12,16826564, 208,17629190, 130,17309979, 176,17498564, 159,17428497, 169,17469761, 177,17502567}; for nb = 1, table.getn(mimic), 2 do if(zone == mimic[nb]) then SpawnMob(mimic[nb + 1],120):updateEnmity(player); setMobPos(mimic[nb + 1],npc:getXPos(),npc:getYPos(),npc:getZPos(),npc:getRotPos()); break; else printf("treasure.lua Mimic missing from zone %d", zone); end end end; --------------------------------------- -- Items --------------------------------------- BurstScroll = 0x12D4; MagesBalladII = 0x1383; AdeptsRope = 0x33AE; ElectrumHairpin = 0x3610; PhalanxRing = 0x34CC; GigantAxe = 0x4146; TropicalShield = 0x3035; ElectrumRing = 0x34CB; EmethPick = 0x4122; Falcastra = 0x4183; LifeBelt = 0x33AF; CougarBaghnakhs = 0x413E; PyroRobe = 0x359B; MothAxe = 0x414F; ShieldEarring = 0x3435; FrostShield = 0x3032; ReplicaMaul = 0x4412; BattleGloves = 0x31FF; HeatRod = 0x42AF; ForceBelt = 0x33A6; FlameBoomerang = 0x438B; SafeguardRing = 0x394E; LightGauntlets = 0x3699; HiReraiser = 0x104D; PhysicalEarring = 0x3456; VileElixir1 = 0x104F; --------------------------------------- -- Gems --------------------------------------- Amber = 0x32E; Amethyst = 0x320; Ametrine = 0x32B; Aquamarine = 0x317; Chrysoberyl = 0x321; ClearTopaz = 0x329; Fluorite = 0x32A; Garnet = 0x316; Goshenite = 0x328; LapisLazuli = 0x31B; LightOpal = 0x31C; Moonstone = 0x322; Onyx = 0x31F; Painite = 0x31D; Peridot = 0x314; Sardonyx = 0x327; Sphene = 0x32F; Sunstone = 0x323; Tourmaline = 0x326; Turquoise = 0x31E; Zircon = 0x325; ------------------------------------------------- -- AF by Zone ------------------------------------------------- function getAFbyZone(zone) -- job#1, quest#1, item#1, job#2, quest#2, item#2, ... if(zone == 147) then -- Beadeaux -- Beast Jackcoat (BST), Gallant Breeches (PLD), Temple Cyclas (MNK) return {9,BORGHERTZ_S_WILD_HANDS,12646, 7,BORGHERTZ_S_STALWART_HANDS,14220, 2,BORGHERTZ_S_STRIKING_HANDS,12639}; elseif(zone == 150) then -- Monastic Cavern -- Chaos Flanchard (DRK), Hunter's Jerkin (RNG), Wizard's Coat (BLM) return { 8,BORGHERTZ_S_SHADOWY_HANDS,14221, 11,BORGHERTZ_S_CHASING_HANDS,12648, 4,BORGHERTZ_S_SORCEROUS_HANDS,12641}; elseif(zone == 151) then -- Castle Oztroja -- Chaos Cuirass(DRK), Choral Cannions (BRD), Rogue's Culottes (THF), Warlock's Tabard (RDM) return { 8,BORGHERTZ_S_SHADOWY_HANDS,12645, 10,BORGHERTZ_S_HARMONIOUS_HANDS,14223, 6,BORGHERTZ_S_SNEAKY_HANDS,14219, 5,BORGHERTZ_S_VERMILLION_HANDS,12642}; elseif(zone == 153) then -- The Boyahda Tree -- Ninja Hatsuburi (NIN) return {13,BORGHERTZ_S_LURKING_HANDS,13869}; elseif(zone == 159) then -- Temple of Uggalepih -- Evoker's Doublet (SMN), Myochin Domaru (SAM) return {15,BORGHERTZ_S_CALLING_HANDS,12650, 12,BORGHERTZ_S_LOYAL_HANDS,13781}; elseif(zone == 161) then -- Castle Zvahl Baileys -- Fighter's Cuisses (WAR), Rogue's Vest (THF) return {1,BORGHERTZ_S_WARRING_HANDS,14214, 6,BORGHERTZ_S_SNEAKY_HANDS,12643}; elseif(zone == 169) then -- Toraimarai Canal -- Evoker's Pigaches (SMN) return {15,BORGHERTZ_S_CALLING_HANDS,14103}; elseif(zone == 176) then -- Sea Serpent Grotto -- Ninja Kyahan (NIN) return {13,BORGHERTZ_S_LURKING_HANDS,14101}; elseif(zone == 195) then -- The eldieme Necropolis -- Wizard's Tonban (BLM) return {4,BORGHERTZ_S_SORCEROUS_HANDS,14217}; elseif(zone == 197) then -- Crawler's Nest -- Choral Roundlet (BRD), Fighter's Mask (WAR), Healer's Pantaloons (WHM), Hunter's Braccae (RNG) return {10,BORGHERTZ_S_HARMONIOUS_HANDS,13857, 1,BORGHERTZ_S_WARRING_HANDS,12511, 3,BORGHERTZ_S_HEALING_HANDS,14216, 11,BORGHERTZ_S_CHASING_HANDS,14224}; elseif(zone == 200) then -- Garlaige Citadel -- Beast Helm (BST), Gallant Coronet (PLD), Healer's Cap (WHM), Temple Crown (MNK), Warlock's Tights (RDM) return {9,BORGHERTZ_S_WILD_HANDS,12517, 7,BORGHERTZ_S_STALWART_HANDS,12515, 3,BORGHERTZ_S_HEALING_HANDS,13855, 2,BORGHERTZ_S_STRIKING_HANDS,12512, 5,BORGHERTZ_S_VERMILLION_HANDS,14218}; elseif(zone == 205) then -- Ifrit's Cauldron -- Drachen Mail (DRG) return {14,BORGHERTZ_S_DRAGON_HANDS,12649}; elseif(zone == 208) then -- Quicksand Caves -- Drachen Greaves (DRG), Myochin Haidate (SAM) return {14,BORGHERTZ_S_DRAGON_HANDS,14102, 12,BORGHERTZ_S_LOYAL_HANDS,14225}; end end --------------------------------------- -- Returns the success increment depending on the THF tool used. --------------------------------------- function thfKeySuccess(trade,playerLVL,treasureLVL) sk = trade:hasItemQty(skeletonKey,1); lk = trade:hasItemQty(livingKey,1); ttk = trade:hasItemQty(thftools,1); success = 0; if( sk ) then success = (playerLVL/treasureLVL) - 0.50 + SK_SUCCESS_INCREMENT; elseif( lk )then success = (playerLVL/treasureLVL) - 0.50 + LK_SUCCESS_INCREMENT; elseif( ttk ) then success = (playerLVL/treasureLVL) - 0.50 + TTK_SUCCESS_INCREMENT; end return success; end --------------------------------------- -- Returns true if the key is a THF "key", false in other case. --------------------------------------- function isTHFKey(trade) sk = trade:hasItemQty(skeletonKey,1); lk = trade:hasItemQty(livingKey,1); ttk = trade:hasItemQty(thftools,1); if( sk or lk or ttk )then return true; else return false; end end --------------------------------------- -- Chance calculation based on job, key used and lvl of the chest/coffer --------------------------------------- function openChance(player,npc,trade,TreasureType,treasureLVL,minLVL,questItemNeeded) success = 0; chance_answer = {nil,nil}; -- {success%,messageType} weak = player:getStatusEffect(EFFECT_WEAKNESS); illu = player:getVar("["..player:getZone().."]".."Treasure_"..TreasureType); -- SE impleted this in order to prevent coffer farming. -- Noone in the same area can open more than 1 coffer per hour except for AF, maps or quests items. if(weak ~= nil) then -- old code: os.time() <= weak chance_answer = {-1,CHEST_WEAK}; elseif(os.time() < illu and questItemNeeded == 0) then UpdateTreasureSpawnPoint(npc:getID()); if(TreasureType == "Chest")then chance_answer = {-2,CHEST_ILLUSION}; elseif(TreasureType == "Coffer") then if(isTHFKey(trade))then chance_answer = {-1,CHEST_ILLUSION}; -- if you used a THF tool you will lose it. else chance_answer = {-2,CHEST_ILLUSION}; -- if you traded a zone key droped from mobs you will keep the key end end elseif(not(isTHFKey(trade))) then chance_answer = {1,nil}; -- Zone Key is always 100% success elseif(player:getMainJob() == 6 and player:getMainLvl() >= minLVL) then -- ifplayer is THF with level higher or equal than minimun lv for coffer/chest success = thfKeySuccess(trade,player:getMainLvl(),treasureLVL); chance_answer = {success,nil}; else -- Player is not THF (as main job) or doesn't haven enough level to open the coffer chance_answer = {-1,CHEST_FAIL}; end return chance_answer; end function chestLoot(zone,npc) --[[----------------------------------------------- Chest Loot --------------------------------------------------- --------------------------------------- -- Items --------------------------------------- BurstScroll = 0x12D4; MagesBalladII = 0x1383; AdeptsRope = 0x33AE; ElectrumHairpin = 0x3610; PhalanxRing = 0x34CC; GigantAxe = 0x4146; TropicalShield = 0x3035; ElectrumRing = 0x34CB; EmethPick = 0x4122; Falcastra = 0x4183; LifeBelt = 0x33AF; CougarBaghnakhs = 0x413E; PyroRobe = 0x359B; MothAxe = 0x414F; ShieldEarring = 0x3435; FrostShield = 0x3032; ReplicaMaul = 0x4412; BattleGloves = 0x31FF; HeatRod = 0x42AF; ForceBelt = 0x33A6; FlameBoomerang = 0x438B; SafeguardRing = 0x394E; LightGauntlets = 0x3699; HiReraiser = 0x104D; PhysicalEarring = 0x3456; VileElixir1 = 0x104F; --------------------------------------- -- Gems --------------------------------------- Amber = 0x32E; Amethyst = 0x320; Ametrine = 0x32B; Aquamarine = 0x317; Chrysoberyl = 0x321; ClearTopaz = 0x329; Fluorite = 0x32A; Garnet = 0x316; Goshenite = 0x328; Jadeite = 0x310; LapisLazuli = 0x31B; LightOpal = 0x31C; Moonstone = 0x322; Onyx = 0x31F; Painite = 0x31D; Peridot = 0x314; Sardonyx = 0x327; Sphene = 0x32F; Sunstone = 0x323; Tourmaline = 0x326; Turquoise = 0x31E; Zircon = 0x325; Description: Gil = Zone, { [1] Drop rate, [2] Minimum gil, [3] Maximum gil } Gems = Zone, { [1] Drop rate, [2] gem1, [3] gem2, [4] gem3, ... ,[10] gem10 } Items = Zone, { [1] Drop rate, [2] item1, [3] item2} Date: Any update should be here with the date which was modified as well as an URL where info was taken. * 07/21/2009 URL : http://wiki.ffxiclopedia.org/wiki/Treasure_Chest/Coffer_Guide Done : First collection of all the loot and drop rate. * 19/06/2013 Done : Drop and drop rate by zone --]]----------------------------------------------- gil = {147,{0.152,3440,9000}, 151,{0.440,3200,6320}, 161,{0.382,5000,13950}, 162,{0.306,5000,10000}, 197,{0.394,4702,10000}, 191,{0.308,450,900}, 149,{0.429,3060,6320}, 157,{0.355,2450,7000}, 158,{0.355,2450,7000}, 195,{0.421,5100,12450}, 204,{0.469,4050,7920}, 141,{0.500,800,2100}, 200,{0.576,4425,10000}, 145,{0.448,800,1600}, 196,{0.302,1980,3600}, 192,{0.459,450,1034}, 194,{0.459,450,1034}, 190,{0.474,390,1300}, 213,{0.806,3200,11679}, 198,{0.525,1800,5200}, 11,{0.731,3200,6400}, 193,{0.310,1800,3600}, 143,{0.455,840,1600}, 9,{0.762,5200,12500}, 28,{0.929,5100,9900}, 176,{0.929,3355,8900}, 142,{0.450,800,235}}; gems = {147,{0.090,0x32B,0x316,0x31C,0x31E,0x328,0x32F}, 151,{0.080,0x32B,0x316,0x328,0x31C,0x314,0x327,0x32F,0x31E}, 161,{0.008,0x32B,0x316,0x328,0x314,0x31F,0x32F}, 162,{0.204,0x31E,0x316,0x328,0x314,0x32F,0x31C}, 197,{0.162,0x32B,0x316,0x328,0x31C,0x31F,0x314,0x32F,0x31E}, 191,{0.230,0x32E,0x320,0x329,0x31B,0x327,0x326}, 149,{0.107,0x32B,0x316,0x328,0x31C,0x31F,0x314,0x32F,0x31E}, 157,{0.161,0x32E,0x320,0x329,0x31B,0x31C,0x31F,0x326}, 158,{0.161,0x32E,0x320,0x329,0x31B,0x31C,0x31F,0x326}, 195,{0.105,0x32B,0x328,0x31C,0x31F,0x32F,0x316}, 204,{0.091,0x32B,0x316,0x328,0x31C,0x31F,0x314,0x32F,0x31E}, 141,{0.036,0x32E,0x320,0x31B,0x327,0x326}, 200,{0.059,0x32B,0x316,0x328,0x31C,0x31F,0x314,0x32F,0x31E}, 145,{0.069,0x32E,0x320,0x329,0x31B,0x327,0x326}, 196,{0.233,0x326,0x329,0x32E,0x320,0x31C,0x31B,0x31F}, 192,{0.109,0x32E,0x320,0x329,0x31B,0x326}, 194,{0.109,0x32E,0x320,0x329,0x31B,0x326}, 190,{0.093,0x32E,0x320,0x329,0x31B,0x327,0x326}, 213,{0.194,0x32B,0x316,0x328,0x31C,0x31F,0x314,0x32F,0x31E}, 198,{0.060,0x32E,0x320,0x329,0x31B,0x31C,0x31F,0x327,0x326}, 11,{0.269,0x32B,0x328,0x31C,0x31F,0x314,0x32F,0x31E}, 193,{0.214,0x320,0x329,0x326,0x327,0x31C,0x31B,0x32E,0x31F}, 143,{0.136,0x31B,0x320,0x32E,0x327,0x326,0x329}, 9,{0.238,0x32B,0x31E,0x32F,0x316,0x31F,0x314,0x328}, 28,{0.071,0x316,0x31F,0x32F,0x314,0x31C}, 176,{0.071,0x32B,0x328,0x316,0x31C,0x32F,0x314,0x31F,0x31E}, 142,{0.100,0x32E,0x320,0x31B,0x327,0x326}}; items = {147,{0.758,0x33AE}, 151,{0.480,0x3610}, 161,{0.610,0x34CC}, 162,{0.490,0x34CC}, 197,{0.444,0x4146}, 191,{0.462,0x3035}, 149,{0.464,0x34CB}, 157,{0.484,0x4122}, 158,{0.484,0x4122}, 195,{0.474,0x4183}, 204,{0.440,0x33AF}, 141,{0.464,0x413E}, 200,{0.365,0x359B}, 145,{0.483,0x3435}, 196,{0.465,0x3032,0x4412}, 192,{0.432,0x414F}, 194,{0.432,0x414F}, 190,{0.433,0x31FF}, 213,{}, 198,{0.415,0x42AF}, 11,{}, 193,{0.476,0x33A6}, 143,{0.409,0x438B}, 9,{}, 28,{}, 176,{}, 142,{0.450,0x413E}}; -- Loot calculation rand = math.random(); rand = math.random(); rand = math.random(); for u = 1, table.getn(gil), 2 do if(gil[u] == zone) then if(rand <= gil[u + 1][1])then reward = {"gil",math.random(gil[u + 1][2],gil[u + 1][3])}; elseif(rand <= (gil[u + 1][1] + gems[u + 1][1])) then local num_gems = 0; local curr_gem = 2; while(gems[u + 1][curr_gem] ~= nil) do curr_gem = curr_gem +1; num_gems = num_gems + 1; end rand_gem = math.random(1,num_gems) + 1; reward = {"item",gems[u + 1][rand_gem]}; else local num_item = 0; local curr_item = 2; while(items[u + 1][curr_item] ~= nil) do curr_item = curr_item +1; num_item = num_item + 1; end rand_item = math.random(1,num_item) + 1; reward = {"item",items[u + 1][rand_item]}; end break; end end return reward; end function cofferLoot(zone,npc) --[[----------------------------------------------- Chest Loot --------------------------------------------------- --------------------------------------- -- Items --------------------------------------- BurstScroll = 0x12D4; MagesBalladII = 0x1383; AdeptsRope = 0x33AE; ElectrumHairpin = 0x3610; PhalanxRing = 0x34CC; GigantAxe = 0x4146; TropicalShield = 0x3035; ElectrumRing = 0x34CB; EmethPick = 0x4122; Falcastra = 0x4183; LifeBelt = 0x33AF; CougarBaghnakhs = 0x413E; PyroRobe = 0x359B; MothAxe = 0x414F; ScreamFungus = 0x115F ShieldEarring = 0x3435; FrostShield = 0x3032; ReplicaMaul = 0x4412; BattleGloves = 0x31FF; HeatRod = 0x42AF; ForceBelt = 0x33A6; FlameBoomerang = 0x438B; SafeguardRing = 0x394E; LightGauntlets = 0x3699; HiReraiser = 0x104D; PhysicalEarring = 0x3456; VileElixir1 = 0x104F; --------------------------------------- -- Gems --------------------------------------- Amber = 0x32E; Amethyst = 0x320; Ametrine = 0x32B; Aquamarine = 0x317; Chrysoberyl = 0x321; ClearTopaz = 0x329; Fluorite = 0x32A; Garnet = 0x316; Goshenite = 0x328; Jadeite = 0x310; LapisLazuli = 0x31B; LightOpal = 0x31C; Moonstone = 0x322; Onyx = 0x31F; Painite = 0x31D; Peridot = 0x314; Sardonyx = 0x327; Sphene = 0x32F; Sunstone = 0x323; Tourmaline = 0x326; Turquoise = 0x31E; Zircon = 0x325; Description: Gil = Zone, { [1] Drop rate, [2] Minimum gil, [3] Maximum gil } Gems = Zone, { [1] Drop rate, [2] gem1, [3] gem2, [4] gem3, ... ,[10] gem10 } Items = Zone, { [1] Drop rate, [2] item1, [3] item2} Date: Any update should be here with the date which was modified as well as an URL where info was taken. * 07/21/2009 URL : http://wiki.ffxiclopedia.org/wiki/Treasure_Chest/Coffer_Guide Done : First collection of all the loot and drop rate. * 19/06/2013 Done : Drop and drop rate by zone --]]----------------------------------------------- gil = {147,{0.375,4700,25000}, 153,{0.793,7110,20520}, 151,{0.652,7320,18000}, 161,{0.731,6300,26880}, 197,{0.387,6040,12100}, 160,{0.700,8000,16770}, 195,{0.500,7590,18039}, 200,{0.750,6668,18700}, 205,{0.897,7200,21060}, 174,{0.943,5200,16100}, 150,{0.818,7320,14400}, 12,{0.927,9800,19180}, 208,{0.773,6160,16100}, 130,{0.821,9576,19460}, 176,{0.550,6145,19580}, 159,{0.846,7320,14400}, 169,{0.900,7440,14280}, 177,{0.500,9940,18900}}; gems = {147,{0.240,0x317,0x321,0x322,0x31D,0x314,0x323,0x325,0x32A,0x310}, 153,{0.092,0x317,0x321,0x32A,0x310,0x322,0x323,0x325,0x31D}, 151,{0.044,0x317,0x321,0x32A,0x310,0x322,0x31D,0x323,0x325}, 161,{0.080,0x317,0x321,0x32A,0x310,0x322,0x31D,0x323,0x325}, 197,{0.387,0x317,0x321,0x310,0x31D,0x325,0x323}, 160,{0.300,0x31D,0x325}, 195,{0.250,0x321,0x32A,0x322,0x31D,0x323}, 200,{0.125,0x321,0x310,0x322}, 205,{0.103,0x322,0x31D,0x323,0x321,0x32A,0x317}, 174,{0.057,0x322,0x321,0x31D,0x310,0x323,0x317,0x325,0x32A}, 150,{0.055,0x321,0x32A,0x310,0x322,0x31D,0x323}, 12,{0.073,0x317,0x31D,0x310,0x323,0x325,0x321,0x322}, 208,{0.227,0x317,0x321,0x32A,0x310,0x31D,0x323}, 130,{0.179,0x317,0x321,0x32A,0x310,0x322,0x31D,0x325,0x323}, 176,{0.450,0x317,0x32A,0x310,0x322,0x323,0x31D,0x321}, 159,{0.154,0x31D,0x321,0x32A,0x322,0x325,0x323}, 169,{0.100,0x317,0x321,0x310,0x322,0x31D,0x323,0x325}, 177,{0.500,0x317,0x325}}; items = {147,{0.385,0x12D4}, 153,{0.115,0x115F}, 151,{0.304,0x394E}, 161,{0.189,0x1383}, 197,{0.226,0x104D}, 160,{}, 195,{0.250,0x104F}, 200,{0.125,0x3699}, 205,{}, 174,{}, 150,{0.127,0x3456}, 12,{}, 208,{}, 130,{}, 176,{}, 159,{}, 169,{}, 177,{}}; -- Loot calculation rand = math.random(); rand = math.random(); rand = math.random(); for u = 1, table.getn(gil), 2 do if(gil[u] == zone) then if(rand <= gil[u + 1][1])then reward = {"gil",math.random(gil[u + 1][2],gil[u + 1][3])}; elseif(rand <= (gil[u + 1][1] + gems[u + 1][1])) then local num_gems = 0; local curr_gem = 2; while(gems[u + 1][curr_gem] ~= nil) do curr_gem = curr_gem +1; num_gems = num_gems + 1; end rand_gem = math.random(1,num_gems) + 1; reward = {"item",gems[u + 1][rand_gem]}; else local num_item = 0; local curr_item = 2; while(items[u + 1][curr_item] ~= nil) do curr_item = curr_item +1; num_item = num_item + 1; end rand_item = math.random(1,num_item) + 1; reward = {"item",items[u + 1][rand_item]}; end break; end end return reward; end
gpl-3.0
will4wachter/Project1
scripts/globals/items/dish_of_spaghetti_peperoncino_+1.lua
35
1403
----------------------------------------- -- ID: 5197 -- Item: dish_of_spaghetti_peperoncino_+1 -- Food Effect: 60Min, All Races ----------------------------------------- -- Health % 30 -- Health Cap 75 -- Vitality 2 -- Store TP 6 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,3600,5197); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_FOOD_HPP, 30); target:addMod(MOD_FOOD_HP_CAP, 75); target:addMod(MOD_VIT, 2); target:addMod(MOD_STORETP, 6); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_FOOD_HPP, 30); target:delMod(MOD_FOOD_HP_CAP, 75); target:delMod(MOD_VIT, 2); target:delMod(MOD_STORETP, 6); end;
gpl-3.0
davidedmonds/darkstar
scripts/zones/Northern_San_dOria/npcs/Narsaude.lua
36
1426
----------------------------------- -- Area: Northern San d'Oria -- NPC: Narsaude -- Standard Info NPC ----------------------------------- package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/quests"); require("scripts/zones/Northern_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:startEvent(0x029c); 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/Davoi/npcs/Storage_Hole.lua
17
1563
----------------------------------- -- Area: Davoi -- NPC: Storage Hole -- Involved in Quest: The Crimson Trial -- @pos -51 4 -217 149 ----------------------------------- package.loaded["scripts/zones/Davoi/TextIDs"] = nil; ----------------------------------- require("scripts/globals/keyitems"); require("scripts/globals/quests"); require("scripts/zones/Davoi/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if (player:getQuestStatus(SANDORIA,THE_CRIMSON_TRIAL) == QUEST_ACCEPTED) then if (trade:hasItemQty(1103,1) and trade:getItemCount() == 1) then player:tradeComplete(); player:addKeyItem(ORCISH_DRIED_FOOD); player:messageSpecial(KEYITEM_OBTAINED,ORCISH_DRIED_FOOD); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:getQuestStatus(SANDORIA,THE_CRIMSON_TRIAL) == QUEST_ACCEPTED) then player:messageSpecial(AN_ORCISH_STORAGE_HOLE); else player:messageSpecial(YOU_SEE_NOTHING); 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
kidaa/darkstar
scripts/zones/Port_Bastok/npcs/Dhen_Tevryukoh.lua
34
1619
----------------------------------- -- Area: Port Bastok -- NPC: Dhen Tevryukoh -- Only sells when Bastok controlls Elshimo Uplands -- @zone 236 -- @pos 35 -2 2 -- Confirmed shop stock, August 2013 ----------------------------------- package.loaded["scripts/zones/Port_Bastok/TextIDs"] = nil; ----------------------------------- require("scripts/globals/shop"); require("scripts/globals/conquest"); require("scripts/zones/Port_Bastok/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) RegionOwner = GetRegionOwner(ELSHIMOUPLANDS); if (RegionOwner ~= BASTOK) then player:showText(npc,DHENTEVRYUKOH_CLOSED_DIALOG); else player:showText(npc,DHENTEVRYUKOH_OPEN_DIALOG); stock = { 0x0585, 1656, --Cattleya 0x0274, 239, --Cinnamon 0x1174, 73, --Pamamas 0x02D1, 147 --Rattan Lumber } showShop(player,BASTOK,stock); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
will4wachter/Project1
scripts/zones/AlTaieu/npcs/Auroral_Updraft.lua
4
1685
----------------------------------- -- Area: Al'Taieu -- NPC: Auroral Updraft -- Type: Standard NPC ----------------------------------- package.loaded["scripts/zones/AlTaieu/TextIDs"] = nil; ----------------------------------- require("scripts/zones/AlTaieu/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local Auroral_Offset = 16912900; local npcID = npc:getID(); if(npcID == Auroral_Offset) then player:startEvent(0x0096); elseif(npcID == Auroral_Offset+1) then player:startEvent(0x009B); elseif(npcID == Auroral_Offset+2) then player:startEvent(0x009B); elseif(npcID == Auroral_Offset+3) then player:startEvent(0x009B); elseif(npcID == Auroral_Offset+4) then player:startEvent(0x009B); elseif(npcID == Auroral_Offset+5) then player:startEvent(0x009B); 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 == 0x009B) and option == 1 then player:setPos(-25,-1 ,-620 ,208 ,33); elseif(csid == 0x0096) and option == 1 then player:setPos(611.931, 132.787, 773.427, 192, 32); -- To Sealion's Den {R} end end;
gpl-3.0
lhog/Zero-K
effects/gundam_prettypop.lua
26
1976
-- prettypop return { ["prettypop"] = { groundflash = { air = true, alwaysvisible = true, circlealpha = 0.0, circlegrowth = 8, flashalpha = 0.9, flashsize = 20, ground = true, ttl = 17, water = true, color = { [1] = 1, [2] = 0, [3] = 0.5, }, }, poof01 = { air = true, class = [[CSimpleParticleSystem]], count = 1, ground = true, properties = { airdrag = 0.2, alwaysvisible = true, colormap = [[1.0 1.0 1.0 0.04 1.0 0.0 0.5 0.01 0.1 0.1 0.1 0.01]], directional = false, emitrot = 45, emitrotspread = 32, emitvector = [[0, 1, 0]], gravity = [[0, -0.005, 0]], numparticles = 16, particlelife = 5, particlelifespread = 16, particlesize = 20, particlesizespread = 0, particlespeed = 16, particlespeedspread = 1, pos = [[0, 2, 0]], sizegrowth = 0.8, sizemod = 1.0, texture = [[randdots]], useairlos = false, }, }, pop1 = { air = true, class = [[heatcloud]], count = 1, ground = true, water = true, properties = { alwaysvisible = true, heat = 10, heatfalloff = 0.8, maxheat = 10, pos = [[r-2 r2, 5, r-2 r2]], size = 1, sizegrowth = 16, speed = [[0, 0, 0]], texture = [[bluenovaexplo]], }, }, }, }
gpl-2.0
davidedmonds/darkstar
scripts/zones/Chateau_dOraguille/npcs/Curilla.lua
17
5152
----------------------------------- -- Area: Chateau d'Oraguille -- NPC: Curilla -- Starts and Finishes Quest: The General's Secret, Enveloped in Darkness, Peace for the Spirit, Lure of the Wildcat (San d'Oria) -- @pos 27 0.1 0.1 233 ----------------------------------- package.loaded["scripts/zones/Chateau_dOraguille/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/quests"); require("scripts/zones/Chateau_dOraguille/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) local mLvL = player:getMainLvl(); local mJob = player:getMainJob(); local theGeneralSecret = player:getQuestStatus(SANDORIA,THE_GENERAL_S_SECRET); local envelopedInDarkness = player:getQuestStatus(SANDORIA,ENVELOPED_IN_DARKNESS); local peaceForTheSpirit = player:getQuestStatus(SANDORIA,PEACE_FOR_THE_SPIRIT); local WildcatSandy = player:getVar("WildcatSandy"); if (player:getQuestStatus(SANDORIA,LURE_OF_THE_WILDCAT_SAN_D_ORIA) == QUEST_ACCEPTED and player:getMaskBit(WildcatSandy,15) == false) then player:startEvent(0x0232); elseif (theGeneralSecret == QUEST_AVAILABLE and player:getFameLevel(SANDORIA) >= 2) then player:startEvent(0x0037); -- Start Quest "The General's Secret" elseif (mJob == 5 and mLvL >= AF2_QUEST_LEVEL and player:getQuestStatus(SANDORIA,THE_CRIMSON_TRIAL) == QUEST_COMPLETED and envelopedInDarkness == QUEST_AVAILABLE) then player:startEvent(0x005E); -- Start Quest "Enveloped in Darkness" elseif (player:hasKeyItem(OLD_POCKET_WATCH) and player:hasKeyItem(OLD_BOOTS) == false) then player:startEvent(0x005D); elseif (player:hasKeyItem(OLD_BOOTS) and player:getVar("needs_crawler_blood") == 0) then player:startEvent(0x0065); elseif (player:getVar("needs_crawler_blood") == 1) then player:startEvent(0x0075); elseif (mJob == 5 and mLvL >= AF2_QUEST_LEVEL and envelopedInDarkness == QUEST_COMPLETED and peaceForTheSpirit == QUEST_AVAILABLE) then player:startEvent(0x006D); -- Start Quest "Peace for the Spirit" elseif (peaceForTheSpirit == QUEST_ACCEPTED) then player:startEvent(0x006C); -- Standard dialog during Peace of the spirit elseif (peaceForTheSpirit == QUEST_ACCEPTED and (player:getVar("peaceForTheSpiritCS") >= 2 and player:getVar("peaceForTheSpiritCS") <= 4)) then player:startEvent(0x0071); elseif (peaceForTheSpirit == QUEST_ACCEPTED and player:getVar("peaceForTheSpiritCS") == 5) then player:startEvent(0x0033); elseif (theGeneralSecret == QUEST_ACCEPTED and player:hasKeyItem(CURILLAS_BOTTLE_EMPTY)) then player:startEvent(0x0035); elseif (theGeneralSecret == QUEST_ACCEPTED and player:hasKeyItem(CURILLAS_BOTTLE_FULL)) then player:startEvent(0x0036); elseif (envelopedInDarkness == QUEST_COMPLETED and peaceForTheSpirit == QUEST_AVAILABLE) then player:startEvent(0x0072); -- Standard dialog after Enveloped in darkness elseif (peaceForTheSpirit == QUEST_COMPLETED) then player:startEvent(0x0034); -- Standard dialog after Peace of the spirit else player:startEvent(0x0212); -- Standard dialog end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); if (csid == 0x0037 and option == 1) then player:addQuest(SANDORIA,THE_GENERAL_S_SECRET) player:addKeyItem(CURILLAS_BOTTLE_EMPTY); player:messageSpecial(KEYITEM_OBTAINED,CURILLAS_BOTTLE_EMPTY); elseif (csid == 0x0036) then if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,16409); -- Lynx Baghnakhs else player:delKeyItem(CURILLAS_BOTTLE_FULL); player:addItem(16409); player:messageSpecial(ITEM_OBTAINED,16409); -- Lynx Baghnakhs player:addFame(SANDORIA,SAN_FAME*30); player:completeQuest(SANDORIA,THE_GENERAL_S_SECRET); end elseif (csid == 0x005E and option == 1) then player:addQuest(SANDORIA,ENVELOPED_IN_DARKNESS); player:addKeyItem(OLD_POCKET_WATCH); player:messageSpecial(KEYITEM_OBTAINED,OLD_POCKET_WATCH); elseif (csid == 0x006D and option == 1) then player:addQuest(SANDORIA,PEACE_FOR_THE_SPIRIT); player:setVar("needs_crawler_blood",0); elseif (csid == 0x0065) then player:setVar("needs_crawler_blood",1); elseif (csid == 0x0232) then player:setMaskBit(player:getVar("WildcatSandy"),"WildcatSandy",15,true); end end;
gpl-3.0
kidaa/darkstar
scripts/globals/mobskills/Antimatter.lua
7
1114
--------------------------------------------------- -- Antimatter -- -- Description: Single-target ranged Light damage (~700-1500), ignores Utsusemi. -- Type: Magical -- --------------------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/monstertpmoves"); --------------------------------------------------- function onMobSkillCheck(target,mob,skill) local mobID = mob:getID(); --(16908295 ,16908302 ,16908309 =omega , 16928966=proto-ultima ) local mobhp = mob:getHPP(); if (( (mobhp > 80 or (mobhp < 60 and mobhp > 20 ) )and mobID == 16928966) or(mobhp < 20 and(mobID == 16908295 or mobID == 16908302 or mobID == 16908309 )))then return 0; end return 1; end; function onMobWeaponSkill(target, mob, skill) local dmgmod = 2.5; local info = MobMagicalMove(mob,target,skill,mob:getWeaponDmg()*3,ELE_LIGHT,dmgmod,TP_MAB_BONUS,1); local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_MAGICAL,MOBPARAM_LIGHT,MOBPARAM_IGNORE_SHADOWS); target:delHP(dmg); return dmg; end
gpl-3.0
kidaa/darkstar
scripts/globals/weaponskills/upheaval.lua
30
1538
----------------------------------- -- Upheaval -- Great Axe weapon skill -- Skill Level: 357 -- Delivers a four-hit attack. Damage varies with TP. -- In order to obtain Upheaval, the quest Martial Mastery must be completed. -- Aligned with Flame Gorget, Light Gorget & Shadow Gorget. -- Aligned with Flame Belt, Light Belt & Shadow Belt. -- Element: None -- Modifiers: VIT: 73~85%, depending on merit points upgrades. -- 100%TP 200%TP 300%TP -- 1.00 3.50 6.5 ----------------------------------- require("scripts/globals/status"); require("scripts/globals/settings"); require("scripts/globals/weaponskills"); ----------------------------------- function onUseWeaponSkill(player, target, wsID) local params = {}; params.numHits = 4; params.ftp100 = 1.0; params.ftp200 = 3.5; params.ftp300 = 6.5; params.str_wsc = 0.0; params.dex_wsc = 0.0; params.vit_wsc = 0.85 + (player:getMerit(MERIT_UPHEAVAL) / 100); 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 = true; params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0; params.atkmulti = 1; if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then params.vit_wsc = 0.7 + (player:getMerit(MERIT_UPHEAVAL) / 100); end local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, params); damage = damage * WEAPON_SKILL_POWER return tpHits, extraHits, criticalHit, damage; end
gpl-3.0
lhog/Zero-K
LuaRules/Gadgets/CAI/UnitClusterHandler.lua
8
5498
--[[ Determines the cluster structure of a list of units. == CreateUnitList(losCheckAllyTeamID, clusterRadius) losCheckAllyTeamID is for the underlying UnitList. clusterRadius is how close two units need to be to be within the same cluster. Close units may be in different clusters depending on how the boundaries work out. === local functions === All UnitList local functions are accessible along with two more. == UpdateUnitPositions() Updates the clusters based on the current unit positions. == ClusterIterator() -> averageX, averageZ, totalCost, unitCount Iterates over the clusters of units. --]] local UnitListHandler = VFS.Include("LuaRules/Gadgets/CAI/UnitListHandler.lua") local UnitClusterHandler = {} local function DisSQ(x1,z1,x2,z2) return (x1 - x2)^2 + (z1 - z2)^2 end function UnitClusterHandler.CreateUnitCluster(losCheckAllyTeamID, clusterRadius) local unitList = UnitListHandler.CreateUnitList(losCheckAllyTeamID) local clusterRadiusSq = clusterRadius^2 local clusterList = {} local clusterCount = 0 -- Cluster Handling local function AddUnitToCluster(index, unitID) local x,_,z = unitList.GetUnitPosition(unitID) if not x then return end if not index then local cost = unitList.GetUnitCost(unitID) clusterCount = clusterCount + 1 clusterList[clusterCount] = { x = x, z = z, averageX = x, averageZ = z, xSum = x*cost, zSum = z*cost, costSum = cost, unitCount = 1, unitMap = {[unitID] = true}, } unitList.SetUnitDataValue(unitID, "clusterX", x) unitList.SetUnitDataValue(unitID, "clusterZ", z) return end local clusterData = clusterList[index] local cost = unitList.GetUnitCost(unitID) unitList.SetUnitDataValue(unitID, "clusterX", x) unitList.SetUnitDataValue(unitID, "clusterZ", z) clusterData.xSum = clusterData.xSum + x*cost clusterData.zSum = clusterData.zSum + z*cost clusterData.costSum = clusterData.costSum + cost clusterData.averageX = clusterData.xSum/clusterData.costSum clusterData.averageZ = clusterData.zSum/clusterData.costSum clusterData.unitMap[unitID] = true clusterData.unitCount = clusterData.unitCount + 1 end local function RemoveUnitFromCluster(index, unitID) local clusterData = clusterList[index] if clusterData.unitCount == 1 then clusterList[index] = clusterList[clusterCount] clusterList[clusterCount] = nil clusterCount = clusterCount - 1 return end local cost = unitList.GetUnitCost(unitID) local unitData = unitList.GetUnitData(unitID) local x, z = unitData.clusterX, unitData.clusterZ clusterData.xSum = clusterData.xSum - x*cost clusterData.zSum = clusterData.zSum - z*cost clusterData.costSum = clusterData.costSum - cost clusterData.averageX = clusterData.xSum/clusterData.costSum clusterData.averageZ = clusterData.zSum/clusterData.costSum clusterData.unitMap[unitID] = nil clusterData.unitCount = clusterData.unitCount - 1 end local function HandleUnitAddition(unitID) local x,_,z = unitList.GetUnitPosition(unitID) if not x then return false end local minDis = false local minIndex = false for i = 1, clusterCount do local clusterData = clusterList[i] local disSq = DisSQ(x,z,clusterData.x,clusterData.z) if disSq < clusterRadiusSq then local aDisSq = DisSQ(x,z,clusterData.averageX,clusterData.averageZ) if (not minDis) or aDisSq < minDis then minDis = disSq minIndex = i end end end AddUnitToCluster(minIndex, unitID) end local function HandleUnitRemoval(unitID) for i = 1, clusterCount do local clusterData = clusterList[i] if clusterData.unitMap[unitID] then RemoveUnitFromCluster(i, unitID) return end end end -- Extra Cluster External local functions local function ClusterIterator() -- x, z, cost, count local i = 0 return function () i = i + 1 if i <= clusterCount then local clusterData = clusterList[i] return clusterData.averageX, clusterData.averageZ, clusterData.costSum, clusterData.unitCount end end end local function UpdateUnitPositions(range) for unitID,_ in unitList.Iterator() do if unitList.HasUnitMoved(unitID,range) then HandleUnitRemoval(unitID) HandleUnitAddition(unitID) end end end -- UnitListHandler External local functions local function AddUnit(unitID, cost, static, newData) if unitList.AddUnit(unitID, cost, static, newData) then HandleUnitAddition(unitID) end end local function RemoveUnit(unitID) if unitList.ValidUnitID(unitID) then HandleUnitRemoval(unitID) end unitList.RemoveUnit(unitID) end local function SetUnitDataValue(unitID, key, value) if key ~= "clusterX" and key ~= "clusterZ" then unitList.SetUnitDataValue(unitID, key, value) end end local unitCluster = { ClusterIterator = ClusterIterator, UpdateUnitPositions = UpdateUnitPositions, AddUnit = AddUnit, RemoveUnit = RemoveUnit, SetUnitDataValue = SetUnitDataValue, GetUnitPosition = unitList.GetUnitPosition, GetNearestUnit = unitList.GetNearestUnit, HasUnitMoved = unitList.HasUnitMoved, IsPositionNearUnit = unitList.IsPositionNearUnit, OverwriteUnitData = unitList.OverwriteUnitData, GetUnitData = unitList.GetUnitData, GetUnitCost = unitList.GetUnitCost, GetTotalCost = unitList.GetTotalCost, ValidUnitID = unitList.ValidUnitID, Iterator = unitList.Iterator, } return unitCluster end return UnitClusterHandler
gpl-2.0
waterlgndx/darkstar
scripts/zones/Arrapago_Reef/npcs/Meyaada.lua
2
2478
----------------------------------- -- Area: Arrapago Reef -- NPC: Meyaada -- Type: Assault -- !pos 22.446 -7.920 573.390 54 ----------------------------------- package.loaded["scripts/zones/Arrapago_Reef/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/keyitems"); require("scripts/globals/missions"); require("scripts/globals/quests"); require("scripts/zones/Arrapago_Reef/TextIDs"); ----------------------------------- function onTrade(player,npc,trade) end; function onTrigger(player,npc) local toauMission = player:getCurrentMission(TOAU); local beginnings = player:getQuestStatus(AHT_URHGAN,BEGINNINGS); -- IMMORTAL SENTRIES if (toauMission == IMMORTAL_SENTRIES) then if (player:hasKeyItem(dsp.ki.SUPPLIES_PACKAGE)) then player:startEvent(5); elseif (player:getVar("AhtUrganStatus") == 1) then player:startEvent(6); end; -- BEGINNINGS elseif (beginnings == QUEST_ACCEPTED) then if (not player:hasKeyItem(dsp.ki.BRAND_OF_THE_SPRINGSERPENT)) then player:startEvent(10); -- brands you else player:startEvent(11); -- a harsh road lies before you end; -- ASSAULT -- elseif (toauMission >= PRESIDENT_SALAHEEM) then local IPpoint = player:getCurrency("imperial_standing"); if (player:hasKeyItem(dsp.ki.ILRUSI_ASSAULT_ORDERS) and player:hasKeyItem(dsp.ki.ASSAULT_ARMBAND) == false) then player:startEvent(223,50,IPpoint); else player:startEvent(7); -- player:delKeyItem(dsp.ki.ASSAULT_ARMBAND); end; -- DEFAULT DIALOG else player:startEvent(4); end; end; function onEventUpdate(player,csid,option) end; function onEventFinish(player,csid,option) -- IMMORTAL SENTRIES if (csid == 5 and option == 1) then player:delKeyItem(dsp.ki.SUPPLIES_PACKAGE); player:setVar("AhtUrganStatus",1); -- BEGINNINGS elseif (csid == 10) then player:addKeyItem(dsp.ki.BRAND_OF_THE_SPRINGSERPENT); player:messageSpecial(KEYITEM_OBTAINED,dsp.ki.BRAND_OF_THE_SPRINGSERPENT); -- ASSAULT -- elseif (csid == 223 and option == 1) then player:delCurrency("imperial_standing", 50); player:addKeyItem(dsp.ki.ASSAULT_ARMBAND); player:messageSpecial(KEYITEM_OBTAINED,dsp.ki.ASSAULT_ARMBAND); end; end;
gpl-3.0
will4wachter/Project1
scripts/zones/Phomiuna_Aqueducts/npcs/qm10.lua
34
1039
----------------------------------- -- Area: Phomiuna Aqueducts -- NPC: qm10 (???) -- Notes: Opens south door @ J-7 -- @pos 113.474 -26.000 91.610 27 ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local DoorOffset = npc:getID() - 63; if (GetNPCByID(DoorOffset):getAnimation() == 9) then GetNPCByID(DoorOffset):openDoor(7); -- _0rh 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
dani-sj/evilboot
bot/creedbot.lua
4
15620
package.path = package.path .. ';.luarocks/share/lua/5.2/?.lua' ..';.luarocks/share/lua/5.2/?/init.lua' package.cpath = package.cpath .. ';.luarocks/lib/lua/5.2/?.so' require("./bot/utils") VERSION = '1.0' -- This function is called when tg receive a msg function on_msg_receive (msg) if not started then return end local receiver = get_receiver(msg) print (receiver) --vardump(msg) msg = pre_process_service_msg(msg) if msg_valid(msg) then msg = pre_process_msg(msg) if msg then match_plugins(msg) -- mark_read(receiver, ok_cb, false) end end end function ok_cb(extra, success, result) end function on_binlog_replay_end() started = true postpone (cron_plugins, false, 60*5.0) _config = load_config() -- load plugins plugins = {} load_plugins() end function msg_valid(msg) -- Don't process outgoing messages if msg.out then print('\27[36mNot valid: msg from us\27[39m') return false end -- Before bot was started if msg.date < now then print('\27[36mNot valid: old msg\27[39m') return false end if msg.unread == 0 then print('\27[36mNot valid: readed\27[39m') return false end if not msg.to.id then print('\27[36mNot valid: To id not provided\27[39m') return false end if not msg.from.id then print('\27[36mNot valid: From id not provided\27[39m') return false end if msg.from.id == our_id then print('\27[36mNot valid: Msg from our id\27[39m') return false end if msg.to.type == 'encr_chat' then print('\27[36mNot valid: Encrypted chat\27[39m') return false end if msg.from.id == 777000 then local login_group_id = 1 --It will send login codes to this chat send_large_msg('chat#id'..login_group_id, msg.text) end return true end -- function pre_process_service_msg(msg) if msg.service then local action = msg.action or {type=""} -- Double ! to discriminate of normal actions msg.text = "!!tgservice " .. action.type -- wipe the data to allow the bot to read service messages if msg.out then msg.out = false end if msg.from.id == our_id then msg.from.id = 0 end end return msg end -- Apply plugin.pre_process function function pre_process_msg(msg) for name,plugin in pairs(plugins) do if plugin.pre_process and msg then print('Preprocess', name) msg = plugin.pre_process(msg) end end return msg end -- Go over enabled plugins patterns. function match_plugins(msg) for name, plugin in pairs(plugins) do match_plugin(plugin, name, msg) end end -- Check if plugin is on _config.disabled_plugin_on_chat table local function is_plugin_disabled_on_chat(plugin_name, receiver) local disabled_chats = _config.disabled_plugin_on_chat -- Table exists and chat has disabled plugins if disabled_chats and disabled_chats[receiver] then -- Checks if plugin is disabled on this chat for disabled_plugin,disabled in pairs(disabled_chats[receiver]) do if disabled_plugin == plugin_name and disabled then local warning = 'Plugin '..disabled_plugin..' is disabled on this chat' print(warning) send_msg(receiver, warning, ok_cb, false) return true end end end return false end function match_plugin(plugin, plugin_name, msg) local receiver = get_receiver(msg) -- Go over patterns. If one matches it's enough. for k, pattern in pairs(plugin.patterns) do local matches = match_pattern(pattern, msg.text) if matches then print("msg matches: ", pattern) if is_plugin_disabled_on_chat(plugin_name, receiver) then return nil end -- Function exists if plugin.run then -- If plugin is for privileged users only if not warns_user_not_allowed(plugin, msg) then local result = plugin.run(msg, matches) if result then send_large_msg(receiver, result) end end end -- One patterns matches return end end end -- DEPRECATED, use send_large_msg(destination, text) function _send_msg(destination, text) send_large_msg(destination, text) end -- Save the content of _config to config.lua function save_config( ) serialize_to_file(_config, './data/config.lua') print ('saved config into ./data/config.lua') end -- Returns the config from config.lua file. -- If file doesn't exist, create it. function load_config( ) local f = io.open('./data/config.lua', "r") -- If config.lua doesn't exist if not f then print ("Created new config file: data/config.lua") create_config() else f:close() end local config = loadfile ("./data/config.lua")() for v,user in pairs(config.sudo_users) do print("Allowed user: " .. user) end return config end -- Create a basic config.json file and saves it. function create_config( ) -- A simple config with basic plugins and ourselves as privileged user config = { enabled_plugins = { "onservice", "inrealm", "ingroup", "inpm", "banhammer", ".", "Feedback", "plugins", "lock_join", "antilink", "antitag", "gps", "auto_leave", "cpu", "calc", "bin", "tagall", "text", "info", "bot_on_off", "welcome", "webshot", "google", "sms", "anti_spam", "add_bot", "owners", "set", "get", "broadcast", "download_media", "invite", "all", "filer", "leave_ban" }, sudo_users = {103365027,24878907},--Sudo users disabled_channels = {}, realm = {},--Realms Id moderation = {data = 'data/moderation.json'}, about_text = [[Creed bot 2.3 Hello my Good friends ‼️ this bot is made by : @creed_is_dead 〰〰〰〰〰〰〰〰 ߔࠀ our admins are : ߔࠀ @rm13790115 〰〰〰〰〰〰〰〰 ♻️ You can send your Ideas and messages to Us By sending them into bots account by this command : تمامی درخواست ها و همه ی انتقادات و حرفاتونو با دستور زیر بفرستین به ما !feedback (your ideas and messages) ]], help_text_realm = [[ Realm Commands: !creategroup [Name] Create a group گروه جدیدی بسازید !createrealm [Name] Create a realm گروه مادر جدیدی بسازید !setname [Name] Set realm name اسم گروه مادر را تغییر بدهید !setabout [GroupID] [Text] Set a group's about text در مورد آن گروه توضیحاتی را بنویسید (ای دی گروه را بدهید ) !setrules [GroupID] [Text] Set a group's rules در مورد آن گروه قوانینی تعیین کنید ( ای دی گروه را بدهید ) !lock [GroupID] [setting] Lock a group's setting تنظیکات گروهی را قفل بکنید !unlock [GroupID] [setting] Unock a group's setting تنظیمات گروهی را از قفل در بیاورید !wholist Get a list of members in group/realm لیست تمامی اعضای گروه رو با ای دی شون نشون میده !who Get a file of members in group/realm لیست تمامی اعضای گروه را با ای دی در فایل متنی دریافت کنید !type Get group type در مورد نقش گروه بگیرید !kill chat [GroupID] Kick all memebers and delete group ⛔️⛔️ ⛔️تمامی اعضای گروه را حذف میکند ⛔️ !kill realm [RealmID] Kick all members and delete realm⛔️⛔️ تمامی اعضای گروه مارد را حذف میکند !addadmin [id|username] Promote an admin by id OR username *Sudo only ادمینی را اضافه بکنید !removeadmin [id|username] Demote an admin by id OR username *Sudo only❗️❗️ ❗️❗️ادمینی را با این دستور صلب مقام میکنید ❗️❗️ !list groups Get a list of all groups لیست تمامی گروه هارو میده !list realms Get a list of all realms لیست گروه های مادر را میدهد !log Get a logfile of current group or realm تمامی عملیات گروه را میدهد !broadcast [text] Send text to all groups ✉️ ✉️ با این دستور به تمامی گروه ها متنی را همزمان میفرستید . !br [group_id] [text] This command will send text to [group_id]✉️ با این دستور میتونید به گروه توسط ربات متنی را بفرستید You Can user both "!" & "/" for them میتوانید از هردوی کاراکتر های ! و / برای دستورات استفاده کنید ]], help_text = [[ Creed bots Help for mods : Plugins Banhammer : Help For Banhammer دستوراتی برای کنترل گروه !Kick @UserName or ID شخصی را از گروه حذف کنید . همچنین با ریپلی هم میشه !Ban @UserName or ID برای بن کردن شخص اسفاده میشود . با ریپلی هم میشه !Unban @UserName برای آنبن کردن شخصی استفاده میشود . همچنین با ریپلی هم میشه For Admins : !banall ID برای بن گلوبال کردن از تمامی گروه هاست باید ای دی بدین با ریپلی هم میشه !unbanall ID برای آنبن کردن استفاده میشود ولی فقط با ای دی میشود 〰〰〰〰〰〰〰〰〰〰 2. GroupManager : !lock leave اگر کسی از گروه برود نمیتواند برگردد !lock tag برای مجوز ندادن به اعضا از استفاده کردن @ و # برای تگ !Creategp "GroupName" you can Create group with this comman با این دستور برای ساخت گروه استفاده بکنید !lock member For locking Inviting users برای جلوگیری از آمدن اعضای جدید استفاده میشود !lock bots for Locking Bots invitation برای جلوگیری از ادد کردن ربا استفاده میشود !lock name ❤️ To lock the group name for every bodey برای قفل کردن اسم استفاده میشود !setfloodߘ㊓et the group flood control߈銙囌زان اسپم را در گروه تعیین میکنید !settings ❌ Watch group settings تنظیمات فعلی گروه را میبینید !owner watch group owner آیدی سازنده گروه رو میبینید !setowner user_id❗️ You can set someone to the group owner‼️ برای گروه سازنده تعیین میکنید !modlist catch Group mods لیست مدیران گروه را میگیرید !lock join to lock joining the group by link برای جلوگیری از وارد شدن به کروه با لینک !lock flood⚠️ lock group flood از اسپم دادن در گروه جلوگیری کنید !unlock (bots-member-flood-photo-name-tag-link-join-Arabic)✅ Unlock Something موارد بالا را با این دستور آزاد میسازید !rules && !set rules TO see group rules or set rules برای دیدن قوانین گروه و یا انتخاب قوانین !about or !set about watch about group or set about در مورد توضیحات گروه میدهد و یا توضیحات گروه رو تعیین کنید !res @username see Username INfo در مورد اسم و ای دی شخص بهتون میده !who♦️ Get Ids Chat امی ای دی های موجود در چت رو بهتون میده !log get members id ♠️ تمامی فعالیت های انجام یافته توسط شما و یا مدیران رو نشون میده !all Says every thing he knows about a group در مورد تمامی اطلاعات ثبت شده در مورد گروه میدهد !newlink Changes or Makes new group link لینک گروه رو عوض میکنه !getlink gets The Group link لینک گروه را در گروه نمایش میده !linkpv sends the group link to the PV برای دریافت لینک در پیوی استفاده میشه 〰〰〰〰〰〰〰〰 Admins :® !add to add the group as knows برای مجوز دادن به ربات برای استفاده در گروه !rem to remove the group and be unknown برای ناشناس کردن گروه برای ربات توسط مدیران اصلی !setgpowner (Gpid) user_id ⚫️ For Set a Owner of group from realm برای تعیین سازنده ای برای گروه از گروه مادر !addadmin [Username] to add a Global admin to the bot برای ادد کردن ادمین اصلی ربات !removeadmin [username] to remove an admin from global admins برای صلب ادمینی از ادمینای اصلی !plugins - [plugins] To Disable the plugin برای غیر فعال کردن پلاگین توسط سازنده !plugins + [plugins] To enable a plugins برای فعال کردن چلاگین توسط سازنده !plugins ? To reload al plugins رای تازه سازی تمامی پلاگین های فعال !plugins Shows the list of all plugins لیست تمامی پلاگین هارو نشون میده !sms [id] (text) To send a message to an account by his/her ID برای فرستادن متنی توسط ربات به شخصی با ای دی اون 〰〰〰〰〰〰〰〰〰〰〰 3. Stats :© !stats creedbot (sudoers)✔️ To see the stats of creed bot برای دیدن آمار ربات !stats To see the group stats برای دیدن آمار گروه 〰〰〰〰〰〰〰〰 4. Feedback⚫️ !feedback (text) To send your ideas to the Moderation group برای فرستادن انتقادات و پیشنهادات و حرف خود با مدیر ها استفاده میشه 〰〰〰〰〰〰〰〰〰〰〰 5. Tagall◻️ !tagall (text) To tags the every one and sends your message at bottom تگ کردن همه ی اعضای گروه و نوشتن پیام شما زیرش 〰〰〰〰〰〰〰〰〰 More plugins soon ... ⚠️ We are Creeds ⚠️ our channel : @creedantispam_channel کانال ما You Can user both "!" & "/" for them می توانید از دو شکلک ! و / برای دادن دستورات استفاده کنید ]] } serialize_to_file(config, './data/config.lua') print('saved config into ./data/config.lua') end function on_our_id (id) our_id = id end function on_user_update (user, what) --vardump (user) end function on_chat_update (chat, what) end function on_secret_chat_update (schat, what) --vardump (schat) end function on_get_difference_end () end -- Enable plugins in config.json function load_plugins() for k, v in pairs(_config.enabled_plugins) do print("Loading plugin", v) local ok, err = pcall(function() local t = loadfile("plugins/"..v..'.lua')() plugins[v] = t end) if not ok then print('\27[31mError loading plugin '..v..'\27[39m') print('\27[31m'..err..'\27[39m') end end end -- custom add function load_data(filename) local f = io.open(filename) if not f then return {} end local s = f:read('*all') f:close() local data = JSON.decode(s) return data end function save_data(filename, data) local s = JSON.encode(data) local f = io.open(filename, 'w') f:write(s) f:close() end -- Call and postpone execution for cron plugins function cron_plugins() for name, plugin in pairs(plugins) do -- Only plugins with cron function if plugin.cron ~= nil then plugin.cron() end end -- Called again in 2 mins postpone (cron_plugins, false, 120) end -- Start and load values our_id = 0 now = os.time() math.randomseed(now) started = false
gpl-2.0
waterlgndx/darkstar
scripts/globals/spells/foe_requiem.lua
2
1862
----------------------------------------- -- Spell: Foe Requiem ----------------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); require("scripts/globals/msg"); ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) local effect = dsp.effect.REQUIEM; local duration = 63; local power = 1; local pCHR = caster:getStat(dsp.mod.CHR); local mCHR = target:getStat(dsp.mod.CHR); local dCHR = (pCHR - mCHR); local params = {}; params.diff = nil; params.attribute = dsp.mod.CHR; params.skillType = dsp.skill.SINGING; params.bonus = 0; params.effect = nil; resm = applyResistance(caster, target, spell, params); if (resm < 0.5) then spell:setMsg(dsp.msg.basic.MAGIC_RESIST); -- resist message return 1; end local iBoost = caster:getMod(dsp.mod.REQUIEM_EFFECT) + caster:getMod(dsp.mod.ALL_SONGS_EFFECT); power = power + iBoost; 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); 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 -- Try to overwrite weaker slow / haste if (canOverwrite(target, effect, power)) then -- overwrite them target:delStatusEffect(effect); target:addStatusEffect(effect,power,3,duration); spell:setMsg(dsp.msg.basic.MAGIC_ENFEEB); else spell:setMsg(dsp.msg.basic.MAGIC_NO_EFFECT); -- no effect end return effect; end;
gpl-3.0