Custom Crafting Processors with skill level and learning points

Patrick

New member
I am using the UIS and UCC. In the Attribute Manager I have amonst other attributes the attributes EP (experience points) and KO_Schmieden (skill: forge). I try to do an own custom crafting processors which check the skill level for KO_Schmieden and compare it with the level of the article. If the article is produced the EP and KO_Schmieden should be raising.
However, I got the follow error (see print screen) and I do not find my custom crafting processor in the drop-down field (see print screen).
What can I do to improve my script?
 

Attachments

  • 11-01-_2021_11-31-39.png
    11-01-_2021_11-31-39.png
    81.9 KB · Views: 4
  • 11-01-_2021_20-28-43.png
    11-01-_2021_20-28-43.png
    59.1 KB · Views: 4
  • SimpleCraftingSchmelze.cs
    3.1 KB · Views: 1
Hi Patrick,

As I mentioned in the Discord chat, you are confusing the Crafting Recipe with the Crafting Processor.

The Crafting Recipe is the type of your recipe scriptable objects.

The Crafting Processor is the logic which you use to craft items.

This video is a bit old but I think it explains the concepts quite well: https://opsive.com/videos/?pid=22330&video=22937

So from my understanding you do need a custom crafting recipe. You only need a custom processor.

So in the second image for the Recipe Type simply choose the default "CraftingRecipe".

Then the second mistake was mine. I told you to add the type in the Unit Options. I was wrong because I misunderstood what you where trying to do. Go back to the Unit Options window and remove your processor type from there.

Then in the GeneratedStubs file, delete line that is giving you the error.

From that point you'll be back to square one.

To use your custom processor you'll need to either override the Crafter component or add a component next to it.
Then you may use simply set the the crafter processor at runtime using:
Code:
crafter.Processor = new CraftingProcessorSchmelze();

Writing this answer made me think that I could make you avoid having to write this additional component by simply improving the Crafter custom Inspector.
I'll try to do that today (no promises though) and I'll send you the code once I am done.

I'm sorry it took so long to come to the bottom of this
 
Please find the new Crafter and Crafter Inspector scripts attached below.

Once you replace those you'll see a new field in the Crafter Inspector:
You'll be able to choose your Crafting Processor from a list and the serialized fields will show up below:
1610446603030.png

All you need to add to your processor script is a [System.Serializable] attribute to make sure it shows up properly in the inspector (You'll need to add it to the built-in processors if you plan to use those too):

Code:
[Serializable]
public class CraftingProcessorSchmelze : SimpleCraftingProcessor
{
....

I hope that solves all your issues and makes it a bit easier for new users in the future.
This change will take place in v1.1.4
 

Attachments

  • Crafter.cs
    7.3 KB · Views: 2
  • CrafterInspector.cs
    5.6 KB · Views: 2
In my opinion this helps very much. However, I got the follow error. What should I do?
 

Attachments

  • 12-01-_2021_21-43-05.png
    12-01-_2021_21-43-05.png
    239.4 KB · Views: 4
You are misusing Attributes.

Make sure you read the documentation and code examples carefully

You are getting an error because you are trying to convert an Attribute<int> to int using "Convert.ToInt32".
That's not how it works.

Attribute<int> is a class that contains an int value, it is not an int value itself. Again make sure to read the documentation in detail.

you can get the value of an attribute using attribute.GetValue() or attribute.Value (UIS and UCC attributes are different)
 
Thank you very much. It is working now. Is there any easy solution to show the player, that the skill level is to low?
 
There is no easy way to do this, since you are making a custom crafting processor, you'll need some custom UI to show that information to the player. It is completely up to you how you go about it.

You could create a custom Crafting Menu, or a custom Recipe Panel. This would give you access to the selected recipe.

OR You could create a custom Item View Module. Since your level limit is defined on the Item itself, you don't even need to know the selected recipe, you just need to know the Item being crafted.

I would recommend the first approach, you'll have a lot more control to do exactly what you want
 
Top