browser icon
You are using an insecure version of your web browser. Please update your browser!
Using an outdated browser makes your computer unsafe. For a safer, faster, more enjoyable user experience, please update your browser today or try a newer browser.

How to Hit Someone With Something

Posted by on August 29, 2010

I’m so sick of this damn melee macro that I’m not even going to explain it.  Suffice to say that I’m really missing the days of rolling dice on a table.

<!–Melee_Attack–>
<!–Attack the current target with a valid weapon and attack–>
<!–Determine if a melee weapon is readied–>
[h: wWeapon=WeaponObject]
[h: wGrip=Grip]
[h: wAttacks=json.get(wWeapon,”Attacks”)]
[h: wAttackArray=”[]”]
[h: wRange=getDistance(CurrentTarget,0)]
[h: wValidAttacks=”{}”]
[h: wMelee=0]
<!–Get valid attacks by grip–>
[h: wAttackArray = json.append(wAttackArray, json.toList(json.fields(wAttacks, “json”)))]
[h: wAttackList = json.toList(wAttackArray)]
[h, forEach(wAttackName,wAttackList), code:
{
[h: wAttack=json.get(wAttacks, wAttackName)]
[h, if(wGrip==json.get(wAttack,”Grip”)), code:
{
[h: wValidAttacks=json.set(wValidAttacks,wAttackName,wAttack)]
[h: wMelee=wMelee+if(json.get(wAttack,”Type”)==”melee”, 1, 0)]
};{}]
}]

<!–Make sure that at least one of the available attacks is melee –>
[h: assert(wMelee>0, “No melee attacks available with your weapon!”,0)]

<!–Determine valid attacks by range to target–>
[h: wValidAttackArray=”[]”]
[h: wValidAttackArray = json.append(wValidAttackArray, json.toList(json.fields(wValidAttacks, “json”)))]
[h: wValidAttackList = json.toList(wValidAttackArray)]
[h: wReachAttacks=”{}”]
[h: wValidAttacksByReach=0]
[h, forEach(wValidAttackName,wValidAttackList), code:
{
[h: wValidAttack=json.get(wValidAttacks, wValidAttackName)]
[h: wValidReachList=json.get(wValidAttack,”Reach”)]
[h, if(listContains(wValidReachList,wRange)), code:
{
[h:wReachAttacks=json.set(wReachAttacks,wValidAttackName,wValidAttack)]
[h:wValidAttacksByReach=wValidAttacksByReach+1]
};{}]
}]

<!–Abort if no valid attacks by reach–>
[h: assert(wValidAttacksByReach>0, “You cannot hit “+CurrentTarget+” with your current weapon and grip!”,0)]

<!–Input box to select the attack–>
[h: wReachAttackArray=”[]”]
[h: wReachAttackArray=json.append(wReachAttackArray, “No Attack”, json.toList(json.fields(wReachAttacks, “json”)))]
[h: wReachAttackList=json.toList(wReachAttackArray)]

[h: wHitLocationObject=getLibProperty(“HitLocations”,”Lib:Weapons”)]
[h: wHitLocationArray=json.fields(wHitLocationObject, “json”)]
[h: wHitLocationList=json.toList(wHitLocationArray)]

[h: input(
“wAttackUsed|”+wReachAttackList+”|Attack to Use|RADIO|SELECT=0 VALUE=STRING”,
“wHitLocation|”+wHitLocationList+”|Hit Location (Eyes/Vitals are for imp/pi only)|LIST|SELECT=0 VALUE=STRING”,
“wChinks|0|Target Chinks in Armor for 1/2 DR? (-8 torso, -10 elsewhere)|CHECK”,
“wDeceptive|No,Deceptive Attack,Telegraphic Attack|Deceptive or Telegraphic Attack?|RADIO|SELECT=0 VALUE=STRING”,
“wModifiers||Enter any other numeric modifiers as a single integer|TEXT”
)]

<!–Abort if no attack is used–>
[h: assert(wAttackUsed!=”No Attack”, “Attack cancelled.”,0)]

<!–Get the penalty for the hit location–>
[h: wHitLocationPenalty=json.get(wHitLocationObject,wHitLocation)]
[h: wHitLocationPenalty=if(wChinks, -10, wHitLocationPenalty)]
[h: wHitLocationPenalty=if(wChinks && wHitLocation==”Torso”, -8, wHitLocationPenalty)]

<!–Determine base effective skill–>
[h: wAttackObject=json.get(wReachAttacks,wAttackUsed)]
[h: wSkillName=json.get(wAttackObject,”Skill”)]
[h: wSkillLevel=json.get(CombatSkills,wSkillName)]
[h: wEffSkillLevel=wSkillLevel+wModifiers+wHitLocationPenalty]

<!–Add a bonus if Telegraphic Attack was chosen–>
[h: wEffSkillLevel=if(wDeceptive==”Telegraphic Attack”,wEffSkillLevel+4,wEffSkillLevel)]

<!–Subroutine for Deceptive Attack to be added later–>
[h: wEffSkillLevel=if(wDeceptive==”Deceptive Attack”,wEffSkillLevel-4,wEffSkillLevel)]

<!–Roll to hit–>
[h: wRoll=3d6]
[h: wHitOrMiss=if(wRoll<=wEffSkillLevel, “<b>hits</b>”,”<b>misses</b>”)]
[h: wMargin=absolutevalue(wEffSkillLevel-wRoll)]

<!–Determine damage base figures==>
[h: wDamBase=json.get(wAttackObject,”DamBase”)]
[h: wDamBaseDice=if(wDamBase==”swing”,json.get(getLibProperty(“swing”,”Lib:Weapons”),Strength),”0″)]
[h: wDamBaseDice=if(wDamBase==”thrust”,json.get(getLibProperty(“thrust”,”Lib:Weapons”),Strength),wDamBaseDice)]
[h: wDamMod=json.get(wAttackObject,”DamMod”)]

<!–Determine Critical thresholds–>
[h: wCritSkillLevel=if(wDeceptive==”Telegraphic Attack”,wEffSkillLevel-4,wEffSkillLevel)]
[h: wCritHitNumber=if(wCritSkillLevel==15,5,4)]
[h: wCritHitNumber=if(wCritSkillLevel>15,6,wCritHitNumber)]

[h: wCritMissNumber=if(wEffSkillLevel>15,18,17)]
[h: wCritMissNumber=min(wEffSkillLevel+10,wCritMissNumber)]

[h: wHitOrMiss=if(wRoll<=wCritHitNumber, “<b>critically hits</b>”, wHitOrMiss)]
[h: wHitOrMiss=if(wRoll>=wCritMissNumber, “<b>critically misses</b>”, wHitOrMiss)]

<!–Roll damage if a hit–>
[h: wDamageFeedback=””]
[h: wDamType=json.get(wAttackObject,”DamType”)]
[h, if(wHitOrMiss==”<b>hits</b>”||wHitOrMiss==”<b>critically hits</b>”), code:
{
[h, if(wDamBase!=”none”&&wDamBase!=”static”), code:
{
[h: wDamageBase=eval(wDamBaseDice)]
[h: wDamageMod=wDamMod]
};
{
[h: wDamageBase=wDamBaseDice]
[h: wDamageMod=eval(wDamMod)]
}]
[h: wDamageTotal=wDamageBase+wDamageMod]
[h: wDamageFeedback=”<br>The attack will do <b>”+wDamageTotal+” “+wDamType+”</b> damage.”]
};{}]

[r: wFeedback=token.name+” attacks “+CurrentTarget+” using “+wAttackUsed+” to the “+wHitLocation+”, rolls “+wRoll+” and “+wHitOrMiss+” by “+wMargin+”.”+wDamageFeedback]

Leave a Reply

Your email address will not be published. Required fields are marked *