sucking experience monster script help - SOLVED
sucking experience monster script help - SOLVED
could somebody please help me to script monster which will decrease experience on each sucesfull hit ? I think some onHit or onDealdamage hook for monster attack and regular gain exp with minus sign for damaged champion should work ?
Last edited by Drakkan on Wed Dec 24, 2014 12:33 am, edited 1 time in total.
Re: sucking experience monster script help pls
Example monster definition:
Script Object: (name it drainExp)
https://www.dropbox.com/s/84cn0jgyylkhb ... h.avi?dl=0
Code: Select all
defineObject{
name = "life_leech",
baseObject = "giant_snake",
components = {
{
class = "MonsterAttack",
name = "basicAttack",
attackPower = 25,
accuracy = 15,
cooldown = 4,
sound = "snake_attack",
causeCondition = "paralyzed",
conditionChance = 20,
onDealDamage= function(self, champion, damage)
local XPattackDamage = 100 -- How much XP damage the monster does.
local pronoun = {["male"] = "He", ["female"] = "She"}
if drainExp.script.loseExp(champion, -XPattackDamage) then
hudPrint("") hudPrint("") hudPrint("")
hudPrint(champion:getName().." feels weakened by the attack!")
hudPrint(pronoun[champion:getSex()].." has lost "..XPattackDamage.." experience!")
playSound("scramble_writer")
end
return true
end,
},
},
}
Code: Select all
--script name: drainExp
function _minimumXP(level)
local XPtable = {0,1000,3000,6000,10000,15000,21000,28000,36000,45000,55000,
75000,100000,150000,200000,250000,300000,400000,500000,1000000}
if level < 20 then
return XPtable[level]
else
return level * 1000000
end
end
function _adjustIfHuman(champion, amount)
if champion:hasTrait("human") then
amount = amount * 0.91
end
return amount
end
function loseExp(champion, amount)
amount = _adjustIfHuman(champion, amount)
local currentLevel = champion:getLevel()
local currentExp = champion:getExp()
local minimum = _minimumXP(currentLevel)
if currentExp > minimum then
if currentExp + amount >= minimum then
champion:gainExp(amount)
return true
else
champion:gainExp((currentExp - minimum)*-1)
champion:gainExp(_adjustIfHuman(champion, (minimum - champion:getExp())))
return true
end
end
return false
end
Re: sucking experience monster script help pls
working perfectly as far as I have tried. thanks Isaac, this is big !Isaac wrote:Example monster definition:Script Object: (name it drainExp)Code: Select all
defineObject{ name = "life_leech", baseObject = "giant_snake", components = { { class = "MonsterAttack", name = "basicAttack", attackPower = 25, accuracy = 15, cooldown = 4, sound = "snake_attack", causeCondition = "paralyzed", conditionChance = 20, onDealDamage= function(self, champion, damage) local XPattackDamage = 100 -- How much XP damage the monster does. local pronoun = {["male"] = "He", ["female"] = "She"} if drainExp.script.loseExp(champion, -XPattackDamage) then hudPrint("") hudPrint("") hudPrint("") hudPrint(champion:getName().." feels weakened by the attack!") hudPrint(pronoun[champion:getSex()].." has lost "..XPattackDamage.." experience!") playSound("scramble_writer") end return true end, }, }, }
https://www.dropbox.com/s/84cn0jgyylkhb ... h.avi?dl=0Code: Select all
--script name: drainExp function _minimumXP(level) local XPtable = {0,1000,3000,6000,10000,15000,21000,28000,36000,45000,55000, 75000,100000,150000,200000,250000,300000,400000,500000,1000000} if level < 20 then return XPtable[level] else return level * 1000000 end end function _adjustIfHuman(champion, amount) if champion:hasTrait("human") then amount = amount * 0.91 end return amount end function loseExp(champion, amount) amount = _adjustIfHuman(champion, amount) local currentLevel = champion:getLevel() local currentExp = champion:getExp() local minimum = _minimumXP(currentLevel) if currentExp > minimum then if currentExp + amount >= minimum then champion:gainExp(amount) return true else champion:gainExp((currentExp - minimum)*-1) champion:gainExp(_adjustIfHuman(champion, (minimum - champion:getExp()))) return true end end return false end