catchy title? I think so,
Through the help of a few of the guru's and some self intuition I have made great leaps in knowledge skill and logic over the past few months. However as seems to be the case I have run into another speed bump. However this time, it is not an error per say, but a poor coding style in my opinion.
I have a segment of code for crafting items, at the present one entry, ie for creating a helmet is about 20 lines, and it has the flexability to use that one entry for 15 metal types and 7 qualities, however I have an entry for every type of armor and weapon, each crafting entry does relatively the same thing with minor changes (sound familiar?). It is my goal to remove these multiple entries and consolidate even further than before. However unlike before there are different variables that go into the equation.
Before I had an entry for every armor type and every metal, and each of these entries calculated 7 types of quality, for a grand total of 6 billion lines of code ;). I am not so superfluous now, but I would like to cut down. At this point the code is very functional and close to completion so I would rather not post it, however I would be more than happy to send it to Lummox JR, or someone of that category of trust. and no I am not flattering myself into thinking I have the holy grail of coding, I just think my work shouldn't find its way into other projects without permission, and I am merely ensuring it doesn't.
I will be making an attempt at it while I await help.
ID:265729
Apr 20 2007, 4:21 am
|
|
In response to Derekjeterisgod
|
|
lummox gave me some great help in the past on this system so he knows it fairly well (ie the reference :P)
the implementation of the various metals and qualities is complete, all 15 metals and all 7 qualities can be calculated flawlessly from the 20 line 'segment'. each segment is from an input list input( forge, forge)in list( item1 ... item 20) if( item 1) calculation for metal calculation for quality item specifics if( item 2) calculation for metal calculation for quality item specifics (small change for say torso armor as opposed to a helmet) Perhaps instead of having 10 defined objects for armor ie obj/helmet obj/torsoarmor i could have one generic armor entry and when equipping it define if its equip location is say for the torso, then usr.torsoarmor gets filled and his defense goes up? |
In response to Perilous Knight
|
|
that is similar to what I have done for my metals. I have one metal that through a proc gets defined as one of 15 different metals, however the difference is, each metal doesnt get equipped much less to a completely different variable.
|
In response to Perilous Knight
|
|
Perilous Knight wrote:
lummox gave me some great help in the past on this system so he knows it fairly well (ie the reference :P) What it sounds like is your making the calculations to many time, instead of all the if(itemx) call a proc to check the type of metal and send a return on the stat bonus for different types of metals, OR if your just trying to get the information just make an equip var and check if theres an item equip like this: mob/var/equip=0 But that seems to basic to need be asking help for, so Im still not 100% sure on what you need, let me know if that helps you. |
In response to Derekjeterisgod
|
|
I believe we are suffering a grave mis-communication here derek.
let me refer you to previous posts concerning this system, perhaps indirectly this will give you a more firm grasp on what I have accomplished so far; http://developer.byond.com/forum/ index.cgi?action=message_read&id=533595&forum=5&view=1 http://developer.byond.com/forum/ index.cgi?action=message_read&id=512900&forum=5&view=0 i will post this much of my present code. turf For some faint reason I feel this is the blind leading the blind. |
In response to Perilous Knight
|
|
If you want to consolidate this you need to have a seperate proc that can be called with arguments to handle the crafting after your user has made his choice. All your craft verb has to do is determine what the user wants to craft and then it could pass that information to a secondary proc as an argument. This way, instead of having the same code copied over and over, you only have it once in your doCrafting() type proc.
Craft(var/obj/mining/ingot/M in usr) Note that you would have the crafting as a single process at the top of the procedure and then determine and create the itemtype afterwords so you're not repeating code again. |
In response to Hobbesx
|
|
indeed this is what I was thinking, however the specifics on exactly how to do this are eluding me.
|
My thinking on this would be that you'd want to calculate the item's stat boosts based on the material it's made of, at the time of forging. I'd probably calculate it like this:
stat = (base value for type) × (material multiplier) × (quality multiplier) You can have different base values and multipliers per stat. One stat might be defense, where material may not vary the multiplier very much except when going from leather to metal. Another might be weight, where quality will almost always have a 1 multiplier. You can calculate the armor's effect on dexterity using the weight, or you can affect it directly: (dexterity loss) = round((base value for type) × (material multiplier) × (quality multiplier)) Normally these values would be small; additionally, high quality might have a slightly lower multiplier. Heavy metals would have a higher material multiplier here. Loss of stealth is another worthy stat to track. There, quality and material would both have an impact, material much more so. So this is what a basic table might look like for a given component. For simplicity, let's say that all base values are calculated such that Material:Iron and Quality:Average have multipliers of 1 all across the board. Item:Plate Mail Item slot: Armor Attack: 0 Defense: 5 Weight: 20 Dexterity loss: 3 Durability: 200 Stealth loss: 20 - Metal only - Material:Copper Attack: 0.8 Defense: 0.5 Weight: 0.7 Dexterity loss: 0.9 Durability: 0.4 Stealth loss: 0.9 Quality:Good Attack: 1.2 Defense: 1.1 Weight: 1 Dexterity loss: 0.98 Durability: 1.1 Stealth loss: 0.95 So as you see, each particular component has variables that affect the calculations. You could stick this in a table and read it in at runtime. You also have the option of playing with trade-offs, where leather for example will give you far better stealth than metal, but in exchange for lower defense ratios. Different metals have different hardness and weight, and price (for upkeep as well as to buy). You could also figure repair cost into the figures above, such that different materials require different amounts of money to fix, and higher quality might exponentially increase the repair cost while buying only a little more durability. Lummox JR |
Give a small example on how your mixing the types of metals. Are they each individually coded? Are you using type of list? Cant really help you if you dont give information on what you need help on.
-Lummox JR(lol)