• 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

Hero's children?

ebpatton

Well-known member
Suppose someone writes
Code:
hero.findchild[Deity].tagids[WepProf.?,"+"]
in a context I don't think is important for this question.

So somehow they know hero has a child called Deity. How do they know this?

When I look in the floating info window to show hero tags, I don't see Deity. I see a Has Deity group name, with a tag name of the deity I've selected for this particular hero (Erastil), and a tag ID of HasDeity.deiErastil.

But I want to know how I can know what the children of hero are so I can go looking for them. Where can I find them? That is, where does Deity appear?
 
Mathias' thread is great, but I just spent about an hour thinking and typing this explanation, so I figure I might as well fire it off anyway. Hope it helps.

Initial Contexts
So, any time you start a line of code there is an initial context from which you start. In eval scripts the initial context is the thing which the eval script is running on. For expr-req scripts it is the container of the thing which it is running on (since most things are added to the hero, this is usually the hero).

If you don't need to to navigate away from the initial context, then you can omit the first part of the code fragment.

For example, if you want to add +2 to the current thing's abValue field, you could write:

Code:
      this.field[abValue].value += 2

But all you need is:

Code:
      field[abValue].value += 2

Setting a New Context
Obviously, the initial context isn't always going to get you where you want to go. That's when you start the code fragment off by setting the context you want to start from. The most common of these is the "hero" context, but here are a couple other ones:

actor
container
parent
gizmo
each

Some contexts are not picks, they are containers (hero, gizmo, and actor). Because of that, you can check for the presence or abscence of a Tag (or apply a tag), but there are no fields associated with such a context to be read or manipulated. For these, there are often "Helper" picks present within the container, which contain fields and can accept tags related to some aspect of the container.

For example, these are good:
Code:
      if (hero.tagis[Hero.Raging] <> 0) then
        ~ Do something
        endif

      perform hero.assign[Hero.EquipShld]
      perform hero.delete[Ability.cMnkAC]

But these won't work:
Code:
      hero.field[tACDeflect].value += 2
      hero.field[tCR].value *= 10

A note: there is such a thing as "herofield", but this is just a shortcut way of saying "hero.child[Totals].field"

For "parent", the context is set to the containing pick, so it can check/manipulate the fields on that but if used outside a gizmo it will cause errors. This is mostly used for things like item powers or rooms/teams, which are added to Custom Magic Items or Buildings/Organization gizmos respectively.

Transitioning from one Context to the next
Each "." in the code fragment is a transition to something else within that context, and then the context becomes what follows the dot. These can be chained until you are where you need to be and can do what you need to do. For example:

Code:
      hero.childfound[ArmorClass].field[tACDodge].value

Means "Start at the hero context, transition to the child pick ArmorClass, transition to the field named tACDodge, then transition to the value of that field"

The last "." could also be an action like assigning or checking a tag.

Code:
      perform hero.child[skClimb].assign[SkillOver.aDEX]

      if (hero.child[skClimb].tagis[SkillAbil.aDEX] <> 0) then
        ~ Do something
        endif

The difference between "child", "childfound", and "findchild".
Yay, finally the part where I answer your question!

"child" and "childfound" are mostly the same but "child" throws an error if the transitioned to pick is not present. "childfound" just stops if the pick is missing, and is the safer of the two to use, so just use that. I've never seen a place where "child" needed to be used instead of "childfound", so I am not precisely sure why we have it at all. Probably a legacy thing.

"findchild" transitions to one pick on the hero without naming a specific pick. Instead it finds a pick which meets the conditions you set in the []. The first part has to be a component (a certain type of thing), and the optional second part is a tag expression (the criteria a pick of that type must meet). I say the tag expression is optional, but that is only true when there is never more than 1 pick of that component on a hero at a time (for example, there is never more than 1 race, or 1 deity on a hero). The code you cited is one such instance.

Example:
Code:
      hero.findchild[BaseWep, "wFtrGroup.Axes & Helper.MainHand & !wClass.TwoHanded"].field[dmmBonus].value += 1

BaseWep is the component for all weapons, so that translates to "Start on the hero, then find a Weapon which is a member of the Axe weapon group, currently equipped in the Main hand, but not any Two Handed weapons. If we found our target, transition to the dmmBonus field, transition to the value, and add 1"

Getting the tag expression just right is a bit tricky. If there is more than 1 pick which meets your criteria, it transitions to a random qualifying pick, if there are 0 that meet the criteria the line ends with no error (same as childfound). I reccommend extensive testing.
 
Last edited:
I guess what I'm asking is, suppose I define a class as follows:

Code:
Class MeleeWeapon
{
    Var Attack as Integer
    Var Damage as Integer
    Var DamType as Char(1)  'B, P, or S
}

Then suppose I declare a instance of MeleeWeapon that I call Longsword. I know everything there is to know about Longsword.

But when I see "hero", the only things I know about it are things I see other people do with it. I want to know all the things that make up hero. I want to know what my options are. I'm not asking about syntax. I'll figure out the syntax. I'm not asking what I can do with things. I'll figure that out too.

I just want a comprehensive list of what makes up hero. I want to see its definition. Otherwise, I'm flying blind, hoping to stumble on something I can use.
 
Erm, I am afraid you're talking too much real-coder at me and I don't understand what you mean by defining classes or declaring instances.

I can tell you that since "hero" is just a context, it's not really "made up" of anything. It's more like a box which holds all the individual bits of a character, like his race, his feats, and all that. I wouldn't describe a box filled with odds and ends as being made up of its contents, but if I were to tell you to look for something particular I would start with "In the box" and then give you directions from there.

If you want to know every single pick which is on the hero though, you can view that list by going to "Develop -> Enable Data File Debugging" and after clicking that go to Develop -> Floating Info Windows -> Show Selection List". If you're interested in looking at the fields or tags on a particular pick, you can use the "Show Selection Tags" or "Show Selection Fields" in the same place and choose one or more picks to see in detail. Hope that helps some.
 
Sorry, your way is probably a better way to think about it than mine anyway. I'll look at these posts and examples some more, and look again at the HL Authoring PDF.

Thank you for taking the time to write the long post.
 
"child" and "childfound" are mostly the same but "child" throws an error if the transitioned to pick is not present. "childfound" just stops if the pick is missing, and is the safer of the two to use, so just use that. I've never seen a place where "child" needed to be used instead of "childfound", so I am not precisely sure why we have it at all. Probably a legacy thing.
I am not really sure I agree with the info about child/childfound. As even with childfound[] I get HL to toss errors at me when a pick is not live. In matter of fact HERE is an old post I did where Mathias and Colen both say it will toss errors and you should do a childlives[] test before doing the childfound[].

So I have not been able to get 100% clear picture of the difference between child[]/childfound[]. Guess I am just putting this out as I agree would love to know the difference between these two.
 
I think it has to do with encountering something that is present but not live.

If a pick is not there at all, child[] will report an error, childfound[] will not.

For example, the trait Structural Knowledge will not report an error when it tries and fails to add a +1 trait bonus to the knowledge (engineering) skill if you haven't added that skill to your character yet, and the "Knowledge (religion) 6 ranks required" prereq on the Thanatopic spell feat will simply fail, without generating an error message, if you haven't added Knowledge (Religion) to your character. Both of those use childfound.

If a pick is there, but not live, because there's a failed bootstrap condition or a failed containerreq, or something like that, child and childfound will both report errors.

For example, the animal companion mechanics use bootstrap conditions, so in the example you linked to, you can't always be sure that the animal companion mechanics will be live, but if you're testing an ability relating to animal companions, you'll probably end up encountering a situation during your testing where the animal companion has not been made live yet but the ability you're testing is running its script, and you're working with a class that has the potential to take an animal companion, so the animal companion picks are present.
 
Ahhh said the blind man to his deaf son about his retarded dog!

That makes allot of sense actually Mathias. Always need to be careful about those "bootstrap" conditions. Sweet! Learn something everyday. :D
 
Back
Top