Lone Wolf Development Forums

Lone Wolf Development Forums (http://forums.wolflair.com/index.php)
-   HL - Authoring Kit (http://forums.wolflair.com/forumdisplay.php?f=58)
-   -   Chooser Table (menu_things?) that dictates the values of two selections in form (http://forums.wolflair.com/showthread.php?t=60078)

Duggan January 31st, 2018 07:47 PM

Chooser Table (menu_things?) that dictates the values of two selections in form
 
I'm still wrapping my head around a lot of things. In Planet Mercenary, each player has three fireteam members, basically a squad that follows him and takes orders. Each fireteam member has a role, something like "Specialist" or "Officer-in-Training" and five skills, Combat, Physical, Mental, Social, and Damage. The role is partly cosmetic and partly determines which skills can be chosen for that fireteam member (for example, a Specialist gets +1 Mental and +1 to another skill that isn't Damage). The skills chose can be doubled up, so a Specialist might have +2 Mental, or an Officer-in-Training might have +2 Social.

Currently, each fireteam member has fields that contain the values for those five skills, and a field for their name. I would like to be able to edit those Fireteam members to set a role, and then the two skills that they can pick based on that role (although I'm currently ignoring the role and working toward letting the user select two skills. I figure I can then refine it to the role setup), and then be able to edit additional details for players who want more info on their Fireteam members (race, biography, etc).

First off, I'm finding myself going back and forth on how to handle the skill bonuses. Since they're user-selected, I'm considering setting each member up with a Gizmo, creating a component/compset for the skills, and then "things" for each of the five skills, and letting a Chooser Table add them to the Fireteam member, either on the Fireteam Tab (which would show the aggregate value of adding up the skill values for each of the team members, then have individual entries below) or using a separate Form (so that the user would use the name and skill values in a table, then could click on a Configure button to actually set details).

Right now, my approach is to set up an FTSkill component/autocompset, and then have "thing" entries for the five skills which have an "eval" to increment the relevant fields on their parent, if present. I'm still trying to set that up, so I don't have code. But that seems kind of ugly and hacky for something working on a set list of skills, which also exist as fields on another thing. I also find myself trying to think through how to set things up so that a particular role has two sets of choices that can be set up.

*wry grin* And, I guess, after that, the user interface for it? Long story short, my brain is just not twisting the direction I need on this. Does it make sense to just add instances onto that Fireteam member representing the Skill Bonus and then total them up instead of storing a Field? Or should the field do that count maybe?

Under assumptions that I feel are safe:
  • The list of skills won't change for the Fireteam members
  • It's reasonably safe to go with there only ever being a fixed number of Fireteam members (in the game, it is possible to have more of them with certain cards, or for some of them to be "Probies" that offer no bonus)
  • Every "role" only offers the ability to boost two skills, and the two skills don't inter-connect such that we need to worry about them being distinct from each other, although they might have different rules

Anyhow, I'm going to keep plugging away, and I'll provide what code I have as I refine my idea, but I want to put it out here.

Code:

<component
  id="FTMember"
  name="Fireteam Member"
  autocompset="no"
  panellink="ftPanel">
 
  <!-- In-play bonuses applied to the trait -->
  <field
    id="ftName"
    name="Fireteam member name"
    type="user"
    maxlength="200">
    </field>
 
  <field
    id="ftPhysical"
    name="Fireteam physical skill"
    type="derived">
    </field>
 
  <field
    id="ftMental"
    name="Fireteam mental skill"
    type="derived">
    </field>
   
  <field
    id="ftSocial"
    name="Fireteam social skill"
    type="derived">
    </field>
   
  <field
    id="ftCombat"
    name="Fireteam combat skill"
    type="derived">
    </field>
 
  <field
    id="ftDamage"
    name="Fireteam damage"
    type="derived"
    defvalue="1">
    </field>
   
  <field
    id="ftComDam"
    name="Combat and Damage"
    type="static"
    maxfinal="10">
    <finalize><![CDATA[
      ~Displays name
      @text = field[ftCombat].value & " (" & field[ftDamage].value & "d6)"
      ]]></finalize>
    </field>
 
  <field
    id="ftNotes"
    name="Fireteam notes"
    type="user">
    </field>   
  </component>

Code:

<!-- Fireteam -->
<compset
  id="FTMember">
  <compref component="FTMember"/>
  </compset>

Code:

<!-- Fireteam Thing -->
<thing
  id="Fireteam"
  name="Fireteam member"
  compset="FTMember"
  isunique="no"
  description="This is a fireteam entry.">
  <child entity="ftDetails"/>
  </thing>


Duggan February 3rd, 2018 11:54 AM

OK... I think I understand this a little better. I made my Fireteam thing a UserSelect to get the two menus (I'll figure out the Role later) and added some FTSkill things to pull the list from.

Code:

<thing
  id="Fireteam"
  name="Fireteam member"
  compset="FTMember"
  isunique="no"
  description="This is a fireteam entry.">
 
  <fieldval field="usrCandid1" value=" "/>
  <fieldval field="usrCandid2" value=" "/>
 
  <eval index="1" phase="PreTraits" priority="4900">
    <before name="Calc trtFinal"/><![CDATA[
    debug field[usrChosen1].chosen.field[name].text & ", " & field[usrChosen2].chosen.field[name].text
    ]]>
    </eval>
 
  <child entity="ftDetails"/>
  </thing>

<thing
  id="ftPhysical"
  name="Physical"
  compset="FTSkill"/>
 
<thing
  id="ftMental"
  name="Mental"
  compset="FTSkill"/>

<thing
  id="ftSocial"
  name="Social"
  compset="FTSkill"/>

<thing
  id="ftCombat"
  name="Combat"
  compset="FTSkill"/>

<thing
  id="ftDamage"
  name="Damage"
  compset="FTSkill"/>

That lets me select skills off of the list, but now I need to use that to modify the relevant fields. Or perhaps I need to address this differently... I want to have those settings change the relevant values for each Fireteam members (so that, for example, selecting Physical and Physical on one Fireteam member will set the ftPhysical field to 2 while setting Physical and Damage on another will result in ftPhysical being 1 and ftDamage being 1. I was trying to use "if/elseif" statements to basically set up a switch statement, but it keeps saying that the righthand side is not valid if I try something like the following in the eval:
Code:

if (field[usrChosen1].chosen.field[name].text = "Physical") then
  debug "It's physical"
  endif

Can one not compare strings?

Duggan February 3rd, 2018 12:01 PM

I'm actually wondering if it would make more sense to be using tags here instead of field values... if I can get the menus to set the relevant tags, then I could assign them to the fireteam members, propagate them to the hero, and then do the counts on each.

Duggan February 3rd, 2018 02:25 PM

Right. And it's the "compare" function to compare strings. Setting up the if/elseif. :)

ShadowChemosh February 3rd, 2018 02:51 PM

Quote:

Originally Posted by Duggan (Post 262604)
Right. And it's the "compare" function to compare strings. Setting up the if/elseif. :)

Comparing strings is really dangerous in any language but especially for HL because is CPU intensive. I mean you sure the name is never ever going to change in any way including capitalization? Can't you add a Tag to look at instead?

Duggan February 3rd, 2018 06:18 PM

What's the best way to set the tag from the menu_thing?

ShadowChemosh February 3rd, 2018 08:37 PM

Quote:

Originally Posted by Duggan (Post 262614)
What's the best way to set the tag from the menu_thing?

If I am following you wouldn't set it on the menu_thing you would set it on the Pick that "field[usrChosen1].chosen." is pointing too.

For example if field[usrChosen1].chosen. was a list of attributes and you had tags of Attr.Physical or Attr.Mental you could have then:
Code:

if (field[usrChosen1].chosen.tagis[Attr.Physical] = 1) then
  debug "It's physical"
endif


Duggan February 4th, 2018 05:03 AM

You're absolutely right. I was overthinking it. Thank you.

Duggan February 8th, 2018 01:54 PM

I'm learning more and more about how to make this all work... among other things, I finally understand how to roll my own menuthings instead of hamfisting UserSelect into everything.

I'm trying to get the Fireteam roles working for proscribing what skills can be picked. It seemed like the easiest way to do that would be to set tags on them for what skills can be picked, and it seems to be working. The part which I'm still a bit hazy on is how to make it so that changing the Role also changes the chosen skills in the menus. Ideally, I'd like to make it so that, if there's just one choice, it sets it. If there are more, it keeps the current value if it's valid, and sets it to either the first valid choice or not defined if the new role doesn't support that skill.

Code:

<thing
  id="ftrDiplo"
  name="Diplomat"
  compset="FTRole">
  <tag group="FTSkChc1" tag="ftSocial"/>
  <tag group="FTSkChc2" tag="ftPhysical"/>
  <tag group="FTSkChc2" tag="ftMental"/>
  <tag group="FTSkChc2" tag="ftSocial"/>
  <tag group="FTSkChc2" tag="ftCombat"/>
  </thing>

The relevant code for setting the menuthing expressions:
Code:

<eval index="1" phase="PreTraits" priority="4500">
  <before name="Calc trtFinal"/><![CDATA[
  var skChoices1 as string
  var skChoices2 as string
  skChoices1 = field[FTRole].chosen.tagids[FTSkChc1.?, " | "]
  skChoices2 = field[FTRole].chosen.tagids[FTSkChc2.?, " | "]
 
  field[availSk1].text = skChoices1
  field[availSk2].text = skChoices2
   
  ]]>
  </eval>

Side note, I think I need to figure out pushtags and pulltags and how to use them.

ShadowChemosh February 9th, 2018 10:10 AM

Quote:

Originally Posted by Duggan (Post 262817)
Side note, I think I need to figure out pushtags and pulltags and how to use them.

Basically these should be called "copy" tag function. And then push/pull is saying which way to copy the tags.

Some examples. Assume these scripts are running on a thing called 'Shadow1'. :) In addition Shadow1 has been set with a tag of Helper.Food.
Code:

~ Copy tag UseAttr.aDEX from aDEX Pick to ourself
perform hero.child[aDEX].pulltags[UseAttr.aDEX]

After doing this the Thing Shadow1 will have a tag called UseAttr.aDEX on itself.

Code:

~ Copy any Helper tags from our self to the Hero container
perform hero.pushtags[Helper.?]

After running this command the Helper.Food tag would get copied and applied to the Hero. If any other Helper tags where on Shadow1 they to would get copied to the hero.

Hope that helps. :)

Duggan February 9th, 2018 10:34 AM

Thank you. I think that does... although the last time I tried, it didn't work for me. Admittedly, that might have been because I was putting things in the wrong place.

Duggan February 9th, 2018 11:59 AM

Hmm... and my problem might be one of indirection. My Fireteam thing has an eval function that takes the chosen menu values and pulls tags off of them like so:
Code:

<eval index="2" phase="PreTraits" priority="4900">
      <before name="Calc trtFinal"/><![CDATA[
      field[skillCh1].chosen.pushtags[FTSkill.ftPhysical]
     
      field[ftPhysical].value = field[skillCh1].chosen.tagcount[FTSkill.ftPhysical] + field[skillCh2].chosen.tagcount[FTSkill.ftPhysical]
     
      field[ftSocial].value = field[skillCh1].chosen.tagcount[FTSkill.ftSocial] + field[skillCh2].chosen.tagcount[FTSkill.ftSocial]
       
      field[ftMental].value = field[skillCh1].chosen.tagcount[FTSkill.ftMental] + field[skillCh2].chosen.tagcount[FTSkill.ftMental]
       
      field[ftCombat].value = field[skillCh1].chosen.tagcount[FTSkill.ftCombat] + field[skillCh2].chosen.tagcount[FTSkill.ftCombat]
       
      field[ftDamage].value = field[skillCh1].chosen.tagcount[FTSkill.ftDamage] + field[skillCh2].chosen.tagcount[FTSkill.ftDamage]
     
      ]]>
      </eval>

How would I go about pulling or pushing the FTSkill tags onto the hero to allow me to just total up the tags? Or am I going to be better off just cycling through the Fireteam members and summing them up?

Mathias February 9th, 2018 12:24 PM

Is this what you're looking for?
Code:

perform field[skillCh1].pulltags[FtSkill.?]
perform field[skillCh2].pulltags[FtSkill?]

field[ftPhysical].value = tagcount[FtSkill.ftPhysical]
etc.


Duggan February 9th, 2018 08:22 PM

Hmm... that would be a more elegant solution than what I'm doing now, although that wasn't what I was intending to ask. ^_^ But that will work.

Duggan February 20th, 2018 04:29 PM

Back to the effects of one menu dictating the others, currently I have the Role MenuThing setting what the valid choices are for the other two MenuThings with the following bit of code:

Code:

<eval index="1" phase="PreTraits" priority="4500">
  <before name="Calc trtFinal"/><![CDATA[
    var skChoices1 as string
    var skChoices2 as string

    skChoices1 = field[FTRole].chosen.tagids[FTSkChc1.?, " | "]
    skChoices2 = field[FTRole].chosen.tagids[FTSkChc2.?, " | "]
   
    field[availSk1].text = skChoices1
    field[availSk2].text = skChoices2     
  ]]>
  </eval>

However, if a given Role only allows one choice (which most of them do for at least one of the skill choices), I'd like to automatically set the "chosen" to the correct value and if the user changes the Role, and a given setting is no longer valid, I'd like to be able to blank it or set it to the first valid option.

It feels like I should be able to code it kind of like this:
Code:

if (field[FTRole].chosen.tagcount[FTSkChc1.?] = 1) then
  foreach thing in FTSkill where field[FTRole].chosen.tagids[FTSkChc1.?, " & "]
    ~ Should only be the one
    field[skillCh1].chosen = eachthing
    nexteach
  endif

at least for the "only one choice" scenario, but I get an "invalid use of the reserved word 'field' in script" error. I am able to do a debug statement showing that "eachthing.idstring" holds the right values, so I think I'm close to on the right track.

Mathias February 21st, 2018 08:01 AM

Why not set up your scripts so that they can detect that circumstance, and generate the correct results without bothering to look at the menu field if that's the case, and then hide the selectors from the user's view - instead, show a label field displaying that one allowed option? (and cancel any error messages about needing to select something if you can figure out that there's only one selection).

Duggan February 21st, 2018 08:20 AM

That is indeed a possible option. Extending it out to the case of where a given role allows a range of skills that does not encompass the entire set, is there a way to set the menu options? To use two slightly artificial example:
Infantry - Skill 1: [Combat or Physical] Skill 2: [Combat or Damage]
Specialist - Skill 1: [Social or Mental] Skill 2: [Combat]

If I have someone who's chosen Infantry, Combat, Combat and then changes their role to Specialist, it would be nice to change Skill 1 to be undecided (or the first valid option) and leave Skill 2 as it is. Alternately, is there a good way to clear choices just so that I avoid having an invalid setting?

:) And I know that the answer might be "No, you can't do that", but I figure it's worth asking.


All times are GMT -8. The time now is 11:04 AM.

Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.