ID:1907927
 
So, I've been making an attempt at having a rather in-depth Crafting System that lets you have a fair amount of freedom involved in the process, but I'm drawing a "blank" at one a certain point; that is, in how this could be done.

The Crafting System would allow Players to craft each individual Component of the Weapon using certain Materials. I'll use a traditional longsword for all examples:

"Blade", "Hilt", and "Grip"

This is then further broken up, to allow Players some more choice, by allowing them to select whatever type of Material (out a selection that can be chosen) they wish to place within each Component:

Blade = Ore
Hilt = Ore
Grip = Ore, Leather, Fur, or Wool

Furthermore, there'd be some required amount to needed for the Material used for the Component:

Blade = 2 Ore
Hilt = 1 Ore
Grip = 1 Ore, 1 Leather, 1 Fur, or 2 Wool

Now, I've (logically) figured out how to accomplish everything here thus far; but then the next bit makes me hit a bit of a stump:

When the Crafting Process actually occurs, the colours from the selected Materials, are what will be used to colour the Object's Components:

Blade = 2 Iron Ore (Grey)
Hilt = 1 Gold Ore (Gold)
Grip = 1 Leather Strap (Brown)

So, for clarity, the longsword's Blade should be Grey, Hilt should be Gold, and Grip should be Brown. This should remain true no matter what; that is, you should still see the Gold hilt on the longsword as you attack with it. The problem here however, is that I don't know of anyway sure-fire way to accomplish this.

* One way I thought of would mean "tearing apart" an icon into 3 different icons, colour them using Blend() or the colour variable, and then putting them back together. To the best of my knowledge however, I do not think such a thing is possible within BYOND?

* Another way, (and possibly the only way that's possible within BYOND, although it would be tedious in the process of making it a reality, as well as building upon it in the future) would be to create each Weapon's Component separately as objects, and then treat them as such. That means, for every icon state that my longsword would traditionally do as a longsword, must now instead be done for my Blade, Hilt, and Grip. So every Attack-State must now be done 3 times for just 1 longsword, for the sake of a Blade, Hilt, and Grip. Furthermore, when I add other Weapons, like say, a greatsword, I would have to go through the process all over again, as the Blade, Hilt, and Grip for a greatsword would look very different when compared to a longsword's. Granted, this would allow me to colour each individual Component as needed but the sheer amount of icons involved with this method is pretty intimidating.

* Another idea I also came up with, was to recolour every individual pixel of an icon through the use of the rgb(). But, I also don't know if such a function which allows me to select individual pixels of an icon exists within BYOND.

So, does anyone have any ideas how this could be done? Or will I have to possibly cut the idea of having a colour theme / style of a Crafted Object be based on the Materials used?
Have you tryed Craft Pro it provides all your dreams!

http://www.byond.com/developer/RedHallDev/Craft_Pro
I've only read through the documentation of that link thus far, but I've seen nothing concerning the colouring of an object, and that's my main issue here.
The first idea you stated is possible, so splitting the icons 3 parts, coloring them, and adding them together is probably the most feasible option out of all of them.
In response to Colesprite
How exactly would I go about this? I mean, I've never heard of it, and the DM Reference doesn't tell me of such a function either.
Here I'll give an example of how I would do it.

First you should start off with your default longsword object
obj
Sword
Longsword

Make sure it doesn't have a icon.

After that split your longsword icons into 3 parts, your hilt, grip, blade.
var/obj/Sword/Longsword/L=new/obj/Sword/Longsword //Makes a new sword

var/hilt='Hilt.dmi' //Hilt Icon
hilt+=rgb(205,173,0) //Gives it the color gold

var/grip='Strap.dmi' //Strap icon
grip+=rgb(92,64,51) //Gives it the color brown

var/blade='Blade.dmi' //Blade Icon
blade+=rgb(84,84,84) //Gives it the color grey

L.overlays+=hilt;L.overlays+=grip;L.overlays+=blade //Basically combines the hilt, grip, blade graphics.


Make sure your default hilt, grip, blade icons are black otherwise it will look pretty ugly when you add color to it.
Oh, I think you misunderstood the first idea. So let me try to clarify it:

When I say "tearing apart" an icon, I mean to tear apart 'Longsword.dmi', which would already be a fully constructed longsword, into 3 different parts -- The Blade, Hilt, and Grip -- through just code. If this is possible, then I'm guessing you'd need to specify some location points of the bottom-left and top-right pixels (?) as parameters, and then take whatever is in there and consider it a new icon. Then, I would use the colour variable or the Blend() or whatever, to colour it, and then use some reverse function to the one used to tear it apart, which would instead just take the pixel location to place the icon's bottom-left-most pixel in.

This way, I would be able to say, take the actual blade from 'Longsword.dmi', and create a 'Blade.dmi', I would then colour it, and then return the actual blade in 'Blade.dmi' into 'Longsword.dmi' -- Meaning, only the blade of 'Longsword.dmi' is now coloured, while the hilt and grip remain black (or white, whichever).

So again, that's possible? A function / method within BYOND that I can use to "tear apart" an icon?

Colesprite wrote:
Here I'll give an example of how I would do it.

First you should start off with your default longsword object
> obj
> Sword
> Longsword
>

Make sure it doesn't have a icon.

After that split your longsword icons into 3 parts, your hilt, grip, blade.
> var/obj/Sword/Longsword/L=new/obj/Sword/Longsword //Makes a new sword
>
> var/hilt='Hilt.dmi' //Hilt Icon
> hilt+=rgb(205,173,0) //Gives it the color gold
>
> var/grip='Strap.dmi' //Strap icon
> grip+=rgb(92,64,51) //Gives it the color brown
>
> var/blade='Blade.dmi' //Blade Icon
> blade+=rgb(84,84,84) //Gives it the color grey
>
> L.overlays+=hilt;L.overlays+=grip;L.overlays+=blade //Basically combines the hilt, grip, blade graphics.
>

Make sure your default hilt, grip, blade icons are black otherwise it will look pretty ugly when you add color to it.


That's just having 3 separate icons called Blade, Hilt, and Grip already made, and not actually creating them from the Longsword. As aresult, this process is more along the lines of my 2nd idea, which is tedious. Because for every icon I've made there, I'd have to now make an Attack-State to match with the Hilt, an Attack-State for the Grip, and an Attack-State for the Blade, and that's just for Attacking, not even when they have it Sheathed, Equipped, Charging for an Attack, Throwing it, etc. And then there's different types of blades (Dirks, Greatswords, etc) that will become a thing in the future.
I think I have seen a library split icons at runtime, but I don't know whether its still there or not.

Have you already made the iconstates for your swords or not?
You're much better off creating individual icons/icon_states for the different parts and combining them into the finished product rather than taking a finished product icon and splitting it up. There will be a lot of math involved and you'll have to input a lot of pre-set numbers for x,y locations in the icons for every single direction, animation, and icon_state. It's far much easier to accomplish it the first way.
icon.Crop() replaces an icon with a specified region of itself.

I suggest you split your things up manually, though, but maybe not so literally. Draw your sword's blade in shades of red, the hilt in shades of green, and the grip in shades of blue, then use icon.MapColors (or SwapColors if you're not using too many colors) to customize the colors at runtime.

Or you could split up the icon literally into the three disconnected parts, all in grayscale, use three separate objects and their color variables, and use that as an overlay.
Gah. Seems like Option 2 is the popular one, despite the amount of work that'll be involved in it...

Just to be clear, if I was to go with Option 2; that is, to create the Longsword in 3 different objects, and colour variables, and use them as an overlay on one object, will this not mean that any time I use the "flick()", I now have to make the icon_state used with it now for each individual component? That's why I'm thinking that'll be such a monolithic amount of work to do, and it'll probably be a pain later as I add more Weapons as well, no?

On a side note though -- Kaiochao just gave me 2 interesting alternatives. I'll look into the Crop(), but the other idea you proposed, with the shades of red, green, and blue -- That seems very likely to be what I want.
In response to Kaiochao
Okay, so the icon.Crop() (from what I've understood from the DM Reference) will simply take the specified region and place it on the bottom-left corner of that exact same icon, so I'm afraid that's a bit too messy for me, and I'm not even sure where to go with it from there.

On the other hand, I've got a few questions related to the 2nd alternative you mentioned:

* I'm trying to completely understand the icon.MapColors() from the DM Reference. If I have understood it correctly, it takes whatever values you've entered -- Let's say I entered 0.3, 0.6, 0.05 in the "Red Section" of the function -- and compares it to the "true value of red", which is 255, 0, 0, right?

* Building from the first question, does this mean that it simply creates a new colour and replaces all shades of "red" with darker shades, almost like a Blend() might?

* Assuming the 2nd question isn't valid, does it instead first combine the 3 "Colour Sections" of the function, and then replace all shades within the icon by this colour generated? Afterall, every time I look at it, it strikes me as a giant rgb, and I cannot help but think they all get thrown into an rgb() and used at the end of it.

* Following your idea of using the shades of red, green, and blue, on the blade, hilt, and grip respectively; I'm inclined to believe 2nd question is valid, since then, this would allow for all the shades of each specified part to be coloured as required. Using simply the blade to explain this: if it blends the shades of red with varying shades of 0.3, 0.6, 0.05, won't the end result be some other strange colour? Or are the shades of red only "swapped" with the newly generated shades instead?

P.S.
I'm not sure if I explained my questions well enough... I feel as if they were too wordy.. Nevertheless, any input on any of them would be nice. I'm also considering just making a test icon and and fiddling with the function and idea myself.
You'd pretty much want the icon components to be split already before doing this. For instance, a longsword icon might have "blade", "hilt", and "grip" components, and they could be blended in that order.

Let's go a step further. Say that in each of these icons, you've drawn it so that the redness of the color is the intensity of that color, and the greenness is used for any white/gray highlights.

obj
var/material_color = "#ffffff" // white by default
var/material_shine = 1 // full shine

// materials is an associative list: e.g., "blade" = an obj of type /obj/iron or such.
proc/CraftIcon(srcicon, list/materials)
var/icon/final
for(var/part in icon_states(srcicon))
var/obj/M = materials[part]
var/col, white
if(!M)
col = "#ffffff"
white = col
else
col = M.material_color
white = M.material_shine * 255
white = rgb(white,white,white)
var/icon/piece = new(srcicon, part)
// red becomes color, green becomes highlight
piece.MapColors(col, white, white)
if(!final) final = piece
else final.Blend(piece, ICON_OVERLAY)
return final ? fcopy_rsc(final) : null

This would need some modification if you had multiple stats like attacking, etc., but I think this could get you on the right path.
In response to Lummox JR
I'm going to assume that
piece.MapColors(color, white, white)


is supposed to be really:
piece.MapColors(col, white, white)


I've also noticed you made no use / mention of blue, so, is it fine to just use it as white? I'm still not 100% clear on how / what the icon.MapColors() works / does afterall.

I'm also thinking on how to incorporate the other various icon states into this, and I think it might have to be something along the line of virtually creating an entire new icon based on numerous different icons / icon states that are based on the components:

(How I'm imagining it)
I would need an icon state for my "Blade" doing an Attack, for my "Hilt" doing an Attack, and for my "Grip" doing an attack. Then, after creating the actual icon that is the longsword, I would need to repeat this process but with the Attack States of each component instead, and then add that icon state to the longsword's icon. Is that about right?

P.S.
This post has made me realized that I may not know enough when it comes to pixel-art, colours, and RGB. Is there anything within the developer section that could help with this? Like a tutorial on pixel-art, or something?
Yep, color was supposed to be col.
So basically you want dragon ages crafting system?
Lummox JR wrote:
Yep, color was supposed to be col.

Yeah, figured. What about the other things I made mention to? Like the lack of mention and use of "blue" and as a result, just using white for it? Or better yet, could you help me get a better grasp on the icon.MapColors() with an explanation of it or something?

DanteVFenris wrote:
So basically you want dragon ages crafting system?

I wasn't aware this was Dragon Age's Crafting System? I've only ever played one game in the series, Dragon Age 2, and that was so long ago, I don't remember much about it at all.

MapColors() is effectively a color matrix. Basically all the red in the icon would become col, all the green would become the white value, and the blue would as well (but I only specifically mentioned using red and green, so blue would be irrelevant).

I suppose my code for shininess is a little off, because really what you'd want would be for the highlight to be sharp when the material is shinier, blurred when the material is duller. Probably the best way to represent that would be raising the color value to a power, though the icon math doesn't really allow for that sort of thing.
In response to Yoren
Take a look at dragon age inquisition may help keep your design simple and structured as they had a well done one that was basically everything you are saying
MapColors() is effectively a color matrix. Basically all the red in the icon would become col, all the green would become the white value, and the blue would as well (but I only specifically mentioned using red and green, so blue would be irrelevant).

Then, is it right in assuming, that icon.MapColors() first does an rgb() on "rr", "rg", "rb", another one on "gr", "gg", "gb", and a 3rd on "br", "bg", "bb". With those three results, it possibly then carries out some mathematical operation (although, I can't really guess at what that might be)?

I suppose my code for shininess is a little off, because really what you'd want would be for the highlight to be sharp when the material is shinier, blurred when the material is duller. Probably the best way to represent that would be raising the color value to a power, though the icon math doesn't really allow for that sort of thing.

I'm guessing that, to get the highlight to be sharper, you would need to increase the "material_shine" value you have there, whereas if you wish it to be duller, you'd decrease. As such, could you not use some set value to perform either operation with (say, 0.25) and have the values be corrected (with the necessary min() and max()) to be no larger than 255 and no smaller than 0 after calculation? Or, am I understanding something completely wrong here?
Page: 1 2