• 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

Faking a new gear slot

TobyFox2002

Well-known member
I have two new gear slots that I am trying to create or "Fake." I've tried twenty ways from Tuesday to force the editor to recognize a new gear slot including copy and paste the xml datafile section on gear slots with new information. It failed.

So, now I'm going to use exsisting mixing it with User tags and eval rules to fake the game into thinking there are two new types. I have code that I think "should" work but for some reason its not giving any errors when I think it should.

I am trying to create a Horn Ring for Unicorns and other horned creatures and "Wing Attachment" for Pegasi and other feathered winged fliers. Both can only have one of each equipped.

Code:
foreach pick in hero from BaseEquip where "gType.Ring"
validif (each.tagis[User.HornRing] <= 1) then
nexteach

Is the code I have been trying to attach to the ring I have as a test item. Granted I know almost nothing about foreach and I'm just doing copy and paste from other sources. But it compiles properly. Also, I know this code isnt checking if the item is equipped. I'll get to that after I get this first part working.

Any ideas on what I'm doing wrong.
 
Yes. You aren't counting the number of items with that tag. It's just looking at each individual item and coming up valid if each item has one or less of that tag. Try this instead:

Code:
var test as number

foreach pick in hero from BaseEquip where "gType.Ring & User.HornRing"
 test += 1
nexteach

validif (test <= 1)
 
So just to but in here. I would go a different way and I would always try and NOT use a Foreach loop. Foreach loop should be last resort!

So as only your "new" gear items can be this type right? Then why loop around when you can set the tags onto the hero yourself.

So I would name all the tags similar like "User.EqpRingHrn" and "User.EqpWing" for example. Then you place either of these on your new Things with the following script:

Pre-Levels/10000
Code:
~ If not equipped get out now!
doneif (field[gIsEquip].value <> 0)

~ Set the custom equipment slot tag onto the hero.
perform pushtags[User.Eqp?]

Then do a pre-req with the following script
Code:
var tags as string

~ get which Custom Equipped tag is on our-self
tags = altpick.tagids[User.Eqp?]

~ Test to make sure we are only wearing one of these pieces of equipment
validif (hero.tagcountstr[tags] <= 1)

Now you have a generic set of scripts that can be used over and over and all controlled by which "User.Eqp?" tag you assign to each piece of equipment.
 
Last edited:
That might work, I'll have to give it a try, probably tomorrow though.

As a matter of curiosity why would you always save for each loops for the last resort and, could you explain the syntax you are using. I've seen some of it before but don't really understand it.

pushtag I know forces a tag onto a given item. But I have never seen altpick.tagids[ ] or hero.tagcountstr[ ].
 
As a matter of curiosity why would you always save for each loops for the last resort and, could you explain the syntax you are using.
Foreach loops use up a "massive" amount of CPU and also energy. Maybe not important right this second for d20 as it only runs on laptops and its not very large. But as it grows and it gets to iPads or people that run on it on a windows tablet more CPU means more battery wasted.

Eventually in systems like Pathfinders hundred to thousands of these "foreach" loops cause slow down even on a powerful computer. Add that overhead to an iPad and the drain and slow down is really seen. :(

So my advice is to try and "future" proof yourself now against this by not using a foreach unless you have too...

pushtag I know forces a tag onto a given item. But I have never seen altpick.tagids[ ] or hero.tagcountstr[ ].
Correct Push tags here is taking what ever "User.Eqp?" tag and assigning it to the Hero container. The use of a "?" means its a wild card so that it will push a tag called "User.EqpHorn" or "User.EqpRing" in example. It also means if both tags are on the Gear Item it will push both of them.

altpick is used in Pre-req (not the same in eval script) scripts to force the check of tagids[] on to itself. By default all scripts in a pre-req section check the hero. So in essence:
Code:
tags = tagids[User.Eqp?]
is exactly the same as doing:
Code:
tags = hero.tagids[User.Eqp?]
In that we will build a string variable based on the User.? tags on the Hero not the gear item. So by using altpick in front we are telling HL to get the tags on the Gear Item instead.

hero.tagcountstr[tags] is the ability to do "tag count" but against a "string" of characters. Let me try an example:
Code:
hero.tagcount[User.EqpRing]
is the same as doing
Code:
hero.tagcountstr["User.EqpRing"]
The difference being that the compiler does not check that "User.EqpRing" is a valid tag until run time. So this also allows one to build a soft-coded "tag" in a string variable.

So this allows me to have a "generic" script that works for any tag that starts as User.Eqp without making it specific to a unique tag. So if tomorrow you add a new tag called "User.EqpWand" it will work without changes.

By not using tagcountstr[] I would have done the following instead:
Code:
validif (hero.tagcount[User.EqpHorn] <= 1)
Then I would have had to change the tag in the pre-req script to be equal to the tag I placed on the Gear Item. It means a 2nd step to remember when making a new item.

Hope that helps...
 
Last edited:
Pre-Levels/10000
Code:
~ If not equipped get out now!
doneif (field[gIsEquip].value <> 0)

~ Set the custom equipment slot tag onto the hero.
perform pushtags[User.Eqp?]

Then do a pre-req with the following script
Code:
var tags as string

~ get which Custom Equipped tag is on our-self
tags = altpick.tagids[User.Eqp?]

~ Test to make sure we are only wearing one of these pieces of equipment
validif (hero.tagcountstr[tags] <= 1)

Doesn't produce any errors when more than one is equipped, in fact I cant get it to give any errors at all.
 
Doesn't produce any errors when more than one is equipped, in fact I cant get it to give any errors at all.
You missed your chance to say Shadow your an idiot! :D

The first script has two little issues:
Code:
~ If not equipped get out now!
doneif (field[gIsEquip].value [B]= 0[/B])

~ Set the custom equipment slot tag onto the hero.
perform [B]hero.[/B]pushtags[User.Eqp?]
It should be done if we have NOT been equipped so equal not (Not equal). Also we need to set the tag on the HERO not yourself. So it needs "hero.".
 
Not my style, Besides I didn't notice it so I don't feel I'd have the right to do so anyway. It could have been me not entering it properly after all :P

Anyways thanks!
 
Back
Top