Tutorial: 2 Hand Weapon Mastery [1.1x] Version 2

Post here about all aspects of D2 mod making whether it's information, problems or whatever. Please specify whether your post is relating to Classic D2 or the Expansion.

Moderator: Nizari

Post Reply
User avatar
Xenast
Retired staff
Angel
Posts: 765
Joined: Wed Nov 05, 2003 12:11 am
Location: Elliot Lake, Ontario

Tutorial: 2 Hand Weapon Mastery [1.1x] Version 2

Post by Xenast » Mon Jan 28, 2013 4:01 am

Update: Jan 29/13
I have figured out a way to make the mastery not work when dual wielding, see section 2 for details. It is a lot of work though, like a lot 8-O . Also lowered perdelay as it makes the skill update way quicker

If you have suggestions for improvements let me know, and if you have a better way to do some parts please share, but make sure you test it first because ideas that should work won't (at least for me)


For this tutorial we are going to make a 2hand weapon mastery for the Barbarian. For the sake of this guide we will replace Sword Mastery. The technique used to make a working 2hand mastery can be used to make any other mastery, 1hand, bows, anything you can think of, possibly even dual wielding (? -see end of tutorial).

Introduction:
Adding a new mastery is not as simple as just adding a new passive, that is because passives are not able to update in real time and the passiveitype column used for other mastery's is very limited in function. So we have to use a workaround, however, the end result looks, functions, and for all purposes is exactly the same as any existing mastery.

What we are going to do is make a dummy passive, the passive will work as a display for our 2 hand mastery, but will actually not grant any actual bonuses.
The actual mastery bonuses will come from a hidden aura that we will place on all 2 hand weapons, however the bonus calculations will be based off of how many points are invested in the dummy passive. If there is no points invested in the 2 hand skill the 2 hand weapons will not gain any bonus from the aura.

Be warned that setting this up is a lot of work, you must manually add the aura to every set and unique 2 hand, all others can be done automatically though.

Required Files:

automagic.txt
itemstatcost.txt
properties.txt
skills.txt
skilldesc.txt
states.txt
weapons.txt

1. Making a hidden aura property
This method requires all 2 hand weapons to have an aura, the problem is we don't want all 2 hand weapons to display "level x aura when equipped". So we are going to make a property that allows us to give items auras without a stat display, while not altering existing items with auras.

Open itemstatcost and find the stat item_aura, copy the entire row and paste it to a new row at the end of itemstatcost. Make the following changes:
Stat: item_aura_display
ID: 359 (or the next available ID)

Now go back to item_aura and delete the entries in these columns:
descpriority
descfunc
desval
descstrpos
descstrneg


Now open properties.txt, find the aura row. Make the following addition:
func2: 22
stat2: item_aura_display

We are then going to add another stat at the end of properties.txt with the following entries:
code: aurahidden
*done: 1
func1: 22
stat1: item_aura

What this does is allow the aura property to continue to display "level x aura when equipped", while allowing our new property aurahidden to add hidden auras to items.

Setting up dummy stats:
This section is from the Creating single use potions tutorial

Now before we set up the skills we will add 2 dummy stats that will be used for our passive and aura. Open itemstatcost.txt and find ID 183. Make the following changes:

Name: 2hcheck
Send Bits: 32
Saved: 1
CSvSigned: 0
CSvBits: 32
Divide: 1024
Direct: 1
*EOL: 0

Now go to ID 184, and do the same as the stat we just did, except name it 2hstart.

Passive bonus values:
We are going to add Damage, Attack Rating, and Critical Strike chance to our passive. These are the values we will use (you can change them as you see fit after you make the passive):

Damage: 20% initially, 5% for each additional skill level
Attack Rating: 20% initially, 7% for each additional skill level
Critical Strike: 5% initially, 1% for each addition skill

Setting up the aura:
For a breakdown of the formula's see Appendix A at the end of the tutorial
Open skills.txt, go to the end of the file and add a new row. Give it the following values:

skill: 2hand
id: 357 *or next available ID
srvdofunc: 65

aurafilter: 65795
aurastate: 2hand
auratargetstat: 2hand
aurarangecalc: par1

aurastat1: passive_mastery_melee_th
aurastatcalc1: skill('Sword Mastery'.lvl)*par2 + stat('2hstart'.accr)*20
aurastat2: passive_mastery_melee_dmg
aurastatcalc2: skill('Sword Mastery'.lvl)*par3 + stat('2hstart'.accr)*20
aurastat3: passive_mastery_melee_crit
aurastatcalc3: skill('Sword Mastery'.lvl)*par4 + stat('2hstart'.accr)*5

immediate: 1
enhanceable: 1
immediate: 1
attackrank: 9
range: none
reqlevel: 1

maxlvl: 1
minmana: 1
manashift: 8
mana: 0
lvlmana: 0

interupt: 1
intown: 1
aura: 1
perdelay: 0

param1: 1 *This is the radius, as per aurarangecalc
param2: 7 *This is the attack rating% increase per level
param3: 5 *This is the damage % increase per level
param4: 1 *This is the crit chance increase per level

Ingame: 1
HitShift: 8
costadd: 0

Making the aura state:
Now we need to make the state that goes with our aura, add a new row at the end of states.txt with the following entries:

state: 2hand
id: 185 *or next available ID
aura: 1
immed: 1
eol: 0

states.txt controls all the sounds and overlays for auras, by not assigning the aura any graphics or sounds we are effectively making it invisible.

Making the passive:
We are going to replace Sword Mastery for this tutorial. I won't bother with string edits, I'm sure if you can follow this tutorial you can make new strings for the skill description ;)
Remember that this passive acts as a display and the real passive boosts are granted by the aura.

Now, open skills.txt and find the Sword Mastery row. Make the following changes:

passiveitype: blank
passivestat1: 2hcheck *This is one of our dummy stats and works for display purposes only
passivecalc1: par1+(lvl*par2)
passivestat2: 2hcheck
passivecalc2: par3+(lvl*par4)
passivestat3: 2hcheck
passivecalc3: par5+(lvl*par6)
passivestat4: 2hstart *our second dummy stat, see Appendix A for its use
passivecalc4: par7

Param1: 20 *initial Attack Rating % bonus
Param2: 7 *Attack Rating % per skill level
Param3: 20 *initial Damage % bonus
Param4: 5 *Damage % per skill level
Param5: 5 *initial Critical Strike % bonus
Param6: 1 *Critical Strike % per skill level
Param7: 1 *Used for initial bonus, see Appendix A

Now open skilldes.txt, find the Sword Mastery row, and make the following changes:

desccalca1: par5+(lvl*par6)
desccalca2: par3+(lvl*par4)
desccalca3: par1+(lvl*par2)

Giving all 2 hand weapons the aura:

As mentioned above, unfortunately the only way to give set and unique items the aura is to manually add the aurahidden stat to each item. However, for all other types this can be done via auto magic

First we need to make an auto magic that can be given to all 2 hand weapons, to do this open automagic.txt, make a new row with the following:

Name: 2hand
version: 100
spawnable: 1
rare: 1
level: 1
frequency: 1
group: 306
mod1code: aurahidden
mod1param: 357
mod1min: 1
mod1max: 1
itype1: weap
divide: 0
multiply: 0
add: 0

Now is the other tedious part, open weapons.txt. From here find the auto prefix column. You will need to add our auto magic from automagic.txt to every 2 hand weapon type. I will leave that up to you to figure out which entries are 2 handed.
The upside to this part is it gives you complete control over what items benefit from your mastery.


If you have done it all properly you should now have a functioning 2 hand mastery.

Appendix A:
I will try and explain this, hopefully it makes sense
Our aura uses the following formula to calculate the Attack Rating % bonus:

skill('Sword Mastery'.lvl)*par2 + stat('2hstart'.accr)*20

Broken down it does:

skill('Sword Mastery'.lvl)*par2

par2 refers to param2, which is our bonus per level. So what this formula does is increase the mastery bonus based on points invested in Sword Mastery.

stat('2hstart'.accr)*20

When we edited Sword Mastery we added the following:

passivestat4: 2hstart
passivecalc4: par7
par7: 1

So basically added +1 to 2hstart the Sword Mastery. So what our formula does is multiple this by 20, to give our initial bonus to Attack Rating %. We do it this way so that if you have no points in the mastery you don't get the initial 20 Attack Rating % (because 0x20 = 0)

Other uses

Remember when I mentioned a dual wield passive at the start? This would be possible with a conditional formula, you could make another dummy stat grouped with the aurahidden stat, and make a check on the aura calc like:

stat('dualweildcheck'.accr)==2 ? *insert bonus calculation here* : 0

So if you have two weapons equipped you gain the bonus, otherwise nothing. However, I have not been able to successfully add any conditional formula to my aura, although it should be possible

Using this method it should be possible to add other stats to masteries as well, such as attack speed, crushing blow, or whatever else

Section 2: Making the mastery not work when dual wielding
Added Jan 29/2013

The main issue with the above method is you will still get the mastery bonus when dual wielding, if you want to prevent this I have figured out a way around this.
First, I can not get conditional formula to work in my aura, and stats formula don't seem to want to update properly either. However, skill formula seems to update it in real time and that's how I make the check to prevent the mastery from working when dual wielding.
The following section assumes you have done everything above.

What we are going to do is add a hidden dummy skill to our aura auto magic, and add a dummy skill to all 1 handed weapons. Then we are going to update our hidden aura calc1 with the following: 2 - skill('Prevent'.lvl)
So our old formula of skill('Sword Mastery'.lvl)*par2 + stat('2hstart'.accr)*20 becomes (skill('Sword Mastery'.lvl)*par2 + stat('2hstart'.accr)*20)*clc1
Basically what this means is our old formula is multiplied by 2 - skill('Prevent'.lvl)

What does this do? Well when you have one 2 handed weapon equipped you have +1 to Prevent (our dummy skill), and when you have 2 weapons equipped you have +2 to Prevent (1 from each weapon).
With +1 to Prevent the formula translates to 2-1, which equals 1. So our formula is multiplied by 1 and thus stays the same.
However with +2 to Prevent our formula translates to 2-2, which equals 0. So our formula is multiplied by 0, making all bonuses become set to 0, thus disabling the mastery when two weapons are equipped.

I would like to note here that stat('value'.accr) would not work for me properly at all, and that's why I use the more difficult option.

Making a hidden skill item property:
This is done the same way a hidden aura is done, and as you can see this method works for making any hidden stat

Open itemstatcost and find the stat item_singleskill, copy the entire row and paste it to a new row at the end of itemstatcost. Make the following changes:
Stat: item_singleskill_display
ID: 360 (or the next available ID)

Now go back to item_singleskill and delete the entries in these columns:
descpriority
descfunc


Now open properties.txt, find the skill row. Make the following addition:
func2: 22
stat2: item_singleskill_display

We are going to add yet another stat at the end of properties.txt with the following entries:
code: skillhidden
*done: 1
func1: 22
stat1: item_singleskill

Setting up auto magics:

First, we need to configure our existing 2 hand auto magic to have the new skill. Add the following to 2hand:

mod2code: skillhidden
mod2param: 358 *or whatever your 'Prevent' skill ID is
mod2min: 1
mod2max: 1

Now, we need a new auto magic to give 1 hand weapons:

Name: 1hand
version: 100
spawnable: 1
rare: 1
level: 1
frequency: 1
group: 307
mod1code: skillhidden
mod1param: 358
mod1min: 1
mod1max: 1
itype1: weap
divide: 0
multiply: 0
add: 0

Now if you did the first half of the tutorial you already assigned all 2 hand weapons your 2hand auto magic, but now you need to go to weapons.txt and give all 1 hand weapons their auto magic.
You also need to manually add the auto magic to all set and unique weapons, as well as the hidden skill. Yes, its probably more work then its worth ;)

Making the dummy skill:

Open skills.txt and make a new row with the following:

skill: Prevent
ID: 358
charclass: bar
skilldesc: prevent
enhancable: 1
attackrank: 0
range: none
monanim: xx
reqlvl: 1
InGame: 1
HitShift: 8
costadd: 0

Few notes here, this is what worked for me, there may be clutter here not needed. Also, I found that I could not get my calc to work properly without the skill being assigned to the class, and without a skill desc. However there is no need to make an actual skill desc.
Having said that, in order to avoid problems all classes must have the same number of skills, so keep that in mind.

Editing our 2 hand aura:

Find your 2hand aura and make the following changes/additions:

aurastatcalc1: (skill('Sword Mastery'.lvl)*par2 + stat('2hstart'.accr)*20)*clc1
aurastatcalc2: (skill('Sword Mastery'.lvl)*par3 + stat('2hstart'.accr)*20)*clc1
aurastatcalc3: (skill('Sword Mastery'.lvl)*par4 + stat('2hstart'.accr)*5)*clc1

calc1: 2 - skill('Prevent'.lvl)



Soooo, that's it, your 2 hand mastery will now only work when you are actually going 2 hand... turns out this was more work then I thought it would be
Last edited by Xenast on Wed Jan 30, 2013 2:35 am, edited 2 times in total.

Aught
Junior Member
Champion of the Light
Posts: 441
Joined: Mon Nov 21, 2011 6:12 pm
Location: Russia
Contact:
Russia

Re: Tutorial: 2 Hand Weapon Mastery [1.1x]

Post by Aught » Mon Jan 28, 2013 12:54 pm

thanks for your work, good guide! I fixed my aura problems with it :lol: i will try this to make shield mastery for Smite


edit: works but for weapons too :x

User avatar
Xenast
Retired staff
Angel
Posts: 765
Joined: Wed Nov 05, 2003 12:11 am
Location: Elliot Lake, Ontario

Re: Tutorial: 2 Hand Weapon Mastery [1.1x]

Post by Xenast » Mon Jan 28, 2013 10:10 pm

Aught" wrote:edit: works but for weapons too :x
You mean with the shield mastery for smite? Just place the aura on all shields instead of 2h weapons, and link the aura calcs to smite

User avatar
prawn
Junior Member
Paladin
Posts: 108
Joined: Sat Oct 27, 2012 12:21 am
Great Britain

Re: Tutorial: 2 Hand Weapon Mastery [1.1x]

Post by prawn » Mon Jan 28, 2013 10:16 pm

thanks for the guide!

User avatar
HarvestWombs
Senior Moderator
Angel
Posts: 972
Joined: Wed May 25, 2011 11:50 pm
United States of America

Re: Tutorial: 2 Hand Weapon Mastery [1.1x]

Post by HarvestWombs » Mon Jan 28, 2013 10:51 pm

Looks like someone actually used my concept. :P
viewtopic.php?f=35&t=58074
Official Phrozen Keep Discord
Common Modding tools: link
My Resource Packs: link

Aught
Junior Member
Champion of the Light
Posts: 441
Joined: Mon Nov 21, 2011 6:12 pm
Location: Russia
Contact:
Russia

Re: Tutorial: 2 Hand Weapon Mastery [1.1x]

Post by Aught » Mon Jan 28, 2013 11:11 pm

You mean with the shield mastery for smite? Just place the aura on all shields instead of 2h weapons, and link the aura calcs to smite
I did it but it affects normal attack too. When i equip shield with this aura my normal attack increases 8-O

User avatar
Xenast
Retired staff
Angel
Posts: 765
Joined: Wed Nov 05, 2003 12:11 am
Location: Elliot Lake, Ontario

Re: Tutorial: 2 Hand Weapon Mastery [1.1x]

Post by Xenast » Tue Jan 29, 2013 12:11 am

Black_Eternity" wrote:Looks like someone actually used my concept. :P
viewtopic.php?f=35&t=58074
I've seen the idea floated in several topics, I don't claim to have come up with the idea :)
I did it but it affects normal attack too. When i equip shield with this aura my normal attack increases
Not sure how to do this

Edit:
Still trying to work out conditional formula in auras, I am not having any luck getting them to work, anyone else able to give it a shot?
Also I just realized the 2 hand bonus still applies when dual wielding, I would like to add a check to prevent that, unfortunately without conditional formula I'm not sure if its possible

Freddy
Posts: 37
Joined: Sat Apr 28, 2012 3:59 pm

Re: Tutorial: 2 Hand Weapon Mastery [1.1x]

Post by Freddy » Tue Jan 29, 2013 8:52 pm

Couldn't you just put '2hand' as type2 for all 2 hand weapons in weapons.txt and then copy a barbarian weapon mastery and put '2hand' as passiveitype in skills.txt
It should work but I think you might also need a new item type with code '2hand' in itemtypes.txt too

User avatar
Xenast
Retired staff
Angel
Posts: 765
Joined: Wed Nov 05, 2003 12:11 am
Location: Elliot Lake, Ontario

Re: Tutorial: 2 Hand Weapon Mastery [1.1x]

Post by Xenast » Tue Jan 29, 2013 9:23 pm

That doesn't work, does not register properly

Post Reply

Return to “General Mod Making”