- Joined
- Dec 26, 2013
- Messages
- 1,635
- Solutions
- 11
- Reaction score
- 878
Ok so I was tinkering around with ideas to take away the edge given to cavebotters over players who play. One idea came that came about was a limit on killing monsters instead of the broken stamina system.
I asked for some ideas on which way would be best for optimization here and ultimately stole a bit of code and help from @Roddet and made it happen.
It's small.
It's simple.
It has low footprint.
It has been tested during development.
It builds itself, and resets when the server starts up.
It prevents monsters from dying to a player who has reached the limit.
It works on each monster individually, meaning a limit of 10 doesn't mean 10 monsters total, means 10 of each monster.
It's one file and free for you to enjoy
It's another {SYC} series, so if you want to enhance it in any kind of way, please share here.
I'm sorry I forgot the title prefix. works for any version with eventcallbacks
I asked for some ideas on which way would be best for optimization here and ultimately stole a bit of code and help from @Roddet and made it happen.
It's small.
It's simple.
It has low footprint.
It has been tested during development.
It builds itself, and resets when the server starts up.
It prevents monsters from dying to a player who has reached the limit.
It works on each monster individually, meaning a limit of 10 doesn't mean 10 monsters total, means 10 of each monster.
It's one file and free for you to enjoy
Lua:
MonsterLimits = {}
Global_Monster_Limit = 3
local startup = CreatureEvent("MonsterLimitStartup")
function startup.onLogin(player)
local guid = player:getGuid()
if not MonsterLimits[guid] then
MonsterLimits[guid] = {}
player:registerEvent("MonsterKillCounter")
return true
end
end
startup:register()
local monsterSpawn = EventCallback
monsterSpawn.onSpawn = function(self, position, startup, artificial)
self:registerEvent("MonsterDeathPrevention")
return true
end
monsterSpawn:register()
local killCounter = CreatureEvent("MonsterKillCounter")
function killCounter.onKill(player, target)
if target:isPlayer() then
return true
end
local counter = MonsterLimits[player:getGuid()][target:getName():lower()]
counter = (counter or 0) + 1
MonsterLimits[player:getGuid()][target:getName():lower()] = counter
if counter == Global_Monster_Limit then
player:sendTextMessage(MESSAGE_INFO_DESCR,"You have reached daily limit for " ..target:getName().. "s.")
end
end
killCounter:register()
local monsterDeathPrevention = CreatureEvent("MonsterDeathPrevention")
function monsterDeathPrevention.onHealthChange(monster, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if not attacker:isPlayer() then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
local count = MonsterLimits[attacker:getGuid()][monster:getName():lower()]
count = (count or 0) --- this line is important, otherwise can not hurt any creature.
if count >= Global_Monster_Limit then
primaryDamage = 0
secondaryDamage = 0
monster:addHealth(monster:getMaxHealth())
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
monsterDeathPrevention:register()
It's another {SYC} series, so if you want to enhance it in any kind of way, please share here.
I'm sorry I forgot the title prefix. works for any version with eventcallbacks
Last edited: