CreatureEvent [CreatureEvent/Npc] Killing in the name of...

Discussion in 'GlobalEvents, Spells & CreatureEvents' started by Darkhaos, Mar 16, 2011.

  1. Darkhaos

    Darkhaos (:

    Joined:
    Apr 17, 2008
    Messages:
    1,922
    Likes Received:
    169
    Best Answers:
    0
    • Now player can start task saying the task name and report task saying (Ex: "report trolls").

    First, add this to your lib/function.lua:
    Code (Lua):
    1. function isSummon(cid)
    2.     return getCreatureMaster(cid) ~= cid or false
    3. end
    Or this if you are using 0.4 DEV
    Code (Lua):
    1. function isSummon(cid)
    2.     return getCreatureMaster(cid) ~= nil
    3. end
    Create a file in data/creaturescripts/scripts called killinginthenameof.lua, and paste this:
    Code (Lua):
    1. local questCreatures =
    2. {
    3.     ["troll"] = {questStarted = 1510, questStorage = 65000, creatureStorage = 15000, killsRequired = 100, raceName = "Trolls"},
    4.     ["frost troll"] = {questStarted = 1510, questStorage = 65000, creatureStorage = 15001, killsRequired = 100, raceName = "Trolls"},
    5.     ["furious troll"] = {questStarted = 1510, questStorage = 65000, creatureStorage = 15002, killsRequired = 100, raceName = "Trolls"},
    6.     ["island troll"] = {questStarted = 1510, questStorage = 65000, creatureStorage = 15003, killsRequired = 100, raceName = "Trolls"},
    7.     ["swamp troll"] = {questStarted = 1510, questStorage = 65000, creatureStorage = 15004, killsRequired = 100, raceName = "Trolls"},
    8.     ["troll champion"] = {questStarted = 1510, questStorage = 65000, creatureStorage = 15005, killsRequired = 100, raceName = "Trolls"},
    9.     ["troll legionnaire"] = {questStarted = 1510, questStorage = 65000, creatureStorage = 15006, killsRequired = 100, raceName = "Trolls"},
    10.  
    11.     ["goblin"] = {questStarted = 1511, questStorage = 65001, creatureStorage = 15007, killsRequired = 150, raceName = "Goblins"},
    12.     ["goblin assassin"] = {questStarted = 1511, questStorage = 65001, creatureStorage = 15008, killsRequired = 150, raceName = "Goblins"},
    13.     ["goblin leader"] = {questStarted = 1511, questStorage = 65001, creatureStorage = 15009, killsRequired = 150, raceName = "Goblins"},
    14.     ["goblin scavenger"] = {questStarted = 1511, questStorage = 65001, creatureStorage = 15010, killsRequired = 150, raceName = "Goblins"},
    15.  
    16.     ["rotworm"] = {questStarted = 1512, questStorage = 65002, creatureStorage = 15011, killsRequired = 300, raceName = "Rotworms"},
    17.     ["carriom worm"] = {questStarted = 1512, questStorage = 65002, creatureStorage = 15012, killsRequired = 300, raceName = "Rotworms"},
    18.  
    19.     ["cyclops"] = {questStarted = 1513, questStorage = 65003, creatureStorage = 15013, killsRequired = 500, raceName = "Cyclops"},
    20.     ["cyclops smith"] = {questStarted = 1513, questStorage = 65003, creatureStorage = 15014, killsRequired = 500, raceName = "Cyclops"},
    21.     ["cyclops drone"] = {questStarted = 1513, questStorage = 65003, creatureStorage = 15015, killsRequired = 500, raceName = "Cyclops"},
    22.  
    23.  
    24.     ["crocodile"] = {questStarted = 1514, questStorage = 65004, creatureStorage = 15016, killsRequired = 300, raceName = "Crocodiles"},
    25.  
    26.     ["tarantula"] = {questStarted = 1515, questStorage = 65005, creatureStorage = 15017, killsRequired = 300, raceName = "Tarantulas"},
    27.  
    28.     ["carniphila"] = {questStarted = 1516, questStorage = 65006, creatureStorage = 15018, killsRequired = 150, raceName = "Carniphilas"},
    29.  
    30.     ["stone golem"] = {questStarted = 1517, questStorage = 65007, creatureStorage = 15019, killsRequired = 200, raceName = "Stone Golems"},
    31.  
    32.     ["mammoth"] = {questStarted = 1518, questStorage = 65008, creatureStorage = 15020, killsRequired = 300, raceName = "Mammoths"},
    33.  
    34.     ["ice golem"] = {questStarted = 1519, questStorage = 65009, creatureStorage = 15021, killsRequired = 300, raceName = "Ice Golems"},
    35.  
    36.     ["quara predator scout"] = {questStarted = 1520, questStorage = 65010, creatureStorage = 15022, killsRequired = 300, raceName = "Quaras Scout"},
    37.     ["quara constrictor scout"] = {questStarted = 1520, questStorage = 65010, creatureStorage = 15023, killsRequired = 300, raceName = "Quaras Scout"},
    38.     ["quara hydromancer scout"] = {questStarted = 1520, questStorage = 65010, creatureStorage = 15024, killsRequired = 300, raceName = "Quaras Scout"},
    39.     ["quara mantassin scout"] = {questStarted = 1520, questStorage = 65010, creatureStorage = 15025, killsRequired = 300, raceName = "Quaras Scout"},
    40.     ["quara pincher scout"] = {questStarted = 1520, questStorage = 65010, creatureStorage = 15026, killsRequired = 300, raceName = "Quaras Scout"},
    41.  
    42.     ["quara predator"] = {questStarted = 1521, questStorage = 65011, creatureStorage = 15027, killsRequired = 300, raceName = "Quaras"},
    43.     ["quara constrictor"] = {questStarted = 1521, questStorage = 65011, creatureStorage = 15028, killsRequired = 300, raceName = "Quaras"},
    44.     ["quara hydromancer"] = {questStarted = 1521, questStorage = 65011, creatureStorage = 15029, killsRequired = 300, raceName = "Quaras"},
    45.     ["quara mantassin"] = {questStarted = 1521, questStorage = 65011, creatureStorage = 15030, killsRequired = 300, raceName = "Quaras"},
    46.     ["quara pincher"] = {questStarted = 1521, questStorage = 65011, creatureStorage = 15031, killsRequired = 300, raceName = "Quaras"},
    47.  
    48.     ["water elemental"] = {questStarted = 1522, questStorage = 65012, creatureStorage = 15032, killsRequired = 70, raceName = "Water Elementals"},
    49.     ["roaring water elemental"] = {questStarted = 1522, questStorage = 65012, creatureStorage = 15033, killsRequired = 70, raceName = "Water Elementals"},
    50.     ["slick water elemental"] = {questStarted = 1522, questStorage = 65012, creatureStorage = 15034, killsRequired = 70, raceName = "Water Elementals"},
    51.     ["massive water elemental"] = {questStarted = 1522, questStorage = 65012, creatureStorage = 15035, killsRequired = 70, raceName = "Water Elementals"},
    52.  
    53.     ["earth elemental"] = {questStarted = 1523, questStorage = 65013, creatureStorage = 15036, killsRequired = 70, raceName = "Earth Elementals"},
    54.     ["jagged earth elemental"] = {questStarted = 1523, questStorage = 65013, creatureStorage = 15037, killsRequired = 70, raceName = "Earth Elementals"},
    55.     ["massive earth elemental"] = {questStarted = 1523, questStorage = 65013, creatureStorage = 15038, killsRequired = 70, raceName = "Earth Elementals"},
    56.     ["muddy earth elemental"] = {questStarted = 1523, questStorage = 65013, creatureStorage = 15039, killsRequired = 70, raceName = "Earth Elementals"},
    57.  
    58.     ["energy elemental"] = {questStarted = 1524, questStorage = 65014, creatureStorage = 15040, killsRequired = 70, raceName = "Energy Elementals"},
    59.     ["charged energy elemental"] = {questStarted = 1524, questStorage = 65014, creatureStorage = 15041, killsRequired = 70, raceName = "Energy Elementals"},
    60.     ["massive energy elemental"] = {questStarted = 1524, questStorage = 65014, creatureStorage = 15042, killsRequired = 70, raceName = "Energy Elementals"},
    61.     ["overcharged energy elemental"] = {questStarted = 1524, questStorage = 65014, creatureStorage = 15043, killsRequired = 70, raceName = "Energy Elementals"},
    62.  
    63.     ["fire elemental"] = {questStarted = 1525, questStorage = 65015, creatureStorage = 15044, killsRequired = 70, raceName = "Fire Elementals"},
    64.     ["blazing fire elemental"] = {questStarted = 1525, questStorage = 65015, creatureStorage = 15045, killsRequired = 70, raceName = "Fire Elementals"},
    65.     ["blistering fire elemental"] = {questStarted = 1525, questStorage = 65015, creatureStorage = 15046, killsRequired = 70, raceName = "Fire Elementals"},
    66.     ["massive fire elemental"] = {questStarted = 1525, questStorage = 65015, creatureStorage = 15047, killsRequired = 70, raceName = "Fire Elementals"},
    67.  
    68.     ["mutated rat"] = {questStarted = 1526, questStorage = 65016, creatureStorage = 15048, killsRequired = 200, raceName = "Mutated Rats"},
    69.  
    70.     ["giant spider"] = {questStarted = 1527, questStorage = 65017, creatureStorage = 15049, killsRequired = 500, raceName = "Giant Spiders"},
    71.  
    72.     ["hydra"] = {questStarted = 1528, questStorage = 65018, creatureStorage = 15050, killsRequired = 2000, raceName = "Hydras"},
    73.  
    74.     ["sea serpent"] = {questStarted = 1529, questStorage = 65019, creatureStorage = 15051, killsRequired = 2000, raceName = "Sea Serpents"},
    75.  
    76.     ["behemoth"] = {questStarted = 1530, questStorage = 65020, creatureStorage = 15052, killsRequired = 2000, raceName = "Behemoths"},
    77.  
    78.     ["serpent spawn"] = {questStarted = 1531, questStorage = 65021, creatureStorage = 15053, killsRequired = 1500, raceName = "Serpents Spawn"},
    79.  
    80.     ["green djinn"] = {questStarted = 1532, questStorage = 65022, creatureStorage = 15054, killsRequired = 500, raceName = "Green Djinns"},
    81.     ["efreet"] = {questStarted = 1532, questStorage = 65022, creatureStorage = 15055, killsRequired = 500, raceName = "Green Djinns"},
    82.  
    83.     ["blue djinn"] = {questStarted = 1533, questStorage = 65023, creatureStorage = 15056, killsRequired = 500, raceName = "Blue Djinns"},
    84.     ["marid"] = {questStarted = 1533, questStorage = 65023, creatureStorage = 15057, killsRequired = 500, raceName = "Blue Djinns"},
    85.  
    86.     ["pirate buccaneer"] = {questStarted = 1534, questStorage = 65024, creatureStorage = 15058, killsRequired = 3000, raceName = "Pirates"},
    87.     ["pirate corsair"] = {questStarted = 1534, questStorage = 65024, creatureStorage = 15059, killsRequired = 3000, raceName = "Pirates"},
    88.     ["pirate cutthroat"] = {questStarted = 1534, questStorage = 65024, creatureStorage = 15060, killsRequired = 3000, raceName = "Pirates"},
    89.     ["pirate ghost"] = {questStarted = 1534, questStorage = 65024, creatureStorage = 15061, killsRequired = 3000, raceName = "Pirates"},
    90.     ["pirate marauder"] = {questStarted = 1534, questStorage = 65024, creatureStorage = 15062, killsRequired = 3000, raceName = "Pirates"},
    91.     ["pirate skeleton"] = {questStarted = 1534, questStorage = 65024, creatureStorage = 15063, killsRequired = 3000, raceName = "Pirates"},
    92.  
    93.     ["pirate buccaneer"] = {questStarted = 1535, questStorage = 65025, creatureStorage = 15064, killsRequired = 3000, raceName = "Pirates"},
    94.     ["pirate corsair"] = {questStarted = 1535, questStorage = 65025, creatureStorage = 15065, killsRequired = 3000, raceName = "Pirates"},
    95.     ["pirate cutthroat"] = {questStarted = 1535, questStorage = 65025, creatureStorage = 15066, killsRequired = 3000, raceName = "Pirates"},
    96.     ["pirate ghost"] = {questStarted = 1535, questStorage = 65025, creatureStorage = 15067, killsRequired = 3000, raceName = "Pirates"},
    97.     ["pirate marauder"] = {questStarted = 1535, questStorage = 65025, creatureStorage = 15068, killsRequired = 3000, raceName = "Pirates"},
    98.     ["pirate skeleton"] = {questStarted = 1535, questStorage = 65025, creatureStorage = 15069, killsRequired = 3000, raceName = "Pirates"},
    99.  
    100.     ["minotaur"] = {questStarted = 1536, questStorage = 65026, creatureStorage = 15070, killsRequired = 5000, raceName = "Minotaurs"},
    101.  
    102.     ["necromancer"] = {questStarted = 1537, questStorage = 65027, creatureStorage = 15071, killsRequired = 4000, raceName = "Magicians"},
    103.     ["priestess"] = {questStarted = 1537, questStorage = 65027, creatureStorage = 15072, killsRequired = 4000, raceName = "Magicians"},
    104.  
    105.     ["necromancer"] = {questStarted = 1538, questStorage = 65028, creatureStorage = 15073, killsRequired = 1000, raceName = "Magicians"},
    106.     ["priestess"] = {questStarted = 1538, questStorage = 65028, creatureStorage = 15074, killsRequired = 1000, raceName = "Magicians"},
    107.  
    108.     ["demon"] = {questStarted = 1539, questStorage = 65029, creatureStorage = 15075, killsRequired = 6666, raceName = "Demons"}
    109. }
    110.  
    111. local msgType = MESSAGE_STATUS_CONSOLE_ORANGE
    112.  
    113. function onKill(cid, target, lastHit)
    114.  
    115. local creature = questCreatures[getCreatureName(target):lower()]
    116.  
    117.     if creature then
    118.         if isPlayer(target) or isSummon(target) then return true end
    119.  
    120.         if getCreatureStorage(cid, creature.questStarted) > 0 then
    121.             if getCreatureStorage(cid, creature.questStorage) < creature.killsRequired then
    122.                 if getCreatureStorage(cid, creature.questStorage) < 0 then
    123.                     doCreatureSetStorage(cid, creature.questStorage, 0)
    124.                 end
    125.  
    126.                 if getCreatureStorage(cid, creature.creatureStorage) < 0 then
    127.                     doCreatureSetStorage(cid, creature.creatureStorage, 0)
    128.                 end
    129.                 doCreatureSetStorage(cid, creature.questStorage, getCreatureStorage(cid, creature.questStorage) + 1)
    130.                 doCreatureSetStorage(cid, creature.creatureStorage, getCreatureStorage(cid, creature.creatureStorage) + 1)
    131.                 doPlayerSendTextMessage(cid, msgType, getCreatureStorage(cid, creature.creatureStorage) .. " " .. getCreatureName(target) .. " defeated. Total [" .. getCreatureStorage(cid, creature.questStorage) .. "/" .. creature.killsRequired .. "] " .. creature.raceName .. ".")
    132.             end
    133.         end
    134.     end
    135.     return true
    136. end
    Paste this in login.lua:
    Code (Lua):
    1.     registerCreatureEvent(cid, "KillingInTheNameOf")
    And this in creaturescripts.xml:
    Code (XML):
    1.     <event type="kill" name="KillingInTheNameOf" event="script" value="killinginthenameof.lua"/>
    Now, go to data/npc/ and create a file called Grizzly Adams.xml and paste this:
    Code (XML):
    1. <?xml version="1.0" encoding="UTF-8"?>
    2.  
    3. <npc name="Grizzly Adams" script="data/npc/scripts/killinginthenameof.lua" access="3" walkinterval="2000" lookdir="2">
    4.     <mana now="800" max="800"/>
    5.     <health now="200" max="200"/>
    6. <look type="144" head="97" body="97" legs="94" feet="97" addons="3"/>
    7. </npc>
    Go to data/npc/scripts/ and create a file called killinginthenameof.lua and paste this:
    Code (Lua):
    1. local THESNAPPER_POSITION = {x = 100, y = 100, z = 7}
    2. local HIDE_POSITION = {x = 100, y = 100, z = 7}
    3. local THEBLOODTUSK_POSITION = {x = 100, y = 100, z = 7}
    4. local SHARDHEAD_POSITION = {x = 100, y = 100, z = 7}
    5. local THUL_POSITION = {x = 100, y = 100, z = 7}
    6. local ESMERALDA_POSITION = {x = 100, y = 100, z = 7}
    7. local THEOLDWIDOW_POSITION = {x = 100, y = 100, z = 7}
    8. local THEMANY_POSITION = {x = 100, y = 100, z = 7}
    9. local LEVIATHAN_POSITION = {x = 100, y = 100, z = 7}
    10. local STONECRACKER_POSITION = {x = 100, y = 100, z = 7}
    11. local THENOXIUSSPAWN_POSITION = {x = 100, y = 100, z = 7}
    12. local MERIKHTHESLAUGHTERER_POSITION = {x = 100, y = 100, z = 7}
    13. local FAHIMTHEWISE_POSITION = {x = 100, y = 100, z = 7}
    14. local RANDOMPIRATEBOSS_POSITION = {x = 100, y = 100, z = 7}
    15. local THEHORNEDFOX_POSITION = {x = 100, y = 100, z = 7}
    16. local NECROPHARUS_POSITION = {x = 100, y = 100, z = 7}
    17.  
    18.  
    19. local tasks =
    20. {
    21.     [1] = {questStarted = 1510, questStorage = 65000, killsRequired = 100, raceName = "Trolls", rewards = {{enable = true, type = "exp", values = 200}, {enable = true, type = "money", values = 200}}},
    22.  
    23.     [2] = {questStarted = 1511, questStorage = 65001, killsRequired = 150, raceName = "Goblins", rewards = {{enable = true, type = "exp", values = 300}, {enable = true, type = "money", values = 250}}},
    24.  
    25.     [3] = {questStarted = 1512, questStorage = 65002, killsRequired = 300, raceName = "Rotworms", rewards = {{enable = true, type = "exp", values = 1000}, {enable = true, type = "money", values = 400}}},
    26.  
    27.     [4] = {questStarted = 1513, questStorage = 65003, killsRequired = 500, raceName = "Cyclops", rewards = {{enable = true, type = "exp", values = 3000}, {enable = true, type = "money", values = 800}}},
    28.  
    29.     [5] = {questStarted = 1514, questStorage = 65004, killsRequired = 300, raceName = "Crocodiles", rewards = {{enable = true, type = "exp", values = 800}, {enable = true, type = "boss", values = THESNAPPER_POSITION}, {enable = true, type = "points", values = 7}}},
    30.  
    31.     [6] = {questStarted = 1515, questStorage = 65005, killsRequired = 300, raceName = "Tarantulas", rewards = {{enable = true, type = "money", values = 1500}, {enable = true, type = "boss", values = HIDE_POSITION}, {enable = true, type = "points", values = 2}}},
    32.  
    33.     [7] = {questStarted = 1516, questStorage = 65006, killsRequired = 150, raceName = "Carniphilas", rewards = {{enable = true, type = "exp", values = 1500}, {enable = true, type = "points", values = 1}}},
    34.  
    35.     [8] = {questStarted = 1517, questStorage = 65007, killsRequired = 200, raceName = "Stone Golems", rewards = {{enable = true, type = "exp", values = 2000}, {enable = true, type = "points", values = 1}}},
    36.  
    37.     [9] = {questStarted = 1518, questStorage = 65008, killsRequired = 300, raceName = "Mammoths", rewards = {{enable = true, type = "exp", values = 4000}, {enable = true, type = "boss", values = THEBLOODTUSK_POSITION}, {enable = true, type = "points", values = 2}}},
    38.  
    39.     [10] = {questStarted = 1519, questStorage = 65009, killsRequired = 300, raceName = "Ice Golems", rewards = {{enable = true, type = "exp", values = 15000}, {enable = true, type = "boss", values = SHARDHEAD_POSITION}, {enable = true, type = "points", values = 2}}},
    40.  
    41.     [11] = {questStarted = 1520, questStorage = 65010, killsRequired = 300, raceName = "Quaras Scout", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "points", values = 1}}},
    42.  
    43.     [12] = {questStarted = 1521, questStorage = 65011, killsRequired = 300, raceName = "Quaras", rewards = {{enable = true, type = "exp", values = 12000}, {enable = true, type = "boss", values = THUL_POSITION}, {enable = true, type = "points", values = 2}}},
    44.  
    45.     [13] = {questStarted = 1522, questStorage = 65012, killsRequired = 70, raceName = "Water Elementals", rewards = {{enable = true, type = "exp", values = 7000}, {enable = true, type = "points", values = 1}}},
    46.  
    47.     [14] = {questStarted = 1523, questStorage = 65013, killsRequired = 70, raceName = "Earth Elementals", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "points", values = 1}}},
    48.  
    49.     [15] = {questStarted = 1524, questStorage = 65014, killsRequired = 70, raceName = "Energy Elementals", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "points", values = 1}}},
    50.  
    51.     [16] = {questStarted = 1525, questStorage = 65015, killsRequired = 70, raceName = "Fire Elementals", rewards = {{enable = true, type = "exp", values = 7000}, {enable = true, type = "points", values = 1}}},
    52.  
    53.     [17] = {questStarted = 1526, questStorage = 65016, killsRequired = 200, raceName = "Mutated Rats", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "boss", values = ESMERALDA_POSITION}, {enable = true, type = "points", values = 2}}},
    54.  
    55.     [18] = {questStarted = 1527, questStorage = 65017, killsRequired = 500, raceName = "Giant Spiders", rewards = {{enable = true, type = "exp", values = 5000}, {enable = true, type = "boss", values = THEOLDWIDOW_POSITION}, {enable = true, type = "points", values = 2}}},
    56.  
    57.     [19] = {questStarted = 1528, questStorage = 65018, killsRequired = 2000, raceName = "Hydras", rewards = {{enable = true, type = "boss", values = THEMANY_POSITION}, {enable = true, type = "points", values = 4}}},
    58.  
    59.     [20] = {questStarted = 1529, questStorage = 65019, killsRequired = 2000, raceName = "Sea Serpents", rewards = {{enable = true, type = "boss", values = LEVIATHAN_POSITION}, {enable = true, type = "points", values = 4}}},
    60.  
    61.     [21] = {questStarted = 1530, questStorage = 65020, killsRequired = 2000, raceName = "Behemoths", rewards = {{enable = true, type = "boss", values = STONECRACKER_POSITION}, {enable = true, type = "points", values = 4}}},
    62.  
    63.     [22] = {questStarted = 1531, questStorage = 65021, killsRequired = 1500, raceName = "Serpents Spawn", rewards = {{enable = true, type = "teleport", values = THENOXIUSSPAWN_POSITION}, {enable = true, type = "points", values = 4}}},
    64.  
    65.     [23] = {questStarted = 1532, questStorage = 65022, killsRequired = 500, raceName = "Green Djinns", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "money", values = 5000}, {enable = true, type = "boss", values = MERIKHTHESLAUGHTERER_POSITION}}},
    66.  
    67.     [24] = {questStarted = 1533, questStorage = 65023, killsRequired = 500, raceName = "Blue Djinns", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "money", values = 5000}, {enable = true, type = "boss", values = FAHIMTHEWISE_POSITION}}},
    68.  
    69.     [25] = {questStarted = 1534, questStorage = 65024, killsRequired = 3000, raceName = "Pirates1", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "money", values = 5000}, {enable = true, type = "boss", values = RANDOMPIRATEBOSS_POSITION}}},
    70.  
    71.     [26] = {questStarted = 1535, questStorage = 65025, killsRequired = 3000, raceName = "Pirates2", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "money", values = 5000}}},
    72.  
    73.     [27] = {questStarted = 1536, questStorage = 65026, killsRequired = 5000, raceName = "Minotaurs", rewards = {{enable = true, type = "boss", values = THEHORNEDFOX_POSITION}}},
    74.  
    75.     [28] = {questStarted = 1537, questStorage = 65027, killsRequired = 4000, raceName = "Magicians1", rewards = {{enable = true, type = "boss", values = NECROPHARUS_POSITION}}},
    76.  
    77.     [29] = {questStarted = 1538, questStorage = 65028, killsRequired = 1000, raceName = "Magicians2", rewards = {{enable = true, type = "exp", values = 40000}}},
    78.  
    79.     [30] = {questStarted = 1539, questStorage = 65029, killsRequired = 6666, raceName = "Demons", rewards = {{enable = true, type = "storage", values = {65535, 1}}}}
    80. }
    81.  
    82. local rankStorage = 32150
    83. local choose = {}
    84.  
    85. local keywordHandler = KeywordHandler:new()
    86. local npcHandler = NpcHandler:new(keywordHandler)
    87. NpcSystem.parseParameters(npcHandler)
    88. local talkState = {}
    89.  
    90. function onCreatureAppear(cid)                          npcHandler:onCreatureAppear(cid) end
    91. function onCreatureDisappear(cid)                       npcHandler:onCreatureDisappear(cid) end
    92. function onCreatureSay(cid, type, msg)                  npcHandler:onCreatureSay(cid, type, msg) end
    93. function onThink()                                      npcHandler:onThink() end
    94.  
    95. function getTasksStarted(cid)
    96.     local tmp = {}
    97.     for k, v in pairs(tasks) do
    98.         if getCreatureStorage(cid, v.questStarted) == 1 then
    99.             table.insert(tmp, k)
    100.         end
    101.     end
    102.     return tmp
    103. end
    104.  
    105. function getTaskByName(name)
    106.     for k, v in pairs(tasks) do
    107.         if v.raceName:lower() == name:lower() then
    108.             return k
    109.         end
    110.     end
    111.     return false
    112. end
    113.  
    114. function creatureSayCallback(cid, type, msg)
    115.  
    116.     if(not npcHandler:isFocused(cid)) then
    117.         return false
    118.     end
    119.     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid
    120.     if isInArray({"task", "tasks"}, msg:lower()) then
    121.         selfSay("There you can see the following tasks, please tell me the number of the task that you want to do.", cid)
    122.         local text = ""
    123.         for i = 1, table.maxn(tasks) do
    124.             text = text .. (text == "" and "" or "\n") .. i .. "  -  " .. tasks[i].raceName .. (getCreatureStorage(cid, tasks[i].questStarted) == 1 and " [...]" or getCreatureStorage(cid, tasks[i].questStarted) == 2 and " [x]" or "")
    125.         end
    126.         return doShowTextDialog(cid, 5956, text)
    127.  
    128.     elseif getTaskByName(msg) or tasks[tonumber(msg)] then
    129.         msg = (getTaskByName(msg) or tonumber(msg))
    130.         if getCreatureStorage(cid, tasks[msg].questStarted) == 1 then
    131.             selfSay("You already started this task.", cid)
    132.             talkState[talkUser] = 0
    133.             return true
    134.         end
    135.         if getCreatureStorage(cid, tasks[msg].questStarted) == 2 then
    136.             selfSay("You already finished this task.", cid)
    137.             talkState[talkUser] = 0
    138.             return true
    139.         end
    140.         if tasks[msg].level and getPlayerLevel(cid) < tasks[msg].level then
    141.             selfSay("You need level " .. tasks[msg].level .. " or higher to make this task.", cid)
    142.             talkState[talkUser] = 0
    143.             return true
    144.         end
    145.         selfSay("Are you sure that do you want to start the task number " .. msg .. "? In this task you will need to defeat " .. tasks[msg].killsRequired .. " " .. tasks[msg].raceName .. ".", cid)
    146.         choose[cid] = msg
    147.         talkState[talkUser] = 1
    148.     elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
    149.         doCreatureSetStorage(cid, tasks[choose[cid]].questStarted, 1)
    150.         selfSay("You have started the task number " .. choose[cid] .. ", remember... in this task you will need to defeat " .. tasks[choose[cid]].killsRequired .. " " .. tasks[choose[cid]].raceName .. ". Good luck!", cid)
    151.         talkState[talkUser] = 0
    152.         return true
    153.  
    154.     elseif msg:lower() == "report" then
    155.         local t = getTasksStarted(cid)
    156.         local response = "You are currently making " .. (#t > 1 and "these" or "this") .. " task" .. (#t > 1 and "s" or "") .. ":\n"
    157.         if table.maxn(t) > 0 then
    158.             for _, tsk in ipairs(t) do
    159.                 if getCreatureStorage(cid, tasks[tsk].questStorage) < 0 then doCreatureSetStorage(cid, tasks[tsk].questStorage, 0) end
    160.                 response = response .. "     Name: " .. tasks[tsk].raceName .. "     Kills: " .. getCreatureStorage(cid, tasks[tsk].questStorage) .. " - " .. tasks[tsk].killsRequired .. ".\n"
    161.             end
    162.             response = response .. "Please say report and the name of the task that do you want to report, example: 'Report Trolls'."
    163.             return selfSay(response, cid)
    164.         else
    165.             return selfSay("You need to start at least one task first.", cid)
    166.         end
    167.     elseif string.sub(msg:lower(), 0, 6) == "report" then
    168.         local t = getTaskByName(string.sub(msg, 8, string.len(msg)))
    169.         if not t then
    170.             return selfSay("That task does not exists.", cid)
    171.         end
    172.  
    173.         if getCreatureStorage(cid, tasks[t].questStarted) == 2 then
    174.             return selfSay("You already finished this task.", cid)
    175.         end
    176.  
    177.         if getCreatureStorage(cid, tasks[t].questStarted) < 1 then
    178.             return selfSay("You don't have started this task.", cid)
    179.         end
    180.  
    181.         if tasks[t].killsRequired > getCreatureStorage(cid, tasks[t].questStorage) then
    182.             return selfSay("Current " .. getCreatureStorage(cid, tasks[t].questStorage) .. " " .. tasks[t].raceName .. " killed, you need to kill " .. tasks[t].killsRequired .. ".", cid)
    183.         end
    184.  
    185.         for i = 1, table.maxn(tasks[t].rewards) do
    186.             if(tasks[t].rewards[i].enable) then
    187.                 if isInArray({"boss", "teleport", 1}, tasks[t].rewards[i].type) then
    188.                     doTeleportThing(cid, tasks[t].rewards[i].values)
    189.                 elseif isInArray({"exp", "experience", 2}, tasks[t].rewards[i].type) then
    190.                     doPlayerAddExperience(cid, tasks[t].rewards[i].values)
    191.                 elseif isInArray({"item", 3}, tasks[t].rewards[i].type) then
    192.                     doPlayerAddItem(cid, v.rewards[i].values[1], tasks[t].rewards[i].values[2])
    193.                 elseif isInArray({"money", 4}, tasks[t].rewards[i].type) then
    194.                     doPlayerAddMoney(cid, tasks[t].rewards[i].values)
    195.                 elseif isInArray({"storage", "stor", 5}, tasks[t].rewards[i].type) then
    196.                     doCreatureSetStorage(cid, tasks[t].rewards[i].values[1], tasks[t].rewards[i].values[2])
    197.                 elseif isInArray({"points", "rank", 2}, tasks[t].rewards[i].type) then
    198.                     doCreatureSetStorage(cid, rankStorage, getCreatureStorage(cid, rankStorage) + tasks[t].rewards[i].values)
    199.                 else
    200.                     print("[Warning - Npc::KillingInTheNameOf] Wrong reward type: " .. (tasks[t].rewards[i].type or "nil") .. ", reward could not be loaded.")
    201.                 end
    202.             end
    203.         end
    204.         local rank = getCreatureStorage(cid, rankStorage)
    205.         selfSay("Great!... you have finished the task number " .. t .. "" .. (rank > 4 and ", you are a " or "") .. "" .. (((rank > 4 and rank < 10) and ("Huntsman") or (rank > 9 and rank < 20) and ("Ranger") or (rank > 19 and rank < 30) and ("Big Game Hunter") or (rank > 29 and rank < 50) and ("Trophy Hunter") or (rank > 49) and ("Elite Hunter")) or "") .. ". Good job.", cid)
    206.         return doCreatureSetStorage(cid, tasks[t].questStarted, 2)
    207.     end
    208.     return true
    209. end
    210.  
    211. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
    212. npcHandler:addModule(FocusModule:new())
    IMPORTANT!
    If you've been using my other script and you want to implement this new script, to prevent players can repeat finished tasks change:
    This:
    Code (Lua):
    1.         if getCreatureStorage(cid, tasks[msg].questStarted) == 2 then
    2.             selfSay("You already finished this task.", cid)
    3.             talkState[talkUser] = 0
    4.             can = false
    5.         end
    For this:
    Code (Lua):
    1.         local storage = 64521 --same storage used in other script
    2.         if getCreatureStorage(cid, tasks[msg].questStarted) == 2 or getCreatureStorage(cid, storage) <= msg then
    3.             selfSay("You already finished this task.", cid)
    4.             talkState[talkUser] = 0
    5.             can = false
    6.         end
    7.  
    How to config?
    Code (Lua):
    1. -- Troll task example
    2. [1] = {questStarted = 1510, questStorage = 65000, killsRequired = 100, raceName = "Trolls", rewards = {{enable = true, type = "exp", values = 200}, {enable = true, type = "money", values = 200}}},
    3.  
    Code (Text):
    1. [B]- [1][/B] =  Number of task.
    2. [B]- quesStarted[/B] = Storage to check if the task has been started.
    3. [B]- questStorage[/B] = Storage to check of player has killed the monter the needed times.
    4. [B]- killsRequired[/B] = How many times the player needs to kill the creature.
    5. [B]- raceName[/B] = Monster's race name.
    6. [B]- rewards[/B] = Here you can config how many rewards will obtain the player in each task.
    7.     --[[
    8.         [B]enable[/B] = Here you can enable/disable the reward, use [COLOR="seagreen"][B]true[/B][/COLOR] or [COLOR="red"][B]false[/B][/COLOR].
    9.         [B]type[/B] = Here you declare the reward type.
    10.             --[[
    11.                 [B]boss[/B] or [b]1[/B] = Player will be teleported to the boss position.
    12.                 [B]exp[/B] or [b]2[/B] = Player will get experience.
    13.                 [B]item[/B] or [b]3[/B] = Player will get an item.
    14.                 [B]money[/B] or [b]4[/B] = Player will get money.
    15.                 [B]storage[/B] or [b]5[/B] = Player will get a storage value.
    16.                 [B]points[/B] or [b]6[/B] = Player will get points(storage value) for the rank.
    17.             ]]--
    18.         [B]values[/B] = Here you declare the values for the reward type.
    19.             --[[
    20.                 [B]Use a position for "boss", Ex: {x = 100, y = 100, z = 7}.
    21.                 Use a number value for "exp", Ex: 1000.
    22.                 Use a table value with two numbers for "item", the first value will be the item id and the second value will be the count, Ex: {2160, 10}.[/B]
    23.                 Use a number value for "money", Ex: 1000.
    24.                 Use a table value with two numbers for "storage", the first value will be the storage value and the second value will be the count, Ex: {10500, 1}.
    25.                 Use a number value for "points", Ex: 5.[/B]
    26.             ]]--
    27.     ]]--
    28. --Only in the creaturescript.
    29. [B]- creatureStorage[/B] = Storage to check the kills for each creature.

    How it works?
    Talk with the npc:
     
    Last edited: Jul 20, 2011
    tucom likes this.
  2. Cykotitan

    Cykotitan Experienced G'

    Joined:
    Nov 4, 2008
    Messages:
    16,897
    Likes Received:
    807
    Best Answers:
    1
    alternative version:

    quests.xml

    000-constant.lua:
    Code (Lua):
    1. tasks = {
    2.     ['demon'] = {storage = 14006, amount = 6666},
    3.     ['crocodile'] = {storage = 14007, amount = 300},
    4.     ['tarantula'] = {storage = 14008, amount = 300},
    5.     ['carniphila'] = {storage = 14009, amount = 150},
    6.     ['stone golem'] = {storage = 14010, amount = 200},
    7.     ['mammoth'] = {storage = 14011, amount = 300},
    8.     ['ice golem'] = {storage = 14012, amount = 300},
    9.     ['quara constrictor scout'] = {storage = 14013, amount = 300},
    10.     ['quara hydromancer scout'] = {storage = 14013, amount = 300},
    11.     ['quara mantassin scout'] = {storage = 14013, amount = 300},
    12.     ['quara pincher scout'] = {storage = 14013, amount = 300},
    13.     ['quara predator scout'] = {storage = 14013, amount = 300},
    14.     ['quara constrictor'] = {storage = 14014, amount = 300},
    15.     ['quara hydromancer'] = {storage = 14014, amount = 300},
    16.     ['quara mantassin'] = {storage = 14014, amount = 300},
    17.     ['quara pincher'] = {storage = 14014, amount = 300},
    18.     ['quara predator'] = {storage = 14014, amount = 300},
    19.     ['water elemental'] = {storage = 14015, amount = 70},
    20.     ['massive water elemental'] = {storage = 14015, amount = 70},
    21.     ['earth elemental'] = {storage = 14016, amount = 70},
    22.     ['massive earth elemental'] = {storage = 14016, amount = 70},
    23.     ['energy elemental'] = {storage = 14017, amount = 70},
    24.     ['massive energy elemental'] = {storage = 14017, amount = 70},
    25.     ['fire elemental'] = {storage = 14018, amount = 70},
    26.     ['massive fire elemental'] = {storage = 14018, amount = 70},
    27.     ['mutated rat'] = {storage = 14019, amount = 200},
    28.     ['giant spider'] = {storage = 14020, amount = 500},
    29.     ['hydra'] = {storage = 14021, amount = 2000},
    30.     ['sea serpent'] = {storage = 14001, amount = 2000},
    31.     ['behemoth'] = {storage = 14022, amount = 2000},
    32.     ['serpent spawn'] = {storage = 14002, amount = 1500},
    33. }
    kill creaturescript:
    Code (Lua):
    1. function onKill(cid, target, damage, flags)
    2.     if damage == false or (flags and flags ~= 3) then
    3.         return true
    4.     else
    5.         local f = getCreatureMaster(target)
    6.         if f and f ~= target then
    7.             return true
    8.         end
    9.     end
    10.  
    11.     local name = getCreatureName(target):lower()
    12.     local a = tasks[name]
    13.     if a then
    14.         if getPlayerStorageValue(cid, 14500) ~= a.storage or getPlayerStorageValue(cid, a.storage) == a.amount then
    15.             return true
    16.         end
    17.  
    18.         local b = getPlayerStorageValue(cid, a.storage) + 1
    19.         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Task (".. name:upper() .."): " .. (b == a.amount and "Completed!" or b .." / ".. a.amount))
    20.         setPlayerStorageValue(cid, a.storage, b)
    21.     end
    22.     return true
    23. end
    npc.lua:
    Code (Lua):
    1. function customCallbackOnBuy(cid, itemid, subType, amount, ignoreCap, inBackpacks, shopWindow)
    2.     local shopItem, npcHandler = nil, NpcHandler
    3.     for _, item in ipairs(shopWindow) do
    4.         if not item.subType then
    5.             item.subType = (isItemFluidContainer(item.id) or isItemStackable(item.id)) and 0 or 1
    6.         end
    7.         if item.id == itemid and item.subType == subType then
    8.             shopItem = item
    9.             break
    10.         end
    11.     end
    12.  
    13.     if(shopItem == nil) then
    14.         error("[ShopModule.onBuy]", "Item not found on shopItems list")
    15.         return false
    16.     end
    17.  
    18.     if(shopItem.buy < 0) then
    19.         error("[ShopModule.onSell]", "Attempt to purchase an item which is only sellable")
    20.         return false
    21.     end
    22.  
    23.     local backpack, totalCost = 1988, amount * shopItem.buy
    24.     if(inBackpacks) then
    25.         totalCost = isItemStackable(itemid) == TRUE and totalCost + 20 or totalCost + (math.max(1, math.floor(amount / getContainerCapById(backpack))) * 20)
    26.     end
    27.  
    28.     if(getPlayerMoney(cid) < totalCost) then
    29.         doPlayerSendCancel(cid, npcHandler:parseMessage(npcHandler:getMessage(MESSAGE_NEEDMONEY), {[TAG_PLAYERNAME] = getPlayerName(cid), [TAG_ITEMCOUNT] = amount, [TAG_TOTALCOST] = totalCost, [TAG_ITEMNAME] = shopItem.name}))
    30.         return false
    31.     end
    32.  
    33.     local a, b = doNpcSellItem(cid, itemid, amount, shopItem.subType or isItemFluidContainer(itemid) and 0 or 1, ignoreCap, inBackpacks, backpack)
    34.     if(a < amount) then
    35.         local msgId = MESSAGE_NEEDMORESPACE
    36.         if(a == 0) then
    37.             msgId = MESSAGE_NEEDSPACE
    38.         end
    39.  
    40.         doPlayerSendCancel(cid, npcHandler:parseMessage(npcHandler:getMessage(msgId), {[TAG_PLAYERNAME] = getPlayerName(cid), [TAG_ITEMCOUNT] = amount, [TAG_TOTALCOST] = totalCost, [TAG_ITEMNAME] = shopItem.name, [TAG_ITEMCOUNT] = a}))
    41.  
    42.         if(a > 0) then
    43.             doPlayerRemoveMoney(cid, ((a * shopItem.buy) + (b * 20)))
    44.             return true
    45.         end
    46.  
    47.         return false
    48.     end
    49.     doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, npcHandler:parseMessage(npcHandler:getMessage(MESSAGE_BOUGHT), {[TAG_PLAYERNAME] = getPlayerName(cid), [TAG_ITEMCOUNT] = amount, [TAG_TOTALCOST] = totalCost, [TAG_ITEMNAME] = shopItem.name}))
    50.     doPlayerRemoveMoney(cid, totalCost)
    51.  
    52.     return true
    53. end
    54.  
    55. function customCallbackOnSell(cid, itemid, subType, amount, ignoreCap, inBackpacks, shopWindow)
    56.     local shopItem, npcHandler, subType = nil, NpcHandler, subType or 0
    57.     for _, item in ipairs(shopWindow) do
    58.         if item.id == itemid and ((item.subType or 0) == subType or not isItemFluidContainer(itemid)) then
    59.             shopItem = item
    60.             break
    61.         end
    62.     end
    63.  
    64.     if(shopItem == nil) then
    65.         error("[ShopModule.onBuy]", "Item not found on shopItems list")
    66.         return false
    67.     end
    68.  
    69.     if(not shopItem.sell or shopItem.sell < 0) then
    70.         error("[ShopModule.onSell]", "Attempt to sell an item which is only buyable")
    71.         return false
    72.     end
    73.  
    74.     if(doPlayerRemoveItem(cid, itemid, amount, isItemFluidContainer(itemid) == TRUE and subType or isItemStackable(itemid) == TRUE and amount or 1) == TRUE) then
    75.         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, npcHandler:parseMessage(npcHandler:getMessage(MESSAGE_SOLD), {[TAG_PLAYERNAME] = getPlayerName(cid), [TAG_ITEMCOUNT] = amount, [TAG_TOTALCOST] = amount * shopItem.sell, [TAG_ITEMNAME] = shopItem.name}))
    76.         doPlayerAddMoney(cid, amount * shopItem.sell)
    77.  
    78.         return true
    79.     end
    80.     doPlayerSendCancel(cid, npcHandler:parseMessage(npcHandler:getMessage(MESSAGE_NEEDITEM), {[TAG_PLAYERNAME] = getPlayerName(cid), [TAG_ITEMCOUNT] = amount, [TAG_TOTALCOST] = amount * shopItem.sell, [TAG_ITEMNAME] = shopItem.name}))
    81.  
    82.     return false
    83. end
    grizzly adams:
    Code (Lua):
    1. local keywordHandler = KeywordHandler:new()
    2. local npcHandler = NpcHandler:new(keywordHandler)
    3. NpcSystem.parseParameters(npcHandler)
    4. local Topic = {}
    5.  
    6. local data = {
    7.     [14007] = {'crocodile', 'Happy hunting, old chap! Come back to me when you are through with your task.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u crocodiles. Come back to me when you are done.', 'Spiffing work, old chap. Now I have a special task for you. Recently several citizens of Port Hope have vanished. It is rumoured that they were killed by a crocodile. The people call it \'Snapper\'. Hunt down and kill that evil man eating beast.', 800, 1, 'Snapper', },
    8.     [14008] = {'tarantula', 'Happy hunting, old chap! Come back to me when you are through with your task.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u tarantulas. Come back to me when you are done.', 'Nicely done! Now I shall assign you a special task. Rumour has it that there is an ancient and evil tarantula who preys on humans. She is called \'Hide\'. Track her down and kill her! Good luck, old chap.', 1500, 1, 'Hide'},
    9.     [14009] = {'carniphila', 'Good show, old chap! Speak to me again when you are done hunting.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u carniphilas. Come back to me when you are done.', 'That took some time, huh? Good hunting though. If you\'re up for another hunting mission just ask me for a {task}.', 1500, 1},
    10.     [14010] = {'stone golem', 'Happy hunting, friend! When you have finished hunting, return here. ', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u stone golems. Come back to me when you are done.', 'Good show, old chap. If you\'re up for another hunting mission just ask me for a task.', 2000, 1},
    11.     [14011] = {'mammoth', 'Happy hunting, friend! Come back to me when you are done hunting.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u mammoths. Come back to me when you are done.', 'Jolly good job you did there, but now I have a special task for you. The citizens of Svargrond live in fear because of a frightfully bad-tempered mammoth they call \'Blood Tusk\'. Go there and put an end to him. Happy hunting!', 'Bloodtusk', 4000, 1},
    12.     [14012] = {'ice golem', 'Happy hunting, friend! Come back to me when you are done hunting.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u ice golems. Come back to me when you are done.', 'As i see it, you need more of a challenge! I have heard that there is an ice golem the hunters in Svargrond call \'Shardhead\'. He is an extremely dangerous example of his kind! I believe you are equal to the task, %s!', 15000, 1, 'Shardhead'},
    13.     [14013] = {'quara constrictor scout', 'Happy hunting, friend! Come back to me when you are done hunting.', 'Alright, then you should go on with your task. You have already killed %u quara scouts in total. Come back to me when you are done.', 'Jolly good show! What a hunter! If you\'re up for another hunting mission just ask me for a {task}.', 10000, 1}, -- ?
    14.     [14014] = {'quara constrictor', 'Happy hunting, friend! Come back to me when you are done hunting.', 'Alright, then you should go on with your task. You have already killed %u underwater quaras in total. Come back to me when you are done.', 'Superb work. However, there is something else I want you to do. It is said that there is a Quara general named \'Thul\' who is responsible for the attacks on Liberty Bay. Find him and kill him and bring peace to Liberty bay!', 12000, 1, 'Thul'}, -- OK
    15.     [14015] = {'water elemental', 'Happy hunting, my old mocker! Come back to me when you are done hunting. ', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u water elementals. Come back to me when you are done.', 'Fantastic! If you\'re up for another hunting mission just ask me for a {task}.', 7000, 1},
    16.     [14016] = {'earth elemental', 'Happy hunting, friend! Come back to me when you are done hunting. ', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u earth elementals. Come back to me when you are done.', 'Fantastic! If you\'re up for another hunting mission just ask me for a {task}.', 10000, 1},
    17.     [14017] = {'energy elemental', 'Happy hunting, pal! Come back to me when you are done hunting. ', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u energy elementals. Come back to me when you are done.', 'Fantastic! If you\'re up for another hunting mission just ask me for a {task}.', 10000, 1},
    18.     [14018] = {'fire elemental', 'Happy hunting, old friend! Come back to me when you are done hunting. ', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u fire elementals. Come back to me when you are done.', 'Fantastic! If you\'re up for another hunting mission just ask me for a {task}.', 7000, 1},
    19.     [14019] = {'mutated rat', 'Happy hunting, old chap! Come back to me when you are done hunting. ', 'Alright, then stop dilly dallying here and go on with your task. You have already exterminated %u mutated rats. Come back to me when you are done.', {'Very good work, old chap. Lucky you are here - I have just been told of a task which is perfect for you. ...', 'The Yalaharians are having a spot of bother with a huge mutated rat. They call it \'Esmeralda\' and you should find her somewhere in the sewers. Good hunting!'}, 10000, 1, 'Esmeralda'}, -- OK
    20.     [14020] = {'giant spider', 'Jolly good show! Come back to me when you are done hunting. ', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u giant spiders. Come back to me when you are done.', 'Well THAT was a hunt. Good job. Have you heared about \'The Old Widow\'? It must have a hideout. Try to find it and slay the beast.', 5000, 1, 'Old Widow'},
    21.     [14021] = {'hydra', 'Happy hunting, old chap! Come back to me when you are done hunting.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u hydras. Come back to me when you are done.', {'With Nornur the God of Fate as my witness, you are truly born to hunt. If anyone can do this task, you can! Listen: ...', 'It is said that the Lizards of Chor are training hydras for attacks against us. They have already successfully bred a hydra named \'The Many\'. Find her and kill her!'}, 0, 2, 'Many'},
    22.     [14001] = {'sea serpent', 'Happy hunting, old chap! Come back to me when you are done hunting.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u sea serpents. Come back to me when you are done.', 'Good job, old chap! Are you up for a challenge? Have you heard of the legendary sea serpent called \'The Leviathan\'? It must be somewhere near the spot you found. This is a true test of your hunting skills - find it and kill it. Good hunting!', 0, 2, 'Leviathan'},
    23.     [14022] = {'behemoth', 'Happy hunting, old chap! Come back to me when you are done hunting.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u behemoths. Come back to me when you are done.', 'Such marvellous hunting skills! Perhaps you can help me with this one. Have you heard about \'Stonecracker\'? ...', 0, 2, 'Stonecracker'}, -- OK
    24.     [14002] = {'serpent spawn', 'Happy hunting, old chap! Come back to me when you are done hunting.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u serpent spawns. Come back to me when you are done.', 'My - you can be proud of yourself! However, you\'re not finished yet. There are rumours about a being called \'The Noxious Spawn\' which was seen deep down in the ruins of Banuta. Try to find its hideout.', 0, 2, 'Noxious Spawn'},
    25. }
    26.  
    27. local curTask = 14500
    28. local points = 14501
    29. local rank = 14502
    30. local questLog = 14503
    31. local tiquanda = 14505
    32. local demodras = 14506
    33.  
    34. function onCreatureAppear(cid)          npcHandler:onCreatureAppear(cid)            end
    35. function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
    36. function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)        end
    37. function onThink()                  npcHandler:onThink()                    end
    38.  
    39. function greetCallback(cid)
    40.     local cur, r, msg = getPlayerStorageValue(cid, points), getPlayerStorageValue(cid, rank)
    41.     if cur >= 5 and r < 1 then
    42.         msg = 'Welcome back |PLAYERNAME|. You have completed 5 tasks for our society. Ask me for a {promotion} to advance your rank!'
    43.     elseif cur >= 10 and r < 2 then
    44.         msg = 'Good to see you again |PLAYERNAME|. You have completed 10 tasks for our society. Ask me for a {promotion} to advance your rank!'
    45.     elseif cur >= 20 and r < 3 then
    46.         msg = 'Salutations |PLAYERNAME|. You have completed 20 tasks for our society. Ask me for a {promotion} to advance your rank!'
    47.     elseif cur >= 30 and r < 4 then
    48.         msg = 'Always good to welcome you back, |PLAYERNAME|. You have completed 30 tasks for our society. Ask me for a {promotion} to advance your rank!'
    49.     elseif cur >= 50 and r < 5 then
    50.         msg = 'By the gods....50 hunting tasks....this is astounding! Ask me for a {promotion} to advance your rank! And while you are here, I also have another {special} task for you.'
    51.     else
    52.         msg = 'Welcome back |PLAYERNAME|. What brings you here this time?'
    53.     end
    54.     npcHandler:setMessage(MESSAGE_GREET, msg)
    55.     Topic[cid] = 0
    56.     return true
    57. end
    58.  
    59. function creatureSayCallback(cid, _type, msg)
    60.     if not npcHandler:isFocused(cid) then
    61.         return false
    62.     end
    63.  
    64.     if msgcontains(msg, 'task') then
    65.         local cur = getPlayerStorageValue(cid, curTask)
    66.         if cur < 1 or (cur ~= 14006 and getPlayerStorageValue(cid, cur) == tasks[data[cur][1]].amount + 1 and getPlayerStorageValue(cid, cur + 100) == -1) then
    67.             local v, lvl = '', getPlayerLevel(cid)
    68.             if lvl < 50 then
    69.                 v, Topic[cid] = '{Crocodiles}, {tarantulas}, {carniphilas}, {stone golems} or {mammoths}', 1
    70.             elseif lvl < 90 then
    71.                 v, Topic[cid] = '{Ice golems}, {Quara}, {elementals}, {mutated rats} or {giant spiders}', 2
    72.             elseif 90 <= lvl then
    73.                 v, Topic[cid] = '{Hydras}, {sea serpents}, {behemoths}' .. (getPlayerStorageValue(cid, rank) == 5 and ', {serpent spawns} or {demons}' or ' or {serpent spawns}'), 3
    74.             end
    75.             selfSay('All right, what would you like to hunt? ' .. v .. '?', cid)
    76.         elseif cur == 14006 and getPlayerStorageValue(cid, cur) == tasks['demon'].amount then
    77.             selfSay({'Such derring do deserves a special reward! Take this holy icon. It neutralizes great evil and gives you access to areas which are protected by those forces. But remember ...', 'This is a one time opportunity! You won\'t get the holy icon twice.'}, cid)
    78.             doPlayerAddItem(cid, 10305, 1)
    79.             setPlayerStorageValue(cid, curTask, -1)
    80.         elseif cur ~= 14006 and getPlayerStorageValue(cid, cur) == tasks[data[cur][1]].amount and getPlayerStorageValue(cid, cur + 100) < 1 then
    81.             local tmp
    82.             if type(data[cur][4]) == 'table' then
    83.                 tmp = {}
    84.                 for i = 1, #data[cur][4] do
    85.                     tmp[i] = string.format(data[cur][4][i], getCreatureName(cid))
    86.                 end
    87.             end
    88.             selfSay(tmp or string.format(data[cur][4], getCreatureName(cid)), cid)
    89.             if data[cur][5] > 0 then
    90.                 doPlayerAddExp(cid, data[cur][5])
    91.                 doSendAnimatedText(getThingPos(cid), data[cur][5], 215)
    92.             end
    93.             if data[cur][6] then
    94.                 setPlayerStorageValue(cid, points, getPlayerStorageValue(cid, points) + 1)
    95.             end
    96.             if data[cur][7] then -- special task (he sends you to kill the boss)
    97.                 setPlayerStorageValue(cid, cur + 100, 1)
    98.             end
    99.             setPlayerStorageValue(cid, cur, getPlayerStorageValue(cid, cur) + 1)
    100.             Topic[cid] = 0
    101.         elseif getPlayerStorageValue(cid, cur + 100) == 2 then
    102.             setPlayerStorageValue(cid, points, getPlayerStorageValue(cid, points) + (isInArray({14001, 14002, 14021, 14022}, cur) and 2 or 1))
    103.             selfSay('Fantastic! If you\'re up for another hunting mission just ask me for a {task}.', cid)
    104.             setPlayerStorageValue(cid, cur + 100, -1)
    105.         else
    106.             selfSay(getPlayerStorageValue(cid, cur + 100) < 1 and 'You are not done with your task yet. Come back to me when you are. Or do you want to abort your task to start a different one?' or string.format('Find %s\'s hideout. I hope for you that you are skilled enough to kill him. Or do you want to abort your task to start a different one?', data[cur][7]), cid)
    107.             Topic[cid] = 4
    108.         end
    109.     elseif msgcontains(msg, 'trade') and getPlayerStorageValue(cid, rank) >= 1 then
    110.         local items = {
    111.             {name='antlers', id=11208, sell=50},
    112.             {name='bloody pincers', id=10549, sell=50},
    113.             {name='crab pincers', id=11183, sell=35},
    114.             {name='cyclops toe', id=10573, sell=55},
    115.             {name='frosty ear of a troll', id=10564, sell=30},
    116.             {name='hydra head', id=11193, sell=600},
    117.             {name='lancer leetle shell', id=11366, sell=80},
    118.             {name='mutated bat ear', id=10578, sell=420},
    119.             {name='sabretooth', id=11222, sell=400},
    120.             {name='sandcrawler shell', id=11367, sell=20},
    121.             {name='scarab pincers', id=10547, sell=280},
    122.             {name='terramite legs', id=11365, sell=60},
    123.             {name='terramite shell', id=11363, sell=170},
    124.             {name='terrorbird beak', id=11184, sell=95},
    125.             {name='cyclops trophy', id=7398, sell=500},
    126.             {name='minotaur trophy', id=7401, sell=500},
    127.         }
    128.         if getPlayerStorageValue(cid, rank) >= 3 then
    129.             table.insert(items, {name='deer trophy', id=7397, sell=3000})
    130.             table.insert(items, {name='lion trophy', id=7400, sell=3000})
    131.             table.insert(items, {name='wolf trophy', id=7394, sell=3000})
    132.         end
    133.         if getPlayerStorageValue(cid, rank) >= 4 then
    134.             table.insert(items, {name='behemoth trophy', id=7396, sell=20000})
    135.             table.insert(items, {name='demon trophy', id=7393, sell=40000})
    136.             table.insert(items, {name='dragon lord trophy', id=7399, sell=10000})
    137.             table.insert(items, {name='demon backpack', id=10518, buy=1000})
    138.         end
    139.         openShopWindow(cid, items,
    140.             function(cid, itemid, subType, amount, ignoreCap, inBackpacks)
    141.                 customCallbackOnBuy(cid, itemid, subType, amount, ignoreCap, inBackpacks, items)
    142.             end,
    143.             function(cid, itemid, subType, amount, ignoreCap, inBackpacks)
    144.                 customCallbackOnSell(cid, itemid, subType, amount, ignoreCap, inBackpacks, items)
    145.             end
    146.         )
    147.         selfSay("Alright, show me what you've got.", cid)
    148.     elseif Topic[cid] == 4 then
    149.         local cur = getPlayerStorageValue(cid, curTask)
    150.         if msgcontains(msg, 'yes') or msgcontains(msg, 'abort') then
    151.             selfSay('Alright, as you wish. Ask me for a task if you are interested in a different hunting mission.', cid)
    152.             setPlayerStorageValue(cid, cur, -1)
    153.             setPlayerStorageValue(cid, curTask, -1)
    154.             if getPlayerStorageValue(cid, cur + 100) > 0 then
    155.                 setPlayerStorageValue(cid, cur + 100, -1)
    156.             end
    157.         else
    158.             selfSay(cur == 14006 and string.format('Alright, then stop dilly dallying here and go on with your task. You have already exterminated %u demons. Come back to me when you are done.', getPlayerStorageValue(cid, cur)) or getPlayerStorageValue(cid, cur + 100) < 1 and string.format(data[getPlayerStorageValue(cid, curTask)][3], getPlayerStorageValue(cid, cur)) or 'Alright, then you should go on with your task.', cid)
    159.         end
    160.         Topic[cid] = 0
    161.     elseif Topic[cid] == 1 and msgcontains(msg, 'crocodile') then
    162.         local v = tasks['crocodile']
    163.         selfSay('They are a nuisance! You\'ll find them here in the jungle near the river. Hunt ' .. v.amount .. ' crocodiles and you\'ll get a nice reward. Interested?', cid)
    164.         Topic[cid] = v.storage
    165.     elseif Topic[cid] == 1 and msgcontains(msg, 'tarantula') then
    166.         local v = tasks['tarantula']
    167.         selfSay('There is a veritable plague of tarantulas living in the caves north of the river to the east. Can you squish ' .. v.amount .. ' tarantulas for the Hunting Elite. What do you say?', cid)
    168.         Topic[cid] = v.storage
    169.     elseif Topic[cid] == 1 and msgcontains(msg, 'carniphila') then
    170.         local v = tasks['carniphila']
    171.         selfSay('Damn walking weed-thingies! You\'ll find them deeper in the jungle. Weed out ' .. v.amount .. ' carniphilas for our society. Alright?', cid)
    172.         Topic[cid] = v.storage
    173.     elseif Topic[cid] == 1 and msgcontains(msg, 'golem') then
    174.         local v = tasks['stone golem']
    175.         selfSay('They can be found all over Tibia. You\'ll find them in mountain caves or rocky dungeons. Hunt ' .. v.amount .. ' of them and come back to me. Understood?', cid)
    176.         Topic[cid] = v.storage
    177.     elseif Topic[cid] == 1 and msgcontains(msg, 'mammoth') then
    178.         local v = tasks['mammoth']
    179.         selfSay('This particular species are found in Svargrond. Impressive beasts, but you wouldn\'t want one in your back garden. Hunt ' .. v.amount .. ' of them. Alright?', cid)
    180.         Topic[cid] = v.storage
    181.     elseif Topic[cid] == 2 and msgcontains(msg, 'golem') then
    182.         local v = tasks['ice golem']
    183.         selfSay('The ice golems on the glacier of Hrodmir are becoming a threat to the civilians in Svargrond. Travel to the Ice Islands and hunt ' .. v.amount .. ' Ice Golems. Do you accept this task?', cid)
    184.         Topic[cid] = v.storage
    185.     elseif Topic[cid] == 2 and msgcontains(msg, 'quara') then
    186.         selfSay('There are different types of quaras. The weaker {scouts} which can be found on Malada, one of the shattered Islands and the more skilled {underwater} kind which can be found in Calassa and some smaller colonies. Which one do you wish to hunt?', cid)
    187.         Topic[cid] = 5
    188.     elseif Topic[cid] == 5 and msgcontains(msg, 'scout') then
    189.         local v = tasks['quara constrictor scout']
    190.         selfSay('Good choice! Hunt down those Quara scouts - remember no less than ' .. v.amount .. '! Focus! Do you accept this task?', cid)
    191.         Topic[cid] = v.storage
    192.     elseif Topic[cid] == 5 and msgcontains(msg, 'underwater') then
    193.         local v = tasks['quara constrictor']
    194.         selfSay('As you wish. Seek out a Quara settlement and hunt ' .. v.amount .. ' Quaras, it doesn\'t matter which type you hunt. Alright?', cid)
    195.         Topic[cid] = v.storage
    196.     elseif Topic[cid] == 2 and msgcontains(msg, 'elemental') then
    197.         selfSay({'Since the creation of the elemental shrines and the portals, the curtain separating the worlds is thin, allowing the elementals to surge into our world. They have to be contained. ...', 'The choice as to which kind of elementals you hunt is yours, as long as they are in the lands of Tibia. Hunt 70 {earth}, {energy}, {fire} or {water} elementals. Which one do you choose?'} , cid)
    198.         Topic[cid] = 6
    199.     elseif Topic[cid] == 6 and msgcontains(msg, 'water') then
    200.         local v = tasks['water elemental']
    201.         selfSay('Alright, go hunt ' .. v.amount .. ' water elementals or massive water elementals. Don\'t forget your umbrella! Alright?', cid)
    202.         Topic[cid] = v.storage
    203.     elseif Topic[cid] == 6 and msgcontains(msg, 'earth') then
    204.         local v = tasks['earth elemental']
    205.         selfSay('Good choice! I need you to slay ' .. v.amount .. ' earth elementals or massive earth elementals. There are some in the so called Taboo-area in the eastern jungle of Tiquanda and I heard about a cave in Edron where you\'ll find them. Are you game?', cid)
    206.         Topic[cid] = v.storage
    207.     elseif Topic[cid] == 6 and msgcontains(msg, 'energy') then
    208.         local v = tasks['energy elemental']
    209.         selfSay('A brave hunter! Kill ' .. v.amount .. ' energy elementals or massive energy elementals. You\'ll find them in the mountains between Darama and Tiquanda. Are you sure you want to do this?', cid)
    210.         Topic[cid] = v.storage
    211.     elseif Topic[cid] == 6 and msgcontains(msg, 'fire') then
    212.         local v = tasks['fire elemental']
    213.         selfSay('Don\'t get burnt! Your challenge, should you choose to accept it, is to kill ' .. v.amount .. ' fire elementals or massive fire elementals. Are you ready?', cid)
    214.         Topic[cid] = v.storage
    215.     elseif Topic[cid] == 2 and msgcontains(msg, 'mutated rat') then
    216.         local v = tasks['mutated rat']
    217.         selfSay('Recently, I heard of a disturbing development in Yalahar - a plague of monstrous Mutated rats! If they were to spread to the rest of Tibia.. <shudders> My task for you is to contain their numbers in Yalahar. Hunt ' .. v.amount .. ' of them. What do you say?', cid)
    218.         Topic[cid] = v.storage
    219.     elseif Topic[cid] == 2 and msgcontains(msg, 'giant spider') then
    220.         local v = tasks['giant spider']
    221.         selfSay('Never liked spiders. Entirely too many legs. And I always find them in my bath! Those nasty creepy crawlies are a threat to the hygiene of every living being in Tibia. Hunt ' .. v.amount .. ' of them. Okay?', cid)
    222.         Topic[cid] = v.storage
    223.     elseif Topic[cid] == 3 and msgcontains(msg, 'hydra') then
    224.         local v = tasks['hydra']
    225.         selfSay('The hydras are located in the eastern jungle of Tiquanda and there are several mountain caves that are inhabited by them. Your task is to hunt a mere ' .. v.amount .. ' hydras. Are you willing to do that?', cid)
    226.         Topic[cid] = v.storage
    227.     elseif Topic[cid] == 3 and msgcontains(msg, 'sea serpent') then
    228.         local v = tasks['sea serpent']
    229.         selfSay({'The sea serpents are a threat to honest seafarers! Captain Haba knows where to find them. ...', 'Go to Svargrond and talk to him. ' .. v.amount .. ' sea serpents should be enough to reduce the threat - but not their young though! After all, they are an endangered species! Got it?'}, cid)
    230.         Topic[cid] = v.storage
    231.     elseif Topic[cid] == 3 and msgcontains(msg, 'behemoth') then
    232.         local v = tasks['behemoth']
    233.         selfSay('Behemoths must be kept away from the settlements at all costs. You\'ll find them east of here in the taboo-area or under the cyclopolis in Edron. Go there and hunt a few of them - shall we say... ' .. v.amount .. '? Are you up for that?', cid)
    234.         Topic[cid] = v.storage
    235.     elseif Topic[cid] == 3 and msgcontains(msg, 'serpent spawn') then
    236.         local v = tasks['serpent spawn']
    237.         selfSay('Very dangerous, nasty, slimey creatures. They live deep in the old ruins of Banuta. I think a mere ' .. v.amount .. ' serpent spawns should do the trick. What do you say?', cid)
    238.         Topic[cid] = v.storage
    239.     elseif Topic[cid] == 3 and getPlayerStorageValue(cid, rank) == 5 and msgcontains(msg, 'demon') and getPlayerStorageValue(cid, curTask) < 1 then
    240.         local v = tasks['demon']
    241.         selfSay('The spawn of pure evil must be erased from Tibia. You\'ll find demons lurking in the northern ruins of Edron as well as in some of other deeper dungeons of Tibia. We need to wipe them out! Slay ' .. v.amount .. ' demons for the Greater Good!', cid)
    242.         setPlayerStorageValue(cid, curTask, v.storage)
    243.         setPlayerStorageValue(cid, v.storage, 0)
    244.         Topic[cid] = 0
    245.     elseif Topic[cid] >= 14000 and msgcontains(msg, 'yes') then
    246.         selfSay(data[Topic[cid]][2], cid)
    247.         setPlayerStorageValue(cid, curTask, Topic[cid])
    248.         setPlayerStorageValue(cid, Topic[cid], 0)
    249.         if getPlayerStorageValue(cid, questLog) < 1 then
    250.             setPlayerStorageValue(cid, questLog, 1)
    251.             setPlayerStorageValue(cid, points, 0)
    252.         end
    253.         Topic[cid] = 0
    254.     elseif msgcontains(msg, 'special') and getPlayerStorageValue(cid, rank) == 5 then
    255.         local v, k = getPlayerStorageValue(cid, tiquanda), getPlayerStorageValue(cid, demodras)
    256.         if v < 1 then
    257.             if getPlayerLevel(cid) >= 90 then
    258.                 setPlayerStorageValue(cid, tiquanda, 1)
    259.                 selfSay({'Have you heard about {Tiquandas Revenge}? It is said that the jungle itself is alive and takes revenge for all the bad things people have done to it. ...', 'I myself believe that there is some truth in this clap trap. Something \'real\' which therefore must have a hideout somewhere. Go find it and take revenge yourself! Ask me about the {special} task when you\'re done.'}, cid)
    260.             else
    261.                 selfSay('Your eagerness is commendable, and your rank within our hunting elite is great buuuut I\'m afraid you\'re a little bit too weak for the special tasks. Get more experience and the special tasks will be no match for you.', cid)
    262.             end
    263.         elseif v == 2 then
    264.             selfSay('Great achievement, old chap! You are an outstanding hunter, no doubt about it!', cid)
    265.             setPlayerStorageValue(cid, tiquanda, 3)
    266.         elseif v == 3 and k < 1 then
    267.             if getPlayerLevel(cid) >= 100 then
    268.                 setPlayerStorageValue(cid, demodras, 1)
    269.                 selfSay('This task is a very dangerous one. I want you to look for {Demodras}\' hideout. It might be somewhere under the {Plains of Havoc}. Good luck, old chap, come back in one piece and ask me about the {special} task when you\'re done.', cid)
    270.             else
    271.                 selfSay('Your eagerness is commendable, and your rank within our hunting elite is great buuuut I\'m afraid you\'re a little bit too weak for the special tasks. Get more experience and the special tasks will be no match for you.', cid)
    272.             end
    273.         elseif k == 2 then
    274.             selfSay('Great achievement, old chap! You are an outstanding hunter, no doubt about it!', cid)
    275.             setPlayerStorageValue(cid, demodras, 3)
    276.         end
    277.     elseif msgcontains(msg, 'promotion') then
    278.         local cur, r, msg, exp, item = getPlayerStorageValue(cid, points), getPlayerStorageValue(cid, rank)
    279.         if cur >= 5 and r < 1 then
    280.             msg, exp = {'You have completed 5 tasks! Let me promote you to the first rank: Huntsman. Congratulations! ...', 'If you find any trophies that you don\'t need, feel free to ask me for a trade.'}, 5000
    281.         elseif cur >= 10 and r < 2 then
    282.             msg, exp = {'You have completed 10 hunting tasks. It\'s time for a promotion. You advance to the rank of \'Ranger\'. Congratulations! ...', 'Oh, I made a deal with Lorek. He ships Rangers from our society - and higher ranks of course - to Banuta, Chor or near the mountain pass to Darama. Just ask him for a passage.'}, 8000
    283.         elseif cur >= 20 and r < 3 then
    284.             msg, exp = {'Good show! You have completed 20 hunting tasks for the \'Paw and Fur - Hunting Elite. You have earned the right to join the ranks of those known as \'Big game hunter\'. Congratulations! ...', 'From now on I\'ll buy more trophies from you!'}, 10000
    285.         elseif cur >= 30 and r < 4 then
    286.             msg, exp, item = 'Spiffing! You have done 30 hunting tasks! From now on you can call yourself a \'Trophy hunter\'. As a reward I have this special backpack for you and in addition you can sell some more rare trophies to me.', 15000, 10518
    287.         elseif cur >= 50 and r < 5 then
    288.             msg, exp = 'Congratulations! You have made the highest rank: \'Elite hunter\'. If haven\'t yet done so ask me for the {special} task.', 30000
    289.         end
    290.         if msg then
    291.             selfSay(msg, cid)
    292.             setPlayerStorageValue(cid, rank, math.max(1, r + 1))
    293.             if exp then
    294.                 doPlayerAddExp(cid, exp)
    295.                 doSendAnimatedText(getThingPos(cid), exp, 215)
    296.             end
    297.             if item then
    298.                 doPlayerAddItem(cid, item, 1)
    299.             end
    300.         end
    301.     end
    302. end
    303.  
    304. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
    305. npcHandler:setMessage(MESSAGE_FAREWELL, 'Happy hunting, old chap!')
    306. npcHandler:setMessage(MESSAGE_WALKAWAY, 'Happy hunting, old chap!')
    307. npcHandler:setCallback(CALLBACK_GREET, greetCallback)
    308. npcHandler:addModule(FocusModule:new())
    boss rooms movement:
    Code (Lua):
    1. local t={
    2.     [14001]={{'Leviathan'}, tp={x=31914, y=31071, z=10}, spawn={x=31905, y=31071, z=10}, from={x=31900, y=31064, z=10}, to={x=31918, y=31081, z=10}},
    3.     [14002]={{'The Noxious Spawn'}, tp={x=32842, y=32668, z=11}, spawn={x=32842, y=32673, z=11}, from={x=32836, y=32665, z=11}, to={x=32849, y=32677, z=11}},
    4.     [14003]={{'Necropharus'}, tp={x=33028, y=32427, z=12}, spawn={x=33028, y=32421, z=12}, from={x=33020, y=32415, z=12}, to={x=33035, y=32430, z=12}},
    5.     [14004]={{'The Horned Fox'}, tp={x=32458, y=31993, z=9}, spawn={x=32458, y=32004, z=9}, from={x=32453, y=31992, z=9}, to={x=32464, y=32008, z=9}},
    6.     [14005]={{'Lethal Lissy', 'Ron The Ripper', 'Deadeye Devious', 'Brutus Bloodbeard'}, tp={x=31975, y=32896, z=0}, spawn={x=31982, y=32896, z=0}, from={x=31972, y=32890, z=0}, to={x=31988, y=32904, z=0}},
    7.     [14007]={{'The Snapper'}, tp={x=32610, y=32724, z=8}, spawn={x=32611, y=32727, z=8}, from={x=32606, y=32720, z=8}, to={x=32620, y=32733, z=8}},
    8.     [14008]={{'Hide'}, tp={x=32815, y=32704, z=8}, spawn={x=32816, y=32708, z=8}, from={x=32810, y=32701, z=8}, to={x=32824, y=32713, z=8}},
    9.     [14012]={{'Shardhead'}, tp={x=32102, y=31125, z=2}, spawn={x=32101, y=31130, z=2}, from={x=32095, y=31122, z=2}, to={x=32108, y=31136, z=2}},
    10.     [14019]={{'Esmeralda'}, tp={x=32759, y=31253, z=9}, spawn={x=32759, y=31256, z=9}, from={x=32755, y=31250, z=9}, to={x=32764, y=31259, z=9}},
    11.     [14020]={{'The Old Widow'}, tp={x=32804, y=32280, z=8}, spawn={x=32800, y=32280, z=8}, from={x=32794, y=32273, z=8}, to={x=32807, y=32288, z=8}},
    12.     [14021]={{'The Many'}, tp={x=32921, y=32894, z=8}, spawn={x=32921, y=32899, z=8}, from={x=32915, y=32891, z=8}, to={x=32927, y=32904, z=8}},
    13.     [14506]={{'Demodras'}, tp={x=32748, y=32287, z=10}, spawn={x=32745, y=32292, z=10}, from={x=32738, y=32283, z=10}, to={x=32757, y=32300, z=10}},
    14.     [14505]={{'Tiquandas Revenge'}, tp={x=32888, y=32580, z=4}, spawn={x=32883, y=32580, z=4}, from={x=32881, y=32578, z=4}, to={x=32892, y=32588, z=4}},
    15.     [14022]={{'Stonecracker'}, tp={x=33259, y=31695, z=15}, spawn={x=33257, y=31702, z=15}, from={x=33252, y=31691, z=15}, to={x=33266, y=31708, z=15}},
    16. }
    17.  
    18. function onStepIn(cid, item, position, fromPosition)
    19.     if isPlayer(cid) then
    20.         local k=t[item.uid]
    21.         if getCreatureStorage(cid, item.uid + (item.uid < 14500 and 100 or 0)) == 1 then
    22.             local m={}
    23.             for x=k.from.x, k.to.x do
    24.                 for y=k.from.y, k.to.y do
    25.                     local v=getTopCreature({x=x, y=y, z=k.from.z}).uid
    26.                     if v ~= 0 then
    27.                         if isPlayer(v) then
    28.                             doTeleportThing(cid, fromPosition, true)
    29.                             doCreatureSay(cid, 'Someone else is in the room.', TALKTYPE_ORANGE_1, false, cid)
    30.                             return
    31.                         elseif isMonster(v) then
    32.                             table.insert(m, v)
    33.                         end
    34.                     end
    35.                 end
    36.             end
    37.             for i=1, #m do
    38.                 doRemoveCreature(m[i])
    39.             end
    40.             doCreatureSetStorage(cid, item.uid + (item.uid < 14500 and 100 or 0), 2)
    41.             doTeleportThing(cid, k.tp)
    42.             doSendMagicEffect(position, CONST_ME_TELEPORT)
    43.             doSendMagicEffect(k.tp, CONST_ME_TELEPORT)
    44.             doCreateMonster(k[1][math.random(#k[1])], k.spawn)
    45.             doSendMagicEffect(k.spawn, CONST_ME_TELEPORT)
    46.             return
    47.         end
    48.     end
    49.     doTeleportThing(cid, fromPosition, true)
    50. end
    quests.cpp patch: (if you don't patch it, quest log won't work)
     
    Last edited: Jun 22, 2011
    nsanee likes this.
  3. Stewie

    Stewie Family Guy # ;3

    Joined:
    May 3, 2010
    Messages:
    786
    Likes Received:
    12
    Best Answers:
    0
    your task system is same RL?
     
  4. Bogart

    Bogart ...has super panda powers

    Joined:
    Jun 21, 2009
    Messages:
    7,750
    Likes Received:
    396
    Best Answers:
    1
    check the code, and check the 'How it works?' section, stop posting dumb questions.

    @ONTOPIC.

    Nice again, 'You must spread some Reputation around before giving it to darkhaos again.' it has been like 4 months since I last repped you. uhmm..
     
  5. LucasFerraz

    LucasFerraz Systems Analyst

    Joined:
    Jun 10, 2010
    Messages:
    2,856
    Likes Received:
    85
    Best Answers:
    0
    1. Can player make more than 1 task?
     
  6. Darkhaos

    Darkhaos (:

    Joined:
    Apr 17, 2008
    Messages:
    1,922
    Likes Received:
    169
    Best Answers:
    0
    yes
     
  7. LucasFerraz

    LucasFerraz Systems Analyst

    Joined:
    Jun 10, 2010
    Messages:
    2,856
    Likes Received:
    85
    Best Answers:
    0
    I'm using your script 'Now player can choose the task'.
    What do I must change? (I cant replace that because I changed somethings)
     
  8. Darkhaos

    Darkhaos (:

    Joined:
    Apr 17, 2008
    Messages:
    1,922
    Likes Received:
    169
    Best Answers:
    0
    If you want that player can start more than one task and start task by name, you need to change all code except the config.
     
  9. LucasFerraz

    LucasFerraz Systems Analyst

    Joined:
    Jun 10, 2010
    Messages:
    2,856
    Likes Received:
    85
    Best Answers:
    0
    "01:10 Grizzly Adams: Are you sure that do you want to start the task number 1?. In this task you will need to defeat 100 Trolls."

    Can you change to:
    "01:10 Grizzly Adams: In this task you will need to defeat 100 Trolls. Are you sure that do you want to start?"
    (Showwing the monster counts, and monster name)?
     
  10. Darkhaos

    Darkhaos (:

    Joined:
    Apr 17, 2008
    Messages:
    1,922
    Likes Received:
    169
    Best Answers:
    0
    You can do that, just edit the text, emove 'Are you sure that do you want to start the task number n?. And after 'In this task bla bla..' write 'Are you sure bla bla..'
     
  11. LucasFerraz

    LucasFerraz Systems Analyst

    Joined:
    Jun 10, 2010
    Messages:
    2,856
    Likes Received:
    85
    Best Answers:
    0
    "01:10 Grizzly Adams: In this task you will need to defeat 100 Trolls. Are you sure that do you want to start?"

    How can I set in message the COUNT and TASKNAME(example: Trolls)?
     
  12. Darkhaos

    Darkhaos (:

    Joined:
    Apr 17, 2008
    Messages:
    1,922
    Likes Received:
    169
    Best Answers:
    0
    But there is already
    "01:10 Grizzly Adams: In this task you will need to defeat 100 Trolls. Are you sure that do you want to start?"
     
  13. LucasFerraz

    LucasFerraz Systems Analyst

    Joined:
    Jun 10, 2010
    Messages:
    2,856
    Likes Received:
    85
    Best Answers:
    0
    Will it works? (My test is offline)
    selfSay("In this task you will need to defeat " .. tasks[msg].killsRequired .. " " .. tasks[msg].raceName .. ". Are you sure that do you want to start?", cid)
     
  14. Darkhaos

    Darkhaos (:

    Joined:
    Apr 17, 2008
    Messages:
    1,922
    Likes Received:
    169
    Best Answers:
    0
    Yes :)
     
  15. LucasFerraz

    LucasFerraz Systems Analyst

    Joined:
    Jun 10, 2010
    Messages:
    2,856
    Likes Received:
    85
    Best Answers:
    0
    Thank you again!

    When you say 'tasks' is possible a better way? This window is not good, maybe NPC list?
    Adams: Trolls, Quaras(done)..


    Edit: You must spread some Reputation around before giving it to darkhaos again.
     
    Last edited: Mar 17, 2011
  16. Darkhaos

    Darkhaos (:

    Joined:
    Apr 17, 2008
    Messages:
    1,922
    Likes Received:
    169
    Best Answers:
    0
    Change
    Code (Lua):
    1. doShowTextDialog(cid, 5956, text)
    With
    Code (Lua):
    1. selfSay(text, cid)
    I don't understand what's that
     
  17. LucasFerraz

    LucasFerraz Systems Analyst

    Joined:
    Jun 10, 2010
    Messages:
    2,856
    Likes Received:
    85
    Best Answers:
    0
    I tried to give you reputation, but I don't have reputation to give.

    How can I set [done] here?
    Code (Lua):
    1. selfSay(bla bla bla, cid)
     
  18. Darkhaos

    Darkhaos (:

    Joined:
    Apr 17, 2008
    Messages:
    1,922
    Likes Received:
    169
    Best Answers:
    0
    Do what i told you, that's already setted here:
    Code (Lua):
    1.         for i = 1, table.maxn(tasks) do
    2.             text = text .. "\n" .. i .. "  -  " .. tasks[i].raceName .. (getCreatureStorage(cid, tasks[i].questStarted) == 2 and " [Done]" or "")
    3.         end
     
  19. LucasFerraz

    LucasFerraz Systems Analyst

    Joined:
    Jun 10, 2010
    Messages:
    2,856
    Likes Received:
    85
    Best Answers:
    0
    Will it work?
    Code (Lua):
    1. selfSay(text .. "\n" .. i .. "  -  " .. tasks[i].raceName .. (getCreatureStorage(cid, tasks[i].questStarted) == 2 and " [Done]" or "", cid)
     
  20. Darkhaos

    Darkhaos (:

    Joined:
    Apr 17, 2008
    Messages:
    1,922
    Likes Received:
    169
    Best Answers:
    0
    That's already included on 'text', just paste
    Code (Lua):
    1. selfSay(text, cid)
    You'll see the same message as in the text dialog but in the npc channel.
     

Share This Page

Loading...