highsanta
Advanced OT User
- Joined
- Dec 20, 2023
- Messages
- 398
- Solutions
- 3
- Reaction score
- 174
Lua:
-- Define a table to store information about each monster
local monsterData = {
{
monstername = "troll",
storageid = 30001,
taskkilltotal = 1000,
experiencereward = 1000,
goldreward = 1000,
taskfinished = 0,
spawnbossrate = 40001,
bossname = "demonic troll"
},
-- Add more monsters as needed
}
function onKill(cid, target)
local player = Player(cid)
local targetName = getCreatureName(target)
if isMonster(target) then
local currentMonsterData = nil
-- Find the data for the killed monster
for _, data in ipairs(monsterData) do
if data.monstername == targetName then
currentMonsterData = data
break
end
end
if not currentMonsterData then
print("Error: Monster data not found for " .. targetName)
return false
end
local storageKey = "kills_" .. currentMonsterData.monstername
local totalKills = player:getStorageValue(storageKey) or 0
totalKills = totalKills + 1
player:setStorageValue(storageKey, totalKills)
local spawnBossRate = player:getStorageValue("spawn_boss_rate") or 0
spawnBossRate = spawnBossRate + 1
player:setStorageValue("spawn_boss_rate", spawnBossRate)
if math.random(1, 10000) == 1 then
-- Spawn the boss
Game.createMonster(currentMonsterData.bossname, player:getPosition(), true, true)
-- Reset the spawnBossRate storage
player:setStorageValue("spawn_boss_rate", 0)
end
if totalKills >= currentMonsterData.taskkilltotal and player:getStorageValue(currentMonsterData.storageid) == 0 then
-- Player finished the task
player:setStorageValue(currentMonsterData.storageid, 1)
player:setStorageValue("spawn_boss_rate", 0) -- Reset spawnBossRate on task completion
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Congratulations! You have completed the task to kill " .. currentMonsterData.taskkilltotal .. " " .. currentMonsterData.monstername .. "s.")
else
local message = player:getName() .. " has killed a " .. targetName .. "! Total monsters killed: " .. totalKills
for _, targetPlayer in ipairs(Game.getPlayers()) do
targetPlayer:sendTextMessage(MESSAGE_EVENT_DEFAULT, message)
end
end
end
return true
end
the chance is 1 i 10000 to spawn a diabolic need a custom diabolic spawning system if you want the aura effect on the dead body this is version 0.1
it should reset the chance every time a boss is spawned
used chat gpt for this the prompt:
Lua:
function onKill(cid, target)
local player = Player(cid)
local targetName = getCreatureName(target)
if isMonster(target) then
local storageKey = "kills_" .. targetName
local totalKills = player:getStorageValue(storageKey) or 0
totalKills = totalKills + 1
player:setStorageValue(storageKey, totalKills)
local message = player:getName() .. " has killed a " .. targetName .. "! Total monsters killed: " .. totalKills
for _, targetPlayer in ipairs(Game.getPlayers()) do
targetPlayer:sendTextMessage(MESSAGE_EVENT_DEFAULT, message)
end
end
return true
end
i want to change this script so that every monster is counted separately and preferably to have a table of content so its like:
{monstername="troll" storageid="30001" taskkilltotal="1000" "experiencereward="1000" goldreward="1000" taskfinished="0 or 1" spawnbossrate="40001" bossname="demonic troll"}
Where basically spawnbossrate storage increments with every kill and is 1 in 10000 chance and everytime it spawns the monsters boss the spawnbossrate storage resets also if player finishes the task it doesnt reward him experience or gold for taskkilltotal killed which is the storageid30001 counter that finishes counting that storage but the boss storage can spawn indefinetely given the chance resets everytime he spawns
[B]prompt 2[/B]
I want the monster data to be table so i can easily include more of the monsters whenever i want