Page 1 of 1
Deal damage to Monster
Posted: Wed Apr 08, 2015 8:15 pm
by Emera Nova
So I took the script from the thread deal damage to party and edited to what I thought would work on a monster.
Code: Select all
function damagemummy()
if findEntity("mummy_2") ~= nil then
mummy_2.monster:damage(5, "shock")
end
end
When I activated the code it ended up freezing the game, why did that happen and how do I fix this? As it is I have it hooked up on a timer that does damage to the mummy every 15 seconds, I want it to check to see if the monster is still there and if it is deal the damage if nothing it just ends.
I front part of my script is what I use when looking for an object on in the dungeon to destroy it. So I thought that part of the script would work for looking at the monster.
Re: Deal damage to Monster
Posted: Wed Apr 08, 2015 8:30 pm
by minmay
MonsterComponent has no method named "damage".
Re: Deal damage to Monster
Posted: Wed Apr 08, 2015 8:33 pm
by Emera Nova

So does that mean It's not possible to damage the monster like the party?
Re: Deal damage to Monster
Posted: Wed Apr 08, 2015 8:40 pm
by GoldenShadowGS
Code: Select all
function damagemummy()
local m = findEntity("mummy_2")
if m ~= nil then
damageTile(m.level, m.x, m.y, 0, m.elevation, 1, "shock", 5)
end
end
Re: Deal damage to Monster
Posted: Wed Apr 08, 2015 8:44 pm
by Emera Nova
Thank you Golden that works lovely
Re: Deal damage to Monster
Posted: Wed Apr 08, 2015 8:47 pm
by minmay
Emera Nova wrote:
So does that mean It's not possible to damage the monster like the party?
There is no direct equivalent to the Champion:damage() method, however you can imitate it pretty much perfectly with MonsterComponent:setHealth(), MonsterComponent:getResistance(), MonsterComponent:showDamageText(), and MonsterComponent:die().
GoldenShadowGS wrote:function damagemummy()
local m = findEntity("mummy_2")
if m ~= nil then
damageTile(m.level, m.x, m.y, 0, m.elevation, 1, "shock", 5)
end
end
This has several problems:
1. it will damage all monsters and HealthComponents in the square (you need to use a TileDamagerComponent with an onHitMonster, onHitObstacle, etc. hook that will check the monster id and only damage the right one)
2. it won't do the right amount of damage because damageTile and TileDamagerComponent use an attack power roll, randomizing the amount of damage, whereas Champion:damage() does the exact amount of damage you specify
Re: Deal damage to Monster
Posted: Wed Apr 08, 2015 9:11 pm
by Azel
Now is a good time to request a new forum: Mod Newbies
Or something similar. Having a place for clueless Moders (myself included) can be beneficial. So that people can fumble through conversations as they engage in the painful aspects of beginner learning, while all the super duper godly mod vet's can enjoy their freedom. Someone with a bigger voice than mine should get a new Forum for newbie moders asap
