Page 1 of 1

giving immunities to objects

Posted: Fri Sep 28, 2012 8:43 am
by Shloogorgh
I noticed that monsters can have immunity to damage types, so when I was making a destructible version of the cave in, I attempted to give it immunities to a lot of different damage types.
cloneObject{
name = "destructable_dungeon_cave_in",
baseObject = "dungeon_cave_in",
health = 100,
evasion = -1000,
hitSound = "impact_blade",
brokenModel = "assets/models/env/floor_dirt.fbx",
immunities = { "poison", "assassination", "fire", "backstab", "cold", "shock" },
}
I tested it in game and everything works except the immunities: I was able to damage it with my fire spells. What gives?

Re: giving immunities to objects

Posted: Fri Sep 28, 2012 12:26 pm
by Blichew
Isn't that only monsters can have immunities ?

Re: giving immunities to objects

Posted: Fri Sep 28, 2012 9:22 pm
by Shloogorgh
Ah, that's a shame

Re: giving immunities to objects

Posted: Fri Sep 28, 2012 9:47 pm
by Montis
you should be able to achieve that with a custom onDamage hook like

Code: Select all

if damageType == "poison" then
   return false
end

Re: giving immunities to objects

Posted: Fri Sep 28, 2012 10:57 pm
by Shloogorgh
That's a great idea, but it doesn't seem to work for me. Tried to make it immune to fire, but right now fire spells seem to work normally

Code: Select all

cloneObject{
	name = "destructable_dungeon_cave_in",
	baseObject = "dungeon_cave_in",
	health = 100,
	evasion = -1000,
	brokenModel = "assets/models/env/floor_dirt.fbx",
	onDamage = function()
		if damageType == "fire" then
			hudPrint("Seems to have no effect")
   			return false
		else
			playSound("impact_blade")
		end
	end
}

Re: giving immunities to objects

Posted: Sat Sep 29, 2012 12:48 am
by Blichew
Seems like you have an error in your onDamage function - it should have 3 parameters, like here:

Code: Select all

cloneObject{
	name = "destructable_cave_in",
	baseObject = "dungeon_cave_in",
	health = 100,
	evasion = -1000,
	brokenModel = "assets/models/env/floor_dirt.fbx",
	onDamage = function(self, damage, damageType)
		if damageType == "fire" then
			hudPrint("Seems to have no effect")
			return false
		else
			playSound("impact_blade")
		end
	end
}

Re: giving immunities to objects

Posted: Sat Sep 29, 2012 2:22 am
by Shloogorgh
ah, that did it, thanks