beenii
Well-Known Member
- Joined
- Jul 26, 2010
- Messages
- 580
- Solutions
- 1
- Reaction score
- 57
So far I have achieved this, but it does not work as I would like.
the random ones are not very random sometimes.
CODE:
Code:
function Monster:onSpawn(position)
local nombres = {"[1] Rotworm Queen", "[2] Minotaur Hunter","[3] Dragon Lord", "[4] Glooth Brigand","[5] Glooth Bandit", "[6] Demodras","[7] Flameborn", "[8] The Welter"}
if isInArray(nombres, self:getName()) then
return true
end
---------------------------------------------------------
-- ADVANCE CHANCE START
---------------------------------------------------------
local config = {
[1] = {chance = 270, min = 1, max = 3},
[2] = {chance = 280, min = 4, max = 5},
[3] = {chance = 170, min = 6, max = 8},
[4] = {chance = 70, min = 9, max = 10},
[5] = {chance = 30, min = 11, max = 13}
}
local totalChance = 0
for i = 1, #config do
totalChance = totalChance + config[i].chance
end
local rand = math.random(totalChance)
local index = -1
for i = 1, #config do
if rand <= config[i].chance then
index = i
break
end
end
if index > -1 then
count = math.random(config[index].min, config[index].max)
end
---------------------------------------------------------
-- ADVANCE CHANCE FINISH
---------------------------------------------------------
maxHealth = self:getHealth()*count
local originalHealth = self:getHealth()
local div = maxHealth / originalHealth
local numdiv = math.floor(div)
if maxHealth < originalHealth then
clase = "[weak]"
end
if numdiv == 1 or numdiv == 2 or numdiv == 3 then -- 45%
clase = "[commun]"
end
if numdiv == 4 or numdiv == 5 then --28%
clase = "[rare]"
end
if numdiv == 6 or numdiv == 7 or numdiv == 8 then --17%
clase = "[royale]"
end
if numdiv == 9 or numdiv == 10 then -- 7%
clase = "[epic]"
end
if numdiv == 11 or numdiv == 12 or numdiv == 13 then -- 3%
clase = "[legendary]"
end
self:setMaxHealth(maxHealth)
self:addHealth(maxHealth)
self:setName(""..clase.." "..self:getName().."", ""..clase.." "..self:getName().."")
return true
end