View Single Post
ShadowChemosh
Senior Member
Volunteer Data File Contributor
 
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729

Old January 14th, 2018, 09:21 AM
Quote:
Originally Posted by dungeonguru View Post
Code:
doneif (tagis[Helper.ShowSpec] = 0)
doneif (tagis[Helper.Disable] <> 0)

foreach pick in hero from BaseSkill where "thingid.skAcrobat"
     if (eachpick.tagis[Helper.Proficient] = 0) then 
          perform eachpick.assign[Helper.Proficient]
     elseif (eachpick.tagis[Helper.Proficient] <> 0) then
          perform eachpick.assign[Helper.ProfDouble]
     endif
nexteach
Unless I miss something in 5e were you can have multiple instances of Acrobatic skill the foreach is allot of overhead. It will work the way you have it coded. Most likely you won't even notice any issues unless you have a higher level character running dozens of these scripts or several dozens at once.

The above could be done with almost no CPU usage by using a FOCUS instead.
Code:
doneif (tagis[Helper.ShowSpec] = 0)
doneif (tagis[Helper.Disable] <> 0)

perform hero.childfound[skAcrobat].setfocus
doneif (state.isfocus = 0)
if (focus.tagis[Helper.Proficient] = 0) then 
      perform focus.assign[Helper.Proficient]
elseif (focus.tagis[Helper.Proficient] <> 0) then
      perform focus.assign[Helper.ProfDouble]
endif
If you plan to use the above logic dozens of times for different feats, traits and abilities I would recommend turning it into a procedure. Then you can call the logic easily from all over.

Procedure Logic:
Code:
<procedure id="5CSkProfDo" context="pick"><![CDATA[
  var v_SkillID as string

  ~ Make a Target.? skill id to be used in the find chile
  v_SkillID = "Target." & v_SkillID

  ~ Set focus to the skill id passed in
  perform hero.findchild[BaseSkill,v_SkillID].setfocus
  doneif (state.isfocus = 0)
  
  ~ If not proficient then make skill proficient
  if (focus.tagis[Helper.Proficient] = 0) then 
    perform focus.assign[Helper.Proficient]
        
  ~..Else if already proficient make double proficient
  elseif (focus.tagis[Helper.Proficient] <> 0) then
    perform focus.assign[Helper.ProfDouble]
  endif
]]></procedure>
Then this is all that anyone would need to do to now reuse the above logic:
Code:
doneif (tagis[Helper.ShowSpec] = 0)
doneif (tagis[Helper.Disable] <> 0)

var v_SkillID as string
v_SkillID = "skAcrobat"
call 5CSkProfDo
The really nice benefit is if any logic needs to be fixed in applying Proficiency tags you only have to update ONE place. That one fix will apply itself to anything in the Pack or individual .user files. Cutting code maintenance time down is a life saver in the long run.

Hero Lab Resources:
Pathfinder - d20pfsrd and Pathfinder Pack Setup
3.5 D&D (d20) - Community Server Setup
5E D&D - Community Server Setup
Hero Lab Help - Hero Lab FAQ, Editor Tutorials and Videos, Editor & Scripting Resources.
Created by the community for the community
- Realm Works kickstarter backer (Alpha Wolf) and Beta tester.
- d20 HL package volunteer editor.

Last edited by ShadowChemosh; January 14th, 2018 at 11:40 AM. Reason: fixed scripting typoes...
ShadowChemosh is offline   #3 Reply With Quote