NewsUnrealEdForumsFilesModsFragBU

Skin

BeyondUnreal


Personal tools

File talk:UT3 Raptor primary damage.png

From Liandri Archives

Revision as of 13:16, 16 February 2014 by WGH (talk | contribs) (Created page with "Here's is the source code if someone wants to improve the figure: <pre> #!/usr/bin/env python3 import numpy as np import matplotlib.pyplot as plt base_damage = 20 base_life_spa...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Here's is the source code if someone wants to improve the figure:

#!/usr/bin/env python3

import numpy as np
import matplotlib.pyplot as plt

base_damage = 20
base_life_span = 1.6
max_speed = 12500.0
base_speed = 2000.0
accel_rate = 20000.0

def damage(time_in_flight):
    life_span = base_life_span - time_in_flight
    speed = min(base_speed + time_in_flight * accel_rate, max_speed)

    if life_span <= 0:
        return 0
    elif life_span < 1.0:
        return 0.75 * base_damage
    else:
        return base_damage * min(2.0, (max_speed / speed) ** 2)

# note: function unused, and might be wrong
def distance(time_in_flight):
    t = min(base_life_span, time_in_flight)
    t1 = (max_speed - base_speed) / accel_rate # time to obtain max speed

    assert t1 == 0.525

    if t < t1:
        return base_speed * t + accel_rate * t * t
    else:
        return base_speed * t1 + accel_rate * t1 * t1 + max_speed * (t - t1)

def main():
    t = np.linspace(0.0, 1.7, 1000)
    damage_t = np.vectorize(damage)(t)
    distance_t = np.vectorize(distance)(t)

    plt.title("Raptor primary fire damage scaling")
    plt.xlabel("Time in flight")
    plt.ylabel("Damage")

    plt.plot(t, damage_t)
    plt.axis([0.0, 1.7, 0.0, 50])
    plt.yticks([40, 30, 20, 15, 10, 0])
    plt.grid()
    
    plt.annotate("Projectile's life span ends", xy=(1.6, 15.0), xytext=(1.0, 20), arrowprops=dict(arrowstyle="->"))

    plt.subplots_adjust(bottom=0.2)

    plt.show()

if __name__ == "__main__":
    main()

--WGH 13:16, 16 February 2014 (CST)