Page 1 of 1

What should one do to make an artefact?

PostPosted: Saturday, 24th March 2012, 10:07
by MyOtheHedgeFox
I thought to try and implement my idea of Gauntlets of Lightning into the Stone Soup code.
Basically, they give electrocution brand to UC attacks.
An obvious solution to this is to submit a patch. But...

Which files should I consult and edit in order to make the artefact usable and make it work well?
And what should I do if I, for example, want them to cast Static Discharge on the attacked monster with chance and power depending on Evocations and Spellcasting?

Thank you in advance. =)

Re: What should one do to make an artefact?

PostPosted: Saturday, 24th March 2012, 15:13
by jpeg
MyOtheHedgeFox wrote:I thought to try and implement my idea of Gauntlets of Lightning into the Stone Soup code.
Basically, they give electrocution brand to UC attacks.


Whew, that's a difficult request as so far there's no instance of armour conferring weapon brands. The closest is probably the bracers' archery brand, so searching the code for SPARM_ARCHERY could give you some ideas where to start.

Still, to give you some pointers in the right direction (all files can be found in the source sub-directory):
1. look at art-data.txt for artefact definitions in general (start out with the gloves conferring rElec or something)
2. you'll need to define a new artefact property for the elec brand: add a new property to special_armour_type in itemprop-enum.h
3. call player_equip_ego_type(ARM_GLOVES, <your new property>) in the apply_damage_brand function in melee_attack.cc under the if (weapon) check to set brand to SPWPN_ELECTROCUTION

Depending on whether the combat overhaul has already been merged into trunk, this information might not be accurate anymore. In general, it might be a good idea to put the weapon brand check on armour into a method of its own in case other such brands are added. Also, this ignores the case of auxiliary unarmed attacks both for the sake of simplicity and because I think that would make the artefact overpowered as it would in effect allow the player to use two weapon brands at the same time.

To add the discharge effect, you could either run another player_equip_ego_type check at the end of the SPWPN_ELECTROCUTION case block or at the end of the entire switch-case block where the chaos brand is checked a second time. (In both cases, make sure that the player is not wielding a weapon!) Static discharge is defined in cast_discharge in spl-damage.cc but you might have to adjust the (currently static) method _discharge_monsters instead if you want to directly target the attacked monster. Use defender->pos to get its current position. If you only want this to apply if the monster hasn't been killed yet, check for defender->alive.

You might also wish to add your new property to describe.cc and itemname.cc, though maybe that's only necessary if it's ever supposed to crop up randomly - otherwise, the artefact description (in the dat/ directory nowadays) might be enough.

Good luck!

Note that I'm not a developer anymore. The idea sounds cool but also really powerful. If it's considered overpowered, it's unlikely to make it into the game.

Re: What should one do to make an artefact?

PostPosted: Saturday, 24th March 2012, 15:57
by galehar
jpeg wrote:Depending on whether the combat overhaul has already been merged into trunk, this information might not be accurate anymore.

It has been merged.

jpeg wrote:The idea sounds cool but also really powerful. If it's considered overpowered, it's unlikely to make it into the game.

I agree and I'm not sure about the balance either. No brand is supposed to be a part of UC's balance. The idea has positive comments on the wiki, but none from a dev.

@MyOtheHedgeFox: Since the implementation isn't trivial, I suggest you come to ##crawl-dev to discuss your idea. It would be a shame to spend a lot of time coding it for nothing.

Re: What should one do to make an artefact?

PostPosted: Saturday, 24th March 2012, 17:12
by MyOtheHedgeFox
Well I thought about settling on simply auto-evoking untargeted Static Discharge on a melee hit (1 out of [27 - Evoc/2] times) with power depending on Evocations/UC. If you have a metallic weapon in your hand (a sword or a dagger except artefacts, almost all maces and flails except whips, clubs and rods; weapons of electrocution block it completely), you get a (1 out of [27 - Evoc/4]) chance and take (3-10) units of damage.
With built-in rElec, it should still be good without being overtly bizarre. And useful against vampires and ynoxinul demons.
Would also explain why Nikola threw them away... :D

What do you think about that?


Thanks, Galehar: will do that when I have time!