here a much newer version of the attack code
Code:
Sub Burst()
'Reading in values
Location = Range("b1").Value 'Body Part attack by Aimed Shot, 1 = unaimed
D = Range("d1").Value 'Distance
ACMod = Range("e1").Value 'Misc AC-modifier
AMDMG = Range("f1").Value 'Ammo Damage Modifier
AMDR = Range("g1").Value 'Ammo DR Modifier
AMAC = Range("h1").Value 'Ammo AC Modifier
WR = Range("i1").Value 'Weapon Range
WL = Range("j1").Value 'Weapon Damage Lower Bound
WU = Range("k1").Value 'Weapon Damage Upper Bound
RoF = Range("l1").Value 'Rate of Fire
MR = Range("m1").Value 'Misrange
CON = Range("n1").Value 'Condition
WType = Range("o1").Value 'Weapon Type n N Normal f F Fire p P Plasma e E Electricity g G Gas
Skill = Range("p1").Value 'Skill
p = Range("q1").Value 'Perception
l = Range("r1").Value 'Luck
CC = Range("s1").Value 'Critical Chance
CT = Range("t1").Value 'Critical Table Roll Modification
CMio = Range("u1").Value 'Critical One in a Million
ACAC = Range("y1").Value 'Armor-AC
Select Case (WType)
Case "n"
ACDT = Range("z1").Value 'Armor-DT
ACDR = Range("aa1").Value 'Armor-DR
Case "l"
ACDT = Range("ab1").Value 'Armor-DT
ACDR = Range("ac1").Value 'Armor-DR
Case "f"
ACDT = Range("ad1").Value 'Armor-DT
ACDR = Range("ae1").Value 'Armor-DR
Case "p"
ACDT = Range("af1").Value 'Armor-DT
ACDR = Range("ag1").Value 'Armor-DR
Case "e"
ACDT = Range("ah1").Value 'Armor-DT
ACDR = Range("ai1").Value 'Armor-DR
Case "g"
ACDT = Range("aj1").Value 'Armor-DT
ACDR = Range("ak1").Value 'Armor-DR
End Select
Debug.Print ACAC, ACDT, ACDR
'Creation of variables and assignment of values
BTH = 0 'Base to Hit
Hits = 0 'Numbers of hits caused by the burst
CRITS = 0 'Number of Criticals
DMG = 0 'Damage dealed
CKD = 0 'Chance of Knock Down
KO = 0 'Knock Out
ID = 0 'Instand Death"
IA = 0 'Ignores Armor
CB = 0 'Chance to cause Blindness
B = 0 'Blindness
LT = 0 'Lose Turn
CCA = 0 'Chance Crippled Arm
CA = 0 'Crippled Arm
CCL = 0 'Chance Crippled Leg
CL = 0 'Crippled Leg
HHead = 0 'Number of shots which hit the Head
HEyes = 0 'Number of shots which hit the Eyes
HTorso = 0 'Number of shots which hit the Torso
HGroin = 0 'Number of shots which hit the Groin
HArms = 0 'Number of shots which hit the Arms
HLegs = 0 'Number of shots which hit the Legs
Shot = 0 'Shot fired
Multi = 1 'Critical Hit Damage Multiplier
RM = 1 'Damage Modifier due Armor and Weapon for internal calculations
CHE = 0 'Critical Hit Effect
CIA = False 'Current Critical Hit ignores armor
CMioC = True 'Critical confirmation variable for One in a Million Trait
RI = 0 'Range Increment
Aimed = False 'Aimed Shot
AMTH = 0 'Modifier to "to Hit" based on sort of attack
AMCC = 0 'Modifier to Critical Chance based on sort of attack
'Definition of Critical Hit allocation; Cummulated
CHead = 11 '11% Chance to hit the Head
CEyes = 17 '6% Chance to hit the Eyes
CTorso = 50 '33% Chance to hit the Torso
CGroin = 65 '15% Chance to hit the Groin
CArms = 80 '15% Chance to hit the Arms
CLegs = 100 '20% Chance to hit the Legs
'Checking if Attack is Aimed
If Location = 1 Then
Aimed = False
Else
Aimed = True
End If
Select Case (Location)
Case 1 'Unaimed Shot
AMTH = 0
AMCC = 0
Case 2 'Aimed Shot - Head
AMTH = -40
AMCC = 20
Case 3 'Aimed Shot - Eyes
AMTH = -60
AMCC = 30
Case 4 'Aimed Shot - Torso
AMTH = 0
AMCC = 0
Case 5 'Aimed Shot - Groin
AMTH = -30
AMCC = 15
Case 6 'Aimed Shot - Arms
AMTH = -30
AMCC = 15
Case 7 'Aimed Shot - Legs
AMTH = -20
AMCC = 10
End Select
'Calculating AC
ACAC = ACAC + AMAC + ACMod
If ACAC < 0 Then
ACAC = 0
End If
'Calculating and capping Hit Chance at 95%
RI = Int(D / (WR + p))
BTH = Skill - RI * 10 - ACAC + AMTH
Select Case (BTH)
Case Is < 0
BTH = 0
Case Is > 95
BTH = 95
End Select
'Calculating Critical Chance
CC = CC + AMCC
'Calculating Resistance Modifier
ACDR = ACDR + AMDR
If ACDR < 0 Then
ACDR = 0
End If
RM = 1 - ACDR / 100
If RM < 0.1 Then
RM = 0.1
End If
'Calaculating Ammo Damage Modifier
AMDMG = 1 + AMDMG / 100
'Check if attacker has One in a Million Trait
If CMio = "" Then
CMio = False
Else
CMio = True
End If
'Check if Mishap accures
MR = 91 + CON - MR
If Int(100 * Rnd + 1) < MR Then
Range("j26").Interior.ColorIndex = 0
Range("j26").Value = ""
Else 'Check if lucky enough to not have a mishap
l = l * 10
If l > 95 Then
l = 95
End If
If Int(100 * Rnd + 1) > l Then
Select Case (Int(10 * Rnd + 1) + CON)
Case 20
Range("j26").Value = "Condition -1"
Case 19
Range("j26").Value = "Condition -1"
Case 18
Range("j26").Value = "Condition -1"
Case 17
Range("j26").Value = "Condition -1"
Case 16
Range("j26").Value = "Condition -1"
Case 15
Range("j26").Value = "Condition -2"
Case 14
Range("j26").Value = "Condition -2"
Case 13
Range("j26").Value = "Condition -2, Lose Ammo"
Case 12
Range("j26").Value = "Condition -2, Lose Ammo"
Case 11
Range("j26").Value = "Condition -3, Lose Ammo"
Case 10
Range("j26").Value = "Condition -3, Jam"
Case 9
Range("j26").Value = "Condition -3, Lose Ammo, Jam"
Case 8
Range("j26").Value = "Condition -3, Lose all Ammo, Jam"
Case 7
Range("j26").Value = "Condition -3, Repair needed"
Case 6
Range("j26").Value = "Condition -3, Special Destroyed or Repair needed"
Case 5
Range("j26").Value = "Weapon destroyed"
Case 4
Range("j26").Value = "Weapon and all Specials destroyed"
Case 3
Range("j26").Value = "Destruction of the Weapon causes a hit against the wielder"
Case 2
Range("j26").Value = "Destruction of the Weapon causes a critical hit against te wielder"
End Select
Else
Range("j26").Value = "Better lucky then good!"
End If
Range("j26").Interior.ColorIndex = 8
End If
'Shot RoF times
Do While Shot < RoF
Shot = Shot + 1
'Check is Shot hits
If Int(100 * Rnd + 1) < (BTH + 1) Then
Hits = Hits + 1
'One in A Million Trait Test
If CMio = True Then
If Int(100 * Rnd + 1) < ((CC * 5) + 1) Then
CMioC = True
Else
CMioC = False
End If
End If
'Check if Critical Hit
If Int(100 * Rnd + 1) < (CC + 1) And CMioC = True Then
CRITS = CRITS + 1
'Determine Bodypart hit by the Critical
If Aimed = False Then
Location = Int(100 * Rnd + 1)
Select Case (Location)
Case Is < 11 '11% Chance to hit the Head
Location = 2
Case 11 To 17 '6% Chance to hit the Eyes
Location = 3
Case 18 To 50 '33% Chance to hit the Torso
Location = 4
Case 51 To 65 '15% Chance to hit the Groin
Location = 5
Case 66 To 80 '15% Chance to hit the Arms
Location = 6
Case 81 To 100 '20% Chance to hit the Legs
Location = 7
End Select
End If
'Determine the severeness of the Critical
CHE = Int(100 * Rnd + 1) + CT
'Determining the effect of the Critical Hit
Select Case (Location)
Case 2 'Head
HHead = HHead + 1
Select Case (CHE)
Case Is < 46
Multi = 2
Case 46 To 90
Multi = 2
CKD = CKD + 1
Case 91 To 100
Multi = 2
KO = KO + 1
Case Is > 100
Multi = 2
ID = ID + 1
End Select
Case 3 'Eyes
HEyes = HEyes + 1
Select Case (CHE)
Case Is < 21
Multi = 2
Case 21 To 45
Multi = 2
CB = CB + 1
CIA = True
Case 46 To 70
Multi = 3
C = CB + 1
CIA = True
Case 71 To 90
Multi = 3
B = B + 1
LT = LT + 1
CIA = True
Case 91 To 100
Multi = 4
B = B + 1
ID = ID + 1
CIA = True
Case Is > 100
Multi = 4
ID = ID + 1
End Select
Case 4 'Torso
HTorso = HTorso + 1
Select Case (CHE)
Case Is < 46
Multi = 1.5
Case 46 To 70
Multi = 2
Case 71 To 100
Multi = 2
CIA = True
Case Is > 100
Multi = 3
ID = ID + 1
End Select
Case 5 'Groin
HGroin = HGroin + 1
Select Case (CHE)
Case Is < 21
Multi = 1.5
Case 21 To 70
Multi = 1.5
CIA = True
Case 71 To 100
Multi = 2
CIA = True
Case Is > 100
Multi = 3
CIA = True
End Select
Case 6 'Arms
HArms = HArms + 1
Select Case (CHE)
Case Is < 46
Multi = 1.5
Case 46 To 90
Multi = 2
CCA = CCA + 1
Case Is > 90
Multi = 2
CA = CA + 1
End Select
Case 7 'Legs
HLegs = HLegs + 1
Select Case (CHE)
Case Is < 46
Multi = 1.5
Case 46 To 90
Multi = 2
CCL = CCL + 1
Case Is > 90
Multi = 2
CL = CL + 1
End Select
End Select
End If
'Calculating and accumulating Damage
If CIA = True Then
TempDMG = Int((WU - WL + 1) * Rnd + WL) * Multi * AMDMG
If TempDMG > 0 Then
DMG = DMG + TempDMG
End If
Else
TempDMG = Int((Int((WU - WL + 1) * Rnd + WL) * Multi * AMDMG - ACDT) * RM)
If TempDMG > 0 Then
DMG = DMG + TempDMG
End If
End If
'Clean up
Multi = 1
CIA = False
End If
Loop
'Writing Results
Range("a26").Value = Hits
If Hits <> 0 Then
Range("a26").Interior.ColorIndex = 7
Else
Range("a26").Interior.ColorIndex = 2
End If
Range("b26").Value = DMG
If DMG <> 0 Then
Range("b26").Interior.ColorIndex = 7
Else
Range("b26").Interior.ColorIndex = 2
End If
Range("c26").Value = CRITS
If CRITS <> 0 Then
Range("c26").Interior.ColorIndex = 7
Else
Range("c26").Interior.ColorIndex = 2
End If
Range("d26").Value = HHead
If HHead <> 0 Then
Range("d26").Interior.ColorIndex = 7
Else
Range("d26").Interior.ColorIndex = 2
End If
Range("e26").Value = HEyes
If HEyes <> 0 Then
Range("e26").Interior.ColorIndex = 7
Else
Range("e26").Interior.ColorIndex = 2
End If
Range("f26").Value = HTorso
If HTorso <> 0 Then
Range("f26").Interior.ColorIndex = 7
Else
Range("f26").Interior.ColorIndex = 2
End If
Range("g26").Value = HGroin
If HGroin <> 0 Then
Range("g26").Interior.ColorIndex = 7
Else
Range("g26").Interior.ColorIndex = 2
End If
Range("h26").Value = HArms
If HArms <> 0 Then
Range("h26").Interior.ColorIndex = 7
Else
Range("h26").Interior.ColorIndex = 2
End If
Range("i26").Value = HLegs
If HLegs <> 0 Then
Range("i26").Interior.ColorIndex = 7
Else
Range("i26").Interior.ColorIndex = 2
End If
Range("c27").Value = CKD
If CKD <> 0 Then
Range("c27").Interior.ColorIndex = 7
Else
Range("c27").Interior.ColorIndex = 2
End If
Range("d27").Value = LT
If LT <> 0 Then
Range("d27").Interior.ColorIndex = 7
Else
Range("d27").Interior.ColorIndex = 2
End If
Range("e27").Value = KO
If KO <> 0 Then
Range("e27").Interior.ColorIndex = 7
Else
Range("e27").Interior.ColorIndex = 2
End If
Range("f27").Value = ID
If ID <> 0 Then
Range("f27").Interior.ColorIndex = 7
Else
Range("f27").Interior.ColorIndex = 2
End If
Range("g27").Value = CB
If CB <> 0 Then
Range("g27").Interior.ColorIndex = 7
Else
Range("g27").Interior.ColorIndex = 2
End If
Range("h27").Value = B
If B <> 0 Then
Range("h27").Interior.ColorIndex = 7
Else
Range("h27").Interior.ColorIndex = 2
End If
Range("i27").Value = CCA
If CCA <> 0 Then
Range("i27").Interior.ColorIndex = 7
Else
Range("i27").Interior.ColorIndex = 2
End If
Range("j27").Value = CA
If CA <> 0 Then
Range("j27").Interior.ColorIndex = 7
Else
Range("j27").Interior.ColorIndex = 2
End If
Range("k27").Value = CCL
If CCL <> 0 Then
Range("k27").Interior.ColorIndex = 7
Else
Range("k27").Interior.ColorIndex = 2
End If
Range("l27").Value = CL
If CL <> 0 Then
Range("l27").Interior.ColorIndex = 7
Else
Range("l27").Interior.ColorIndex = 2
End If
End Sub
Bookmarks