• 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

Foreach Target Container

Is there a way to make a foreach statement target only the container (or pick) it is currently in?

For example, let's say I have a sword that has the flaming quality, and I want a script on that sword that has a script that wants to see if it has the flaming quality and does something with it. As I understand it, if I use a foreach statement, it would apply to all picks with the flaming quality on it, when I only want it to apply to the thing I am currently looking at. Is there another way to see if a pick exists on a specific thing in a script?

This example is NOT what I am doing, it is merely an example. Actually, I realize now it is a bit more complex. What I need to do is look at the parent of the pick I am looking at, and see if that parent has a pick on it (I am essentially trying to get my Shield Bash script to incorporate your Shield Spikes correctly). The problem I'm having is, if it finds anything on the hero with the pick, it applies it to all of those things that run the script, when essentially I want it to only apply it to the one thing that is running the script and HAS that thing on its parent.

What I'm doing.

Shield -> Shield Spikes (shadowed)
`------> Shield Bash (shadowed): Script to forward tags from shield spikes (on this shield only) and append the shield bash with " (Spikes)".

When doing this, it does it to all shields on the hero, when I want it to apply only to the relevant shield. I can't seem to figure out how to internally target only the specific shield parent via a script. I had thought that "foreach pick in container" would work, since the wiki says it looks at the parent of the current thing (which would be the shield), but this is not what it is doing and I'm perplexed what to do from here.
 
Last edited:
Wouldn't it be easier to use an if statement instead of a foreach statement for something like this? As in "If this item has this quality, then do this"?
 
container.childlives[flaming's ID]

is how you would test (in an eval script on one item power) for the presence of another item power on the same weapon.

gizmo.childlives[flaming's ID]

is that same test from a script on the weapon itself.
 
@Sendric, the real issue lies in the transition back up to the parent, then back down to the second child. The if statement just won't do that transition.

@Mathias, thanks, I will give that a try. I've tried the container part, but not the gizmo part. I'm pretty sure though, that this transition won't work as I stated to Sendric above, as it will tell me that the child is present in the container (which should be the shield, but for some reason goes all the way back to the parent; I'm doing the script in shield bash). Then there is the problem of only the shield spikes on THAT shield to which the shield bash I'm looking at is referring to. Hopefully this will work, but it may be impossible within the limitations of the scripting language.
 
I have a parent and two children things, I need a transition from the 1st child to the 2nd child of the same parent. That's what I've been trying to do without much success, when I try a transition to the parent, it instead transitions to the hero. It's the parent shield's children I want to access.

Hero -> Shield->1st Child: Shield Bash->2nd Child:Shield Spikes

So, from a script in Shield Bash, I need a transition to grab the tags and a field from Shield Spikes (all from the same Shield parent) and move those tags and field to Shield Bash. I'm just not sure the scripting language allows the child to move back to the parent so that I can do that (most tree structures don't allow for it).
 
A script on the shield bash forwards whatever tags to its container.

Then, a script on the shield spikes looks for those tags on its container.

They never need to check for each other's existance, only the presence/absence of those tags.
 
This is a version of the code, I know why it doesn't work. It is what I have put together to remind me when I return to it what I'm trying to do with this script. As long as only 1 shield is on a hero, this works, but when two shields are there, it doesn't. I don't want ANY shield, I want only the shield container I'm currently in. This script is in a Shield Bash thing I created that is a weapon bootstrapped and shadowed onto the original shield (in the same manner as HL does Shield Spikes).

Code:
~ If we have shield spikes, copy over our damage.
foreach pick in container where "thingid.wShieldSpk"
  perform each.pulltags[wMain.?]
  perform each.pulltags[wClass.?]
  perform each.pulltags[wCritMult.?]
  perform each.pulltags[wCritMin.?]
  perform each.pulltags[wType.?]
  if (each.tagis[Helper.NoOutGear] = 0) then
    perform each.assign[Helper.NoOutGear]
  endif
  field[BonEnhance].value = maximum (field[BonEnhance].value, each.field[BonEnhance].value)
  if (field[BonEnhance].value <> 0) then
    field[livename].text = field[name].text & " (+" & each.field[BonEnhance].value & " Spikes)"
  else
    field[livename].text = field[name].text & " (Spikes)"
  endif
nexteach
 
Last edited:
Here's the Pathfinder script on the shield spike item power:

Code:
<eval phase="PreLevel" priority="1000"><![CDATA[
~find our parent shield, then field the linked weapon
if (container.haschild[BaseWep,"!thingid.wMetalThr & !thingid.wWoodThr"] <> 0) then
perform container.findchild[BaseWep,"!thingid.wMetalThr & !thingid.wWoodThr"].setfocus
 
~increase the weapon's damage 1 step
perform focus.assign[Helper.DamageUp]
 
~make the damage type piercing
perform focus.delete[wType.?]
perform focus.assign[wType.P]
 
~shield spikes are metal
perform focus.assign[EquipType.Metal]
endif]]></eval>

Once you shadowed your weapon, its container became both the hero and the custom/magic armor (and for the purpose of foreaches from it, its container is only the hero), so it's easier to travel from the shield spikes to the shield bash than it is to travel from the shield bash to the shield spikes.

Your findchild line will probably be:

perform container.findchild[BaseWep].setfocus
d20 doesn't have throwing shields (which don't gain any benefit from being spiked because you throw them like big frisbees, not spike first), so you don't need to exclude them.
 
I think you meant "so you don't need to include them." ;)

The reason I was doing this from my Shield Bash is because I don't have access in the Editor for d20 files to the Shield Spikes power, and thus I can't modify a script on it. I have no idea how to add a script to Shield Spikes at the moment, which is why I was going the way I was.

I think I'm just going to put this on the back burner for now.
 
Last edited:
Agh, I got the thing working. It was a PITA, but I had to work it from the parent item (the shield itself). I realized there is no reason to copy tags over if I know the type of shield that the spikes are being placed on. I also realized, I didn't need to look for special cases, since the shield spikes are always attached to a custom item (so I only look if the item is custom, then see if the gizmo is attached, otherwise I just ignore the script). Whew.
 
Back
Top