23 public static boolean CRITS =
false;
35 public void applyEffectsAfterShipCreation(ShipAPI ship, String
id) {
36 ship.addListener(
new RangedSpecDamageDealtMod());
39 public void unapplyEffectsAfterShipCreation(ShipAPI ship, String
id) {
40 ship.removeListenerOfClass(RangedSpecDamageDealtMod.class);
43 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String
id,
float level) {}
44 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String
id) {}
46 public String getEffectDescription(
float level) {
50 public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill,
51 TooltipMakerAPI info,
float width) {
55 info.addPara(
"Ballistic and energy weapons have a chance to deal %s damage at long range",
57 info.addPara(
indent +
"%s chance at %s range and below, " +
58 "%s chance at %s range and above",
66 info.addPara(
"Ballistic and energy weapons deal up to %s damage at long range",
68 info.addPara(
indent +
"%s at %s range and below, " +
69 "%s at %s range and above",
80 public ScopeDescription getScopeDescription() {
81 return ScopeDescription.PILOTED_SHIP;
85 public static class Level2
implements ShipSkillEffect {
86 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String
id,
float level) {
90 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String
id) {
91 stats.getProjectileSpeedMult().unmodify(
id);
94 public String getEffectDescription(
float level) {
95 return "+" + (int)(
PROJ_SPEED_BONUS) +
"% ballistic and energy projectile speed";
98 public String getEffectPerLevelDescription() {
102 public ScopeDescription getScopeDescription() {
103 return ScopeDescription.PILOTED_SHIP;
108 public static class RangedSpecDamageDealtMod
implements DamageDealtModifier {
109 public String modifyDamageDealt(Object param,
110 CombatEntityAPI target, DamageAPI damage,
111 Vector2f point,
boolean shieldHit) {
112 if (param instanceof MissileAPI)
return null;
114 Vector2f from =
null;
115 if (param instanceof DamagingProjectileAPI) {
116 from = ((DamagingProjectileAPI)param).getSpawnLocation();
117 }
else if (param instanceof BeamAPI) {
118 from = ((BeamAPI)param).getFrom();
123 float chancePercent = 0f;
124 float dist = Misc.getDistance(from, point);
136 if (chancePercent <= 0)
return null;
140 Vector2f vel =
new Vector2f();
141 if (target instanceof ShipAPI) {
142 vel.set(target.getVelocity());
145 if (param instanceof DamagingProjectileAPI) {
147 if ((
float) Math.random() < chancePercent * 0.01f) {
148 id =
"ranged_spec_dam_mod";
153 id =
"ranged_spec_dam_mod";
154 damage.getModifier().modifyPercent(
id, chancePercent);
157 }
else if (param instanceof BeamAPI) {
159 if ((
float) Math.random() < chancePercent * 0.01f) {
160 id =
"ranged_spec_dam_mod";
165 id =
"ranged_spec_dam_mod";
166 damage.getModifier().modifyPercent(
id, chancePercent);