Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/core/blackboard/blackboardDefinitions.script
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 10 additions & 12 deletions scripts/core/components/scriptComponents/vehicleComponent.script
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
}

Expand All @@ -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();
Expand Down Expand Up @@ -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 );
}
}

Expand Down
4 changes: 2 additions & 2 deletions scripts/core/components/vehicleCustomizationComponent.Script
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
22 changes: 20 additions & 2 deletions scripts/core/gameplay/vehicles.script
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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() )
Expand All @@ -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 )
Expand Down Expand Up @@ -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 >;
Expand Down
75 changes: 64 additions & 11 deletions scripts/core/systems/autoDriveSystem.script
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,6 +56,10 @@ class StopAutoDriveOnTeleportRequest extends ScriptableSystemRequest
{
}

class AutoDriveHitRequest extends ScriptableSystemRequest
{
}

class AutodriveHealthChangeListener extends CustomValueStatPoolsListener
{
var m_autodriveSystem : weak< AutoDriveSystem >;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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() );
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions scripts/cyberpunk/UI/widgets/autodrive/autodrive.script
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
46 changes: 46 additions & 0 deletions scripts/cyberpunk/ai/commands/aiDriveCommandHandler.script
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
28 changes: 28 additions & 0 deletions scripts/cyberpunk/player/psm/inputContextTransitions.script
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down