Page 1 of 1
sucking experience monster script help - SOLVED
Posted: Sun Dec 21, 2014 3:19 pm
by Drakkan
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 ?
Re: sucking experience monster script help pls
Posted: Mon Dec 22, 2014 9:58 am
by Isaac
Example monster definition:
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,
},
},
}
Script Object: (name it drainExp)
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
https://www.dropbox.com/s/84cn0jgyylkhb ... h.avi?dl=0
Re: sucking experience monster script help pls
Posted: Tue Dec 23, 2014 6:02 pm
by Drakkan
Isaac wrote:Example monster definition:
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,
},
},
}
Script Object: (name it drainExp)
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
https://www.dropbox.com/s/84cn0jgyylkhb ... h.avi?dl=0
working perfectly as far as I have tried. thanks Isaac, this is big !