Lone Wolf Development Forums

Lone Wolf Development Forums (http://forums.wolflair.com/index.php)
-   HL - D&D 5th Edition SRD (http://forums.wolflair.com/forumdisplay.php?f=89)
-   -   Question on Feat (http://forums.wolflair.com/showthread.php?t=59929)

Freewolf January 13th, 2018 08:24 AM

Question on Feat
 
So I am creating some new feats.

I plugged in this code to allow the feat to provide proficieny in Investigation, or double proficiency if already proficient.

Interesting thing that happens is when i select the feat it applies double proficiency just fine, but the Investigation with double proficieny now appears twice both in the program and the print out.

Why is that??

Code:

doneif (tagis[Helper.ShowSpec] = 0)
doneif (tagis[Helper.Disable] <> 0)

if (hero.tagis[ProfSkill.skInvestig] <> 0) then
      perform hero.assign[ProfDouble.skInvestig]
else
      perform hero.childfound[skInvestig].assign[Helper.Proficient]
endif


dungeonguru January 14th, 2018 03:20 AM

It likely has to deal with timing, would have to see all the scripts being applied on the hero to be sure.

Have you looked at the UA article Feats for Skills code? The feat Acrobat has some code in there that does exactly what you want for Acrobatics, but doesn't leave a second copy on the sheet. Should be easily modified for whatever skill you want.

The code runs Post-Level at 15500, which is after Helper.Proficient tags are assigned on most abilities (around 10000) but before the proficiency & double proficiency tags are pushed (around 16000 if I remember).

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


ShadowChemosh January 14th, 2018 09:21 AM

Quote:

Originally Posted by dungeonguru (Post 261420)
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.

dungeonguru January 14th, 2018 10:29 AM

ShadowChemosh,

I'm trying your procedure code out and getting a generic error on the line:

"Invalid ID specified for component" on the line

Code:

  hero.findchild["BaseSkill",v_SkillID].setfocus
Same happens when I try the focus method

Code:

hero.childfound[skAcrobat].setfocus
except the error states "unspecified error parsing script"

Something with 5e maybe doesn't like focusing on skills?

ShadowChemosh January 14th, 2018 11:38 AM

Quote:

Originally Posted by dungeonguru (Post 261445)
ShadowChemosh,

I'm trying your procedure code out and getting a generic error on the line:

"Invalid ID specified for component" on the line

Code:

  hero.findchild["BaseSkill",v_SkillID].setfocus
Same happens when I try the focus method

Code:

hero.childfound[skAcrobat].setfocus
except the error states "unspecified error parsing script"

Something with 5e maybe doesn't like focusing on skills?

Oppss I was a little distracted while writting this. :( :o

This:
Code:

  hero.findchild["BaseSkill",v_SkillID].setfocus
Should be this:
Code:

 
perform hero.findchild[BaseSkill,v_SkillID].setfocus

The component should not have quotes and it needs "perform".

Similiar this:
Code:

hero.childfound[skAcrobat].setfocus
should be:
Code:

perform hero.childfound[skAcrobat].setfocus
setfocus is a "perform" type action like working with tags. Sorry!

dungeonguru January 14th, 2018 12:43 PM

Quote:

Originally Posted by ShadowChemosh (Post 261447)
Oppss I was a little distracted while writting this. :( :o


setfocus is a "perform" type action like working with tags. Sorry!

Ah, so more things I'm reading on the hlkitwiki are starting to make sense. Thanks for the valuable lesson, I'll try to get the procedure into the community files and swap out where the other inefficient code is used in the UA Feats for Skills article.

Also, some clarification for Freewolf on timing on running double proficiency:

At Post-Levels 15000, the script "Assign Helper.Proficient based on ProfSkill tags on Hero" kicks off, which translates the ProfSkill tags over to a proficiency.

At Post-Levels 20000, the scrip "Calc skProfBon" looks at the Helper.Proficient and the proficiency bonus of the hero to calc out the final proficiency modifier.

So technically, assigning the Helper.ProfDouble tag has to happen after you know that the Helper.Proficient is or is not present at post-levels 15000 and before the proficiency is calculated at 20000.

Enforcer84 January 16th, 2018 03:24 PM

I want to thank all three of you for this. Adding that procedure to my notes!

Freewolf January 17th, 2018 07:24 PM

Thanks for the help gents.

Been out of pocket last week with trying to pack up and move.

I do not understand the whole Procedure aspect yet. I did copy the code from the UA Feats originally. I tried the FOCUS code you offered Shadow, but investigation still shows up twice, however this time only one has the double proficiency to it.

I have tried the post-levels at 15500 and 17000 with the same result.

http://i.imgur.com/Hip1zJS.png

I am attaching an image of what I have.


All times are GMT -8. The time now is 07:37 PM.

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