View Single Post
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 13,213

Old December 1st, 2009, 09:00 AM
Writing an email to Rob and Colen is one of my best ways to get through a problem, because organizing my thoughts about the problem in order to explain it well often leads me to the solution.

Since you've mentioned elegance, I thought you might appreciate some style and optimization notes.

In terms of style, I'd use = 0 in the doneif, instead of <1 - just a programming style thing - 0 means no, not 0 means yes.

An optimization that you could use is to restrict the foreach to only look through armors, and not every pick attached to the character:

Code:
 
foreach pick in hero from BaseArmor where "mClass.Heavy"
The "from <component>" option in foreach-es is relatively new, so you may not see it in everything you look at for examples. I left out the EquipType.Armor, since it seemed redundant, once we're checking for the component.

FYI, a piece of armor exists and is equipped on every character to store the natural armor values, so that's why your script found it when you were searching for all armors.

In the develop menu, make sure the first option, "Enable Data File Debugging" is selected, then add a couple pieces of armor to your character, along with a shield and on the gear tab, something else. Right-click on each and select "Show debug tags for XXX". You'll be shown a menu that displays all the tags that thing has at the end of the evaluation cycle. That's where you can figure out that all the armors use the BaseArmor component, but the gear doesn't.
Mathias is online now   #4 Reply With Quote