Cancel jacking if a vehicle is moving (#290)

* Add Medical / Adv Medical / Expert Electronics to default certs

* Cancel jacking when object is moving more than a small amount
This commit is contained in:
Mazo 2019-11-29 16:00:30 +00:00 committed by Fate-JH
parent 31bdf58ea4
commit 9e99dc75e3
2 changed files with 31 additions and 16 deletions

View file

@ -21,7 +21,7 @@ object HackState extends Enumeration {
val
Unknown0,
Start,
Unknown2,
Cancelled,
Ongoing,
Finished,
Unknown5,

View file

@ -3186,30 +3186,43 @@ class WorldSessionActor extends Actor with MDCContextAware {
def HandleHackingProgress(progressType : Int, tplayer : Player, target : PlanetSideServerObject, tool_guid : PlanetSideGUID, delta : Float, completeAction : ()=>Unit, tickAction : Option[()=>Unit]) : Unit = {
progressBarUpdate.cancel
if(progressBarValue.isDefined) {
val progressBarVal : Float = progressBarValue.get + delta
val progressBarVal : Float = if (progressBarValue.get + delta > 100) { 100f } else { progressBarValue.get + delta }
val vis = if(progressBarVal == 0L) {
//hack state for progress bar visibility
HackState.Start
}
else if(progressBarVal > 100L) {
else if(progressBarVal >= 100L) {
HackState.Finished
}
else if(target.Velocity.isDefined && Vector3.Distance(Vector3.Zero, target.Velocity.get) > 1f) {
// If the object is moving (more than slightly to account for things like magriders rotating, or the last velocity reported being the magrider dipping down on dismount) then cancel the hack
HackState.Cancelled
}
else {
HackState.Ongoing
}
sendResponse(HackMessage(progressType, target.GUID, player.GUID, progressBarVal.toInt, 0L, vis, 8L))
if(progressBarVal > 100) {
//done
progressBarValue = None
// sendResponse(HackMessage(0, target.GUID, player.GUID, 100, 1114636288L, HackState.Hacked, 8L))
completeAction()
if(vis == HackState.Cancelled) {
// Object moved. Cancel the hack (e.g. vehicle drove away)
sendResponse(HackMessage(progressType, target.GUID, player.GUID, 0, 0L, vis, 8L))
}
else {
//continue next tick
tickAction.getOrElse(() => Unit)()
progressBarValue = Some(progressBarVal)
import scala.concurrent.ExecutionContext.Implicits.global
progressBarUpdate = context.system.scheduler.scheduleOnce(250 milliseconds, self, HackingProgress(progressType, tplayer, target, tool_guid, delta, completeAction))
else
{
sendResponse(HackMessage(progressType, target.GUID, player.GUID, progressBarVal.toInt, 0L, vis, 8L))
if(progressBarVal >= 100) {
//done
progressBarValue = None
completeAction()
}
else {
//continue next tick
tickAction.getOrElse(() => Unit)()
progressBarValue = Some(progressBarVal)
import scala.concurrent.ExecutionContext.Implicits.global
progressBarUpdate = context.system.scheduler.scheduleOnce(250 milliseconds, self, HackingProgress(progressType, tplayer, target, tool_guid, delta, completeAction))
}
}
}
}
@ -3452,7 +3465,6 @@ class WorldSessionActor extends Actor with MDCContextAware {
avatar.Certifications += ReinforcedExoSuit
avatar.Certifications += ATV
avatar.Certifications += Harasser
//
avatar.Certifications += InfiltrationSuit
avatar.Certifications += Sniping
avatar.Certifications += AntiVehicular
@ -3479,6 +3491,9 @@ class WorldSessionActor extends Actor with MDCContextAware {
avatar.Certifications += AssaultEngineering
avatar.Certifications += Hacking
avatar.Certifications += AdvancedHacking
avatar.Certifications += ElectronicsExpert
avatar.Certifications += Medical
avatar.Certifications += AdvancedMedical
avatar.CEP = 6000001
this.avatar = avatar