Aller au contenu

Photo

Creating new craftable items


  • Veuillez vous connecter pour répondre
81 réponses à ce sujet

#1
CPK87

CPK87
  • Members
  • 73 messages
 While I'm waiting for the IRC channel to come back up, I figured I'd post this here for now.

Basically, I've decided to create a mod that's based around crafting.  Therefore, I'm hoping to be able to do things like such:

- create specific enchantments that result from gem/essence combinations (ex: diamond + weak fire essence on sword adds 1d6 fire damage, but on half plate adds 5 fire resistance)

- create new materials such as metals/wood that add bonuses to equipment when crafted (similar to darksteel giving +1 electrical damage)

I tried out Lilac's Script Generator to see if I could do something with its Blacksmith / Item Forge Script, and while the script compiled successfully, when I tested it in game, it seemed to only partially work.  In my case, I attached the script to On Spell Cast At on a magician's workbench, required 1 diamond and 1 weak earth essence (with the appropriate tags) to be in the workbench, and the Barkskin spell to be cast on the workbench with the items inside.  The spell consumed only the diamond and left the earth essence, and did not provide the item I wanted to create (specified the ResRef correctly in the script). 

Has anyone had any success with this, or is there a better way to go about it?  For the record, I'm not planning on using SoZ crafting at the moment.

#2
kevL

kevL
  • Members
  • 4 052 messages
uhm, since you posted i'll reply
you might not like the answers, and i know it's only my perspective, so here goes

CPK87 wrote...

Basically, I've decided to create a mod that's based around crafting.

o.0

first mod? OC-style crafting is *very* intricate.

- create specific enchantments that result from gem/essence combinations (ex: diamond + weak fire essence on sword adds 1d6 fire damage, but on half plate adds 5 fire resistance)

- create new materials such as metals/wood that add bonuses to equipment when crafted (similar to darksteel giving +1 electrical damage)

These sound very doable, but my memory tells me they might require indepth .2da edits, and possibly even a change or two to the core crafting script (esp. for the 2nd example; the first probly involves only additions to the crafting .2da and its index .2da).

I tried out Lilac's Script Generator to see if I could do something with its Blacksmith / Item Forge Script, and while the script compiled successfully, when I tested it in game, it seemed to only partially work.

While i didn't mod NwN crafting, I seem to recall that IG the two systems are quite different. Lilac's likely won't handle NwN2 crafting...

Has anyone had any success with this, or is there a better way to go about it? For the record, I'm not planning on using SoZ crafting at the moment.

Kaldor knows more than me about SoZ crafting. What I can say after more than 100 hrs. of OC-style craft modding is

- one of the devs/scripters, ChazM, put out a module just for doing craft edits, Crafting.mod.

Now, personally i bypassed it after checking it out, in favor of doing things manually because I went straight for the balanced / rebalanced versions of OC-style crafting, which don't rely on the main goal of ChazM's module,

which is to output a .2da [edit: two .2da's] in text form to the NwN2 log, which you'd then turn into [edit: two] real .2da's that have your edits. Or something like that, as i say I bypassed it. But if you really want to do this it's probably the way to go, to get around half the complexity of OC-style crafting. Or at least to sort of see what might be going on under the hood. The system they devised is not efficient, and much of the complexity is necessary simply to reduce the massive overhead of .2da lookups that have thousands upon thousands of entries and components. And if i'm guessing right, much of the complexity you may run across in the subcore scripts is for outputting modified .2das to a log -- without slamming into "too many instructions" errors.

Modifié par kevL, 01 février 2014 - 06:51 .


#3
kevL

kevL
  • Members
  • 4 052 messages
note the main reason i suggest sticking to official crafting (and not the rebalanced/enhanced versions) is because the latter two are buggy.

#4
kevL

kevL
  • Members
  • 4 052 messages
ok, Things are coming back to me a little:

to create a new recipe (using old materials, just with new components ie. gems+essences and spells)

you have to find the spell section in Crafting.2da (all spells that're used for various recipes need to be grouped together in the .2da)

Add a line there (the spell# will ofc be its reference in Spells.2da). Add the components in case-sensitive alphabetical order <- that really screwed me up for a while [edit: with (A..Z) before (a..z)]. Fill in the rest of the lines, blah blah.

Finally go to Crafting_index.2da. Find the spell#. Increment the reference to Crafting.2da in the *successive* lines that follow, such that they refer to the new, displaced lines in Crafting.2da


Ps. am feeling pretty sure that adding molds & stock materials like woods & metals requires changes to the scripts.

Modifié par kevL, 01 février 2014 - 10:47 .


#5
Tchos

Tchos
  • Members
  • 5 030 messages
I used ChazM's crafting.mod to add a new item that could be distilled into an OC-compatible essence. It seemed like a pretty roundabout way of doing it, but it worked. However, you could create your own crafting system from scratch, or base it on one of the other extensible crafting systems that have been posted as resources. For instance, there's a hunting and cooking system that you could rework and extend.

If I could, I'd use the Legends crafting system, which does mining, skinning, leatherworking, blacksmithing, and more, but it's designed for a PW, and I'd have to make some modifications to get it to work for a single-player module.

#6
CPK87

CPK87
  • Members
  • 73 messages
Thanks for the responses,

I don't want to create an entirely new system, but rather create new items using the existing system. So an enchantment would still use a gem and an essence like in the OC, but it would be a different gem/essence combination and put a different effect on the item. I didn't think it would be too drastic of a change, although I expected that I would have to learn to modify 2da files at some point.

kevL, I'll take a look at those, thanks. Hopefully once I get the hang of how the 2da files work, it should be smoother from there. They don't seem much different than massive Excel sheets anyway - tedious but not necessarily complicated. And the only reason I want to create new materials is to add different stat bonuses - instead of +1 electrical damage from darksteel, for instance, it would give +3 AB. Technically I wouldn't have to create "new" materials, I could modify the stat bonus from existing ones instead. The whole reason I want to change the enchantment effects is because I am creating a quest that focuses entirely around item progression, with no experience gain or leveling up. Therefore I need to re-balance the current crafting to match what I'm trying to do.

#7
kevL

kevL
  • Members
  • 4 052 messages
ah cool.

i just popped open Crafting.2da. It's been a while, the EFFECTS column is the most difficult to get a handle on; the numbers refer to various 2da's iirc.


There's really only a few scripts, plus a few functions in 'ginc_crafting' that are used. (but some of the helper functions are a nightmare to follow, i found)

with the caveat that I'm not looking at the original scripts here, you'll probably find yourself having to define extra look at string constants, for tag-prefixes/suffixes to get additional materials to do what you want, as against what i find is the more straightforward (though still obscure) gem+essence+spell = itemproperty recipies.


If you need a hand i'm willing to look into specific questions,

Modifié par kevL, 01 février 2014 - 10:37 .


#8
andysks

andysks
  • Members
  • 1 645 messages
I don't get why this is complicated KevL. Is it the adding effects that causes it, or the system generally which involves many 2da files?
ColorsFade has custom crafting in his campaign, perhaps he might be able to shed some light on your questions CPK. I don't know though if his crafting adds properties to your existing equipment, or simply gives you a nice item if you have the materials. Also, it happens through dialogue and not on a bench I think. Maybe it's important?

#9
Tchos

Tchos
  • Members
  • 5 030 messages
In the crafting.mod, ChazM warns against editing the crafting 2DA by hand, and listed off some reasons, but I can't remember what they are. Something about things having to be in an unintuitive order, like perhaps new items can't be at the bottom, and so the mod does the arrangement work for you.

Of course, if you're going to do it through dialogue, as you say Andy, then there's really no restriction, because you're not using the same system, and are essentially doing it all manually, like the hunting/cooking system does.

Modifié par Tchos, 01 février 2014 - 04:54 .


#10
kevL

kevL
  • Members
  • 4 052 messages
go up and read the fourth post, Andy. It is actually very accurate, and yet still incomplete.

Eg. an EFFECT in the .2da looks like this: 23,6,2,0,0. Those are references to a series of .2das: which ones.

yes, The simplest recipes simply output items from blueprints. And one of the reasons for ChazM's mod is to keep Crafting.2da in sync w/ Crafting_index.2da

On the other hand, a dialog that checks if PC has two items and if so removes them and creates a third is ... not like this.


Tchos wrote...

Something about things having to be in an unintuitive order, like perhaps new items can't be at the bottom, and so the mod does the arrangement work for you.

in addition to keep the two .2da's in sync, the recipes have to be kept grouped according to the trigger-spell used.* Can't just put new recipes at the bottom, and if mr.CPK wants to reuse lines it will make things much easier. First find the group of a spell, in Crafting.2da, that you'd want to use ... (if that group already exists ofc)


on the easy side, it looks like adding new (or changing) materials won't require changes to scripts (unless *maybe* if using one of the advanced craft extension add-ons)



* or perhaps the mold-tag in the case of mundane crafting, or .. technically recipes have to be grouped according to a string, that might represent a Spells.2da entry, a mold-tag, or a defined string-constant like "ALC" for Alchemy recipes, etc.

Modifié par kevL, 01 février 2014 - 06:41 .


#11
kevL

kevL
  • Members
  • 4 052 messages
CPK:
after a few more glances, it looks relatively simple to change say Darksteel from +1 electrical to say +3 AB.

in Crafting.2da
- find the appropriate mold-entries grouping under CATEGORY
- find the correct REAGENTS line(s) within that grouping
- change the OUTPUT, to either an existing or custom blueprint-resref of the desired item w/ +3AB
- leave SKILL at "26" => Craft Weapon
- adjust the LEVEL (ranks of SKILL) needed

#12
CPK87

CPK87
  • Members
  • 73 messages

kevL wrote...

CPK:
after a few more glances, it looks relatively simple to change say Darksteel from +1 electrical to say +3 AB.

in Crafting.2da
- find the appropriate mold-entries grouping under CATEGORY
- find the correct REAGENTS line(s) within that grouping
- change the OUTPUT, to either an existing or custom blueprint-resref of the desired item w/ +3AB
- leave SKILL at "26" => Craft Weapon
- adjust the LEVEL (ranks of SKILL) needed


I figured as much, thanks for confirming that for me.  I can probably afford to modify existing lines in the .2DA's because I don't plan on making any of the original recipes viable for this mod.  That way I shouldn't have to mess with the order of things in the 2DA, if I'm understanding correctly.  I wish I could get into the IRC channel to discuss it on there, it would certainly make understanding this easier.  I am guessing that I'll need to create copies of the existing .2DA files that I need and put them in the Campaigns folder under My Documents?  I don't want to break anything in the existing game if I can help it!

#13
kevL

kevL
  • Members
  • 4 052 messages
yes just copy Crafting.2da and (even though it shouldn't change) Crafting_index.2da to your mod's Campaign folder

( i haven't tried those .2da's in the campaign folder myself, only in \\Override but should work ok )


The originals in the installation folder ought be very secure this way.

#14
kevL

kevL
  • Members
  • 4 052 messages
ps. Here's an idea: why not create brand new Crafting.2da*, copying and editing only those lines you'll need?

that'd wipe out all standard crafting and keep things manageable...


* and Crafting_index.2da, wiped clean at first


[edit] you'd have to maintain the Crafting_index.2da yourself if you do this.
But the index is a very small simple, straightforward file anyway,

Modifié par kevL, 01 février 2014 - 07:42 .


#15
CPK87

CPK87
  • Members
  • 73 messages
kevL,

If I'm understanding correctly, isn't that what I am doing by copying a duplicate of the file into my mod's campaign folder? Or do you mean just wipe everything out entirely from that duplicate file and fill it in myself? I'd be afraid that that would mess up the order stuff needs to be in to work.

#16
kevL

kevL
  • Members
  • 4 052 messages

CPK87 wrote...

kevL,

If I'm understanding correctly, isn't that what I am doing by copying a duplicate of the file into my mod's campaign folder? Or do you mean just wipe everything out entirely from that duplicate file and fill it in myself? I'd be afraid that that would mess up the order stuff needs to be in to work.

not once you understand how the index file works.

ok, hopefully you've grasped that entries in Crafting need to be grouped according to a trigger (spell, mold-tag, "ALC", etc)

The scripts, to prevent having to iterate through the entire Crafting.2da, first check the index and get the beginning entry. Then it iterates through *only that group* to find if the correct reagents are present in the workbench.

So the index contains only two things:
1. the CATEGORY to search through (spell, mold-tag, "ALC", etc)
2. the beginning entry line in Crafting.2da


get it?

#17
CPK87

CPK87
  • Members
  • 73 messages
Ah, got it. I was about to ask about what Category was for next, but you read my mind. The categories that just have a number, like 150 for instance, what is that number referring to? I assumed a spell of some sort, but noticed that the recipes those are referring to use differing spells to be cast.

Edit:  Just double-checked and realized I made a mistake there - the category number does in fact refer to a specific spell.  

Modifié par CPK87, 01 février 2014 - 08:28 .


#18
kevL

kevL
  • Members
  • 4 052 messages
CATEGORY 150 refers to Resist Energy (row #150 in Spells.2da)

If you ... notice that the recipes those refer to use different spells ... I suggest ye notice again!

but i am willing to be shown wrong.

#19
CPK87

CPK87
  • Members
  • 73 messages
Yeah sorry kevL, just edited my post above!

#20
kevL

kevL
  • Members
  • 4 052 messages
kk, me thinks yer good to go

oh, i just want to remind you that

Add the components in case-sensitive alphabetical order <- that really screwed me up for a while [edit: with (A..Z) before (a..z)].



iirc

Modifié par kevL, 01 février 2014 - 08:31 .


#21
CPK87

CPK87
  • Members
  • 73 messages
Hehe yeah, case-sensitive mistakes can really lead one astray when trying to debug a problem. Anyway, so far this doesn't seem too bad - I'll run some tests on it and see what I can make happen. Thanks a ton for your time and knowledge on this, I'm sure you've saved me hours of headaches!

#22
CPK87

CPK87
  • Members
  • 73 messages
From what I've found so far, in Crafting.2da, under the EFFECTS tab, there are 5 consecutive numeric values:

- The 1st determines the type of item prop it is, which is referred to in itempropdef.2da.

- The 2nd determines the sub-type of the item prop, like sonic damage for the damage reduction prop. The file the subtype exists in is specified under IPRP_Abilities in itempropdef.2da.

- The 3rd seems to represent the value of the prop, but I'm not sure if there's a .2da file for this.

I'm still not sure about the 4th and 5th ones. Most of them are just 0, but some of the 4th ones are 10 or 24, and there is only one enchantment where the 5th is a 1 instead of a 0, and it seems it's a bugged enchantment. Any ideas what these last two numbers might represent?

Also curious about what the TAGS tab means, which is always either a 2 or a 1, right before the EFFECTS tab.

#23
kevL

kevL
  • Members
  • 4 052 messages
i was afraid you were going to ask about TAGS hehe

give me a minute or 35

#24
kevL

kevL
  • Members
  • 4 052 messages
First the easy one: EFFECTS

This is what the doc says:

+-------+---------------
| E | EFFECTS
+-------+---------------
An encoded effect. The first number represents the itemproperty to apply, the folllowing numbers are the parameters specific to that function.
See script x2_inc_itemprops for the mappings between constants and specific ItemProperty functions.
Recipes may only have EFFECTS or OUTPUT, not both


5 params, the 1st one is most important, refers as you say to Itempropdef.2da (although i get this confused with Itemprops.2da)

note: Refers to one of about 100 constants defined in nwscript.nss (core hardcoded constants/functions) as int ITEM_PROPERTY_*

From Itemprop.def, go to column SubTypeResRef -> that's the name of the .2da used to reference the 2nd param. For example, my first entry in Crafting has EFFECTS "23,6,2,0,0"

23 = DamageResist, w/ SubTypeResRef = IPRP_DAMAGETYPE

Go to Iprp_damagetype.2da:

6 = Acid resistance

Now make the guess that the 3rd param refers to Iprp_resistcost.2da, where

2 = 10 resistance

So "23,6,2,0,0" means 10 damage resistance vs acid.


The zeros in there are probably unnecessary and the EFFECT could be written as "23,6,2" (but that's a guess based on the fact that a few other EFFECTS look that way)*. If there were more effect-params, like "48,14,3,13,0" that means more values are needed to fully define the itemproperty.

48 = OnHit, IPRP_ONHIT.2da
14 = Silence
-> guess IPRP_ONHITDUR.2da
3 = 50%

Now go haywire and cheat by tracking down the function that applies the effect:

itemproperty ItemPropertyOnHitProps(int nProperty, int nSaveDC, int nSpecial=0);
// SILENCE :nSpecial is the duration/percentage of effecting victim.
// constant(IP_CONST_ONHIT_DURATION_*)

14 = nProperty = IP_CONST_ONHIT_SILENCE
3 = nSaveDC (i find this hard to believe..)
13 = nSpecial = IP_CONST_ONHIT_DURATION_25_PERCENT_1_ROUNDS



Ok! next up: TAGS


* I'd leave the zeros in, in case they refer to row#0 sometimes.

Modifié par kevL, 01 février 2014 - 11:53 .


#25
kevL

kevL
  • Members
  • 4 052 messages
here's the doc:

+-------+---------------
| D | TAGS
+-------+---------------
The items that can be affected
This will either be a number representing an Item category or a list preceded with a "B" indicated a list of Base Item Types

TAGS looks like it refers (directly or indirectly) to Baseitems.2da, with constants defined in nwscript.nss

in other words you can specify a recipe that takes hold only on a weapon, eg.

'ginc_item' defines the constants, -1 meaning ANY (although 12 looks like it works kinda the same, by including several types into one). I'll list them but like anything NwN2, testing is needed.

// item categories - weapon, armor/shield, other
const int ITEM_CATEGORY_ANY = -1;
const int ITEM_CATEGORY_NONE = 0;
const int ITEM_CATEGORY_WEAPON = 1;
const int ITEM_CATEGORY_ARMOR_SHIELD = 2;
const int ITEM_CATEGORY_BOW = 3;
const int ITEM_CATEGORY_XBOW = 4;
const int ITEM_CATEGORY_SLING = 5;
const int ITEM_CATEGORY_AMMO = 6;
const int ITEM_CATEGORY_MISC_EQUIPPABLE = 8; // amulet, ring, cloak, etc.
const int ITEM_CATEGORY_OTHER = 9; // everything not armor & weapons
const int ITEM_CATEGORY_RANGED = 10;
const int ITEM_CATEGORY_GLOVES = 36;// <-- kL, SHOULD THIS BE "11" ... for crafting esp. What 36! see Attack Bonuses ipType #56
// Recipes in 'crafting.2da' for gloves ( i believe ) use "11" in Col_TAGS

// derived item categories
const int ITEM_CATEGORY_ALL = 12; // ITEM_CATEGORY_WEAPON + ITEM_CATEGORY_ARMOR_SHIELD + ITEM_CATEGORY_OTHER
const int ITEM_CATEGORY_EQUIPPABLE = 13; // ITEM_CATEGORY_MISC_EQUIPPABLE + ITEM_CATEGORY_ARMOR_SHIELD + ITEM_CATEGORY_WEAPON


forgive my little note there. I got as far as bit-flags in 'ginc_math' and said that's nuff. Use educated guesses based on what's there already; this is what i do.