• 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

Script "Wield Two Handed weapon as One Handed"

bodrin

Well-known member
I have an ability that allows the wielding of spiked chains, and similar weapons, as one-handed weapons.

Scripts posted for future reference

First 2000

Code:
~if we've been replaced, get out now
      doneif (tagis[Helper.SpcReplace] <> 0)

 ~if we aren't our chosen race get out now
      doneif (#hasrace[rFCOphiAng] = 0)
      
      foreach thing in BaseWep where "wFtrGroup.Flails"
        perform eachthing.pulltags[WepProf.?]
        perform eachthing.pulltags[wClass.?] 
        nexteach

    ~ I don't know what this does but it's in the original script I've copied and modified.
      perform hero.pushtags[WepProf.?]
      perform hero.pushtags[wClass.?]

      
      ~ Cycle through and apply the Helper.ExoticProf tag to all examples of 
      ~ the chosen weapon on the hero. This is important for the Aldori Dueling
      ~ Sword specifically, and possibly others.
       ~ I know this relates to Flails but i've left it alone.

      var searchexpr as string

      searchexpr = tagids[WepProf.?,"|"]

      foreach pick in hero from BaseWep where searchexpr
        perform eachpick.assign[Helper.ExoticProf]
        nexteach[SIZE=2]


            [/SIZE]~Lets assign the One Handed tag to our chosen weapon deleting the Two Handed tag first.
                 foreach pick in hero from BaseWep where "wFtrGroup.Flails"
            perform eachpick.delete[wClass.TwoHanded]
                     perform eachpick.assign[wClass.OneHanded] 
                       nexteach



 
Last edited:
Are you having problems? Or does this work fine and you're just posting it so others can see and use it in the future?
 
Are you having problems? Or does this work fine and you're just posting it so others can see and use it in the future?

No problem, just posting a working script for future reference. Helping others, paying it forward. :)
 
If you want to post examples, I recommend you fix a few coding style issues:

You should never use SpcReplace as your test for whether something is disabled. SpcReplace should never be present without SpcDisable also being present, because it's there only to describe why a thing was disabled, and there are many things that will disable without replacing.

Your WepProf and wClass tag handling should have comments - I can't figure out why you're forwarding those to the hero, or why you're pulling in two different tags, then only using one of them in the search.

For a search through weapons, don't you want to use IsWeapon - that's the tag that means "we count as this weapon"?

A single line of tagreplace[] can be used instead of two lines of delete[] and assign[].

I recommend making sure that the weapon is two-handed before assigning one-handed to it. Otherwise, you'll be assigning the one-handed tag to all the light weapons, too, and you'll be doubling up that tag on all the weapons that were already one-handed.
 
Last edited:
If you want to post examples, I recommend you fix a few coding style issues:

You should never use SpcReplace as your test for whether something is disabled. SpcReplace should never be present without SpcDisable also being present, because it's there only to describe why a thing was replaced, and there are many things that will disable without replacing.

Your WepProf and wClass tag handling should have comments - I can't figure out why you're forwarding those to the hero, or why you're pulling in two different tags, then only using one of them in the search.

For a search through weapons, don't you want to use IsWeapon - that's the tag that means "we count as this weapon".

A single line of tagreplace[] can be used instead of two lines of delete[] and assign[].

This was butchered from the Tengu Swordtrained script.
Once I'd got the desired effect I left it alone.

I needed the race this applies to to gain the proficiency with the selected weapons, I presumed the push tags part would do that.

Thank you for the tagreplace[] suggestion. I'll try this later. It's still a work in progress.
 
Your WepProf and wClass tag handling should have comments.....
In my opinion, there is nothing in the programming field more despicable than an uncommented program. A programmer can be forgiven many sins and flights of fancy, however no programmer, no matter how wise, no matter how experienced, no matter how hard-pressed for time, no matter how well-intentioned, should be forgiven an uncommented and undocumented program.

Thats my favorite saying to give to my programmers when doing a code review. Its even written up in my standards document. Once a person has to debug a 3,000 line program without a single comment they will never leave code uncommented again.... :D
 
So the pushtags / pulltags comment would be :-

~ I don't know what this does but it's in the original script I've copied and modified. ;)
 
So the pushtags / pulltags comment would be :-

~ I don't know what this does but it's in the original script I've copied and modified. ;)
Are you trying to make the person proficient with the weapons also as that is what it is doing by pushing the tags to the hero.

If you took out that code what happened? What happens when you add it back in? Sometimes you have to find answers via trial/error and see what the results are when you do "X".

Trust me I have no magic way of knowing what HL does. I have access to the same information everyone else on these boards do. I have learned that you often learn more from errors than from something that works.

Heck just the other day I actually did some bad stuff so badly that it hard crashed HL. I quickly figured out that trying to inherit the tag group properties from a group that was defined afterwards is NOT good. :D The point is now I know and won't do that again. Plus if someone presented to me the same situation I can easily find the reason.

Break scripts up into pieces and see what the results are of those pieces. Breaking things down to very very small pieces of code will help allot in how it all works together.
 
So the pushtags / pulltags comment would be :-

~ I don't know what this does but it's in the original script I've copied and modified. ;)
P.S. - Actually not a bad comment. I had sort of guessed that from the above code as I am using seeing copied code that is just left. At least with a comment the next person is not "guessing" they know it was left and if not needed could be taken out.

When fixing/debugging its very helpful to know the mind of the original programmer.
 
Newest iteration of the working script
Code:
~if we've been replaced, get out now
        doneif (tagis[Helper.SpcReplace] <> 0)
         doneif (tagis[Helper.SpcDisable] <> 0)

  ~if we aren't our chosen race get out now
        doneif (#hasrace[rFCOphiAng] = 0)
       
  ~ We need to be proficient with these weapons
        foreach thing in BaseWep where "wFtrGroup.Flails"
         perform eachthing.pulltags[WepProf.?]
          nexteach

          perform hero.pushtags[WepProf.?]
      
  ~ Now assign the One Handed tag whilst deleting the 
   ~ tag Two Handed but we need to check that we are not a light
    ~ or One handed weapon first
         doneif (tagis[wClass.OneHanded] <> 0)
          doneif (tagis[wClass.Light] <> 0)
           
         foreach pick in hero from BaseWep where "wFtrGroup.Flails"
          perform eachpick.tagreplace[wClass.?,wClass.OneHanded]
           nexteach  
      
   ~ Cycle through and apply the Helper.ExoticProf tag 
    ~ to all examples of the chosen weapon on the hero.
     ~ This could be important for the future.
          var searchexpr as string
           searchexpr = tagids[WepProf.?,"|"]

          foreach pick in hero from BaseWep where searchexpr
           perform eachpick.assign[Helper.ExoticProf]
            nexteach
 
Newest iteration of the working script
I think to help everyone lets go through this script in small pieces...

Code:
~if we've been replaced, get out now
[B]doneif (tagis[Helper.SpcReplace] <> 0)[/B]
doneif (tagis[Helper.SpcDisable] <> 0)
You should never use SpcReplace as your test for whether something is disabled. SpcReplace should never be present without SpcDisable also being present, because it's there only to describe why a thing was disabled, and there are many things that will disable without replacing.
So Mathias is saying that you should never ever need to check for Replace tag. We only want to check to see if we are disabled or not. So the above script should become:
Code:
~if we've been disabled, get out now!
doneif (tagis[Helper.SpcDisable] <> 0)


Code:
  ~if we aren't our chosen race get out now
        doneif (#hasrace[rFCOphiAng] = 0)
This bit of code is locking us to a single specific race and will NOT run on any other race. I have to ask why as you may later wish to use this Racial Special on a different race. As we have to be bootstrapped to the race in the editor putting in such a check is not needed. This should be removed.

Code:
~ We need to be proficient with these weapons
foreach thing in BaseWep where "wFtrGroup.Flails"
     perform eachthing.pulltags[WepProf.?]
nexteach

perform hero.pushtags[WepProf.?]
Foreach loops are VERY CPU intensive so if we can combine things together we should combine them into single foreach loops. So this section we will get back too.

Code:
~ Now assign the One Handed tag whilst deleting the 
~ tag Two Handed but we need to check that we are not a light
~ or One handed weapon first
doneif (tagis[wClass.OneHanded] <> 0)
doneif (tagis[wClass.Light] <> 0)
So the above is saying to test our Racial Special to see if our Racial Special ability is a One Handed or Light weapon??? This seems to fall into the same idea of testing to see if our Racial Special is a Vegetable or not. Logically are Racial Special is not going to have tags for being One Handed or Light. On top of that you are saying we have to have a value 0 or FALSE. Meaning your double checking that your Racial Special really does not have Weapon Tags.

So these checks just need to go away.

Code:
foreach pick in hero from BaseWep where "wFtrGroup.Flails"
    perform eachpick.tagreplace[wClass.?,wClass.OneHanded]
nexteach
Unless giving your code to LW you really should line up the Blocks of Code. So that the "IF" lines up with an "ELSE" and the "foreach" lines up above the "nexteach". Its VERY old school coding where blocks of code don't line up.

So the above has no comments but my take is that you are trying to convert all Fails (including Light, One-handed, and Two-Handed) into One Handed fails. Cause that is what the above is doing. From earlier posts your idea is to ONLY convert Two-handed flails. So you want the following:
Code:
~ Find all Two-Handed fails on the Hero and change them to one-handed weapons
foreach pick in hero from BaseWep where "wFtrGroup.Flails & wClass.TwoHanded"
    perform eachpick.tagreplace[wClass.TwoHanded,wClass.OneHanded]
nexteach
Note this will change even more in the final script though as we want to combine multiple foreach loops together.


Code:
   ~ Cycle through and apply the Helper.ExoticProf tag 
    ~ to all examples of the chosen weapon on the hero.
     ~ This could be important for the future.
          var searchexpr as string
           searchexpr = tagids[WepProf.?,"|"]

          foreach pick in hero from BaseWep where searchexpr
           perform eachpick.assign[Helper.ExoticProf]
            nexteach
Looking around this appears to automatically make a person proficient with this weapon even if it is exotic. Looks like the code came from cleric domain. This here can be combined with above code to reduce the number of foreach loops we are doing. The primary loop is needed as its pulling from Things and these later loops are doing Picks but we want to reduce the code as much as we can.

Here is a final script. I just tested it out and it works and only converts two-handed weapons to one-handed but makes the character proficient with all flails.

Code:
~ If we've been disabled, get out now!
doneif (tagis[Helper.SpcDisable] <> 0)

~ Pull all the Flail proficincy tags to ourself. 
~ Note: This is pulling from Things not Picks. This means
~       the weapons do NOT have to be live on the character.
foreach thing in BaseWep where "wFtrGroup.Flails"
   perform eachthing.pulltags[WepProf.?]
nexteach
~ Push all the Wepon Proficiency tags to the hero.
~ This will make our character proficient with all flails.
~ Note: This means the script should run as early as possiable.
perform hero.pushtags[WepProf.?]
      
var searchexpr as string
~ Build a search sting of all the Fail Weapons we pulled above
searchexpr = tagids[WepProf.?,"|"]
~ Loop through all the weapons that are actually present on the
~ character based on the search expression built from the WepProf tags.
~ We can only modify tags on a Pick which is why we are doing a 2nd 
~ foreach loop.
foreach pick in hero from BaseWep where searchexpr
   ~ If we are a two-handed weapon convert us to a one-handed
   perform eachpick.tagreplace[wClass.TwoHanded,wClass.OneHanded]
   ~ If we are an exotic weapon assign helper tag to make us 
   ~ proficient
   If (eachpick.tagis[wProfReq.Exotic] <> 0) Then
      perform eachpick.assign[Helper.ExoticProf]
   Endif
nexteach
 
I doff my cap to the codemeiester.;)

Nicely done Shadow, :D

This is for a specific variant of race however there are 3 types but only one can wield Spiked chains or similar weapons, ie Flails one handed. The rest just need to be proficient with them.

Also Double weapons aren't affected by this either.
 
I doff my cap to the codemeiester.;)

Nicely done Shadow, :D
Thanks but was just trying to be helpful in going over the code. I figured that it may help you or others. Guess it sort looks like I was showing off but that was not the case. :o

This is for a specific variant of race however there are 3 types but only one can wield Spiked chains or similar weapons, ie Flails one handed. The rest just need to be proficient with them.
Ahhh. See how though a comment to exactly what you have above would have made that clear for the next person. :) And the idea is that a comment should be in plain English for best affect.

Also Double weapons aren't affected by this either.
Is this just a statement or asking for help to change the script to not affect double weapons?
 
Is this just a statement or asking for help to change the script to not affect double weapons?

Not just a statement, a veiled request.:o

However I tinkered around with this but of code, plugged it into the optimised script

Code:
If (eachpick.tagis[wCategory.Double] <> 0) Then
      perform eachpick.tagreplace[wClass.?,wClass.TwoHanded]
   Endif

And it worked. Unless you can see anything that needs amending this ability is done.
 
Back
Top