Lone Wolf Development Forums

Lone Wolf Development Forums (http://forums.wolflair.com/index.php)
-   HL - Savage Worlds (http://forums.wolflair.com/forumdisplay.php?f=59)
-   -   Common Code Examples (http://forums.wolflair.com/showthread.php?t=33740)

SeeleyOne August 16th, 2014 04:18 PM

Sometimes it is desirable to have a value show up with a given Edge or racial ability.

At this time it does not appear that Savage Worlds has access to Pathfinder's abValue field, which is a value that can be added to by other sources (such as other edges). So far I have only tested it with the Traits 5000, in anticipation to potentially linking it to attribute values, and it works.

Here is what I did to a replaced version of the Command edge.
Code:

var CommRad as number
CommRad = 5

if (hero.tagis[Edge.edgComPres] = 1) then
      CommRad += 5
endif

field[livename].text = field[thingname].text & " (Radius: " & CommRad & ")"

As I show above, it can add to the value if specific Edges are present (in this case Command Presence).

SeeleyOne August 18th, 2014 10:03 PM

Some settings and/or house rules might want a more fluid amount of Major and Minor Hindrances. Instead of requiring a set number you can base it on a targeted maximum Reward Point value.

To get this to work I used a replace Thing ID for valHinders, which is a Simple called Hindrances.

In the first Eval Rule script, I changed the equations for the
~RDS SWD Max Major and Max Minor are now dynamic values

In this example I decided on a maximum of 10, which can be 5 Major Hindrances, 10 Minor Hindrances, or any combination that equals 10 Reward Points.

Code:


      var major as number
      var minor as number

      ~iterate through all hindrances and tally up the number of majors and minors
      ~Note: We must only tally hindrances that are user added and not an advance.
      foreach pick in hero from Hindrance
        if (eachpick.isuser + !eachpick.tagis[Advance.?] >= 2) then
          if (eachpick.field[hinMajor].value = 0) then
            minor += 1
          else
            major += 2
            endif
          endif
        nexteach

      ~determine our maximum number of major and minor hindrances
      var max_major as number
      var max_minor as number

      ~RDS SWD Max Major and Max Minor are now dynamic values
      max_major = minimum(major, 10)
      max_minor = minimum(minor, 10 - max_major)

      ~if we have no more than our maximum major and minor hindrances, we're good
      if (major <= max_major) then
        validif (minor <= max_minor)
        endif

      ~synthesize our validation message appropriately
      @message="Maximum of " & max_major & " points worth of major and " & max_minor & " points worth of minor hindrances allowed"

      ~mark associated tabs as invalid
      container.panelvalid[edges] = 0

      ~assign a tag to the hero to indicate the invalid state
      ~Note: This is used to color highlight the title above hindrances on the tab.
      perform hero.assign[Hero.BadHinders]

The effect is that as Major are selected, it will diminish the number of possible Minor Hindrances. For a more by-the-book value you might want to put 4 instead of my 10 above.

Paragon February 19th, 2015 06:51 PM

From Caped Crusader, a note about how to make sure someone can take a normal amount of Hindrances if their racial template already gives them one:

Code:

#resmax[resHinder] += 1 (or 2 if it's Major)

SeeleyOne June 2nd, 2015 07:14 AM

I just came up with an even more efficient code for enforcing Novice and character creation and for enforcing the Rank while choosing Advances.

It can also be used with an alternate XP table. All that you have to do (as far as Rank is concerned) is change the value of xpPerRank in this code and you are done. You would possibly have to alter the number of Advances in a different Eval script.

I spread out the code a bit so that it is easier for us to read.

Phase: Final
Priority: 5010

Code:

    var endRank as number
    var xpPerRank as number
    var advPerRank as number
    var advCount as number
    var xp as number
    var xpRank as number
    var rankCount as number
    var endRank as number

    xpPerRank = 20
    advPerRank = xpPerRank / 5
    advCount = 0
    xp = hero.child[resXP].field[resMax].value
    xpRank = xpPerRank
    rankCount = 0
    endRank = 0

  ~ Check for spent Advances
  foreach pick in hero from Advance sortas _CompSeq_
      advCount += eachpick.field[advCost].value
  nexteach

  ~ Determine Rank based on current Advance
  ~ Seasoned
  rankCount = advPerRank -1
  if (advCount >= rankCount) then
      if (xp >= xpRank) then
          endRank = 1
      endif
  endif

  ~ Veteran
  rankCount = rankCount + advPerRank
  xpRank = xpRank + xpPerRank
  if (advCount >= rankCount) then
      if (xp >= xpRank) then
          endRank = 2
      endif
  endif

  ~ Heroic
  rankCount = rankCount + advPerRank
  xpRank = xpRank + xpPerRank
  if (advCount >= rankCount) then
      if (xp >= xpRank) then
          endRank = 3
      endif
  endif

  ~ Legendary
  rankCount = rankCount + advPerRank
  xpRank = xpRank + xpPerRank
  if (advCount >= rankCount) then
      if (xp >= xpRank) then
          endRank = 4
      endif
  endif

  ~ Apply the Rank
  herofield[acRank].value = endRank


SeeleyOne June 7th, 2015 11:43 AM

There are times that you will want a Racial Ability or an Edge make it so that you can ignore the Rank requirements for certain edge types.

For the first example, I made a Racial Property that ignores the Rank requirement for all Combat edges. I figured that it was a good racial property to give a particularly warlike race/culture. It has two Eval scripts.

Phase: Validation
Priority: 100
Code:

foreach pick in hero from Edge where "EdgeType.Combat"
    perform assign[Helper.IgnoreRank]
nexteach

Phase: Initialization
Priority: 200
Code:

foreach thing in Edge where "EdgeType.Combat"
      var ignoretag as string
      ignoretag = "IgnoreRank." & eachthing.idstring
      perform hero.assignstr[ignoretag]
nexteach

For the second example, I revised the Valhalla Graduate edge. Before I had made the leadership edges be Novice but then used an Exp-Req to get their Rank requirement back if the Valhalla Graduate was not on the character. This revised way is better because I don't have to make copies of any leadership edges to make it work and it is far simpler.

It also requires two eval scripts to work. They are similar to above, but the priority of the Initialization had to change because it is from an edge.

Phase Validation
Priority 100
Code:

foreach pick in hero from Edge where "EdgeType.Leadership"
    perform assign[Helper.IgnoreRank]
nexteach

Phase Initialization
Priority 2101
Code:

foreach thing in Edge where "EdgeType.Leadership"
      var ignoretag as string
      ignoretag = "IgnoreRank." & eachthing.idstring
      perform hero.assignstr[ignoretag]
nexteach


dartnet June 16th, 2015 09:31 PM

Here is the code to raise the max cap on an Attribute.

Pre-Traits/5000
Code:
Code:

#traitbonus[attrStr] += 1
hero.child[attrStr].field[trtMaximum].value += 1

Before:

Calc trtFinal

Endtransmission July 7th, 2015 12:03 AM

Bootstrapping Vs AutoAdd

So we've all seen and played with Bootstrapping one Thing to another, lets call them Thing 1 and Thing 2. This adds Thing 2 to a character as long as Thing 1 is attached and can never be removed. Sometimes useful, mostly... not so much. What happens if we want to automatically some equipment or an injury that should later be removable, or add a skill to someone when they pick up an object, but keep it when they drop the object again?

This is where AutoAdd comes into play

Code:

<autoadd thing="injACSLoss" portal="peInjury"></autoadd>
autoadd thing="xxxxxx" adds the requested Thing to the character, but if you don't add the Portal ID as well, it will either not show up on the character at all, or will be permenantly attached with no way to ever remove it. You can find the Portal IDs by going through the tab_*.dat files in Savage/Source. Each of the tab_ files equates to one of the screens in Hero Lab.

For simplicity sake, here's the list of available portals... assuming you've not created any of your own. You'll notice that the portals are prefixed with the tab abbreviation, e.g. ba for Basic, sk for Skills etc. etc.

Basics tab
- baAttrib - This is the Attributes panel
- baTrait - This is the Derived Traits panel
- baRank - This is the character Rank
- baCreation - Shows character creation details (Advances, edges, hindrance points etc.)
- baStatus - Shows the current status (encumrance/load limit)

Skills tab
- skSkills - shows the list of current skills
- skLangs - Shows the Languages panel

Edges tab
- edEdges - Shows the Edges area
- edHinders - Shows the hindrances area
- edRewards - shows the rewards area

Arcane Tab
- apPowers - Lists all powers


Armoury tab
- arMelee - shows the Melee weapons section
- arRange - shows the Ranged weapons section
- arSpecial - Special weapons
- arDefense - Defensive items

Gear tab
- grGear - Misc gear area
- grGizmos - Weird science gear
- grVehicle - Vehicles

Advances tab
- adAdvances - Selected advances

Personal tab
- peImages - Shows image
- peInjury - Shows the Temporary injuries
- peAdjust - Permanent Adjustments
The other personal information seems to come from elsewhere and is included using the Thing mscPerson

Allies
- alAllies - Shows the list of allies

Journal
- jrTitle - This is just a title according to the code comments
- Journal - This is a table to add new journal entries

In-Play
- ipTracker - This is where you'd add new trackers
- ipActive - This is the list of active abilities
- ipFCActiv - This is a list of the magic item powers for the character
- ipFCActiSh - This is for Fantasy Companion Magic item skill bonuses
- ipFCActivE - Lists active Edges
- ipFCActiPh - Fantasy Companion Magic Item granted powers with a header
- ipSPCActih - Lists the active super powers with a header
- ipAdjust - Shows any adjustments

Special tab
- spSpecial - Lists all special traits

Endtransmission July 7th, 2015 11:23 AM

Something else that came up tonight that I've meant to put in here before.

If you are just writing and testing on a Windows environment, you may not see these problems, but the Mac client (much like the OS) is case sensitive and *demands* perfect match.

This can explain some errors you may encounter with errors that appear to be syntactically correct.

AndrewD2 July 7th, 2015 11:53 AM

Everything in Hero Lab is case sensitive.

Endtransmission July 7th, 2015 12:03 PM

Quote:

Originally Posted by AndrewD2 (Post 212249)
Everything in Hero Lab is case sensitive.

It should be, yes, but I've encountered this problem a few times when developing or testing something on my windows machine works and testing on the mac where it doesn't. In every case it has been case sensitivity.


All times are GMT -8. The time now is 03:34 AM.

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