DukeeH
Active Member
- Joined
- Dec 6, 2010
- Messages
- 550
- Solutions
- 3
- Reaction score
- 39
Hello, I'm using TFS 0.3.7/OTX2.
I'm trying to change a code by @buchaLL
He made a monster of the day code, but on my server I have a few dragon lords, I want that if the monster of the day is dragon lord, it affects all the ones in the group.
I wasn't able to use a table for this.
Monster Picker, would be a globalevent at midnight:
And this is the creaturescript, but what I need is that, if the storage is "dragon lord" it works for all that dragon lords on the group.
How to do it to use table? I've tried to add some prints but I couldn't.
And another thing is that sometimes it is working, and sometimes don't.
If I print bonusexp, it works okay, but I kill the monster and it doesn't give the exp and the animated text sometimes.
Thanks!
I'm trying to change a code by @buchaLL
He made a monster of the day code, but on my server I have a few dragon lords, I want that if the monster of the day is dragon lord, it affects all the ones in the group.
I wasn't able to use a table for this.
Monster Picker, would be a globalevent at midnight:
Lua:
math.randomseed(os.time())
local boostedMonstersList = {"dragon lord", "frost dragon", "hydra", "warlock", "medusa", "grim reaper", "demon"}
local randomMonster = math.random(#boostedMonstersList)
setGlobalStorageValue(BOOSTED_MONSTER, boostedMonstersList[randomMonster])
setGlobalStorageValue(BOOSTED_EXP_BONUS, math.random(20, 50))
setGlobalStorageValue(BOOSTED_LOOT_BONUS, math.random(20, 50))
local spawn = {x = 250, y = 195, z = 14} -- monster spawn position
doCreateMonster(boostedMonstersList[randomMonster], spawn)
print("Today's boosted monster is: " .. boostedMonstersList[randomMonster])
Lua:
local ignoredList = {1987}
function addBonusLoot(position, name)
for i = 0, 255 do
position.stackpos = i
corpse = getTileThingByPos(position)
if corpse.uid > 0 and isCorpse(corpse.uid) then
break
end
end
local newRate = (1 + (getGlobalStorageValue(12382)/100)) * getConfigValue("rateLoot")
local monsterLoot = getMonsterLootList(name)
local mainbp = doCreateItemEx(1987, 1)
for i, loot in pairs(monsterLoot) do
if math.random(1, 100000) <= newRate * loot.chance then
if #ignoredList > 0 then
if (not isInArray(ignoredList, loot.id)) then
doAddContainerItem(mainbp, loot.id, loot.countmax and math.random(1, loot.countmax) or 1)
end
else
doAddContainerItem(mainbp, loot.id, loot.countmax and math.random(1, loot.countmax) or 1)
end
end
doAddContainerItemEx(corpse.uid, mainbp)
end
end
boostedMonstersListEx = {
[1] = {"dragon lord", "dragon lord vip", "fast dlord", "hard dlord"},
[2] = {"frost dragon", "frost dragon vip", "fast fdragon", "hard fdragon"},
[3] = {"hydra", "hydra vip", "fast hydra", "hard hydra"},
[4] = {"warlock", "warlock vip", "fast warlock", "hard warlock"},
[5] = {"medusa", "medusa vip", "fast medusa", "hard medusa"},
[6] = {"grim reaper", "grim reaper vip", "fast greaper", "hard greaper"},
[6] = {"demon", "demon vip", "fast demon", "hard demon"}
}
function onDeath(cid, corpse, deathList)
local BOOSTED_MONSTER = getGlobalStorageValue(12380)
local BOOSTED_EXP_BONUS = getGlobalStorageValue(12381)
local master = getCreatureMaster(cid)
if (master and master ~= cid) then
return true
end
local curMonster = getCreatureName(cid):lower()
if curMonster == BOOSTED_MONSTER then
for i = 1, #deathList do
local bonusExp = getMonsterInfo(getCreatureName(cid)).experience/i * getPlayerRates(deathList[i])[SKILL__LEVEL] * getExperienceStage(getPlayerLevel(deathList[i])) * BOOSTED_EXP_BONUS/100
doPlayerAddExperience(deathList[i], bonusExp)
doSendAnimatedText(getPlayerPosition(deathList[i]), bonusExp, 215)
addEvent(addBonusLoot, 10, getCreaturePosition(cid), getCreatureName(cid))
end
end
return true
end
And this is the creaturescript, but what I need is that, if the storage is "dragon lord" it works for all that dragon lords on the group.
How to do it to use table? I've tried to add some prints but I couldn't.
And another thing is that sometimes it is working, and sometimes don't.
If I print bonusexp, it works okay, but I kill the monster and it doesn't give the exp and the animated text sometimes.
Thanks!