Page 1 of 1
Monster Resistance
Posted: Sun Nov 18, 2012 6:28 pm
by Soaponarope
Was looking to make monsters who are resistant to certain attacks without being completely immune.
Example;
resist_fire = 50,
resist_shock = 50,
Thought this would do it, since other stats like protection and evasion work this way for monsters, but it doesn't. Can monsters just not have resistance?
Re: Monster Resistance
Posted: Sun Nov 18, 2012 6:52 pm
by mahric
Soaponarope wrote:Was looking to make monsters who are resistant to certain attacks without being completely immune.
Example;
resist_fire = 50,
resist_shock = 50,
Thought this would do it, since other stats like protection and evasion work this way for monsters, but it doesn't. Can monsters just not have resistance?
I don't think there is an easy way to do this.
Maybe you can use the onDamage event on the monster, check it's damage type, reduce it and damage it for the reduced amount in a category that the monster has 0 reduction.
Example:
Monster has 0% resistance against physical attack, and 50% resistance against fire.
The onDamage() event might look like this
Code: Select all
function onDamage(who, amount, kind)
if (kind == "fire") then
damageTile(who.level, who.x, who.y, who.facing, 61, "physical", amount/2)
return false
end
end
I didn't check the above function so it might be full of typo's, but it's to give you a general idea of the solution.

Re: Monster Resistance
Posted: Sun Nov 18, 2012 6:55 pm
by Batty
ok, I'm back, I like answering easy questions, makes me look smart.
If you wanted a monster that was 70% resistant to fire, you would use the onDamage hook like this:
Code: Select all
onDamage = function(self, amount, type)
if type == "fire" then
amount = amount * 0.3
end
return amount
end,
Haven't tested so no guarantees.

Re: Monster Resistance
Posted: Sun Nov 18, 2012 8:38 pm
by Soaponarope
Batty, your script really should work, but it doesn't either.
Damage is the same no matter what.
Re: Monster Resistance
Posted: Sun Nov 18, 2012 9:14 pm
by Batty
Yeah, doesn't work, it seems to return all or nothing for damage. Mahric's should work but you need to figure out which champ did the damage so they get exp.
Re: Monster Resistance
Posted: Sun Nov 18, 2012 9:22 pm
by Komag
You could hack it by having the damage be completely negated (make the hook return false) but then also trigger a script to damage the square with the reduced amount of damage
Re: Monster Resistance
Posted: Mon Nov 19, 2012 5:16 am
by Soaponarope
At first I wasn't sure about using damageTile for this, but it works well.
I use this to find champion doing damage.
local originator = 2 ^ (champion:getOrdinal()+1)
Thanks Mahric
Re: Monster Resistance
Posted: Mon Nov 19, 2012 8:52 am
by mahric
No problem, glad to help anytime!
