Superloading Damage Types and Categories

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
Razakai
Uruivellas
Posts: 889
Joined: Tue May 14, 2013 3:45 pm

Superloading Damage Types and Categories

#1 Post by Razakai »

Currently I'm working on a modification for the Necromancer. Among other things, it's going to make Necrosis generic to solve the lack of generic sinks, but I can't figure out how to do that. I'm guessing it involves superloading the line defining Necrosis in spells.lua and putting is_generic="true", but I can't figure out a) what the exact sorta syntax would be for loading that and b) how to superload spells.lua in the first place!

In addition, I'm putting in a new damage tree, Acid. The first 3 talents are working and very fun, but the capstone is this:

Dissolution - Your acid damage melts away at weakened targets, causing it to instantly kill targets below x% health. Targets killed by this effect explode into a cloud of corrosive vapour, dealing Acid damage equal to y% of their total health every turn for 3 turns in a 1 radius ball.

So what I planned to do as the first step was superload Acid in damage_types.lua with a line similar to Natural Acid, namely that if Dissolution was sustained, it'd do something like this:

if target:canBe("instakill") and target.life > 0 and ((target.life < target.max_life * 0.25 and target.rank < 3.5) or target.life < target.max_life * 0.10) then
target:die(who)
game.logSeen(target, "#RED#%s#GOLD# has been bursts into a cloud of acid!#LAST#", target.name:capitalize())
end

(code taken from the ultimatum axe, real values would use the talent rather than a flat life %)
And in addition, after target:die it would create a lasting map effect. But unfortunately I can't figure out how to superload damage_types and specifically modify Acid, and to be honest I've no idea if the above code would work once I did put it in (although at least I could give it a try).

Any help would be greatly appreciated.

HousePet
Perspiring Physicist
Posts: 6215
Joined: Sun Sep 09, 2012 7:43 am

Re: Superloading Damage Types and Categories

#2 Post by HousePet »

Firstly, you don't want to edit the acid damage type to do that at all. Check Quantum Spike for a similar effect with neater implementation.

I haven't edited a talent category before but to load extra categories I load a new spells.lua file via the load hook.
To then make Necrosis generic I think you would do:
Talents.talents_types_def["spell/necrosis"].generic = true
My feedback meter decays into coding. Give me feedback and I make mods.

Razakai
Uruivellas
Posts: 889
Joined: Tue May 14, 2013 3:45 pm

Re: Superloading Damage Types and Categories

#3 Post by Razakai »

The generic code for necrosis worked perfectly, thank you! Was no changed at all required beyond copying that line directly into the existing spells.lua in data, I didn't realise that could modify existing trees, thought it was just used to load new ones.
I see Quantum Spike's instakill code is a lot neater yes, thanks. Looking at some other code, I think I can just copy how Endless Woes triggers its acid damage proc and put the instakill/create acid cloud segment in.
And special thanks for your own Necromancy+ addon, before making this I spent alot of time looking over it to understand how I'd go about making my own addon, so you'll deserve credit when mine is eventually finished.

HousePet
Perspiring Physicist
Posts: 6215
Joined: Sun Sep 09, 2012 7:43 am

Re: Superloading Damage Types and Categories

#4 Post by HousePet »

You might find it simpler to just copy the instant kill code into the acid talents, though if you have a cloud effect you would need to make a new damage type that inflicts acid damage and checks instant kill afterwards.
My feedback meter decays into coding. Give me feedback and I make mods.

Razakai
Uruivellas
Posts: 889
Joined: Tue May 14, 2013 3:45 pm

Re: Superloading Damage Types and Categories

#5 Post by Razakai »

Turns out its doable with load.lua under hooks (although I decided a flat damage based off spellpower works better than % of max hp):

Code: Select all

	if data.type == DamageType.ACID then
		if data.dam > 0 and data.src:isTalentActive(data.src.T_DISSOLUTION) then
			local t = data.src:getTalentFromId(data.src.T_DISSOLUTION)
			if target:checkHit(self:combatSpellpower(), target:combatPhysicalResist(), 0, 95, 15) and target:canBe("instakill") and target.life > 0 and target.life < target.max_life * (t.getKill(data.src, t)/100) then
				game.logSeen(target, "%s dissolves into a pool of acid!", target.name:capitalize())
				target:die(self)
				game.level.map:addEffect(self,
				data.x, data.y, 3,
				DamageType.ACID, t.getDamage(data.src, t),
				1,
				5, nil,
				engine.Entity.new{alpha=100, display='', color_br=30, color_bg=200, color_bb=60},
				nil, false
		    )
			end
		end
	end
Works quite nicely, although I'll have to play around with all the talents together to make sure they're actually fun and balanced ingame. Thanks for the help.

HousePet
Perspiring Physicist
Posts: 6215
Joined: Sun Sep 09, 2012 7:43 am

Re: Superloading Damage Types and Categories

#6 Post by HousePet »

Yeah, I had thought of doing it that way, but didn't want to throw you in the deep end. :lol:
My feedback meter decays into coding. Give me feedback and I make mods.

Razakai
Uruivellas
Posts: 889
Joined: Tue May 14, 2013 3:45 pm

Re: Superloading Damage Types and Categories

#7 Post by Razakai »

Oh dear. It seems that while Necrosis did get moved into the generic tab, it still requires class points rather than generics. There must be some additional parameter on top of the previous change...

Razakai
Uruivellas
Posts: 889
Joined: Tue May 14, 2013 3:45 pm

Re: Superloading Damage Types and Categories

#8 Post by Razakai »

DG was nice enough to explain - each talent needs setting individually. So superloading Talents.talents_def.BLURRED_MORTALITY.generic=true for each talent (thought I'd write that down here in case anyone else needs to know).

Post Reply