Skip to content

Commit

Permalink
making lava no longer deadly; wait ...
Browse files Browse the repository at this point in the history
  • Loading branch information
Fate-JH committed Feb 23, 2024
1 parent 6790ced commit bed4983
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import net.psforever.objects.vital.environment.EnvironmentReason
import net.psforever.objects.vital.interaction.DamageInteraction
import net.psforever.objects.zones.InteractsWithZone

import scala.annotation.unused
import scala.concurrent.duration._

class WithLava()
extends InteractionWith {
val attribute: EnvironmentTrait = EnvironmentAttribute.Lava

private var stopBurn: Boolean = false

/**
* Lava causes players to take (considerable) damage until they inevitably die.
* @param obj the target
Expand All @@ -25,9 +26,11 @@ class WithLava()
def doInteractingWith(
obj: InteractsWithZone,
body: PieceOfEnvironment,
@unused data: Option[Any]
data: Option[Any]
): Unit = {
if (!obj.Destroyed) {
if (stopBurn && data.nonEmpty) {
stopBurn = false
} else if (!obj.Destroyed) {
obj.Actor ! Vitality.Damage(
DamageInteraction(
SourceEntry(obj),
Expand All @@ -37,7 +40,12 @@ class WithLava()
)
obj.Actor ! AuraEffectBehavior.StartEffect(Aura.Fire, duration = 1250L) //burn
//keep doing damage
obj.Actor ! RespondsToZoneEnvironment.Timer(attribute, delay = 250 milliseconds, obj.Actor, interaction.InteractingWithEnvironment(body, None))
obj.Actor ! RespondsToZoneEnvironment.Timer(attribute, delay = 250 milliseconds, obj.Actor, interaction.InteractingWithEnvironment(body, Some("burning")))
}
}

override def stopInteractingWith(obj: InteractsWithZone, body: PieceOfEnvironment, parentInfo: Option[Any]): Unit = {
stopBurn = true
obj.Actor ! RespondsToZoneEnvironment.StopTimer(attribute)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package net.psforever.objects.serverobject.environment.interaction

import akka.actor.{Actor, ActorRef, Cancellable}
import net.psforever.objects.Default
import net.psforever.objects.serverobject.environment.EnvironmentTrait
import net.psforever.objects.zones.InteractsWithZone

Expand Down Expand Up @@ -41,6 +42,7 @@ trait RespondsToZoneEnvironment {

case RespondsToZoneEnvironment.StopTimer(attribute) =>
interactionTimers.get(attribute).foreach(_.cancel())
interactionTimers.update(attribute, Default.Cancellable)

case InteractingWithEnvironment(body, optional) =>
applicableInteractions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import net.psforever.objects.vital.environment.EnvironmentReason
import net.psforever.objects.vital.interaction.DamageInteraction
import net.psforever.objects.zones.InteractsWithZone

import scala.annotation.unused
import scala.concurrent.duration._

class WithLava()
extends InteractionWith {
val attribute: EnvironmentTrait = EnvironmentAttribute.Lava

private var stopBurn: Boolean = false

/**
* Lava causes vehicles to take (considerable) damage until they are inevitably destroyed.
* @param obj the target
Expand All @@ -25,9 +26,11 @@ class WithLava()
def doInteractingWith(
obj: InteractsWithZone,
body: PieceOfEnvironment,
@unused data: Option[Any]
data: Option[Any]
): Unit = {
if (!obj.Destroyed) {
if (stopBurn && data.nonEmpty) {
stopBurn = false
} else if (!obj.Destroyed) {
obj.Actor ! Vitality.Damage(
DamageInteraction(
SourceEntry(obj),
Expand All @@ -36,7 +39,12 @@ class WithLava()
).calculate()
)
//keep doing damage
obj.Actor ! RespondsToZoneEnvironment.Timer(attribute, delay = 250 milliseconds, obj.Actor, interaction.InteractingWithEnvironment(body, None))
obj.Actor ! RespondsToZoneEnvironment.Timer(attribute, delay = 250 milliseconds, obj.Actor, interaction.InteractingWithEnvironment(body, Some("burning")))
}
}

override def stopInteractingWith(obj: InteractsWithZone, body: PieceOfEnvironment, parentInfo: Option[Any]): Unit = {
stopBurn = true
obj.Actor ! RespondsToZoneEnvironment.StopTimer(attribute)
}
}

0 comments on commit bed4983

Please sign in to comment.