Fix implant auto activation not always working

This commit is contained in:
Jakob Gillich 2021-04-18 08:22:47 +02:00
parent 490e6244e7
commit 2dc1b5736a
2 changed files with 11 additions and 18 deletions

View file

@ -846,12 +846,6 @@ class AvatarActor(
case other => other
})
// automatic targeting implant activation is a client side feature
// For some reason it doesn't always work with 100% reliability, so we're also activating it server side
// Must be delayed by a bit or the client will toggle it off again
if (implantType == ImplantType.Targeting) {
context.scheduleOnce(2.seconds, context.self, ActivateImplant(implantType))
}
case None => log.error(s"set initialized called for unknown implant $implantType")
}
@ -1071,14 +1065,6 @@ class AvatarActor(
)
)
// Start client side initialization timer, visible on the character screen
// Progress accumulates according to the client's knowledge of the implant initialization time
// What is normally a 60s timer that is set to 120s on the server will still visually update as if 60s
session.get.zone.AvatarEvents ! AvatarServiceMessage(
avatar.name,
AvatarAction.SendResponse(Service.defaultPlayerGUID, ActionProgressMessage(slot + 6, 0))
)
implantTimers.get(slot).foreach(_.cancel())
implantTimers(slot) = context.scheduleOnce(
implant.definition.InitializationDuration.seconds,
@ -1086,6 +1072,14 @@ class AvatarActor(
SetImplantInitialized(implant.definition.implantType)
)
// Start client side initialization timer, visible on the character screen
// Progress accumulates according to the client's knowledge of the implant initialization time
// What is normally a 60s timer that is set to 120s on the server will still visually update as if 60s\
session.get.zone.AvatarEvents ! AvatarServiceMessage(
avatar.name,
AvatarAction.SendResponse(Service.defaultPlayerGUID, ActionProgressMessage(slot + 6, 0))
)
case (None, _) => ;
}
}

View file

@ -4600,14 +4600,13 @@ class SessionActor(middlewareActor: typed.ActorRef[MiddlewareActor.Command], con
if (action == ImplantAction.Activation) {
CancelZoningProcessWithDescriptiveReason("cancel_implant")
avatar.implants(slot) match {
case Some(implant) if implant.initialized =>
if (!implant.active) {
case Some(implant) =>
if (status == 1) {
avatarActor ! AvatarActor.ActivateImplant(implant.definition.implantType)
} else {
avatarActor ! AvatarActor.DeactivateImplant(implant.definition.implantType)
}
case Some(implant) if !implant.initialized => ()
case _ => log.error(s"AvatarImplantMessage: ${player.Name} has an unknown implant in $slot")
case _ => log.error(s"AvatarImplantMessage: ${player.Name} has an unknown implant in $slot")
}
}