mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-02-24 17:13:34 +00:00
working comet calculations
This commit is contained in:
parent
80c1a34fb0
commit
a79fc6bd2f
5 changed files with 107 additions and 26 deletions
|
|
@ -4,6 +4,14 @@ import net.psforever.objects.equipment.TargetValidation
|
|||
import net.psforever.objects.serverobject.aggravated.Aura
|
||||
import net.psforever.objects.vital.DamageType
|
||||
|
||||
final case class AggravatedTiming(duration: Long, ticks: Option[Int])
|
||||
|
||||
object AggravatedTiming {
|
||||
def apply(duration: Long): AggravatedTiming = AggravatedTiming(duration, None)
|
||||
|
||||
def apply(duration: Long, ticks: Int): AggravatedTiming = AggravatedTiming(duration, Some(ticks))
|
||||
}
|
||||
|
||||
final case class AggravatedInfo(damage_type: DamageType.Value,
|
||||
degradation_percentage: Float,
|
||||
infliction_rate: Long) {
|
||||
|
|
@ -12,13 +20,44 @@ final case class AggravatedInfo(damage_type: DamageType.Value,
|
|||
|
||||
final case class AggravatedDamage(info: List[AggravatedInfo],
|
||||
effect_type: Aura,
|
||||
duration: Long,
|
||||
timing: AggravatedTiming,
|
||||
max_factor: Float,
|
||||
cumulative_damage_degrade: Boolean,
|
||||
vanu_aggravated: Boolean,
|
||||
targets: List[TargetValidation])
|
||||
|
||||
object AggravatedDamage {
|
||||
def apply(info: AggravatedInfo,
|
||||
effect_type: Aura,
|
||||
timing: AggravatedTiming,
|
||||
max_factor: Float,
|
||||
targets: List[TargetValidation]): AggravatedDamage =
|
||||
AggravatedDamage(
|
||||
List(info),
|
||||
effect_type,
|
||||
timing,
|
||||
max_factor,
|
||||
cumulative_damage_degrade = true,
|
||||
vanu_aggravated = false,
|
||||
targets
|
||||
)
|
||||
|
||||
def apply(info: AggravatedInfo,
|
||||
effect_type: Aura,
|
||||
timing: AggravatedTiming,
|
||||
max_factor: Float,
|
||||
vanu_aggravated: Boolean,
|
||||
targets: List[TargetValidation]): AggravatedDamage =
|
||||
AggravatedDamage(
|
||||
List(info),
|
||||
effect_type,
|
||||
timing,
|
||||
max_factor,
|
||||
cumulative_damage_degrade = true,
|
||||
vanu_aggravated,
|
||||
targets
|
||||
)
|
||||
|
||||
def apply(info: AggravatedInfo,
|
||||
effect_type: Aura,
|
||||
duration: Long,
|
||||
|
|
@ -27,7 +66,7 @@ object AggravatedDamage {
|
|||
AggravatedDamage(
|
||||
List(info),
|
||||
effect_type,
|
||||
duration,
|
||||
AggravatedTiming(duration),
|
||||
max_factor,
|
||||
cumulative_damage_degrade = true,
|
||||
vanu_aggravated = false,
|
||||
|
|
@ -43,7 +82,7 @@ object AggravatedDamage {
|
|||
AggravatedDamage(
|
||||
List(info),
|
||||
effect_type,
|
||||
duration,
|
||||
AggravatedTiming(duration),
|
||||
max_factor,
|
||||
cumulative_damage_degrade = true,
|
||||
vanu_aggravated,
|
||||
|
|
|
|||
|
|
@ -122,19 +122,27 @@ trait AuraEffectBehavior {
|
|||
case Some(list) => effectToEntryId -> (list :+ id)
|
||||
}
|
||||
//setup timer data
|
||||
val tick = 1000 //each second
|
||||
val duration = aggravation.duration
|
||||
val iterations = (duration / tick).toInt
|
||||
val leftoverTime = duration - (iterations * tick)
|
||||
val timing = aggravation.timing
|
||||
val duration = timing.duration
|
||||
val (tick: Long, iterations: Int) = timing.ticks match {
|
||||
case Some(n) if n < 1 =>
|
||||
val rate = info.infliction_rate
|
||||
(rate, (duration / rate).toInt)
|
||||
case Some(ticks) =>
|
||||
(duration / ticks, ticks)
|
||||
case None =>
|
||||
(1000, (duration / 1000).toInt)
|
||||
}
|
||||
val leftoverTime = duration - (tick * iterations)
|
||||
//quality per tick
|
||||
val totalPower = (duration.toFloat / info.infliction_rate).toInt - 1
|
||||
val averagePowerPerTick = math.max(1, totalPower.toFloat / iterations).toInt
|
||||
val averagePowerPerTick = totalPower.toFloat / iterations
|
||||
val lastTickRemainder = totalPower - averagePowerPerTick * iterations
|
||||
val qualityPerTick: List[Int] = if (lastTickRemainder > 0) {
|
||||
0 +: List.fill[Int](iterations - 1)(averagePowerPerTick) :+ (lastTickRemainder + averagePowerPerTick)
|
||||
val qualityPerTick: List[Float] = if (lastTickRemainder > 0) {
|
||||
0f +: List.fill[Float](iterations - 1)(averagePowerPerTick) :+ (lastTickRemainder + averagePowerPerTick)
|
||||
}
|
||||
else {
|
||||
0 +: List.fill[Int](iterations)(averagePowerPerTick)
|
||||
0f +: List.fill[Float](iterations)(averagePowerPerTick)
|
||||
}
|
||||
//pair id with entry
|
||||
PairIdWithAggravationEntry(id, effect, tick, data, data.target, qualityPerTick)
|
||||
|
|
@ -150,7 +158,7 @@ trait AuraEffectBehavior {
|
|||
retime: Long,
|
||||
data: ResolvedProjectile,
|
||||
target: SourceEntry,
|
||||
powerOffset: List[Int]
|
||||
powerOffset: List[Float]
|
||||
): AuraEffectBehavior.Entry = {
|
||||
val aggravatedDamageInfo = ResolvedProjectile(
|
||||
AuraEffectBehavior.burning(data.resolution),
|
||||
|
|
@ -224,21 +232,22 @@ trait AuraEffectBehavior {
|
|||
|
||||
private def PerformAggravation(entry: AuraEffectBehavior.Entry, tick: Int = 0) : Unit = {
|
||||
val data = entry.data
|
||||
val info = ResolvedProjectile(
|
||||
val model = data.damage_model
|
||||
val aggravatedProjectileData = ResolvedProjectile(
|
||||
data.resolution,
|
||||
data.projectile.quality(entry.qualityPerTick(tick).toFloat),
|
||||
data.projectile.quality(entry.qualityPerTick(tick)),
|
||||
data.target,
|
||||
data.damage_model,
|
||||
model,
|
||||
data.hit_pos
|
||||
)
|
||||
TakesDamage.apply(Vitality.Damage(info.damage_model.Calculate(info)))
|
||||
TakesDamage.apply(Vitality.Damage(model.Calculate(aggravatedProjectileData)))
|
||||
}
|
||||
}
|
||||
|
||||
object AuraEffectBehavior {
|
||||
type Target = PlanetSideServerObject with Vitality with AuraContainer
|
||||
|
||||
private case class Entry(id: Long, effect: Aura, retime: Long, data: ResolvedProjectile, qualityPerTick: List[Int])
|
||||
private case class Entry(id: Long, effect: Aura, retime: Long, data: ResolvedProjectile, qualityPerTick: List[Float])
|
||||
|
||||
private case class Aggravate(id: Long, iterations: Int, leftover: Long)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue