• 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

changing weapon category

jmm

Member
I'm trying to create a new weapon ability that will adjust the category of the weapon it's applied to. Two handed weapons become one handed, one-handed weapons become light weapons, and light weapons.... well, too bad. Anyway, not being exceptionally gifted at coding (understatement), I tried something like this:

Code:
        if (container.tagis[wClass.TwoHanded] <> 0) then
          perform container.delete[wClass.TwoHanded]
          perform container.assign[wClass.OneHanded]
        if (container.tagis[wClass.OneHanded] <> 0) then
          perform container.delete[wClass.OneHanded]
          perform container.assign[wClass.Light]

It's a modified version of the code used to make mithral armor, but it's clearly not working, so I could use some help. If anyone give me a hand, or direct me to something else that creates the same kind of modifications, I'd appreciate it.
 
Your script is basically fine, but I suspect your timing may be wrong.

Try this code at Pre-levels/1000

Code:
if (container.tagis[wClass.TwoHanded] <> 0) then
          perform container.delete[wClass.TwoHanded]
          perform container.assign[wClass.OneHanded]
elseif (container.tagis[wClass.OneHanded] <> 0) then
          perform container.delete[wClass.OneHanded]
          perform container.assign[wClass.Light]
endif
 
Assuming what posted is exactly what your trying to use the main issue is you don't have endif statements. Also what timing are you using? Early in the Pre-Levels phase is the timing I'd try first.

Also in like 3.6 of HL a new feature was added to make this a little easier. Basically tagreplace does the same actions of delete and assign but all in one step.

Also my advice is to add "COMMENTS" to your scripts. You do this by having a "~" in front of text. Everyone hates adding comments but god it makes code easier to read for yourself when you come back to stuff in a day or week or even a month.

Code:
~ Check the magic container Thing to see if we are a Two-Handed weapon
~ if we are then make us a One-Handed weapon instead
if (container.tagis[wClass.TwoHanded] <> 0) then
    container.tagreplace[wClass.TwoHanded,wClass.OneHanded]
endif

~ Check the magic container Thing to see if we are a one-Handed weapon
~ if we are then make us a Light weapon instead
if (container.tagis[wClass.OneHanded] <> 0) then
    container.tagreplace[wClass.TwoHanded,wClass.Light]
endif
 
ShadowChemosh - you want elseif, not a second if statement. Currently, if it's a two-handed weapon, the first if will succeed and turn it into a one-handed weapon, and then the second if will be tested - it'll suceed, so it'll become a light weapon.
 
ShadowChemosh - you want elseif, not a second if statement. Currently, if it's a two-handed weapon, the first if will succeed and turn it into a one-handed weapon, and then the second if will be tested - it'll suceed, so it'll become a light weapon.
I was testing you Mathias and you passed. :D

Yep your totally correct on that one. May bad.. :(

Of course this is a good lessen in why you should always TEST your script. :)
 
Last edited:
Ah, thanks so much, guys. The responses were very helpful. Nice to find out about the tagreplace command. SC's code worked perfectly, once I added the perform command and the elseif statement to it.

I was also able to add the fragile condition (yes, all by my little lonesome; aren't I all grown up now), however I'm having some difficulty finding the proper tag to require that these be masterwork weapons. Any suggestions?
 
however I'm having some difficulty finding the proper tag to require that these be masterwork weapons. Any suggestions?
I wish I could say there was a tag for Masterwork but their is not one. LW has mentioned adding one for a long time but it has yet to happen.

So what I have done and this *sort of* works is to look at the field[wAttBonus] and see if its 1. That is the field that gets set when the weapon is Masterwork. While the field[wBonus] gets set when magical. Now of course here is the kicker that is possible for scripts to set those values when the item is NOT MW or magical.

So like I said this *sort of* works. I am all ears if anyone has found a better way. :)
 
Back
Top