Weapon Exchange and Attacking

Doc requests, organization, and submissions

Moderators: Azhrei, dorpond, trevor

Post Reply
LastRose
Kobold
Posts: 10
Joined: Fri Apr 05, 2013 8:36 am

Weapon Exchange and Attacking

Post by LastRose »

If I submitted in the wrong area sorry...

Okay so I was trying to make a macro that would work with three other macros. The three macros are when I'd be wielding a light mace, a longsword, and a javelin. The latter of the three on a near identical only using Dexmod for attack instead of Strmod.

I was wondering if there was a better way to do this, or a way to make this all into one macro so I could select between the two melee weapons in a window, that would modify the 1d4 to a 1d8, and add the +1 to attack for the longsword. After that I could make a duplicate and edit to make a ranged version with a second one.

With the way that I made the macro I couldn't make a critical confirm macro at the end, though considering the longsword has a different crit that would probably be too much trouble then what it's worth.

This was my attempt, so that maybe I could explain things a bit better with it, I also didn't want to just ask without trying myself for an hour or two....

Side note: Misc2-5 are there for expansion

Code 1:

Code: Select all

[h:A2=Ability2]
[h,if(A2 >= 1),code:
{
    [if(A2 == 1),code:
{
    [h:damage=1d8]
};
{
[h:damage=1d4]
}]
};
]
<table border="0">
  <tr bgcolor="#CC0000">
    <table width="100%">
      <tr>
        <td style="padding:0px 5px;">
          <span style="color:white"><b>Stike True {Ability1}!</b></font>
          <span style="color:Green"> <br>Zanward has a +[t:Attack1Bonus=Bab+Strmod+Misc1+Misc2+Misc3] to Attack</font>
        </td>
      </tr>
    </table>
  </tr>
  <tr>
    <td>
      Zanward Greyhunt swings his {Ability1} ([t:roll=1d20]+ [t:Attack1Bonus] = {results=roll+Attack1bonus}) and does ([t:damage+strmod+Misc4+Misc5]) damage!

   </td>
  </tr>
</table>


Code 2,3,4 (Pretty Much):

Code: Select all

[t:Ability1="Hammer, light"]
[h:Misc1=0]
[h:Ability2=2]

User avatar
wolph42
Deity
Posts: 9707
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Weapon Exchange and Attacking

Post by wolph42 »

its too vague for me what you actually want to achieve.

You have three weapons and they all three have small differences. can you point out in a table what those differences are and what the ranges of values are... e.g. this:

Code: Select all

[h,if(A2 >= 1),code:{
    [if(A2 == 1),code:{
        [h:damage=1d8]
    };{
        [h:damage=1d4]
    }]
}]
 
looks rather convoluted, what happens if A2 < 0 ? is that possible in your case (your code will break then btw).
If you use e.g. this:

Code: Select all

[h,if(A2 == 1),code:{
    [damage=1d8]
};{
    damage=1d4]
}]
 

then at least your code can't break, which you can write as

Code: Select all

[h,if(A2 == 1):    damage=1d8 ; damage=1d4] 

or even faster:

Code: Select all

[h: damage    = if(A2 == 1, 1d8, 1d4)] 

LastRose
Kobold
Posts: 10
Joined: Fri Apr 05, 2013 8:36 am

Re: Weapon Exchange and Attacking

Post by LastRose »

Honestly, no the code will never be 0 since longsword adds 1, hammer is 2, and javelin is 3. One and two, and two and three are separated as pairs since one uses dexmod, rather then str mod to damage.

But thank you for tips of how to condense it, it'll make it look better, and not be one giant mess.

User avatar
wolph42
Deity
Posts: 9707
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Weapon Exchange and Attacking

Post by wolph42 »

well since you failed to give the table, I just made some stuff up. This is roughly where you should be heading to, both in structure of code (input, calc, output) as in fast execution. You can add the html flavour ofcourse and since that is all 'string' you can just add that to the txtOutPut variable.

Code: Select all

<!-- INPUT -->
[
h:tok    getSelectedNames()]
[
h:assert(listCount(tok)==1,"Please select (only) one token first",0)]
[
h:switchToken(tok)]
[
h:input("weapon|Longsword,Hammer,Javelin|Choose weapon|RADIO|VALUE=STRING SELECT=1")]

<!-- 
CALCULATIONS -->
[
h,switch(weapon),code:
case 
"Longsword": {
    [
damage        1d8]
    [
addDamage    dexMod]
};
case 
"Hammer": {
    [
damage        1d4]
    [
addDamage    dexMod]
};
case 
"Javelin": {
    [
damage        1d8]
    [
addDamage    strMod]
};
default: {
    [
assert(0,strformat("You chose %{weapon}, which is not a valid choice"),0)]
}]
[
h:totalDamage    damage addDamage misc]

<!-- 
OUTPUT -->
[
h:txtOutPut    strformat("%{tok} strikes with his/her %{weapon} and does %{totalDamage} (roll=%{damage}, mod=%{addDamage}, misc=%{misc}).")]

[
r:txtOutPut]
<!-- OR -->
[
h:broadcast(txtOutPut)]
 


UNTESTED!!

User avatar
shizuo
Kobold
Posts: 1
Joined: Fri Oct 24, 2014 10:59 pm

Re: Weapon Exchange and Attacking

Post by shizuo »

Please Identify the range and the proper codes to re-code it and by the way can you put some print screen about the weapons form?

Post Reply

Return to “Documentation Requests/Discussion”