diff --git a/scripts/core/blackboard/blackboardDefinitions.script b/scripts/core/blackboard/blackboardDefinitions.script index 37ce370..6736ae2 100644 --- a/scripts/core/blackboard/blackboardDefinitions.script +++ b/scripts/core/blackboard/blackboardDefinitions.script @@ -724,6 +724,8 @@ class UI_AutodriveDataDef extends BlackboardDefinition var AutoDriveEnabled : BlackboardID_Bool; var AutoDriveDelamain : BlackboardID_Bool; var FreeRoamEnabled : BlackboardID_Bool; + var DestinationRemainingLength : BlackboardID_Float; + var DestinationRemainingTime : BlackboardID_Float; var CinematicCameraActive : BlackboardID_Bool; public constexpr export const function AutoCreateInSystem() : Bool diff --git a/scripts/core/components/scriptComponents/vehicleComponent.script b/scripts/core/components/scriptComponents/vehicleComponent.script index 8a092d8..7eff3cf 100644 --- a/scripts/core/components/scriptComponents/vehicleComponent.script +++ b/scripts/core/components/scriptComponents/vehicleComponent.script @@ -5739,29 +5739,29 @@ class VehicleComponent extends ScriptableDeviceComponent { var customizationEvent : NewVehicleVisualCustomizationTemplateEvent; var newTemplate : VehicleVisualCustomizationTemplate; + var customizationLightsDelay : Float; var customizationDelay : Float; + DisableCurrentCustomization(); + customizationLightsDelay = 0.5; if( reset ) { GetPS().SetVehicleVisualCustomizationActive( false ); - DisableCurrentCustomization(); - customizationDelay = 0.5; } else { GetPS().SetVehicleVisualCustomizationActive( set ); - DisableCurrentCustomization(); - customizationDelay = 0.5; newTemplate = GetPS().GetVehicleVisualCustomizationTemplate(); if( ( set && VehicleVisualCustomizationTemplate.IsValid( newTemplate ) ) && !( VehicleVisualCustomizationTemplate.IsLightsOnly( newTemplate ) ) ) { customizationEvent = new NewVehicleVisualCustomizationTemplateEvent; customizationEvent.template = newTemplate; customizationEvent.isInstant = instant; - GameInstance.GetDelaySystem( GetVehicle().GetGame() ).DelayEvent( GetVehicle(), customizationEvent, 0.60000002 ); - customizationDelay += 1.10000002; + customizationDelay = 0.60000002; + GameInstance.GetDelaySystem( GetVehicle().GetGame() ).DelayEvent( GetVehicle(), customizationEvent, customizationDelay ); + customizationLightsDelay += 1.10000002; } } - GameInstance.GetDelaySystem( GetVehicle().GetGame() ).DelayEvent( GetVehicle(), new VehicleCustomizationLightsEvent, customizationDelay ); + GameInstance.GetDelaySystem( GetVehicle().GetGame() ).DelayEvent( GetVehicle(), new VehicleCustomizationLightsEvent, customizationLightsDelay ); StatusEffectHelper.ApplyStatusEffect( GetPlayer( GetVehicle().GetGame() ), T"BaseStatusEffect.VehicleVisualModCooldown" ); } @@ -5774,7 +5774,7 @@ class VehicleComponent extends ScriptableDeviceComponent PlayVehicleVisualCustomizationShader( false ); } - protected function PlayVehicleVisualCustomizationShader( play : Bool, optional instant : Bool, optional affectRims : Bool ) + public function PlayVehicleVisualCustomizationShader( play : Bool, optional instant : Bool, optional affectRims : Bool ) { var vehicle : VehicleObject; vehicle = GetVehicle(); @@ -5825,14 +5825,12 @@ class VehicleComponent extends ScriptableDeviceComponent { packedColorA = PackColorForEffect( GenericTemplatePersistentData.GetPrimaryColor( template.genericData ) ); packedColorB = PackColorForEffect( GenericTemplatePersistentData.GetSecondaryColor( template.genericData ) ); - m_customizationComponent.SetupGenericCustomization( record.ExcludedComponentsGeneric(), record.GenericCustomizationMask(), packedColorA, packedColorB ); - PlayVehicleVisualCustomizationShader( true, isInstant, record.CustomizeCarRims() ); + m_customizationComponent.SetupGenericCustomization( record.ExcludedComponentsGeneric(), record.GenericCustomizationMask(), packedColorA, packedColorB, isInstant, record.CustomizeCarRims() ); } else { - m_customizationComponent.SetupUniqueCustomization( GetMultilayersForCurrentVehicle( template.uniqueData.customMultilayers ), template.uniqueData.globalClearCoatOverrides, template.uniqueData.partsClearCoatOverrides ); + m_customizationComponent.SetupUniqueCustomization( GetMultilayersForCurrentVehicle( template.uniqueData.customMultilayers ), template.uniqueData.globalClearCoatOverrides, template.uniqueData.partsClearCoatOverrides, isInstant ); m_customizationComponent.ShowUniqueCustomizationDecalsWithDisolve( template.uniqueData.customDecals ); - PlayVehicleVisualCustomizationShader( true, isInstant, false ); } } diff --git a/scripts/core/components/vehicleCustomizationComponent.Script b/scripts/core/components/vehicleCustomizationComponent.Script index 0687f02..ed2c3df 100644 --- a/scripts/core/components/vehicleCustomizationComponent.Script +++ b/scripts/core/components/vehicleCustomizationComponent.Script @@ -75,8 +75,8 @@ import struct VehiclePartsClearCoatOverrides importonly class VehicleCustomizationComponent extends IComponent { public import final function SetComponentExcludedFromCustomization( componentsExcludedFromCustomization : array< CName > ); - public import final function SetupGenericCustomization( componentsExcludedFromMask : array< CName >, mask : ResRef, packedColorA : Float, packedColorB : Float ); - public import final function SetupUniqueCustomization( customMultilayers : array< VehicleCustomMultilayer >, globalClearCoatOverrides : VehicleClearCoatOverrides, partsClearCoatOverrides : array< VehiclePartsClearCoatOverrides > ); + public import final function SetupGenericCustomization( componentsExcludedFromMask : array< CName >, mask : ResRef, packedColorA : Float, packedColorB : Float, isInstant : Bool, affectRims : Bool ); + public import final function SetupUniqueCustomization( customMultilayers : array< VehicleCustomMultilayer >, globalClearCoatOverrides : VehicleClearCoatOverrides, partsClearCoatOverrides : array< VehiclePartsClearCoatOverrides >, isInstant : Bool ); public import final function ShowUniqueCustomizationDecalsWithDisolve( decals : array< VehicleDecalAttachmentData > ); public import final function HideUniqueCustomizationDecalsWithDisolve(); public import final function SetDefaultDecalsEnabled( enabled : Bool ); diff --git a/scripts/core/gameplay/vehicles.script b/scripts/core/gameplay/vehicles.script index 8814624..39b8872 100644 --- a/scripts/core/gameplay/vehicles.script +++ b/scripts/core/gameplay/vehicles.script @@ -212,7 +212,7 @@ import class VehicleObject extends GameObject m_hitByPlayer = false; if( ( GetVehiclePS().GetIsVehicleVisualCustomizationActive() && GetVehiclePS().GetIsVehicleApperanceCustomizationInDistanceTermination() ) && !( GetVehiclePS().GetIsVehicleVisualCustomizationBlockedByDamage() ) ) { - ExecuteVisualCustomizationWithDelay( true, false, true, 0.0 ); + ExecuteVisualCustomizationWithDelay( true, false, false, 0.0 ); GameInstance.GetDelaySystem( GetGame() ).DelayEvent( this, new CheckVehicleVisialCustomizationDistanceTermination, 2.0 ); } } @@ -329,7 +329,7 @@ import class VehicleObject extends GameObject m_abandoned = false; if( ( GetVehiclePS().GetIsVehicleVisualCustomizationActive() && !( GetVehiclePS().GetIsVehicleApperanceCustomizationInDistanceTermination() ) ) && !( GetVehiclePS().GetIsVehicleVisualCustomizationBlockedByDamage() ) ) { - ExecuteVisualCustomizationWithDelay( true, false, true, 0.0 ); + ExecuteVisualCustomizationWithDelay( true, false, false, 0.0 ); } else { @@ -1072,6 +1072,9 @@ import class VehicleObject extends GameObject public override function ReactToHitProcess( hitEvent : gameHitEvent ) { var isFromPrevention : Bool; + var autodriveSystem : AutoDriveSystem; + var attackType : gamedataAttackType; + attackType = hitEvent.attackData.GetAttackType(); super.ReactToHitProcess( hitEvent ); isFromPrevention = false; if( hitEvent.attackData.GetInstigator() ) @@ -1086,6 +1089,13 @@ import class VehicleObject extends GameObject { m_vehicleComponent.InjectThreat( hitEvent.attackData.GetInstigator() ); } + if( IsAutoDriveModeEnabled() && attackType != gamedataAttackType.Direct ) + { + if( autodriveSystem = ( ( AutoDriveSystem )( GameInstance.GetScriptableSystemsContainer( GetGame() ).Get( 'AutoDriveSystem' ) ) ) ) + { + autodriveSystem.QueueRequest( new AutoDriveHitRequest ); + } + } } private override final function OnHitSounds( hitEvent : gameHitEvent ) @@ -1481,6 +1491,14 @@ import class VehicleObject extends GameObject } } + public function PlayVehicleVisualCustomizationShader( play : Bool, optional instant : Bool, optional affectRims : Bool ) + { + if( m_vehicleComponent ) + { + m_vehicleComponent.PlayVehicleVisualCustomizationShader( play, instant, affectRims ); + } + } + public function GetCustomizationWidgets() : array< worlduiWidgetComponent > { var widgets : array< worlduiWidgetComponent >; diff --git a/scripts/core/systems/autoDriveSystem.script b/scripts/core/systems/autoDriveSystem.script index 0bc5d71..02d5113 100644 --- a/scripts/core/systems/autoDriveSystem.script +++ b/scripts/core/systems/autoDriveSystem.script @@ -20,6 +20,12 @@ importonly class StopAutoDriveOnDestinationReachedRequest extends ScriptableSyst { } +importonly class StopAutoDriveRequest extends ScriptableSystemRequest +{ + import var locKey : String; + import var isDelamain : Bool; +} + importonly class SendAutoDriveNotificationRequest extends ScriptableSystemRequest { import var locKey : String; @@ -50,6 +56,10 @@ class StopAutoDriveOnTeleportRequest extends ScriptableSystemRequest { } +class AutoDriveHitRequest extends ScriptableSystemRequest +{ +} + class AutodriveHealthChangeListener extends CustomValueStatPoolsListener { var m_autodriveSystem : weak< AutoDriveSystem >; @@ -147,6 +157,8 @@ class AutoDriveSystem extends NativeAutodriveSystem { var psmBB : IBlackboard; var psmState : Int32; + var psmRangedWeaponState : Int32; + var psmMeleeWeaponState : Int32; var vehicleHealth : Float; var healthThreshold : Float; var mountedVehicle : VehicleObject; @@ -164,23 +176,22 @@ class AutoDriveSystem extends NativeAutodriveSystem return false; } psmBB = m_player.GetPlayerStateMachineBlackboard(); - psmState = psmBB.GetInt( GetAllBlackboardDefs().PlayerStateMachine.Vehicle ); - if( ( ( psmState != ( ( Int32 )( gamePSMVehicle.Driving ) ) ) && ( psmState != ( ( Int32 )( gamePSMVehicle.Passenger ) ) ) ) && ( psmState != ( ( Int32 )( gamePSMVehicle.DriverCombat ) ) ) ) + psmRangedWeaponState = psmBB.GetInt( GetAllBlackboardDefs().PlayerStateMachine.Weapon ); + if( GetAutodriveEnabled() && ( psmRangedWeaponState == ( ( Int32 )( gamePSMRangedWeaponStates.Shoot ) ) ) ) { return false; } - psmState = psmBB.GetInt( GetAllBlackboardDefs().PlayerStateMachine.Combat ); - if( psmState == ( ( Int32 )( gamePSMCombat.InCombat ) ) ) + if( GetAutodriveEnabled() && ( ( ( psmMeleeWeaponState == ( ( Int32 )( gamePSMMeleeWeapon.ComboAttack ) ) ) || ( psmMeleeWeaponState == ( ( Int32 )( gamePSMMeleeWeapon.StrongAttack ) ) ) ) || ( psmMeleeWeaponState == ( ( Int32 )( gamePSMMeleeWeapon.ThrowAttack ) ) ) ) ) { return false; } - psmState = psmBB.GetInt( GetAllBlackboardDefs().PlayerStateMachine.Weapon ); - if( psmState != ( ( Int32 )( gamePSMRangedWeaponStates.Default ) ) ) + psmState = psmBB.GetInt( GetAllBlackboardDefs().PlayerStateMachine.Combat ); + if( ( psmState == ( ( Int32 )( gamePSMCombat.InCombat ) ) ) && !( GetAutodriveEnabled() ) ) { return false; } - psmState = psmBB.GetInt( GetAllBlackboardDefs().PlayerStateMachine.MeleeWeapon ); - if( psmState != ( ( Int32 )( gamePSMMeleeWeapon.NotReady ) ) ) + psmState = psmBB.GetInt( GetAllBlackboardDefs().PlayerStateMachine.Vehicle ); + if( ( ( psmState != ( ( Int32 )( gamePSMVehicle.Driving ) ) ) && ( psmState != ( ( Int32 )( gamePSMVehicle.Passenger ) ) ) ) && ( psmState != ( ( Int32 )( gamePSMVehicle.DriverCombat ) ) ) ) { return false; } @@ -259,8 +270,8 @@ class AutoDriveSystem extends NativeAutodriveSystem GameInstance.GetQuestsContentSystem( GetGameInstance() ).RegisterLockListener( m_autodriveQuestContentLockListener ); m_playerVehicleStateCallbackHandle = GetActiveVehicleDataBB().RegisterListenerVariant( GetAllBlackboardDefs().UI_ActiveVehicleData.VehPlayerStateData, this, 'OnPlayerVehicleChange' ); m_playerCombatStateCallbackHandle = m_player.GetPlayerStateMachineBlackboard().RegisterListenerInt( GetAllBlackboardDefs().PlayerStateMachine.Combat, this, 'OnPlayerStateChange' ); - m_playerWeaponStateCallbackHandle = m_player.GetPlayerStateMachineBlackboard().RegisterListenerInt( GetAllBlackboardDefs().PlayerStateMachine.Weapon, this, 'OnPlayerStateChange' ); - m_playerMeleeWeaponStateCallbackHandle = m_player.GetPlayerStateMachineBlackboard().RegisterListenerInt( GetAllBlackboardDefs().PlayerStateMachine.MeleeWeapon, this, 'OnPlayerStateChange' ); + m_playerWeaponStateCallbackHandle = m_player.GetPlayerStateMachineBlackboard().RegisterListenerInt( GetAllBlackboardDefs().PlayerStateMachine.Weapon, this, 'OnWeaponStateChange' ); + m_playerMeleeWeaponStateCallbackHandle = m_player.GetPlayerStateMachineBlackboard().RegisterListenerInt( GetAllBlackboardDefs().PlayerStateMachine.MeleeWeapon, this, 'OnMeleeWeaponStateChange' ); SignalAutodriveAvailable(); } } @@ -348,6 +359,15 @@ class AutoDriveSystem extends NativeAutodriveSystem SendNotification( request.locKey, ( ( request.isDelamain ) ? ( SimpleMessageType.DelamainTaxi ) : ( SimpleMessageType.Autodrive ) ) ); } + private function OnStopAutoDriveRequest( request : StopAutoDriveRequest ) + { + if( GetAutodriveEnabled() ) + { + SendNotification( request.locKey, ( ( request.isDelamain ) ? ( SimpleMessageType.DelamainTaxi ) : ( SimpleMessageType.Autodrive ) ) ); + SetAutodriveEnabled( false, request.isDelamain ); + } + } + private function OnStopAutoDriveOnDestinationReachedRequest( request : StopAutoDriveOnDestinationReachedRequest ) { var playerVehicle : VehicleObject; @@ -441,6 +461,32 @@ class AutoDriveSystem extends NativeAutodriveSystem } } + private function OnWeaponStateChange( value : Int32 ) + { + if( !( GetAutodriveIsDelamain() ) ) + { + if( GetAutodriveEnabled() && ( value == ( ( Int32 )( gamePSMRangedWeaponStates.Shoot ) ) ) ) + { + SendNotification( "LocKey#97386", SimpleMessageType.Autodrive ); + } + SignalAutodriveAvailable(); + StopAutodriveIfNecessary( false ); + } + } + + private function OnMeleeWeaponStateChange( value : Int32 ) + { + if( !( GetAutodriveIsDelamain() ) ) + { + if( GetAutodriveEnabled() && ( ( ( value == ( ( Int32 )( gamePSMMeleeWeapon.ComboAttack ) ) ) || ( value == ( ( Int32 )( gamePSMMeleeWeapon.StrongAttack ) ) ) ) || ( value == ( ( Int32 )( gamePSMMeleeWeapon.ThrowAttack ) ) ) ) ) + { + SendNotification( "LocKey#97386", SimpleMessageType.Autodrive ); + } + SignalAutodriveAvailable(); + StopAutodriveIfNecessary( false ); + } + } + private function OnUpdateAutodriveStateAfterVehicleHealthChangeRequest( request : UpdateAutodriveStateAfterVehicleHealthChange ) { SignalAutodriveAvailable(); @@ -459,6 +505,13 @@ class AutoDriveSystem extends NativeAutodriveSystem StopAutodriveIfNecessary( false ); } + private function OnAutoDriveHitRequest( request : AutoDriveHitRequest ) + { + SendNotification( "LocKey#97386", SimpleMessageType.Autodrive ); + SetAutodriveEnabled( false ); + SignalAutodriveAvailable(); + } + private function SignalAutodriveAvailable() { GetAutodriveDataBB().SetBool( GetAutodriveDataBBDef().AutoDriveAvailable, GetAutodriveAvailable() ); @@ -535,7 +588,7 @@ class AutoDriveSystem extends NativeAutodriveSystem m_player.UnregisterInputListener( this, 'Decelerate' ); } - private export function SendNotification( const message : String, type : SimpleMessageType ) + private export const function SendNotification( const message : String, type : SimpleMessageType ) { var warningMsg : SimpleScreenMessage; warningMsg.isShown = true; diff --git a/scripts/cyberpunk/UI/widgets/autodrive/autodrive.script b/scripts/cyberpunk/UI/widgets/autodrive/autodrive.script index aa58bc2..b709a73 100644 --- a/scripts/cyberpunk/UI/widgets/autodrive/autodrive.script +++ b/scripts/cyberpunk/UI/widgets/autodrive/autodrive.script @@ -405,9 +405,9 @@ class AutoDriveController extends inkHUDGameController if( m_autoDriveSystem.GetAutodriveDestinationType() != gameAutodriveDestinationType.None ) { inkWidgetRef.SetVisible( m_remainingDistanceCounterContainer, true ); - m_remainingDistanceCounterTextParams.UpdateMeasurement( "DISTANCE", m_autoDriveSystem.GetDistanceToCurrentDestination(), EMeasurementUnit.Meter ); + m_remainingDistanceCounterTextParams.UpdateMeasurement( "DISTANCE", ( ( Float )( FloorF( m_autodriveBB.GetFloat( m_autodriveBBDef.DestinationRemainingLength ) ) ) ), EMeasurementUnit.Meter ); inkWidgetRef.SetVisible( m_remainingTimeCounterContainer, true ); - m_remainingTimeCounterTextParams.UpdateTime( "TIME", FloorF( m_autoDriveSystem.GetEstimatedTimeToArrival() ) ); + m_remainingTimeCounterTextParams.UpdateTime( "TIME", FloorF( m_autodriveBB.GetFloat( m_autodriveBBDef.DestinationRemainingTime ) ) ); } else { diff --git a/scripts/cyberpunk/ai/commands/aiDriveCommandHandler.script b/scripts/cyberpunk/ai/commands/aiDriveCommandHandler.script index a514ddd..8a0df48 100644 --- a/scripts/cyberpunk/ai/commands/aiDriveCommandHandler.script +++ b/scripts/cyberpunk/ai/commands/aiDriveCommandHandler.script @@ -205,6 +205,52 @@ class AIDriveCommandsDelegate extends ScriptBehaviorDelegate return true; } + public function DoStartDriveToPointAutonomousAutodriveInCombat( context : ScriptExecutionContext ) : Bool + { + var owner : gamePuppet; + var gameInstance : GameInstance; + var vehicle : weak< VehicleObject >; + owner = ScriptExecutionContext.GetOwner( context ); + gameInstance = owner.GetGame(); + VehicleComponent.GetVehicle( gameInstance, owner, vehicle ); + targetPosition = ( ( Vector3 )( vehicle.GetWorldPosition() ) ); + return true; + } + + public function DoStartDriveToPointAutonomousAutodrive( context : ScriptExecutionContext ) : Bool + { + var autoDriveSystem : AutoDriveSystem; + var owner : gamePuppet; + var gameInstance : GameInstance; + var vehicle : weak< VehicleObject >; + owner = ScriptExecutionContext.GetOwner( context ); + gameInstance = owner.GetGame(); + VehicleComponent.GetVehicle( gameInstance, owner, vehicle ); + autoDriveSystem = ( ( AutoDriveSystem )( GameInstance.GetScriptableSystemsContainer( ScriptExecutionContext.GetOwner( context ).GetGame() ).Get( 'AutoDriveSystem' ) ) ); + targetPosition = autoDriveSystem.GetAutodriveDestination(); + return true; + } + + public function DoUpdateDriveToPointAutonomousAutodrive( context : ScriptExecutionContext ) : Bool + { + var autoDriveSystem : AutoDriveSystem; + var owner : gamePuppet; + var gameInstance : GameInstance; + var vehicle : weak< VehicleObject >; + var driveToPointUpdate : DriveToPointAutonomousUpdate; + owner = ScriptExecutionContext.GetOwner( context ); + gameInstance = owner.GetGame(); + driveToPointUpdate = new DriveToPointAutonomousUpdate; + VehicleComponent.GetVehicle( gameInstance, owner, vehicle ); + autoDriveSystem = ( ( AutoDriveSystem )( GameInstance.GetScriptableSystemsContainer( ScriptExecutionContext.GetOwner( context ).GetGame() ).Get( 'AutoDriveSystem' ) ) ); + if( targetPosition != autoDriveSystem.GetAutodriveDestination() ) + { + driveToPointUpdate.targetPosition = ( ( Vector4 )( autoDriveSystem.GetAutodriveDestination() ) ); + vehicle.GetAIComponent().SetDriveToPointAutonomousUpdate( driveToPointUpdate ); + } + return true; + } + private var m_driveToPointAutonomousCommand : AIVehicleDriveToPointAutonomousCommand; diff --git a/scripts/cyberpunk/player/psm/inputContextTransitions.script b/scripts/cyberpunk/player/psm/inputContextTransitions.script index 40314aa..028ce4f 100644 --- a/scripts/cyberpunk/player/psm/inputContextTransitions.script +++ b/scripts/cyberpunk/player/psm/inputContextTransitions.script @@ -2595,6 +2595,34 @@ class VehicleAutodriveContextDecisions extends AutodriveAndCinematicCameraContex EnableOnEnterCondition( ( m_autodriveEnabled && !( m_cinematicCameraActive ) ) && !( m_delamainTaxi ) ); } + protected const override function EnterCondition( const stateContext : StateContext, const scriptInterface : StateGameScriptInterface ) : Bool + { + var driverCombatType : gamedataDriverCombatType; + driverCombatType = GetDriverCombatType( stateContext ); + return driverCombatType != gamedataDriverCombatType.MountedWeapons; + } + +} + +class VehicleMountedWeaponsAutodriveContextEvents extends VehicleAutodriveContextEvents +{ +} + +class VehicleMountedWeaponsAutodriveContextDecisions extends AutodriveAndCinematicCameraContextDecisions +{ + + protected override function OnStateChanged() + { + EnableOnEnterCondition( ( m_autodriveEnabled && !( m_cinematicCameraActive ) ) && !( m_delamainTaxi ) ); + } + + protected const override function EnterCondition( const stateContext : StateContext, const scriptInterface : StateGameScriptInterface ) : Bool + { + var driverCombatType : gamedataDriverCombatType; + driverCombatType = GetDriverCombatType( stateContext ); + return driverCombatType == gamedataDriverCombatType.MountedWeapons; + } + } class VehicleCinematicCameraContextEvents extends InputContextTransitionEvents