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 |
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:
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) |
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 |
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 |
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 |
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. |
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 |
I must be missing something, then. But if what you've got's working, great!
|
Quote:
I think I may need to run some sort of check after the unarmed damage ahs been calculated. |
No one has a suggestion?
|
All times are GMT -8. The time now is 06:57 PM. |
Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.