-----------------------------------------------------------------------
-- Time in minute, after the boss is dead the player have timeOut minute(s) to get his gift.
timeOut = 1
bosses = {
['rat'] = {status = 1, storage = 8005}
}
boss = {}
-----------------------------------------------------------------------
local function giveGift(cid)
item = doCreateItemEx( 2392 , 1)
if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
return 0, 0
end
end
-----------------------------------------------------------------------
function onLogin(cid)
-- registerCreatureEvent(cid,"bossKiller_fight")
registerCreatureEvent(cid,"bossKiller_death")
player = cid
player:say('onLogin.', TALKTYPE_MONSTER_SAY)
local position = getCreaturePosition(cid)
local ret = doSummonCreature( "rat" , position, false)
if(tonumber(ret) == nil) then
doPlayerSendDefaultCancel(cid, (ret == false and RETURNVALUE_NOTPOSSIBLE or RETURNVALUE_NOTENOUGHROOM))
end
registerCreatureEvent(tonumber(ret), "bossKiller_fight")
return true
end
-----------------------------------------------------------------------
-- function onCombat(cid, target)
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
cid = attacker
target = creature
local bossConfig = bosses[target:getName():lower()]
if (not bossConfig) then
return false
end
if isPlayer(cid) ~= true then
return false
end
if getPlayerStorageValue(cid, bossConfig.storage ) < 0 then
setPlayerStorageValue(cid, bossConfig.storage , 0 )
else
local i = getPlayerStorageValue(cid, bossConfig.storage )
setPlayerStorageValue(cid, bossConfig.storage , i+1 )
end
return primaryDamage, primaryType, secondaryDamage, secondaryType, origin
end
-----------------------------------------------------------------------
function onKill(creature, target)
player = creature
player:say('bravo, Boss Killer.', TALKTYPE_MONSTER_SAY)
boss = bosses[target:getName():lower()]
if not next(boss) then
return true
end
setGlobalStorageValue( boss.storage , os.time() + timeOut*60 ) -- os.time+(30*60)
end
-----------------------------------------------------------------------
function onUse(cid, item, frompos, item2, topos)
player = cid
if next(boss) then
-- player:say( getGlobalStorageValue( boss.storage ) , TALKTYPE_MONSTER_SAY)
-- player:say( os.time() , TALKTYPE_MONSTER_SAY)
if getGlobalStorageValue( boss.storage ) <= os.time() then
player:say("Sorry, but nobody killed any bosses recent! ", TALKTYPE_MONSTER_SAY)
doSendMagicEffect(getCreaturePosition(cid), 2)
return false
end
if getPlayerStorageValue(cid, boss.storage ) < 1 then
cid:say( " Did u were really there ? " , TALKTYPE_MONSTER_SAY)
elseif getPlayerStorageValue(cid, boss.storage ) < 200 then
cid:say( " Good job. " , TALKTYPE_MONSTER_SAY)
else
cid:say( " Great, brave Warior " , TALKTYPE_MONSTER_SAY)
end
giveGift(cid)
setPlayerStorageValue(cid, boss.storage, 0)
else
doPlayerSendCancel(cid, "Sorry, but nobody killed any bosses at all! ")
end
return true
end
-----------------------------------------------------------------------