viewtopic.php?f=8&t=26&hilit=camera+mouse+movement&start=0
However I get weird results when adding certain nodes. For instance, I use the the Camera look at node when I start a conversation with another entity. I then use Clear camera look at when the conversation is over. However when either of these two nodes are attached in the scene flow I am no longer able to move the camera using the mouse. It seems to use an entirely different camera, that's still in the first person view of the player, but is different from g_firstPersonCameraEntity.
Looking at the scene's CScript, there doesn't seem to be anything that would cause this behavior.
Scene's CScript:
- Code: Select all
//-------------------------------------------------------------------------------
// NewScene1.cscript created by VBS Worlds Authoring Tool 20/04/2012 15:53:22
//-------------------------------------------------------------------------------
// Temporary particle effect constant data
constant_integer g_NUM_FIRES := 1
constant_integer g_NUM_FOUNTAINS := 1
constant_integer g_NUM_SMOKE_DOWNS := 1
constant_integer g_NUM_SMOKE_UPS := 1
constant_integer g_NUM_STEAMS := 1
// Animation variables
integer Animation1_AnimationID
integer Animation2_AnimationID
integer Animation3_AnimationID
// Logic variables
integer CurrentHealthLogicVariableValue
integer Enemy1HealthLogicVariableValue
integer Enemy2HealthLogicVariableValue
integer ExplosiveAttackLogicVariableValue
integer LaughterAttackLogicVariableValue
integer NewVariable1LogicVariableValue
// Entity ID variables
integer Enemy1_EntityID
integer Enemy2_EntityID
integer FlashlightObject_EntityID
integer Guard1_EntityID
integer Guard2_EntityID
integer GuardPath1_EntityID
integer NewObject1_EntityID
integer NewObject2_EntityID
integer NewObject3_EntityID
integer StartCameraCameraEntity_EntityID
// Entity2D ID variables
integer Circle1_Entity2DID
// Interaction ID variables
integer CommunicationInteraction1_InteractionID
integer ConversationInteraction1_InteractionID
integer ConversationInteraction2_InteractionID
// Node specific variables
integer CustomHUDActionButtonID
integer CustomHUDHUDButtonFireButton_Enabled
integer CustomHUDHUDButtonFireButton_Entity2DID
integer CustomHUDHUDButtonFireButtonRender
integer CustomHUDHUDButtonFireButtonShowControl
integer CustomHUDHUDProgressHeathProgress_Entity2DID
integer CustomHUDHUDProgressHeathProgressHDI
integer CustomHUDHUDProgressHeathProgressIsHorizontal
integer CustomHUDHUDProgressHeathProgressMax
integer CustomHUDHUDProgressHeathProgressMin
integer CustomHUDHUDProgressHeathProgressRender
integer CustomHUDHUDProgressHeathProgressShowControl
constant_Vector2 CustomHUDHUDProgressHeathProgressSize := 259.00000000 37.00000000
integer CustomHUDHUDProgressHeathProgressValue
integer CustomHUDHUDProgressHeathProgressVariableCurrentHealth
integer CustomHUDInventoryButtonID
integer CustomHUDInventoryButtonX
integer CustomHUDInventoryButtonY
integer DefaultHudActionButtonID
integer distanceWatchEnabled1
integer Enemy1_CurrentAnimFlag1
integer Enemy1_LastInteractionID1
float Enemy1TriggerVolume_HalfSize
constant_Vector3 Enemy1TriggerVolume_Position := -415.80590000 34.90000000 -109.66580000
integer Enemy2_CurrentAnimFlag1
integer Enemy2_LastInteractionID1
constant_Vector3 Enemy2Marker_Position := -325.59630000 223.03250000 94.17204000
constant_Vector3 Enemy2Marker_Rotation := 0.00000000 270.00000000 0.00000000
constant_Vector3 Enemy2Marker_Scale := 1.00000000 1.00000000 1.00000000
float entityAngularVelocity
integer entityClickWatchEnabled1
integer entityClickWatchEnabled2
integer entityClickWatchEnabled3
integer entityControlEnabled1
integer entityControlEnabled2
integer entityControlFrames
integer entityControlFrames1
integer fadeUpActive1
integer FlashlightObject_LastInteractionID1
integer Guard1_CurrentAnimFlag1
integer Guard1_LastInteractionID1
integer Guard2_CurrentAnimFlag1
integer Guard2_LastInteractionID1
Vector3 manipulateEntityAngularVelocity1
integer manipulateEntityFinished1
Vector3 manipulateEntityScaleVelocity1
Vector3 manipulateEntityVelocity1
integer NewObject1_LastInteractionID1
integer NewObject2_LastInteractionID1
integer NewObject3_LastInteractionID1
integer soundPlaying
integer soundPlaying1
integer soundPlaying2
integer soundPlaying3
float soundPlayTime
float soundPlayTime1
float soundPlayTime2
float soundPlayTime3
integer splineEnd1
integer splineFollowEnabled1
constant_Vector3 StartMarker_Position := -439.54240000 100.23260000 -514.77550000
constant_Vector3 StartMarker_Rotation := 0.00000000 0.00000000 0.00000000
constant_Vector3 StartMarker_Scale := 1.00000000 1.00000000 1.00000000
integer timerEnabled1
integer timerEnabled2
float timerEndTime1
float timerEndTime2
float TriggerVolume1_HalfSize
constant_Vector3 TriggerVolume1_Position := -759.66270000 17.20000000 -658.90150000
integer triggerVolumeWatchWatchEnabled1
integer triggerVolumeWatchWatchEnabled2
integer triggerVolumeWatchWatchEnabled3
integer triggerVolumeWatchWatchEnabled4
integer triggerVolumeWatchWatchEnabled5
float UpstairsTrigger_HalfSize
constant_Vector3 UpstairsTrigger_Position := -510.77480000 219.40000000 96.93190000
integer variableWatchIsEnabled1
integer variableWatchIsEnabled2
// Sound variables
integer Sound1_SoundID
integer Sound2_SoundID
// Temporary variables
float tempFloatVar
integer tempIntVar
integer tempIntVar2
string tempStringVar
string tempStringVar2
Vector2 tempVector2Var
// Camera overrides
integer cameraOverideEntity_ID
integer CollectObjectInteraction_InteractionID
// Interaction variable data
integer g_interactionStartTime := 0.0
// Miscellaneous global variables
integer g_followCameraEntity
integer g_firstPersonCameraEntity
float g_timeElapsed
integer g_communicatorEntity
Vector3 g_authoringTempVector
string g_defaultFont := "Tahoma/Tahoma_20_bold"
integer g_defaultFontID
integer g_hideHud := 0
integer g_activeHud := 0
integer g_showInventoryButton := 1
integer g_currentInventoryEntity := 0
integer g_currentActionEntity := 0
function MainLoop()
{
CreatePlayer()
InitialiseCameras()
InitialiseBillboards()
InitialiseParticles()
InitialiseGameTimer()
InitialiseGameScore()
InitialisePlayerLives()
CreateCommunicator()
InitialiseEntity( worldEntityID )
InitialiseRadarScript()
InitialisePadScript()
g_timeElapsed := 0.0
// Animation variables
Animation1_AnimationID := LoadSkinMeshAnimation( "07aba5c0-fe72-4715-8156-d3a0f027c4e8/Fall Over" )
Animation2_AnimationID := LoadSkinMeshAnimation( "2cf13cc8-bc70-4ab0-a6c6-f0ee4e5963b4/Hands Together (Idle)" )
Animation3_AnimationID := LoadSkinMeshAnimation( "4630ecf1-7140-4216-96a5-0d380406791e/Angry Response 2" )
// Logic variables
CurrentHealthLogicVariableValue := 0
Enemy1HealthLogicVariableValue := 0
Enemy2HealthLogicVariableValue := 0
ExplosiveAttackLogicVariableValue := 0
LaughterAttackLogicVariableValue := 0
NewVariable1LogicVariableValue := 0
// Entity ID variables
Enemy1_EntityID := GetEntity( "Enemy1" )
Enemy2_EntityID := GetEntity( "Enemy2" )
FlashlightObject_EntityID := GetEntity( "FlashlightObject" )
Guard1_EntityID := GetEntity( "Guard1" )
Guard2_EntityID := GetEntity( "Guard2" )
NewObject1_EntityID := GetEntity( "NewObject1" )
NewObject2_EntityID := GetEntity( "NewObject2" )
NewObject3_EntityID := GetEntity( "NewObject3" )
StartCameraCameraEntity_EntityID := GetEntity( "StartCameraCameraEntity" )
// Entity2D ID variables
Circle1_Entity2DID := GetEntity2D( "Circle1" )
// Interaction ID variables
CommunicationInteraction1_InteractionID := GetInteraction( "CommunicationInteraction1" )
ConversationInteraction1_InteractionID := GetInteraction( "ConversationInteraction1" )
ConversationInteraction2_InteractionID := GetInteraction( "ConversationInteraction2" )
// Node specific variables
CustomHUDActionButtonID := 0
CustomHUDHUDButtonFireButton_Enabled := 0
CustomHUDHUDButtonFireButton_Entity2DID := 0
CustomHUDHUDButtonFireButtonRender := 1
CustomHUDHUDButtonFireButtonShowControl := 1
CustomHUDHUDProgressHeathProgress_Entity2DID := 0
CustomHUDHUDProgressHeathProgressHDI := 0
CustomHUDHUDProgressHeathProgressIsHorizontal := 1
CustomHUDHUDProgressHeathProgressMax := 100
CustomHUDHUDProgressHeathProgressMin := 0
CustomHUDHUDProgressHeathProgressRender := 1
CustomHUDHUDProgressHeathProgressShowControl := 1
CustomHUDHUDProgressHeathProgressValue := 0
CustomHUDHUDProgressHeathProgressVariableCurrentHealth := 0
CustomHUDInventoryButtonID := 0
CustomHUDInventoryButtonX := 920
CustomHUDInventoryButtonY := 28
DefaultHudActionButtonID := 0
distanceWatchEnabled1 := 0
Enemy1_CurrentAnimFlag1 := 0
Enemy1_LastInteractionID1 := 0
Enemy1TriggerVolume_HalfSize := 42.50000000
Enemy2_CurrentAnimFlag1 := 0
Enemy2_LastInteractionID1 := 0
entityAngularVelocity := 0.00000000
entityClickWatchEnabled1 := 0
entityClickWatchEnabled2 := 0
entityClickWatchEnabled3 := 0
entityControlEnabled1 := 0
entityControlEnabled2 := 0
entityControlFrames := 0
entityControlFrames1 := 0
fadeUpActive1 := 0
FlashlightObject_LastInteractionID1 := 0
Guard1_CurrentAnimFlag1 := 0
Guard1_LastInteractionID1 := 0
Guard2_CurrentAnimFlag1 := 0
Guard2_LastInteractionID1 := 0
manipulateEntityFinished1 := 0
NewObject1_LastInteractionID1 := 0
NewObject2_LastInteractionID1 := 0
NewObject3_LastInteractionID1 := 0
soundPlaying := 0
soundPlaying1 := 0
soundPlaying2 := 0
soundPlaying3 := 0
soundPlayTime := 0.00000000
soundPlayTime1 := 0.00000000
soundPlayTime2 := 0.00000000
soundPlayTime3 := 0.00000000
splineEnd1 := 0
splineFollowEnabled1 := 0
timerEnabled1 := 0
timerEnabled2 := 0
timerEndTime1 := 0.00000000
timerEndTime2 := 0.00000000
TriggerVolume1_HalfSize := 140.99990000
triggerVolumeWatchWatchEnabled1 := 0
triggerVolumeWatchWatchEnabled2 := 0
triggerVolumeWatchWatchEnabled3 := 0
triggerVolumeWatchWatchEnabled4 := 0
triggerVolumeWatchWatchEnabled5 := 0
UpstairsTrigger_HalfSize := 50.00000000
variableWatchIsEnabled1 := 0
variableWatchIsEnabled2 := 0
// Sound variables
Sound1_SoundID := LoadSound( "2333d105-3283-4232-9736-57e23a725f4c/Explosion.wav", 4 )
Sound2_SoundID := LoadSound( "37da37b1-31d1-4bd8-820f-210268379fae/Evil Laugh.wav", 4 )
// Temporary variables
tempFloatVar := 0.00000000
tempIntVar := 0
tempIntVar2 := 0
tempStringVar := ""
tempStringVar2 := ""
// Camera overrides
CollectObjectInteraction_InteractionID := GetInteraction( "CollectObjectInteraction" )
// Construct spline entities
GuardPath1_EntityID := CreateEntity( "GuardPath1", "SplineEntity" )
AddSplinePointAsCurve( GuardPath1_EntityID, -59.29956000, 25.20000000, -438.40250000 )
AddSplinePointAsCurve( GuardPath1_EntityID, 87.04901000, 10.70000000, -505.87670000 )
AddSplinePointAsCurve( GuardPath1_EntityID, 100.22220000, 10.70000000, -589.12800000 )
AddSplinePointAsCurve( GuardPath1_EntityID, 94.71301000, 10.70000000, -664.60650000 )
AddSplinePointAsCurve( GuardPath1_EntityID, 341.72770000, 10.70000000, -710.31910000 )
AddSplinePointAsCurve( GuardPath1_EntityID, 406.88360000, 10.70000000, -793.98380000 )
AddSplinePointAsCurve( GuardPath1_EntityID, 147.58980000, 10.70000000, -772.99910000 )
AddSplinePointAsCurve( GuardPath1_EntityID, -1.63714600, 10.70000000, -733.73930000 )
AddSplinePointAsCurve( GuardPath1_EntityID, -106.33420000, 10.70000000, -699.29170000 )
AddSplinePointAsCurve( GuardPath1_EntityID, -177.15540000, 10.70000000, -668.84050000 )
AddSplinePointAsCurve( GuardPath1_EntityID, -202.47200000, 10.70000000, -621.82530000 )
AddSplinePointAsCurve( GuardPath1_EntityID, -199.32890000, 10.70000000, -572.10770000 )
AddSplinePointAsCurve( GuardPath1_EntityID, -169.21800000, 10.70000000, -532.22470000 )
AddSplinePointAsCurve( GuardPath1_EntityID, -102.03810000, 10.70000000, -504.69730000 )
AddSplinePointAsCurve( GuardPath1_EntityID, -17.97388000, 10.70000000, -494.21780000 )
AddSplinePointAsCurve( GuardPath1_EntityID, 213.85330000, 10.70000000, -521.48340000 )
AddSplinePointAsCurve( GuardPath1_EntityID, 317.69260000, 10.70000000, -558.66400000 )
AddSplinePointAsCurve( GuardPath1_EntityID, 362.75750000, 10.70000000, -584.06360000 )
AddSplinePointAsCurve( GuardPath1_EntityID, 367.56170000, 10.70000000, -614.01090000 )
AddSplinePointAsCurve( GuardPath1_EntityID, 361.75120000, 10.70000000, -643.87970000 )
AddSplinePointAsCurve( GuardPath1_EntityID, 295.21640000, 10.70000000, -681.48830000 )
AddSplinePointAsCurve( GuardPath1_EntityID, 267.10200000, 10.70000000, -717.64510000 )
AddSplinePointAsCurve( GuardPath1_EntityID, 219.27300000, 10.70000000, -759.60060000 )
AddSplinePointAsCurve( GuardPath1_EntityID, 142.73300000, 10.70000000, -784.22930000 )
AddSplinePointAsCurve( GuardPath1_EntityID, 111.96940000, 10.70000000, -779.16720000 )
TerminateSpline( GuardPath1_EntityID )
CreateCameraOverrides()
InitialiseRadarPips()
InitialiseHUD()
OnLogicStart()
while 1
{
g_global_elaspedTime := g_global_elaspedTime + timeStep
if( g_global_elaspedTime >= TIME_LIMIT)
{
Print( "time limit reached" )
LoadWorld( "TimeOut" )
}
UpdateCamera()
UpdateGameTimer()
UpdateGameScore()
UpdatePlayerLives()
UpdateRadar()
UpdateParticles()
UpdateProgressBars()
UpdateHUDText()
if ( IsInventoryOpen() and ( g_showInventoryButton = 0 ) )
{
CloseInventory()
SetEntity2DRender( g_currentInventoryEntity, 0 )
}
if ( IsInventoryOpen() )
{
SetEntity2DRender( g_currentInventoryEntity, 0 )
SetEntity2DRender( g_currentActionEntity, 0 )
}
integer interactionCount := IsInteractionPossible()
if ( interactionCount > 0 and not interaction and (IsInventoryOpen() = 0) )
{
SetEntity2DRender( g_currentActionEntity, 1 )
}
else
{
SetEntity2DRender( g_currentActionEntity, 0 )
}
if cscriptDebug
{
if WasKeyPressed( KEY_NUMPAD4 )
{
Vector3 translation
GetEntityTranslation( cameraEntity, translation )
SetEntityTranslationVector( playerEntity, translation )
}
}
g_timeElapsed := g_timeElapsed + timeStep
HandCodedUpdate()
//----------------------------------------------------------------------------------------
// cscript generated from logic canvas
if( entityClickWatchEnabled1 = 1 and not interaction)
{
if WasMouseButtonPressed( 0 )
{
GetMousePosition( tempVector2Var )
tempIntVar := GetClosestEntityUnderPoint( tempVector2Var, 0 )
if tempIntVar = Guard1_EntityID
{
entityClickWatchEnabled1 := 0
Guard1_LastInteractionID1 := 0
if DoesEntityHaveInteraction(Guard1_EntityID)
{
Guard1_LastInteractionID1 := GetEntityInteraction(Guard1_EntityID)
}
InteractionStop()
StartInteraction( ConversationInteraction1_InteractionID, Guard1_EntityID, playerEntity )
SetEntityInteraction(Guard1_EntityID, Guard1_LastInteractionID1)
}
}
}
if( triggerVolumeWatchWatchEnabled1 )
{
Vector3 entityTranslationTriggerVolumeWatch146
CopyVector3( entityTranslationTriggerVolumeWatch146, playerTranslation )
float xDisTriggerVolumeWatch146 := FloatAbs( TriggerVolume1_Position[ 0 ] - entityTranslationTriggerVolumeWatch146[ 0 ] )
float zDisTriggerVolumeWatch146 := FloatAbs( TriggerVolume1_Position[ 2 ] - entityTranslationTriggerVolumeWatch146[ 2 ] )
float yDisTriggerVolumeWatch146 := entityTranslationTriggerVolumeWatch146[ 1 ] - TriggerVolume1_Position[ 1 ]
if( xDisTriggerVolumeWatch146 <= TriggerVolume1_HalfSize and zDisTriggerVolumeWatch146 <= TriggerVolume1_HalfSize and yDisTriggerVolumeWatch146 <= ( TriggerVolume1_HalfSize * 2 ) and yDisTriggerVolumeWatch146 >= -10)
{
triggerVolumeWatchWatchEnabled1 := 0
Guard2_LastInteractionID1 := 0
if DoesEntityHaveInteraction(Guard2_EntityID)
{
Guard2_LastInteractionID1 := GetEntityInteraction(Guard2_EntityID)
}
InteractionStop()
StartInteraction( ConversationInteraction2_InteractionID, Guard2_EntityID, playerEntity )
SetEntityInteraction(Guard2_EntityID, Guard2_LastInteractionID1)
}
}
if( entityClickWatchEnabled2 = 1 and not interaction)
{
if WasMouseButtonPressed( 0 )
{
GetMousePosition( tempVector2Var )
tempIntVar := GetClosestEntityUnderPoint( tempVector2Var, 0 )
if tempIntVar = Enemy1_EntityID
{
entityClickWatchEnabled2 := 0
Enemy1HealthLogicVariableValue := Enemy1HealthLogicVariableValue - 50
timerEnabled1 := 1
timerEndTime1 := g_timeElapsed + 0.25000000
}
}
}
if( timerEnabled1 = 1 )
{
if( g_timeElapsed >= timerEndTime1 )
{
timerEnabled1 := 0
entityClickWatchEnabled2 := 1
}
}
if( triggerVolumeWatchWatchEnabled2 )
{
Vector3 entityTranslationTriggerVolumeWatch148
CopyVector3( entityTranslationTriggerVolumeWatch148, playerTranslation )
float xDisTriggerVolumeWatch148 := FloatAbs( Enemy1TriggerVolume_Position[ 0 ] - entityTranslationTriggerVolumeWatch148[ 0 ] )
float zDisTriggerVolumeWatch148 := FloatAbs( Enemy1TriggerVolume_Position[ 2 ] - entityTranslationTriggerVolumeWatch148[ 2 ] )
float yDisTriggerVolumeWatch148 := entityTranslationTriggerVolumeWatch148[ 1 ] - Enemy1TriggerVolume_Position[ 1 ]
if( xDisTriggerVolumeWatch148 <= Enemy1TriggerVolume_HalfSize and zDisTriggerVolumeWatch148 <= Enemy1TriggerVolume_HalfSize and yDisTriggerVolumeWatch148 <= ( Enemy1TriggerVolume_HalfSize * 2 ) and yDisTriggerVolumeWatch148 >= -10)
{
triggerVolumeWatchWatchEnabled2 := 0
CurrentHealthLogicVariableValue := CurrentHealthLogicVariableValue - 5
timerEnabled2 := 1
timerEndTime2 := g_timeElapsed + 1.50000000
}
}
if( timerEnabled2 = 1 )
{
if( g_timeElapsed >= timerEndTime2 )
{
timerEnabled2 := 0
triggerVolumeWatchWatchEnabled2 := 1
}
}
if( triggerVolumeWatchWatchEnabled3 )
{
Vector3 entityTranslationTriggerVolumeWatch147
CopyVector3( entityTranslationTriggerVolumeWatch147, playerTranslation )
float xDisTriggerVolumeWatch147 := FloatAbs( Enemy1TriggerVolume_Position[ 0 ] - entityTranslationTriggerVolumeWatch147[ 0 ] )
float zDisTriggerVolumeWatch147 := FloatAbs( Enemy1TriggerVolume_Position[ 2 ] - entityTranslationTriggerVolumeWatch147[ 2 ] )
float yDisTriggerVolumeWatch147 := entityTranslationTriggerVolumeWatch147[ 1 ] - Enemy1TriggerVolume_Position[ 1 ]
if( xDisTriggerVolumeWatch147 <= Enemy1TriggerVolume_HalfSize and zDisTriggerVolumeWatch147 <= Enemy1TriggerVolume_HalfSize and yDisTriggerVolumeWatch147 <= ( Enemy1TriggerVolume_HalfSize * 2 ) and yDisTriggerVolumeWatch147 >= -10)
{
triggerVolumeWatchWatchEnabled3 := 0
triggerVolumeWatchWatchEnabled4 := 1
SetActorAnimation( Enemy1_EntityID, Animation3_AnimationID, 1.00000000, 1 )
Enemy1_CurrentAnimFlag1 := 117
LaughterAttackLogicVariableValue := PlaySound( Sound2_SoundID, 100.00000000, 1.00000000, 1 )
soundPlayTime := 0
soundPlaying := 1
}
}
if( triggerVolumeWatchWatchEnabled4 )
{
Vector3 entityTranslationTriggerVolumeWatch149
CopyVector3( entityTranslationTriggerVolumeWatch149, playerTranslation )
float xDisTriggerVolumeWatch149 := FloatAbs( Enemy1TriggerVolume_Position[ 0 ] - entityTranslationTriggerVolumeWatch149[ 0 ] )
float zDisTriggerVolumeWatch149 := FloatAbs( Enemy1TriggerVolume_Position[ 2 ] - entityTranslationTriggerVolumeWatch149[ 2 ] )
float yDisTriggerVolumeWatch149 := entityTranslationTriggerVolumeWatch149[ 1 ] - Enemy1TriggerVolume_Position[ 1 ]
if( xDisTriggerVolumeWatch149 > Enemy1TriggerVolume_HalfSize or zDisTriggerVolumeWatch149 > Enemy1TriggerVolume_HalfSize or ( yDisTriggerVolumeWatch149 > ( Enemy1TriggerVolume_HalfSize * 2 ) or yDisTriggerVolumeWatch149 < -10 ))
{
triggerVolumeWatchWatchEnabled4 := 0
triggerVolumeWatchWatchEnabled3 := 1
if IsSoundChannelPlaying( LaughterAttackLogicVariableValue )
{
StopSoundChannel ( LaughterAttackLogicVariableValue )
}
SetActorIdleAnimation( Enemy1_EntityID, Animation2_AnimationID )
if ICompareString( GetEntityFSMState( Enemy1_EntityID ), "Idle" ) = 0
{
SetEntityFSMState( Enemy1_EntityID, "WalkTo" )
SetEntityFSMState( Enemy1_EntityID, "Idle" )
}
}
}
if( Enemy1_CurrentAnimFlag1 = 117 )
{
if( HasActorAnimationFinished( Enemy1_EntityID ) )
{
Enemy1_CurrentAnimFlag1 := 0
}
}
if( variableWatchIsEnabled1 = 1 )
{
if Enemy1HealthLogicVariableValue = 0
{
variableWatchIsEnabled1 := 0
if IsSoundChannelPlaying( LaughterAttackLogicVariableValue )
{
StopSoundChannel ( LaughterAttackLogicVariableValue )
}
SetActorAnimation( Enemy1_EntityID, Animation1_AnimationID, 1.50000000, 0 )
Enemy1_CurrentAnimFlag1 := 118
}
}
if( Enemy1_CurrentAnimFlag1 = 118 )
{
if( HasActorAnimationFinished( Enemy1_EntityID ) )
{
Enemy1_CurrentAnimFlag1 := 0
ExplosiveAttackLogicVariableValue := PlaySound( Sound1_SoundID, 100.00000000, 1.00000000, 0 )
soundPlayTime1 := 0
soundPlaying1 := 1
GetEntityTranslation( Enemy1_EntityID, g_authoringTempVector )
CharacterDeath( g_authoringTempVector )
entityControlEnabled1 := 1
entityControlFrames := 0
SetEntityRender( Enemy1_EntityID, 0 )
SetEntityActive( Enemy1_EntityID, 0 )
}
}
if( soundPlaying1 = 1 )
{
soundPlayTime1 := soundPlayTime1 + timeStep
tempFloatVar := GetSoundLength( Sound1_SoundID )
if( soundPlayTime1 >= tempFloatVar )
{
soundPlaying1 := 0
if IsSoundChannelPlaying( ExplosiveAttackLogicVariableValue )
{
StopSoundChannel ( ExplosiveAttackLogicVariableValue )
}
}
}
if( entityControlEnabled1 = 1 )
{
if( entityControlFrames = 1 )
{
entityControlEnabled1 := 0
}
entityControlFrames := entityControlFrames + 1
}
if( distanceWatchEnabled1 = 1 )
{
Vector3 entity1TranslationDistanceWatch30
Vector3 entity2TranslationDistanceWatch30
CopyVector3( entity1TranslationDistanceWatch30, playerTranslation )
GetEntityTranslation( Enemy2_EntityID, entity2TranslationDistanceWatch30 )
float disDistanceWatch30
disDistanceWatch30 := XZDistanceSquaredVector3( entity1TranslationDistanceWatch30, entity2TranslationDistanceWatch30 )
if disDistanceWatch30 < ( 5.00000000 * 39.3700787 ) * ( 5.00000000 * 39.3700787 )
{
distanceWatchEnabled1 := 0
SetActorAnimation( Enemy2_EntityID, Animation3_AnimationID, 1.00000000, 1 )
Enemy2_CurrentAnimFlag1 := 119
LaughterAttackLogicVariableValue := PlaySound( Sound2_SoundID, 100.00000000, 1.00000000, 1 )
soundPlayTime2 := 0
soundPlaying2 := 1
}
}
if( Enemy2_CurrentAnimFlag1 = 119 )
{
if( HasActorAnimationFinished( Enemy2_EntityID ) )
{
Enemy2_CurrentAnimFlag1 := 0
}
}
if( triggerVolumeWatchWatchEnabled5 )
{
Vector3 entityTranslationTriggerVolumeWatch150
CopyVector3( entityTranslationTriggerVolumeWatch150, playerTranslation )
float xDisTriggerVolumeWatch150 := FloatAbs( UpstairsTrigger_Position[ 0 ] - entityTranslationTriggerVolumeWatch150[ 0 ] )
float zDisTriggerVolumeWatch150 := FloatAbs( UpstairsTrigger_Position[ 2 ] - entityTranslationTriggerVolumeWatch150[ 2 ] )
float yDisTriggerVolumeWatch150 := entityTranslationTriggerVolumeWatch150[ 1 ] - UpstairsTrigger_Position[ 1 ]
if( xDisTriggerVolumeWatch150 <= UpstairsTrigger_HalfSize and zDisTriggerVolumeWatch150 <= UpstairsTrigger_HalfSize and yDisTriggerVolumeWatch150 <= ( UpstairsTrigger_HalfSize * 2 ) and yDisTriggerVolumeWatch150 >= -10)
{
triggerVolumeWatchWatchEnabled5 := 0
g_manipulateEntityDuration[ 0 ] := 2.00000000
StartManipulateEntity( 0, Enemy2_EntityID, Enemy2Marker_Position, manipulateEntityVelocity1, Enemy2Marker_Rotation, manipulateEntityAngularVelocity1, Enemy2Marker_Scale, manipulateEntityScaleVelocity1 )
}
}
tempIntVar := g_manipulateEntityActive[ 0 ]
if tempIntVar
{
manipulateEntityFinished1 := UpdateManipulateEntity( 0, Enemy2Marker_Position, manipulateEntityVelocity1, Enemy2Marker_Rotation, manipulateEntityAngularVelocity1, Enemy2Marker_Scale, manipulateEntityScaleVelocity1 )
if manipulateEntityFinished1
{
}
}
if( entityClickWatchEnabled3 = 1 and not interaction)
{
if WasMouseButtonPressed( 0 )
{
GetMousePosition( tempVector2Var )
tempIntVar := GetClosestEntityUnderPoint( tempVector2Var, 0 )
if tempIntVar = Enemy2_EntityID
{
entityClickWatchEnabled3 := 0
Enemy2HealthLogicVariableValue := Enemy2HealthLogicVariableValue - 100
}
}
}
if( variableWatchIsEnabled2 = 1 )
{
if Enemy2HealthLogicVariableValue = 0
{
variableWatchIsEnabled2 := 0
SetActorAnimation( Enemy2_EntityID, Animation1_AnimationID, 1.00000000, 0 )
Enemy2_CurrentAnimFlag1 := 120
}
}
if( Enemy2_CurrentAnimFlag1 = 120 )
{
if( HasActorAnimationFinished( Enemy2_EntityID ) )
{
Enemy2_CurrentAnimFlag1 := 0
ExplosiveAttackLogicVariableValue := PlaySound( Sound1_SoundID, 100.00000000, 1.00000000, 0 )
soundPlayTime3 := 0
soundPlaying3 := 1
if IsSoundChannelPlaying( LaughterAttackLogicVariableValue )
{
StopSoundChannel ( LaughterAttackLogicVariableValue )
}
GetEntityTranslation( Enemy2_EntityID, g_authoringTempVector )
CharacterDeath( g_authoringTempVector )
entityControlEnabled2 := 1
entityControlFrames1 := 0
SetEntityRender( Enemy2_EntityID, 0 )
SetEntityActive( Enemy2_EntityID, 0 )
}
}
if( soundPlaying3 = 1 )
{
soundPlayTime3 := soundPlayTime3 + timeStep
tempFloatVar := GetSoundLength( Sound1_SoundID )
if( soundPlayTime3 >= tempFloatVar )
{
soundPlaying3 := 0
if IsSoundChannelPlaying( ExplosiveAttackLogicVariableValue )
{
StopSoundChannel ( ExplosiveAttackLogicVariableValue )
}
}
}
if( entityControlEnabled2 = 1 )
{
if( entityControlFrames1 = 1 )
{
entityControlEnabled2 := 0
}
entityControlFrames1 := entityControlFrames1 + 1
}
if fadeUpActive1
{
if GetOverlayAlpha() = 0
{
fadeUpActive1 := 0
}
}
if( splineFollowEnabled1 = 1 )
{
if( splineEnd1 = 1 )
{
splineFollowEnabled1 := 0
SetEntityStatic( Guard1_EntityID, 1 )
}
}
Wait()
}
}
function InitialiseCameras()
{
g_followCameraEntity := CreateEntity( "followCamera", "FollowCamera" )
AddChildEntityToFront( worldEntityID, g_followCameraEntity )
SetFollowCameraEntity( g_followCameraEntity, playerEntity )
g_firstPersonCameraEntity := CreateEntity( "firstPersonCamera", "FirstPersonCamera" )
AddChildEntityToFront( worldEntityID, g_firstPersonCameraEntity )
SetFirstPersonCameraEntity( g_firstPersonCameraEntity, playerEntity )
SetCamera( g_firstPersonCameraEntity )
}
function CreateCameraOverrides()
{
cameraOverideEntity_ID := CreateEntity( "1st Person Player CameraCameraOverride", "LookAtCameraOverride" )
AddChildEntityToFront( worldEntityID, cameraOverideEntity_ID )
SetCameraToOverride( cameraOverideEntity_ID, g_firstPersonCameraEntity )
}
function UpdateCamera()
{
if cscriptDebug
{
if WasKeyPressed( KEY_NUMPAD7 )
{
SetCamera( g_followCameraEntity )
}
elseif WasKeyPressed( KEY_NUMPAD8 )
{
Vector3 translation
GetEntityTranslation( cameraEntity, translation )
SetEntityTranslationVector( freeCameraEntityID, translation )
SetCamera( freeCameraEntityID )
}
}
}
function CreatePlayer()
{
playerEntity := CreateEntityFromDefinition( "Player", "Player", "PlayerDefinition" )
AddChildEntity( worldEntityID, playerEntity )
SetEntityTranslationVector( playerEntity, startPosition )
SetEntityEulerRotation( playerEntity, 0.0, startAngle, 0.0 )
}
function InteractionStop()
{
if interaction
{
StopInteraction()
}
}
function InitialiseHUD()
{
g_defaultFontID := LoadFont( g_defaultFont )
CustomHUDHUDProgressHeathProgress_Entity2DID := GetEntity2D( "CustomHUDHUDProgressHeathProgress" )
SetEntity2DRender( CustomHUDHUDProgressHeathProgress_Entity2DID, 1 )
CustomHUDHUDButtonFireButton_Entity2DID := GetEntity2D( "CustomHUDHUDButtonFireButton" )
SetEntity2DRender( CustomHUDHUDButtonFireButton_Entity2DID, 1 )
CustomHUDInventoryButtonID := GetEntity2D( "CustomHUDInventoryButton" )
SetEntity2DRender( CustomHUDInventoryButtonID, 0 )
CustomHUDActionButtonID := GetEntity2D( "CustomHUDActionButton" )
SetEntity2DRender( CustomHUDActionButtonID, 0 )
tempIntVar := GetEntity2D( "_HUDInventoryButton" )
g_currentInventoryEntity := tempIntVar
tempIntVar := GetEntity2D( "DefaultHudActionButton" )
g_currentActionEntity := tempIntVar
UpdateHUDs()
}
function UpdateHUDText()
{
}
function UpdateProgressBars()
{
if (CustomHUDHUDProgressHeathProgressRender = 1)
{
float barLength1 := CustomHUDHUDProgressHeathProgressSize[ 0 ]
float barHeight1 := CustomHUDHUDProgressHeathProgressSize[ 1 ]
if CustomHUDHUDProgressHeathProgressIsHorizontal
{
barLength1 := ( (CurrentHealthLogicVariableValue - CustomHUDHUDProgressHeathProgressMin) / (CustomHUDHUDProgressHeathProgressMax - CustomHUDHUDProgressHeathProgressMin) ) * CustomHUDHUDProgressHeathProgressSize[ 0 ]
}
else
{
barHeight1 := ( (CurrentHealthLogicVariableValue - CustomHUDHUDProgressHeathProgressMin) / (CustomHUDHUDProgressHeathProgressMax - CustomHUDHUDProgressHeathProgressMin) ) * CustomHUDHUDProgressHeathProgressSize[ 1 ]
}
SetEntity2DSize( CustomHUDHUDProgressHeathProgress_Entity2DID, barLength1, barHeight1 )
}
}
function UpdateHUDs()
{
if ( g_activeHud = 1 )
{
tempIntVar := GetEntity2D( "_HUDInventoryButton" )
SetInventoryButtonEntity( tempIntVar )
g_currentInventoryEntity := tempIntVar
SetEntity2DRender( tempIntVar, 1 )
if g_currentActionEntity
{
SetEntity2DRender( g_currentActionEntity , 0 )
}
tempIntVar := GetEntity2D( "DefaultHudActionButton" )
SetActionButtonEntity( tempIntVar )
g_currentActionEntity := tempIntVar
SetEntity2DRender( g_currentActionEntity , 1 )
}
else
{
tempIntVar := GetEntity2D( "_HUDInventoryButton" )
SetEntity2DRender( tempIntVar, 0 )
tempIntVar := GetEntity2D( "DefaultHudActionButton" )
SetEntity2DRender( tempIntVar, 0 )
}
if ( g_activeHud = 2)
{
CustomHUDHUDProgressHeathProgressRender := 1
SetEntity2DRender( CustomHUDHUDProgressHeathProgress_Entity2DID , CustomHUDHUDProgressHeathProgressShowControl )
CustomHUDHUDButtonFireButtonRender := 1
SetEntity2DRender( CustomHUDHUDButtonFireButton_Entity2DID , CustomHUDHUDButtonFireButtonShowControl )
SetInventoryButtonEntity( CustomHUDInventoryButtonID )
g_currentInventoryEntity := CustomHUDInventoryButtonID
SetEntity2DRender( CustomHUDInventoryButtonID , g_showInventoryButton )
if g_currentActionEntity
{
SetEntity2DRender( g_currentActionEntity , 0 )
}
SetActionButtonEntity( CustomHUDActionButtonID )
g_currentActionEntity := CustomHUDActionButtonID
SetEntity2DRender( CustomHUDActionButtonID , 1 )
}
else
{
CustomHUDHUDProgressHeathProgressRender := 0
SetEntity2DRender( CustomHUDHUDProgressHeathProgress_Entity2DID , 0 )
CustomHUDHUDButtonFireButtonRender := 0
SetEntity2DRender( CustomHUDHUDButtonFireButton_Entity2DID , 0 )
SetEntity2DRender( CustomHUDInventoryButtonID , 0 )
SetEntity2DRender( CustomHUDActionButtonID , 0 )
}
}
function HideHud()
{
SetEntity2DRender( g_currentInventoryEntity, 0 )
SetEntity2DRender( g_currentActionEntity, 0 )
if (CustomHUDHUDProgressHeathProgressShowControl and CustomHUDHUDProgressHeathProgressRender and interaction)
{
SetEntity2DRender( CustomHUDHUDProgressHeathProgress_Entity2DID, CustomHUDHUDProgressHeathProgressHDI)
}
if ( (CustomHUDHUDProgressHeathProgressShowControl and not interaction) or g_hideHud = 1 )
{
SetEntity2DRender( CustomHUDHUDProgressHeathProgress_Entity2DID, 0)
}
SetEntity2DRender( CustomHUDHUDButtonFireButton_Entity2DID, 0 )
}
function ResumeHud()
{
SetEntity2DRender( g_currentInventoryEntity, g_showInventoryButton )
SetEntity2DRender( g_currentActionEntity, 1 )
if ( g_hideHud = 0 )
{
if ( CustomHUDHUDProgressHeathProgressShowControl and CustomHUDHUDProgressHeathProgressRender )
{
SetEntity2DRender( CustomHUDHUDProgressHeathProgress_Entity2DID, 1 )
}
else
{
SetEntity2DRender( CustomHUDHUDProgressHeathProgress_Entity2DID, 0 )
}
if ( CustomHUDHUDButtonFireButtonShowControl and CustomHUDHUDButtonFireButtonRender )
{
SetEntity2DRender( CustomHUDHUDButtonFireButton_Entity2DID, 1 )
}
else
{
SetEntity2DRender( CustomHUDHUDButtonFireButton_Entity2DID, 0 )
}
}
}
function CreateCommunicator()
{
g_communicatorEntity := CreateEntityFromDefinition( "Communicator", "InteractionEntity", "Communicator" )
SetEntityRender( g_communicatorEntity, 0 )
AddChildEntity( worldEntityID, g_communicatorEntity )
}
function EndCommunication()
{
constant_integer entity := interactionEntity1
if entity
{
SetEntityInteraction( entity, 0 )
StopInteraction()
SetEntityFSMState( entity, "Idle" )
SetEntityActive( entity, 0 )
}
}
function ExternalParamValue(string value) string
{
return ""
}
function OnLogicStart()
{
SetCamera( cameraOverideEntity_ID )
Vector3 commTrans10
CopyVector3( commTrans10, playerTranslation )
commTrans10[ 1 ] := commTrans10[ 1 ] + GetActorHeadHeight( playerEntity )
Vector3 rotation10
GetEntityEulerRotation( playerEntity, rotation10 )
ProjectVector3( commTrans10, 0, rotation10[ 1 ], 100.0 )
SetEntityTranslationVector( g_communicatorEntity, commTrans10 )
InteractionStop()
StartInteraction( CommunicationInteraction1_InteractionID, g_communicatorEntity, playerEntity )
SetOverlayColour( 0, 0, 0 )
SetOverlayAlpha( 1.0 )
SetOverlayFadeUp( 1.5 )
fadeUpActive1 := 1
splineFollowEnabled1 := 1
splineEnd1 := 0
SetEntityStatic( Guard1_EntityID, 0 )
SetNPCSplineEndFunction(Guard1_EntityID, "OnsplineEnd1Callback" )
SetNPCWalkAlongSpline( Guard1_EntityID, GuardPath1_EntityID )
SetEntityFSMState( Guard1_EntityID, "WalkTo" )
InitialiseControls()
}
integer g_manipulateEntityActive[ 1 ]
integer g_manipulateEntityEntities[ 1 ]
float g_manipulateEntityTime[ 1 ]
float g_manipulateEntityDuration[ 1 ]
function StartManipulateEntity( integer index, integer currentEntity, float targetLocation[ 3 ], float velocity[ 3 ], float targetRotation[ 3 ], float angularVelocity[ 3 ], float targetScale[ 3 ], float scaleVelocity[ 3 ] )
{
integer active := g_manipulateEntityActive[ index ]
if active
{
return
}
integer n := 1 - 1
integer i
for i from 0 to n
{
integer entity := g_manipulateEntityEntities[ i ]
if( entity = currentEntity)
{
return
}
}
g_manipulateEntityEntities[ index ] = currentEntity
g_manipulateEntityTime[ index ] := 0
float duration := g_manipulateEntityDuration[ index ]
Vector3 distance
float value
// Calculate translation velocity
Vector3 currentPosition
GetEntityTranslation( currentEntity, currentPosition )
SubtractVector3( distance, targetLocation, currentPosition )
value := distance[ X ]
velocity[ X ] := value / duration
value := distance[ Y ]
velocity[ Y ] := value / duration
value := distance[ Z ]
velocity[ Z ] := value / duration
// Calculate angular velocity
Vector3 currentRotation
GetEntityEulerRotation( currentEntity, currentRotation )
SubtractVector3( distance, currentRotation, targetRotation )
// Calculate x rotation
float targetX := targetRotation[ X ]
value := CalculateAngleDelta( currentRotation[ 0 ], targetX )
value := value / duration
angularVelocity[ X ] := value
// Calculate y rotation
float targetY := targetRotation[ Y ]
value := CalculateAngleDelta( currentRotation[ 1 ], targetY )
value := value / duration
angularVelocity[ Y ] := value
// Calculate z rotation
float targetZ := targetRotation[ Z ]
value := CalculateAngleDelta( currentRotation[ 2 ], targetZ )
value := value / duration
angularVelocity[ Z ] := value
// Calculate scale velocity
Vector3 currentScale
GetEntityScale( currentEntity, currentScale )
SubtractVector3( distance, targetScale, currentScale )
value := distance[ X ]
scaleVelocity[ X ] := value / duration
value := distance[ Y ]
scaleVelocity[ Y ] := value / duration
value := distance[ Z ]
scaleVelocity[ Z ] := value / duration
g_manipulateEntityActive[ index ] := 1
}
function UpdateManipulateEntity( integer index, float targetLocation[ 3 ], float velocity[ 3 ], float targetRotation[ 3 ], float angularVelocity[ 3 ], float targetScale[ 3 ], float scaleVelocity[ 3 ] ) integer
{
integer active := g_manipulateEntityActive[ index ]
if active
{
integer currentEntity := g_manipulateEntityEntities[ index ]
// Rotation
Vector3 currentRotation
GetEntityEulerRotation( currentEntity, currentRotation )
MultiplyAddVector3( currentRotation, angularVelocity, timeStep, currentRotation )
SetEntityEulerRotationVector( currentEntity, currentRotation )
// Scale
Vector3 currentScale
GetEntityScale( currentEntity, currentScale )
MultiplyAddVector3( currentScale, scaleVelocity, timeStep, currentScale )
SetEntityScale( currentEntity, currentScale[ 0 ], currentScale[ 1 ], currentScale[ 2 ] )
// Translation
Vector3 currentPosition
GetEntityTranslation( currentEntity, currentPosition )
MultiplyAddVector3( currentPosition, velocity, timeStep, currentPosition )
SetEntityTranslationVector( currentEntity, currentPosition )
float duration := g_manipulateEntityDuration[ index ]
float myCurrentTime := g_manipulateEntityTime[ index ]
myCurrentTime := myCurrentTime + timeStep
g_manipulateEntityTime[ index ] := myCurrentTime
if myCurrentTime >= duration
{
SetEntityTranslationVector( currentEntity, targetLocation )
SetEntityEulerRotationVector( currentEntity, targetRotation )
Vector3 scale
CopyVector3( scale, targetScale )
SetEntityScale( currentEntity, scale[ 0 ], scale[ 1 ], scale[ 2 ] )
integer n := 1 - 1
integer i
for i from 0 to n
{
integer entity := g_manipulateEntityEntities[ i ]
if( entity = currentEntity)
{
g_manipulateEntityEntities[ i ] := 0
}
}
g_manipulateEntityActive[ index ] := 0
return 1
}
}
return 0
}
//-----------------------------------------------------------------------------
// Compute the angle delta between the specified angles and clamp to [-180', 180']
//-----------------------------------------------------------------------------
function CalculateAngleDelta( float startAngle, float destAngle ) float
{
float angleDelta := destAngle - startAngle
if angleDelta > 180.0
{
angleDelta := angleDelta - 360
}
elseif angleDelta < -180.0
{
angleDelta := angleDelta + 360
}
return angleDelta
}
// CommunicationInteraction1 on complete handler 1
function Function29()
{
entityClickWatchEnabled1 := 1
triggerVolumeWatchWatchEnabled1 := 1
}
// CommunicationInteraction1 on complete handler 2
function Function30()
{
entityClickWatchEnabled2 := 1
triggerVolumeWatchWatchEnabled2 := 1
triggerVolumeWatchWatchEnabled3 := 1
Enemy1HealthLogicVariableValue := 100
variableWatchIsEnabled1 := 1
distanceWatchEnabled1 := 1
triggerVolumeWatchWatchEnabled5 := 1
entityClickWatchEnabled3 := 1
Enemy2HealthLogicVariableValue := 100
variableWatchIsEnabled2 := 1
}
// CommunicationInteraction1 on complete handler 3
function Function31()
{
CurrentHealthLogicVariableValue := 100
}
// CommunicationInteraction1 on complete handler 4
function Function32()
{
SetEntityStatic( FlashlightObject_EntityID, 0 )
SetEntityAngularVelocity( FlashlightObject_EntityID, 0, 120.00000000, 0 )
}
// ConversationInteraction2 on complete handler 1
function Function33()
{
ClearEntityToLookAt( cameraOverideEntity_ID )
}
function InitialiseRadarPips()
{
AddBlueCircleToRadar( Guard1_EntityID )
AddBlueCircleToRadar( Guard2_EntityID )
AddYellowCircleToRadar( FlashlightObject_EntityID )
}
function OnObjectCollected()
{
PlayerCollectInteractionEntity( interactionEntity1 )
}
function OnsplineEnd1Callback()
{
splineEnd1 := 1
}
Am I missing something from the CScript or does anyone have any ideas?
