Lua Clones Dungeon [Quest]

Discussion in 'Support' started by Carlitos Flow, Mar 24, 2017.

  1. Aled

    Aled Active Member

    Joined:
    Mar 30, 2017
    Messages:
    129
    Likes Received:
    71
    Best Answers:
    6
    For all of the boxes on your map, say, itemid == 1738 and put actionid == 1000 then do in actions
    Code (Lua):
    1. function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    2.    doTransformItem(item, 2250)
    3.    doSummonCreature(monster,fromPosition)
    4.    setGlobalStorageValue(key,getGlobalStorageValue(key)+1)
    5. end
    then do
    Code (Lua):
    1. for i, box in ipairs(boxes) do
    2.     doTransformItem(box, __boxitemid__)
    3. end
    4. setGlobalStorageValue(key,0)
    when player dies or quest is completed
     
    Last edited: Apr 21, 2017 at 11:44 AM
  2. Carlitos Flow

    Carlitos Flow Developer (lvl*1)

    Joined:
    Mar 2, 2011
    Messages:
    100
    Likes Received:
    6
    Best Answers:
    1
    When I back to house I test all, im on cel now im no seeing good, @Aled but Also remember the will got the global storage after kill the monster. Like this?
    Actions/box.lua
    Code (Lua):
    1.  
    2. local summon={
    3.     {'Dragon'},
    4.     {'Demon'},
    5.     {'Dragon Lord'},
    6.     {'Fury'}
    7. }
    8. function onUse(cid, item, fromPosition, itemEx, toPosition)
    9.    if item.actionid == 1000 then -- Change itemid and actionid
    10.    local i = math.random(#summon)
    11.        doRemoveItem(item.uid, 1)
    12.       doCreateMonster(summon[i][1], toPosition)
    13.       doSendMagicEffect(toPosition, CONST_ME_TELEPORT)
    14.    end
    15.    return true
    16. end
    17.  
    creaturescripts/endquest.lua
    Code (Lua):
    1.  
    2. dofile('data/actions/box.lua')
    3.  
    4. function onKill(cid, target)
    5. local config = {
    6.     ["summon[i]"] = {amount = 1, storage = 26700}
    7. }
    8.  
    9. local monster = config[getCreatureName(target):lower()]
    10.  
    11.     if(isPlayer(target)) or not monster then
    12.         return true
    13.     end
    14.  
    15.     if getPlayerStorageValue(cid, monster.storage) >= -1 and (getPlayerStorageValue(cid, monster.storage) +1) < monster.amount then  
    16.         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) +1)
    17.     end
    18.     if (getPlayerStorageValue(cid, monster.storage) +1) == monster.amount then
    19.         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, +1)
    20.     end
    21.     return TRUE
    22. end
     
  3. GarQet

    GarQet Own3d!

    Joined:
    Feb 10, 2009
    Messages:
    1,281
    Likes Received:
    45
    Best Answers:
    4
    Imo in that case better to use that "shit" items: [​IMG]
    Code (Lua):
    1.  
    2.     local boxes = {
    3.        {x = 1000, y = 1200, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    4.        {x = 1001, y = 1200, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    5.        {x = 1002, y = 1200, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    6.        {x = 1003, y = 1200, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    7.        {x = 1004, y = 1200, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    8.        {x = 1005, y = 1200, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}
    9.    }
    10.    local container_id_new = 1428
    11.    local container_id_broken = 1427
    12.    local actionid = 1000
    13.    local storage_amount_of_opened_boxes = 1001
    14.    local key = 1000
    15.    for i = 1, #boxes do
    16.        if getThingFromPos(boxes[i]).itemid == container_id_broken then
    17.            doTransformItem(getThingFromPos(boxes[i]).uid, container_id_new)
    18.            doSetItemActionId(getThingFromPos(boxes[i]).uid, actionid)
    19.        end
    20.    end
    21.    setGlobalStorageValue(key, 0)
    22.    setGlobalStorageValue(storage_amount_of_opened_boxes, 0)
    23.  
    Code (Lua):
    1.  
    2. local summon = {
    3.        {'Dragon'},
    4.        {'Demon'},
    5.        {'Dragon Lord'},
    6.        {'Fury'}
    7.    }
    8.    local container_id_broken = 1427
    9.    local actionid = 1000
    10.    local storage_amount_of_opened_boxes = 1001
    11.  
    12.    function onUse(cid, item, fromPosition, itemEx, toPosition)
    13.        if item.actionid == actionid then -- Change itemid and actionid
    14.            local i = math.random(#summon)
    15.            local pos = getClosestFreeTile(cid, toPosition)
    16.            doTransformItem(item.uid, 1427)
    17.            doSetItemActionId(item.uid, 0)
    18.            doCreateMonster(summon[i][1], pos)
    19.            doSendMagicEffect(pos, CONST_ME_TELEPORT)
    20.            setGlobalStorageValue(storage_amount_of_opened_boxes, tonumber(getGlobalStorageValue(storage_amount_of_opened_boxes) + 1))
    21.        end
    22.        return true
    23.    end
    24.  
     
    Last edited: Apr 21, 2017 at 4:09 PM
    Mummrik likes this.
  4. Carlitos Flow

    Carlitos Flow Developer (lvl*1)

    Joined:
    Mar 2, 2011
    Messages:
    100
    Likes Received:
    6
    Best Answers:
    1
    Now my creaturescript : (i want it script take +1 of storage when i kill 1 monster, until (+10) getStorageValue(43600,10) for done the quest. Error on console: <luaGetCreatureStorage> Creature not found
    Code (Lua):
    1.  
    2. function resetQuest()
    3.   local boxes = {
    4.        {x = 996, y = 1001, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    5.        {x = 998, y = 1001, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    6.        {x = 1000, y = 1001, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    7.        {x = 1002, y = 1001, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    8.        {x = 1004, y = 1001, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    9.        {x = 996, y = 1003, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    10.        {x = 998, y = 1003, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    11.        {x = 1000, y = 1003, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    12.        {x = 1002, y = 1003, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    13.        {x = 1004, y = 1003, z = 7, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}
    14.    }
    15.    
    16.    local container_id_new = 1428
    17.    local container_id_broken = 1427
    18.    local actionid = 43600
    19.    local storage_amount_of_opened_boxes = 1001
    20.    for i = 1, #boxes do
    21.    
    22.        if getThingFromPos(boxes[i]).itemid == container_id_broken then
    23.            doTransformItem(getThingFromPos(boxes[i]).uid, container_id_new)
    24.            doSetItemActionId(getThingFromPos(boxes[i]).uid, actionid)
    25.        end
    26.    end
    27. return TRUE
    28. end
    29.  
    30.  
    31. function onKill(cid, target)
    32. local config = {
    33.     ["dragon"] = {storage = 1050},
    34.     ["dragon lord"] = {storage = 1050}
    35. }
    36.  
    37. local monster = config[getCreatureName(target):lower()]
    38.  
    39.  
    40.     if(isPlayer(target)) or not monster then
    41.     return TRUE
    42.     end
    43.        
    44.     if getGlobalStorageValue(cid, monster.storage) >= 0 then  
    45.      setGlobalStorageValue(cid, monster.storage, getGlobalStorageValue(cid, monster.storage) +1)
    46.     end
    47.  
    48.    --- end quest --
    49.     if getPlayerStorageValue(cid,1050,0) and getGlobalStorageValue(cid, 2050,10) then
    50.     setPlayerStorageValue(cid,1050,-1)
    51.     setGlobalStorageValue(cid,2050,-1)
    52.     doPlayerTeleportThing(cid,{x=1000, y=1000, z=7}, false)
    53.     resetQuest()
    54. end
    55. return TRUE
    56. end
     
  5. GarQet

    GarQet Own3d!

    Joined:
    Feb 10, 2009
    Messages:
    1,281
    Likes Received:
    45
    Best Answers:
    4
    Code (Lua):
    1. getGlobalStorageValue(cid,2050,10)
    remove all "cid," from globalStorages
    Code (Lua):
    1. getPlayerStorageValue(cid,1050) == 0
    2. getGlobalStorageValue(2050) == 10
     
    Carlitos Flow likes this.
  6. Carlitos Flow

    Carlitos Flow Developer (lvl*1)

    Joined:
    Mar 2, 2011
    Messages:
    100
    Likes Received:
    6
    Best Answers:
    1
    all working, but one question, i only can set globalstorages right? because if i try only storage all team using "setplayerstorage"doesnt works:/ Also here the bug of now with globalstorages: (when the team kill the 10 monster, they will be tp to a position and got the reward, and storage of 31 days for do again. the problem is: data/live/032-position 'toPosition' <a nil value> in function 'isInArea' [isIn Arena works on other quest, idk what happen)

    Code (Lua):
    1.  
    2. function resetQuest()
    3.   local boxes = {
    4.        {x = 996, y = 1001, z = 5, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    5.        {x = 998, y = 1001, z = 5, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    6.        {x = 1000, y = 1001, z = 5, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    7.        {x = 1002, y = 1001, z = 5, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    8.        {x = 1004, y = 1001, z = 5, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    9.        {x = 996, y = 1003, z = 5, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    10.        {x = 998, y = 1003, z = 5, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    11.        {x = 1000, y = 1003, z = 5, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    12.        {x = 1002, y = 1003, z = 5, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE},
    13.        {x = 1004, y = 1003, z = 5, stackpos = STACKPOS_FIRST_ITEM_ABOVE_GROUNDTILE}
    14.    }
    15.    
    16.    local container_id_new = 1428
    17.    local container_id_broken = 1427
    18.    local actionid = 43600
    19.    local storage_amount_of_opened_boxes = 1001
    20.    for i = 1, #boxes do
    21.    
    22.    
    23.        if getThingFromPos(boxes[i]).itemid == container_id_broken then
    24.            doTransformItem(getThingFromPos(boxes[i]).uid, container_id_new)
    25.            doSetItemActionId(getThingFromPos(boxes[i]).uid, actionid)  
    26.        end
    27.    end
    28. return TRUE
    29. end
    30.  
    31. local config = {
    32. questFromPos = {x=991,y=995,z=5, stackpos=253},
    33. questToPos = {x=1009,y=1011,z=5, stackpos=253}}
    34.  
    35. function endDungeon()
    36. for _, pid in ipairs(getPlayersOnline()) do
    37.         if isInArea(getPlayerPosition(pid), config.questFromPos, config.questTopos) then
    38.             doTeleportThing(pid, {x=1000,y=1000,z=7,stackpos=1}, false)
    39.         end
    40.     end
    41. end
    42.  
    43. function onKill(cid, target)
    44. local config = {
    45.     ["rat"] = {storage = 1050},
    46.     ["cave rat"] = {storage = 1050}
    47. }
    48.  
    49. local monster = config[getCreatureName(target):lower()]
    50.  
    51.  
    52.     if(isPlayer(target)) or not monster then
    53.     return TRUE
    54.     end
    55.        
    56.     if getGlobalStorageValue(monster.storage) >= 0 then  
    57.      setGlobalStorageValue(monster.storage, getGlobalStorageValue(monster.storage) +1)
    58.     end
    59.    
    60.     if getGlobalStorageValue(2050) == 0 and getGlobalStorageValue(1050) == 10 then
    61.     setGlobalStorageValue(1050,-1)
    62.     setGlobalStorageValue(2050,-1)
    63.     resetQuest()
    64.     endDungeon()
    65. end
    66. return TRUE
    67. end
     

Share This Page

Loading...