RPTools.net
http://forums.rptools.net/

Weapon Exchange and Attacking
http://forums.rptools.net/viewtopic.php?f=12&t=25367
Page 1 of 1

Author:  LastRose [ Tue Sep 09, 2014 5:47 pm ]
Post subject:  Weapon Exchange and Attacking

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:
[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:
[t:Ability1="Hammer, light"]
[h:Misc1=0]
[h:Ability2=2]

Author:  wolph42 [ Wed Sep 10, 2014 2:00 am ]
Post subject:  Re: Weapon Exchange and Attacking

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:
[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:
[h,if(A2 == 1),code:{
    [damage=1d8]
};{
    damage=1d4]
}]
 

then at least your code can't break, which you can write as
Code:
[h,if(A2 == 1):    damage=1d8 ; damage=1d4] 

or even faster:
Code:
[h: damage    = if(A2 == 1, 1d8, 1d4)] 

Author:  LastRose [ Wed Sep 10, 2014 8:14 pm ]
Post subject:  Re: Weapon Exchange and Attacking

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.

Author:  wolph42 [ Thu Sep 11, 2014 2:27 am ]
Post subject:  Re: Weapon Exchange and Attacking

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:
<!-- 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!!

Author:  shizuo [ Fri Oct 24, 2014 10:10 pm ]
Post subject:  Re: Weapon Exchange and Attacking

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?

Page 1 of 1 All times are UTC - 6 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/