@Wolph42 thanks, something I wanted to do since 2013 xD, Im currently adding Las,Single, semi, autoo, Plasma single, semi, overcharged, Bolter, single, semi, auto, Heavy bolter auto, chain weapon, hit, miss and idle. Heres my archive:
https://archive.org/details/@razorfiend
Hey thanks Aliasmask! First off, Im very grateful for your assistance, you clearly know this programming very well!
Ok I see I should explain a bit xD this is a D100 based system.
TB is Toughness bonus - the first digit of the Toughness stat - and is deducted from nearly ALL damage, so 50% Toughness = TB 5
Toughness is not affected by Penetration.
Ag is agility and the base Dodge chance - however skill dodge can be bought to+10 or +20, dodging completely negates damage.
AP = Armor points These are actually often different pr body part, so in its final form the macro should use the hitlocation to get
HeadAP:0
BodyAP:0
ArmLeftAP:0
ArmRightAP:0
LegLeftAP:0
LegRightAP:0 - at the moment I use just a AP stat because *Im just a script kitty*
Defence is a dodge, which in wh40k Deathwatch negates 1 hit pr success. Defined as if my Ag is 30 and I have Dodge +20 - I roll d100 ~ 30
-I succeeded with 2 degrees EG. I dodge 3 hits, one for succeeding plus 2 for the degrees.
The correct battle mechanic therefore would be
1-Test BS to hit (in Full auto this is +20 and a hit pr degree, in semi its +10 and a hit pr second degree.
So a semi auto attack is rol d100- test vs my imput BS (because its easier to enter BS by hand due to many many modifiers) calculate potential hits.
2-Test Ag+dodge vs d100 for defender and see if any hits are negated.
3-Apply and output results..
So with those denountions in mind Id change skill to Dodge, like so
Code: Select all
[h:switchToken(getSelected())]
[h:abort(input(
"BSInput|0|BS",
"fullAuto|Single,Full Auto auto|Single or Full Auto|RADIO|SELECT=0"
))]
<!-- ag and skill should be properties of token (I would use better names though) -->
[h:attackRoll = 1d100]
(attackRoll >= BS)
<!--Calculate degrees and hits-->
[H: attackDiff = BS vs d100]
[H: defense = Ag + Dodge]
[H: defence roll = d100]
<!-- Magical comparison of number of degrees BS hits Vs Dodge-->
[H: armorDefense = getProperty("AP")]
[H: mysteryStat = getProperty("Tb")]
[H: weaponDamage = "2d10+5"]
[h: Pen = 5]
<!-- test for 0, 1 hit and every +10 after that -->
[H, if(attackDiff >= 0): successes = if(fullAuto,1 + floor(attackDiff / 10),1); successes = 0]
<!-- generate basic attack info -->
[H, if(fullAuto && successes): attackOutput = strformat("%{token.name} is attacked with Bolter (%{weaponDamage}), full auto. Is hit %{successes} time(s).")]
[H, if(! fullAuto && successes): attackOutput = strformat("%{token.name} is attacked with Bolter (%{weaponDamage}), single shot. Is hit 1 time.")]
[H, if(! successes): attackOutput = strformat("%{token.name} is attacked with Bolter. Miss.")]
<!-- calc damage -->
[H: totalDamage = 0]
[H, c(successes), code: {
[H: hitLocation = tbl("HitLocation")]
[H: damage = max(0,eval(weaponDamage) - max(0,armorDefense - Pen) - mysteryStat)]
<!-- add damage to attack output -->
[H, if(damage): attackOutput = json.append(attackOutput,strformat("Shot %d: %{damage} to location %{hitLocation}",roll.count +1));
attackOutput = json.append(attackOutput,strformat("Shot %d: Absorbed by armor."))
]
[H: totalDamage = totalDamage + damage]
}]
<!-- update health and states -->
[H: Wounds = max(-10,Wounds - totalDamage)]
[h: state.Dead = if(Wounds <= -10, 1, 0)]
[h: state.Critical_wound = if(Wounds < 0 && Wounds > -10, 1, 0)]
[h: state.Wounded = if(Wounds < MaxWounds/2 && Wounds >= 0, 1, 0)]
[h: state.Lightly_Wounded = if(Wounds < MaxWounds/3 && Wounds >= MaxWounds/2, 1, 0)]
<!-- special effects at the end -->
[H, if(fullAuto): link = "https://ia601501.us.archive.org/7/items/bolter-autofire/Bolter%20Autofire.mp3";
link = "https://ia601508.us.archive.org/29/items/Boltersinglefire/Boltersinglefire.mp3"
]
[H: execFunction("playClip",json.append("",link),1,"all")]
<!-- output -->
[R: json.toList(attackOutput,"<BR>")]