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 val
Unknown0, Unknown0,
Start, Start,
Unknown2, Cancelled,
Ongoing, Ongoing,
Finished, Finished,
Unknown5, 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 = { def HandleHackingProgress(progressType : Int, tplayer : Player, target : PlanetSideServerObject, tool_guid : PlanetSideGUID, delta : Float, completeAction : ()=>Unit, tickAction : Option[()=>Unit]) : Unit = {
progressBarUpdate.cancel progressBarUpdate.cancel
if(progressBarValue.isDefined) { 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) { val vis = if(progressBarVal == 0L) {
//hack state for progress bar visibility //hack state for progress bar visibility
HackState.Start HackState.Start
} }
else if(progressBarVal > 100L) { else if(progressBarVal >= 100L) {
HackState.Finished 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 { else {
HackState.Ongoing HackState.Ongoing
} }
sendResponse(HackMessage(progressType, target.GUID, player.GUID, progressBarVal.toInt, 0L, vis, 8L))
if(progressBarVal > 100) { if(vis == HackState.Cancelled) {
//done // Object moved. Cancel the hack (e.g. vehicle drove away)
progressBarValue = None sendResponse(HackMessage(progressType, target.GUID, player.GUID, 0, 0L, vis, 8L))
// sendResponse(HackMessage(0, target.GUID, player.GUID, 100, 1114636288L, HackState.Hacked, 8L))
completeAction()
} }
else { else
//continue next tick {
tickAction.getOrElse(() => Unit)() sendResponse(HackMessage(progressType, target.GUID, player.GUID, progressBarVal.toInt, 0L, vis, 8L))
progressBarValue = Some(progressBarVal)
import scala.concurrent.ExecutionContext.Implicits.global if(progressBarVal >= 100) {
progressBarUpdate = context.system.scheduler.scheduleOnce(250 milliseconds, self, HackingProgress(progressType, tplayer, target, tool_guid, delta, completeAction)) //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 += ReinforcedExoSuit
avatar.Certifications += ATV avatar.Certifications += ATV
avatar.Certifications += Harasser avatar.Certifications += Harasser
//
avatar.Certifications += InfiltrationSuit avatar.Certifications += InfiltrationSuit
avatar.Certifications += Sniping avatar.Certifications += Sniping
avatar.Certifications += AntiVehicular avatar.Certifications += AntiVehicular
@ -3479,6 +3491,9 @@ class WorldSessionActor extends Actor with MDCContextAware {
avatar.Certifications += AssaultEngineering avatar.Certifications += AssaultEngineering
avatar.Certifications += Hacking avatar.Certifications += Hacking
avatar.Certifications += AdvancedHacking avatar.Certifications += AdvancedHacking
avatar.Certifications += ElectronicsExpert
avatar.Certifications += Medical
avatar.Certifications += AdvancedMedical
avatar.CEP = 6000001 avatar.CEP = 6000001
this.avatar = avatar this.avatar = avatar