Here's the code from the macro:
Spoiler
Code: Select all
[h:selectTokens(currentToken())]
[h:currManeuver=getProperty("currManeuver")]
[h, if(json.isEmpty(currManeuver)): continueMacro=0; continueMacro=1 ]
[h:exitMsg=getName(currentToken())+" has not chosen a maneuver. <br> On your turn, pick a maneuver, pick a weapon, and attack something."]
[s,h: assert (continueMacro,exitMsg,0)]
<!-- Setting up weapon variables from arguments -->
[h:args=json.fromStrProp(macro.args)]
[h:attacker=json.get(args,"attacker")]
[h:weaponUsedIndex=json.get(args,"currItemIndex")]
[h:methodUsed=json.get(args,"method")]
[h:weaponUsed=json.get(inventory,weaponUsedIndex)]
[r:minReach=json.get(weaponUsed,methodUsed+"minReach")]
[r:maxReach=json.get(weaponUsed,methodUsed+"maxReach")]
<!-- Setting up maneuver bonus variables -->
[h:currManeuverName=json.get(currManeuver,"name")]
[h:manSkillBonus=json.get(currManeuver,"offSkillBonus")]
[h:manSkillLimit=json.get(currManeuver,"offSkillLimit")]
[h:rangeBonus=json.get(currManeuver,"rangeBonus")]
[h:manDamageBonus=json.get(currManeuver,"damageBonus")]
<!-- Determining penalty from attacker's posture -->
[h:postureList=getTokenStates("json", "Postures")]
[h:posture="standing"]
[h:attackerPostureMod=0]
[foreach(p, postureList,""), h , code: { [h,if(getState(p)):posture=p;""] } ]
[h, if (posture == "crouching" || posture == "kneeling" || posture == "sitting" ) : attackerPostureMod=-2;""]
[h, if (posture == "crawling" || posture == "face_up" || posture == "prone" ) : attackerPostureMod=-4;""]
<!-- Setting up conditions to determine which tokens are possible targets -->
[h:range=json.set("{}","token",attacker,"from",minReach,"upto",maxReach+rangeBonus,"distancePerCell",0)]
[h:NPCsInRange=json.set("{}","range",range,"npc",1,"visible",1)]
[h:PCsInRange=json.set("{}","range",range,"pc",1,"visible",1)]
<!-- Setting up list of possible targets -->
[if( isPC() ), h, code : {
[h:targetListFirst=getTokens(",",NPCsInRange)]
[h:targetListSecond=getTokens(",",PCsInRange)]
};{
[h:targetListFirst=getTokens(",",PCsInRange)]
[h:targetListSecond=getTokens(",",NPCsInRange)]
}]
[h,if(targetListSecond==""):
targetList=targetListFirst ;
targetList=listAppend(targetListFirst,targetListSecond) ]
[if (listCount(targetList)==1),h:checkedIfOneTarget="checked";checkedIfOneTarget=""]
[if (listCount(targetList)==0),h:msg="<br><br>You do not see any tokens within melee distance. Make sure the token you would like to target is visible on your map and is within your weapon's reach. Then try again.";msg=""]
<!-- Setting up list of dialog box width and form action-->
[h:START_NEW_ROW=6]
[if (listCount(targetList)>START_NEW_ROW),h:
dialogSpecs="width=470; height=620; temporary=0; input=1; noframe=0";
dialogSpecs="width=470; height=550; temporary=0; input=1; noframe=0"]
[h:formAction=macroLinkText("evalAttack@"+getMacroLocation(),"all","",currentToken())]
[dialog("meleeAttack", dialogSpecs): {
<html>
<head>
<link rel="stylesheet" type="text/css" href="DialogCSS@Lib:GURPS">
<title>Choose Target and Method of Attack</title>
</head>
<body>
<form name="attack" action="[r:formAction]">
<input type="hidden" name="weaponUsedIndex" value="[r:weaponUsedIndex]">
<input type="hidden" name="methodUsed" value="[r:methodUsed]">
<h1>[r:upper(json.get(weaponUsed,"name"),1)] [r:json.get(weaponUsed,methodUsed+"descr")] at base skill [r:json.get(weaponUsed,methodUsed+"skill")]</h1>
[r:msg]
<table width="100%" cellspacing="1" cellpadding="2">
<tr>
[foreach(possTarget, targetList,""),code:{
[token(possTarget),if(getProperty("HP")==getProperty("maxHP")),h: tokenHealth="healthy"; tokenHealth="injured"]
[token(possTarget),if(getState("healthy")==1),h: tokenHealth="healthy"]
[token(possTarget),if(getState("injured")==1),h: tokenHealth="injured"]
[token(possTarget),if(getState("maimed")==1),h: tokenHealth="maimed"]
[token(possTarget),if(getState("dying")==1),h: tokenHealth="dying"]
<!-- Start a new row of possible targets if you have an even multiple of START_NEW_ROW setting. Wanted: XmodY.-->
[if( roll.count/START_NEW_ROW==floor(roll.count/START_NEW_ROW)), r : "</tr><tr>";""]
<td valign="top" align="center">
<img src="[token(possTarget),r:getTokenImage(50)]"><br>
<b>[token(possTarget),r:getName()]</b><br>
[r:tokenHealth]<br>
<input type="radio" name="targetID" value="[r:possTarget]" [r:checkedIfOneTarget]></td>
}]
</tr>
</table>
<h1>Select skill modifiers for circumstances and style of attack</h1>
<b>Maneuver Effects: [r:manSkillBonus]</b><input type="hidden" name="maneuver" value="[r:manSkillBonus]">
<br><span style=color:gray>[r:currManeuverName] - [r:json.get(currManeuver,"descr")].</span>
<br>
[h, if(getProperty("shock")==0): textColor="gray";textColor="red"]
<span style=color:[r:textColor]><b>Shock Penalty: [r:shock]</b></span><input type="hidden" name="shock" value="[r:shock]">
<br>
[h, if(posture=="standing"): textColor="gray";textColor="red"]
<span style=color:[r:textColor]><b>Posture: [r:posture]: [r:attackerPostureMod]</b></span><input type="hidden" name="attackerPostureMod" value="[r:attackerPostureMod]">
<br><br>
<table cellspacing="0" cellpadding="0">
<tr class="oddRow">
<th valign="middle">Other Modifiers</th>
<td align="center"><input type="radio" name="miscMod" value="-10"></td>
<td align="center"><input type="radio" name="miscMod" value="-9"></td>
<td align="center"><input type="radio" name="miscMod" value="-8"></td>
<td align="center"><input type="radio" name="miscMod" value="-7"></td>
<td align="center"><input type="radio" name="miscMod" value="-6"></td>
<td align="center"><input type="radio" name="miscMod" value="-5"></td>
<td align="center"><input type="radio" name="miscMod" value="-4"></td>
<td align="center"><input type="radio" name="miscMod" value="-3"></td>
<td align="center"><input type="radio" name="miscMod" value="-2"></td>
<td align="center"><input type="radio" name="miscMod" value="-1"></td>
<td align="center"><input type="radio" name="miscMod" value="0" checked></td>
<td align="center"><input type="radio" name="miscMod" value="1"></td>
<td align="center"><input type="radio" name="miscMod" value="2"></td>
<td align="center"><input type="radio" name="miscMod" value="3"></td>
<td align="center"><input type="radio" name="miscMod" value="4"></td>
<td align="center"><input type="radio" name="miscMod" value="5"></td>
<td align="center"><input type="radio" name="miscMod" value="6"></td>
<td align="center"><input type="radio" name="miscMod" value="7"></td>
<td align="center"><input type="radio" name="miscMod" value="8"></td>
<td align="center"><input type="radio" name="miscMod" value="9"></td>
<td align="center"><input type="radio" name="miscMod" value="10"></td></tr>
<tr class="oddRow">
<th valign="middle"> </th>
<td align="center">-10</td>
<td align="center"> </td>
<td align="center">-8</td>
<td align="center"> </td>
<td align="center">-6</td>
<td align="center"> </td>
<td align="center">-4</td>
<td align="center"> </td>
<td align="center">-2</td>
<td align="center"> </td>
<td align="center">0</td>
<td align="center"> </td>
<td align="center">2</td>
<td align="center"> </td>
<td align="center">4</td>
<td align="center"> </td>
<td align="center">6</td>
<td align="center"> </td>
<td align="center">8</td>
<td align="center"> </td>
<td align="center">10</td></tr>
<tr>
<td colspan="22"> </td></tr>
<tr>
<th valign="middle" colspan="3">Other Large Modifiers</th>
<td align="left" colspan="19"><input type="text" name="largeMod" value="0" size="2" maxlength="3"></td>
</table>
[macro("bodyPartTable@"+ getMacroLocation()):""]
<p align="center"> <input type="submit" value="attack!"> <input type="reset" value="reset to defaults"></p></form></body></html>
}]
<!-- passes targetID, weaponUsedIndex, methodUsed, maneuver, shock, attackerPostureMod, miscMod, largeMod, targetedLocObj (region, penalty) -->