Hello together:
grizzly adam work well and the kills count and i get a reward ( reward is storage ID for Boss)
And how can i make that the Boss kill count? for the quest log?
I can enter the Boss room and Boss spawns.
But how can i make a Boss reward like reset a ID?
Kill Counter:
The lib of the quest
movement boss
grizzly adam work well and the kills count and i get a reward ( reward is storage ID for Boss)
And how can i make that the Boss kill count? for the quest log?
I can enter the Boss room and Boss spawns.
But how can i make a Boss reward like reset a ID?
Kill Counter:
Lua:
function onKill(player, target)
if target:isPlayer() or target:getMaster() then
return true
end
local targetName, startedTasks, taskId = target:getName():lower(), player:getStartedTasks()
for i = 1, #startedTasks do
taskId = startedTasks[i]
if isInArray(tasks[taskId].creatures, targetName) then
local killAmount = player:getStorageValue(KILLSSTORAGE_BASE + taskId)
if killAmount < tasks[taskId].killsRequired then
player:setStorageValue(KILLSSTORAGE_BASE + taskId, killAmount + 1)
end
end
end
return true
end
The lib of the quest
Lua:
--[[
TODO
Unite all related variables / functions in a table
rewrite functions like "getTasksByPlayer" to "Player.getTasks"
]]
RANK_NONE = 0
RANK_JOIN = 1
RANK_HUNTSMAN = 2
RANK_RANGER = 3
RANK_BIGGAMEHUNTER = 4
RANK_TROPHYHUNTER = 5
RANK_ELITEHUNTER = 6
REWARD_MONEY = 1
REWARD_EXP = 2
REWARD_ACHIEVEMENT = 3
REWARD_STORAGE = 4
REWARD_POINT = 5
REWARD_ITEM = 6
QUESTSTORAGE_BASE = 1500
JOIN_STOR = 100157
KILLSSTORAGE_BASE = 65000
REPEATSTORAGE_BASE = 48950
POINTSSTORAGE = 2500
tasks =
{
[26] = {killsRequired = 5, raceName = "Giant Spiders", level = {50, 1000}, premium = true, creatures = {"giant spider"}, rewards = {{type = "exp", value = {20000}},{type = "storage", value = {35010, 1}}}},
}
tasksByPlayer = 3
repeatTimes = 3
function Player.getPawAndFurRank(self)
return (self:getStorageValue(POINTSSTORAGE) >= 100 and RANK_ELITEHUNTER or self:getStorageValue(POINTSSTORAGE) >= 70 and RANK_TROPHYHUNTER or self:getStorageValue(POINTSSTORAGE) >= 40 and RANK_BIGGAMEHUNTER or self:getStorageValue(POINTSSTORAGE) >= 20 and RANK_RANGER or self:getStorageValue(POINTSSTORAGE) >= 10 and RANK_HUNTSMAN or self:getStorageValue(JOIN_STOR) == 1 and RANK_JOIN or RANK_NONE)
end
function Player.getPawAndFurPoints(self)
return math.max(self:getStorageValue(POINTSSTORAGE), 0)
end
function getTaskByName(name, table)
local t = (table and table or tasks)
for k, v in pairs(t) do
if v.name then
if v.name:lower() == name:lower() then
return k
end
else
if v.raceName:lower() == name:lower() then
return k
end
end
end
return false
end
function Player.getTasks(self)
local canmake = {}
local able = {}
for k, v in pairs(tasks) do
if self:getStorageValue(QUESTSTORAGE_BASE + k) < 1 and self:getStorageValue(REPEATSTORAGE_BASE + k) < repeatTimes then
able[k] = true
if self:getLevel() < v.level[1] or self:getLevel() > v.level[2] then
able[k] = false
end
if v.storage and self:getStorageValue(v.storage[1]) < v.storage[2] then
able[k] = false
end
if v.rank then
if self:getPawAndFurRank() < v.rank then
able[k] = false
end
end
if v.premium then
if not self:isPremium() then
able[k] = false
end
end
if able[k] then
canmake[#canmake + 1] = k
end
end
end
return canmake
end
function Player.canStartTask(self, name, table)
local v = ""
local id = 0
local t = (table and table or tasks)
for k, i in pairs(t) do
if i.name then
if i.name:lower() == name:lower() then
v = i
id = k
break
end
else
if i.raceName:lower() == name:lower() then
v = i
id = k
break
end
end
end
if v == "" then
return false
end
if self:getStorageValue(QUESTSTORAGE_BASE + id) > 0 then
return false
end
if self:getStorageValue(REPEATSTORAGE_BASE + id) >= repeatTimes or v.norepeatable and self:getStorageValue(REPEATSTORAGE_BASE + id) > 0 then
return false
end
if v.level and self:getLevel() >= v.level[1] and self:getLevel() <= v.level[2] then
if v.premium then
if self:isPremium() then
if v.rank then
if self:getPawAndFurRank() >= v.rank then
if v.storage then
if self:getStorageValue(v.storage[1]) >= v.storage then
return true
end
else
return true
end
end
else
return true
end
else
return true
end
else
return true
end
end
return false
end
function Player.getStartedTasks(self)
local tmp = {}
for k, v in pairs(tasks) do
if self:getStorageValue(QUESTSTORAGE_BASE + k) > 0 and self:getStorageValue(QUESTSTORAGE_BASE + k) < 2 then
tmp[#tmp + 1] = k
end
end
return tmp
end
--in case other scripts are using these functions, i'll let them here
function getPlayerRank(cid) local p = Player(cid) return p and p:getPawAndFurRank() end
function getPlayerTasksPoints(cid) local p = Player(cid) return p and p:getPawAndFurPoints() end
function getTasksByPlayer(cid) local p = Player(cid) return p and p:getTasks() end
function canStartTask(cid, name, table) local p = Player(cid) return p and p:canStartTask(name, table) end
function getPlayerStartedTasks(cid) local p = Player(cid) return p and p:getStartedTasks() end
movement boss
Lua:
local function roomIsOccupied(centerPosition, rangeX, rangeY)
local spectators = Game.getSpectators(centerPosition, false, true, rangeX, rangeX, rangeY, rangeY)
if #spectators ~= 0 then
return true
end
return false
end
function clearBossRoom(playerId, bossId, centerPosition, rangeX, rangeY, exitPosition)
local spectators, spectator = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)
for i = 1, #spectators do
spectator = spectators[i]
if spectator:isPlayer() and spectator.uid == playerId then
spectator:teleportTo(exitPosition)
exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
end
if spectator:isMonster() and spectator.uid == bossId then
spectator:remove()
end
end
end
local bosses = {
[3240] = {bossName = 'the old widow', storage = 35010, playerPosition = Position(626, 536, 10), bossPosition = Position(626, 529, 10), centerPosition = Position(626, 531, 10), rangeX = 5, rangeY = 5, flamePosition = Position(626, 537, 10)},
}
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player then
return true
end
local boss = bosses[item.uid]
if not boss then
return true
end
if player:getStorageValue(boss.storage) ~= 1 or roomIsOccupied(boss.centerPosition, boss.rangeX, boss.rangeY) then
player:teleportTo(fromPosition)
return true
end
player:setStorageValue(boss.storage, 0)
player:teleportTo(boss.playerPosition)
boss.playerPosition:sendMagicEffect(CONST_ME_TELEPORT)
local monster = Game.createMonster(boss.bossName, boss.bossPosition)
if not monster then
return true
end
addEvent(clearBossRoom, 60 * 10 * 1000, player.uid, monster.uid, boss.centerPosition, boss.rangeX, boss.rangeY, fromPosition)
player:say('You have ten minutes to kill and loot this boss. Otherwise you will lose that chance and will be kicked out.', TALKTYPE_MONSTER_SAY)
return true
end
XML:
<mission name="Paw and Fur: The Old Widow" storageid="35010" startvalue="0" endvalue="2" description="Try find its hideout and kill it. You killed |STATE|. " />