Quote:
Originally Posted by dungeonguru
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.