• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

Trying to code a new flaw.

Degenpaladin

New member
Im trying to code a new flaw, Elven Pride of Arms.

You only consider those weapons designed specifically for use by the noblest of elves to be fit to wield. Using any other object as a weapon is beneath your dignity.
Prerequisite: Elven blood.
Effect: You suffer a -4 penalty on attack rolls when using a weapon other than a longsword, rapier, or bow (long, short, or composite). Attacks made while fighting unarmed, touch attacks (including ranged touch attacks), or attacks made with natural weaponry also incur this penalty.
Suggested Class/Race: Elf
Source: Dragon Magazine #328 (Nobody’s Perfect – New Flaws for Nonhumans)

Im really at a loss on how to proceed and any help would be appreciated.
 
I ran this at Post-attributes/12000:

Code:
foreach pick in hero from BaseWep where "!IsWeapon.wRapier & !IsWeapon.wLongsword & !IsWeapon.wLongbow & !IsWeapon.wShortbow"
 eachpick.field[wAttBonus].value -= 4
nexteach

To understand what's happening here, I'll break down the different sections and explain them.

Code:
foreach pick in hero from BaseWep

foreach loops go through the various "picks" on your character. A pick is basically anything your character has, from skills to ability scores to the various armor classes and of course weapons. BaseWep is a reference to a tag that all weapons have -- component.BaseWep. All things have component flags, and when you are doing a foreach loop you can use component flags to limit the searching. In this case, we only care about weapons, so we use this flag.

Note: To see flags on a weapon, you can right-click on them in the portfolio and select "Show Debug Tags for XXX"

Code:
 where "!IsWeapon.wRapier & !IsWeapon.wLongsword & !IsWeapon.wLongbow & !IsWeapon.wShortbow"

This part of the foreach statement defines which items you are looking for...or in this case which items to exclude. The "!" at the beginning means "not this", so this part is telling the foreach loop that any items with these tags are omitted from the search. Any weapons that don't have these tags will then be used for any scripting that takes place within the foreach loop.

Code:
eachpick.field[wAttBonus].value -= 4

This part just says that any pick that qualifies based on the restrictions we provided get a -4 to their attack bonus. Like tags, you can see the various fields on a weapon by right-clicking on it. In this case, we are using wAttBonus. We could have used the Penalty field, but that would have reduced both attack and damage from the item, which we don't want.

Code:
nexteach

This closes the foreach loop. It's essentially the same thing as endif for if statements, and is required to compile.

A couple of things to note. After I created this in the editor and added it to a portfolio it gave me a weird error about timing. The message suggests reloading the code, which I did and it seems to be fine now. Also, in regards to the weapon tags that I chose, these should also cover any composite bows, and any weapons that count the same as a rapier or a longsword for the purposes of proficiency (assuming they've been properly tagged).
 
Back
Top