Code: Select all
if($reload_f == 0) $reload_f = 1;
if ($row['is_melee'] == 1) // If this is a melee weapon
{
$dps = $dmg_hp / ($windup + $winddown + $cooldown);
}
elseif ($burst > 0) // If this is a ranged burst weapon
{
if ($row['is_missile'] == 1) // If it fires a missile but has burst for animation reasons, let's not fuck up DPS with burst formula
{
$dps = ($reload_f * $dmg_hp) / (($reload_f * ($windup + $winddown + $burst + $cooldown)) + $reload_d);
}
else // Otherwise it's an actual burst weapon
{
$dps = ($reload_f * $burst * $dmg_hp) / (($reload_f * ($windup + $winddown + $burst + $cooldown)) + $reload_d);
}
}
elseif (($windup + $winddown + $cooldown) > 0) // Otherwise it must be a ranged single-shot weapon, but check for division by zero
{
$dps = ($reload_f * $dmg_hp) / (($reload_f * ($windup + $winddown + $cooldown)) + $reload_d);
}
else // Same, but replace that bit by 1 if it was 0
{
$dps = ($reload_f * $dmg_hp) / (($reload_f * 1) + $reload_d);
}
The first part (if) is for melee weapons.
The second (the first elseif, with a sub-if and else) is for weapons with burst value.
The third (the second elseif) is for weapons without burst value, but with windup, winddown, or cooldown.
The fourth (else) is for anything else (hence the else : P).
reload_f + reload_d = reload frequency + reload duration
This is in the code Lulgrim wrote for the creation of the weapons pages in the Codex.
So here's the Kasrkin's grenade launchers as an example:
Not melee, no burst duration, but they do have windup+winddown+cooldown >0
So: DPS = (0 * 45) / (0 * ( .1 + .6 + 5) + 0); Clearly this equals zero, but the code also says to take reload frequency in this case to be 1 since you're just taking it to not be part of the equation. (see the top of the code)
So we have 45/5.7 = 7.89,
which is what it says in the codex.
And then if you reduce the cooldown by 1, which is what Weapon Expertise does, you get 45/4.7 = 9.57 dps. -> 21.3% increase in dps
So there ya go.
Edit2: Plasma Guns for fun and procrastination: Not melee, no burst, so same equation: reload frequency is 6 to 8, so take the average (7)
DPS = (7 * 40) / (7 * (0 + .5 + 1.5) + 3) = 16.47 dps
Whaddya know.With the weapon expertise granting -30% reload time, since 3 * .7 = 2.1:
(7 * 40) / (7 * (0 + .5 + 1.5) + 2.1) = 17.39 dps -> 5.59% increase in dps
Edit: Whoa, I have a blue thing.