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)
-   -   Need help with Code fix (http://forums.wolflair.com/showthread.php?t=65824)

spannclann April 23rd, 2021 10:05 AM

Need help with Code fix
 
Okay, my code checks to see if the Actor is unarmed and, if so, then checks their level to apply something. My issue is, that when the Actor is armed, this check should not be done.

For Example. When unarmed, the Actors unarmed damage goes up one die level from d6 to d8. However, if armed, the unarmed damage should stay at d6. Currently, with the code I have, it is still at a d8 when armed.

How do I fix this?

if (tagis[IsWeapon.wUnarmed] = 0) then
if (act_level >= 18) then
act_level += 6
elseif (act_level >= 11) then
act_level += 6
elseif (act_level >= 6) then
act_level += 6
elseif (act_level >= 3) then
act_level += 3
else
act_level += 2
endif
endif

Fenris447 April 23rd, 2021 10:46 AM

I'm totally unfamiliar with act_level. We normally test for total levels using a macro "if (#totallevelcount[] >= X) then". But that's not what you're asking.

Your code is testing to see if the tag "IsWeapon.wUnarmed" is present on the Thing that's running the code. You don't mention whether it's a feature, weapon, etc. But regardless, you're not testing the hero for anything here. That tag is used to tell Hero Lab to treat something as if it's an Unarmed Strike (for example, we add that tag to the Tabaxi's Claws or a Centaur's hooves).

What you're looking for are tests whether the Hero has something in either of their hands. There's three tags you may want to look at:
  • Hero.EquipMain - if something is in the hero's main hand, this will be present on the hero
  • Hero.EquipOff - if something is in their offhand, this will be present on the hero
  • Hero.EquipWep - if the hero has a weapon equipped, this will be present on the hero

If you want to test whether the hero's hands are totally free, test for the first two, either using nested if statements or two doneif statements. Here's the latter:

Code:

doneif (hero.tagis[Hero.EquipMain] <> 0)
doneif (hero.tagis[Hero.EquipOff] <> 0)

The third tag might work on its own instead, if you're okay with this thing working even while something like a shield is equipped. If not, use the first two.

spannclann April 23rd, 2021 11:47 AM

I have tried the code you've proposed. However, it does not conduct the check and reduces the unarmed damage to literal STR modifier damage.

As the character gains levels, their unarmed damage goes up one damage die at specific levels.

Character Level Unarmed Strike Damage
1–2 1
3–5 1d4
6–11 1d6
12–17 1d8
18–20 1d10

When a character holds no weapon (or shield) in either hand, they go up one damage die.

When a weapon is held in either hand, the damage dice stays at whatever the characters level is. If the character has the Grappler feat, they are considered one character level higher when calculating unarmed damage dice. Also, if the character has Tavern Brawler, the character is considered one character level higher when calculating unarmed damage dice. With the tests you have given me, it reduces the die damage to STR modifier damage only. The following is my full code.





~ If we're not shown, just get out now
doneif (tagis[Helper.ShowSpec] = 0)

~ If we're disabled, do nothing
doneif (tagis[Helper.Disable] <> 0)

~ first we have to establish our benchmark, based on our level
~ all comparisons are made assuming that the wielder is medium,
~ because
~ that is what wMain tags assume. Damage dice are then adjusted up

~ or down
~ appropriately based on size.

~ There are two feats that can increase the level upward.

var act_level as number

act_level = field[xAllLev].value

~ Checking for Grappler or Tavern Brawler feats
if (#hasfeat[fGrappler] <> 0) then
act_level += 1
endif

if (#hasfeat[ft5CTaverB] <> 0) then
act_level += 1
endif


if (tagis[IsWeapon.wUnarmed] = 0) then
if (act_level >= 18) then
act_level += 6
elseif (act_level >= 11) then
act_level += 6
elseif (act_level >= 6) then
act_level += 6
elseif (act_level >= 3) then
act_level += 3
else
act_level += 2
endif
endif

if (act_level >= 24) then
~ Medium folks get 1d12 at this level. Avg = 6.5
field[wDieCount].value = 1
field[wDieSize].value = 12
field[abValue].value += 6.5
elseif (act_level >= 18) then
~ Medium folks get 1d10 at this level. Avg = 5.5
field[wDieCount].value = 1
field[wDieSize].value = 10
field[abValue].value += 5.5
elseif (act_level >= 12) then
~ Medium folks get 1d8 at this level. Avg = 4.5
field[wDieCount].value = 1
field[wDieSize].value = 8
field[abValue].value += 4.5
elseif (act_level >= 6) then
~ Medium folks get 1d6 at this level. Avg = 3.5
field[wDieCount].value = 1
field[wDieSize].value = 6
field[abValue].value += 3.5
elseif (act_level >= 3) then
~ Medium folks get 1d4 at this level. Avg = 2.5
field[wDieCount].value = 1
field[wDieSize].value = 4
field[abValue].value += 2.5
else
~ Medium folks get 1d1 at this level. Avg = 1
field[wDieCount].value = 1
field[wDieSize].value = 1
field[abValue].value += 1
endif


var v_text as string

call wMainText

field[abText].text = v_text

Fenris447 April 23rd, 2021 01:10 PM

I see a few issues. You're looking for tags and fields like "IsWeapon.wUnarmed" and "xAllLev" without any context, without putting Hero or something like that before it. That means that this Ability is going to look for those tags and fields on itself. If it doesn't find them, it's not going to do what you want.


Try this. I've added comments preceeded by ~!!! to see what's from me:

Code:

~ If we're not shown, just get out now
doneif (tagis[Helper.ShowSpec] = 0)

~ If we're disabled, do nothing
doneif (tagis[Helper.Disable] <> 0)

~ first we have to establish our benchmark, based on our level
~ all comparisons are made assuming that the wielder is medium,
~ because
~ that is what wMain tags assume. Damage dice are then adjusted up

~ or down
~ appropriately based on size.

~ There are two feats that can increase the level upward.

var act_level as number

~!!! You were looking for the field xAllLev on this ability, not the hero. Doing
~!!! herofield[xAllLev].value may work, but this macro should work, too.

act_level = #totallevelcount[]


~!!! I added this debug code; you can see its output from Develop > Floating Info Windows > Show debug output
~!!! It'll tell you what act_level is at this stage in the script. If you add it again later, you can
~!!! see whether it's calculating correctly. You can do this with any field, variable, etc.

debug "Current act_level: " & act_level


~ Checking for Grappler or Tavern Brawler feats
if (#hasfeat[fGrappler] <> 0) then
act_level += 1
endif

if (#hasfeat[ft5CTaverB] <> 0) then
act_level += 1
endif


~!!! Changed your test because it was looking to see if this ability has the tag "IsWeapon.wUnarmed"
~!!! Now instead we're looking to see if the hero has the tags for equipping stuff in their main and offhand

if (hero.tagis[Hero.EquipMain] = 0) then
if (hero.tagis[Hero.EquipOff] = 0) then
if (act_level >= 18) then
act_level += 6
elseif (act_level >= 11) then
act_level += 6
elseif (act_level >= 6) then
act_level += 6
elseif (act_level >= 3) then
act_level += 3
else
act_level += 2
endif
endif
endif


~!!! added hero.childfound[wUnarmed] to the beginning of these, to tell HL to go to the
~!!! wUnarmed thing (Unarmed Strikes) and modify it's weapon dice #'s
~!!! Another thing you may want to think about doing is telling it to be the maximum of
~!!! whatever damage dice is present, otherwise you're overriding a possibly higher dice,
~!!! like if they're a Monk. You'd do this:hero.childfound[wUnarmed].field[wDieSize].value =
~!!! maximum(hero.childfound[wUnarmed].field[wDieSize].value,12)


if (act_level >= 24) then
~ Medium folks get 1d12 at this level. Avg = 6.5
hero.childfound[wUnarmed].field[wDieCount].value = 1
hero.childfound[wUnarmed].field[wDieSize].value = 12
field[abValue].value += 6.5
elseif (act_level >= 18) then
~ Medium folks get 1d10 at this level. Avg = 5.5
hero.childfound[wUnarmed].field[wDieCount].value = 1
hero.childfound[wUnarmed].field[wDieSize].value = 10
field[abValue].value += 5.5
elseif (act_level >= 12) then
~ Medium folks get 1d8 at this level. Avg = 4.5
hero.childfound[wUnarmed].field[wDieCount].value = 1
hero.childfound[wUnarmed].field[wDieSize].value = 8
field[abValue].value += 4.5
elseif (act_level >= 6) then
~ Medium folks get 1d6 at this level. Avg = 3.5
hero.childfound[wUnarmed].field[wDieCount].value = 1
hero.childfound[wUnarmed].field[wDieSize].value = 6
field[abValue].value += 3.5
elseif (act_level >= 3) then
~ Medium folks get 1d4 at this level. Avg = 2.5
hero.childfound[wUnarmed].field[wDieCount].value = 1
hero.childfound[wUnarmed].field[wDieSize].value = 4
field[abValue].value += 2.5
else

~!!! I removed the part where you're telling it to be 1d1, since that's already the default
~!!! Again, you might accidentally override a higher die that someone has from another source

field[abValue].value += 1
endif


~!!! I have no idea what this is, but it's likely unrelated to your problem

var v_text as string

call wMainText

field[abText].text = v_text


spannclann April 23rd, 2021 01:29 PM

I forgot to mention that I had a second Eval script that is as follows:



~ If we're not shown, just get out now
doneif (tagis[Helper.ShowSpec] = 0)

~ If we're disabled, do nothing
doneif (tagis[Helper.Disable] <> 0)

~ Now foreach through and carry out calculations to replace the wMain tag if the average
~ damage of our current tag is higher than the current one.
var curdicenum as number
var curdicesiz as number
var curwepavg as number
var dotpos as number
var tagstring as string

var searchexpr as string
searchexpr = "IsWeapon.wUnarmed"

foreach pick in hero from BaseWep where searchexpr

~We have the option of using Dex instead of Str for attack and damage
perform eachpick.assign[MelAttOpt.aDEX]
perform eachpick.assign[DamageOpt.aDEX]

~See if our replacement damage would offer a better average damage than what the weapon can currently deal

~debug "We're active. This is " & eachpick.idstring

curdicenum = eachpick.field[wDieCount].value
curdicesiz = eachpick.field[wDieSize].value

~debug "curdicenum is " & curdicenum
~debug "curdicesiz is " & curdicesiz

curwepavg = (curdicesiz + 1)/2
curwepavg *= curdicenum

~debug "After calculations, curwepavg is " & curwepavg & " and our threshold is " & field[abValue].value

if (field[abValue].value > curwepavg) then
~debug "Ability is pushing the higher tag."
eachpick.field[wDieCount].value = field[wDieCount].value
eachpick.field[wDieSize].value = field[wDieSize].value
endif
nexteach

Fenris447 April 27th, 2021 06:43 AM

If you're storing the target dice size and count values within this Thing, so that you can compare them in the second script before applying them to the acutal wUnarmed thing, then I'd suggest pulling them into an abValue.

In the first script, instead of directly applying the die count with "hero.childfound[wUnarmed].field[wDieCount].value = 1", do "field[abValue2].value = 1" Do the same thing with the Die Size and abValue3.

Then in the second script, on the last chunk of code, do:
if (field[abValue].value > curwepavg) then
~debug "Ability is pushing the higher tag."
eachpick.field[wDieCount].value = field[abValue2].value
eachpick.field[wDieSize].value = field[abValue3].value
endif
nexteach


That should work, combined with the code I posted previously. But let me know.

spannclann April 28th, 2021 04:32 PM

2 Attachment(s)
@Fenris447
I have used your code and it is not working. I have a level 10 fighter with Grappler and Tavern Brawler. He should be doing 1d10+4 damage. With your code, he is doing 5 damage.

Attachment 6686
your code

Attachment 6687
my code

Fenris447 April 28th, 2021 04:57 PM

I must be missing something, then. But if what you've got's working, great!

spannclann April 28th, 2021 07:12 PM

Quote:

Originally Posted by Fenris447 (Post 294719)
I must be missing something, then. But if what you've got's working, great!

The issue with my code is that, when that fighter holds a weapon in either hand, his unarmed 1d10+4 damage is supposed to drop to an unarmed 1d8+4 damage and I do not know how to do that.

I think I may need to run some sort of check after the unarmed damage ahs been calculated.

spannclann May 5th, 2021 11:41 AM

No one has a suggestion?


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

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