-- Script to handle an amsterdam cop -- -- This object will -- o Play an animation in a cutscene when it receives an activate trigger -- o When the animation finishes, trigger the collection target -- -- *WARNING* -- This script is currently hardocoded to player/viewport 0. It won't -- work in a multiplayer environment. If this is required, the script will -- need to be extended. function InitCop () print("initing cop") print("Loading all my models...") cop_clip1 = Anim.LoadAnimation("Animations/Pedestrians/man_idle.bac") cop_clip2 = Anim.LoadAnimation("Animations/Pedestrians/police_bust.bac") end function CreateCop (id) Object.CreateAnimationManager(id,3) return coroutine.create(UpdateCop) end function UpdateCop(myID) local dt=0 local reason=0 local CopCharacter = Object.LoadCharacter("Amsterdam/Ams5") Object.SetCharacter(myID,CopCharacter) Object.PlayAnimation(myID,cop_clip1,true,0.1) Object.UpdateOnReceiveMessage(myID,true) Object.SetUpdateRate(myID,0) while true do dt,reason = coroutine.yield() if reason == 4 then Object.StopAnimation(myID) Object.UpdateOnAnimFinished(myID,true) -- Setup the cutscene camera local lastCamera lastCamera = Camera.GetType(0) -- Hardcoding viewport Camera.SetScriptedCameraPosition( 0, Object.TransformToWorldPosition(myID,1.5,2,6) ) Camera.SetScriptedCameraLookat(0,Object.GetPosition(myID)) Camera.SetScriptedCamera(0) -- Enter a cutscene State.PauseForCutscene() -- Play my animation Object.PlayAnimation(myID,cop_clip2,false,1.0) -- Wait till its done dt, reason = coroutine.yield() Camera.SetType(0,lastCamera) State.ResumeAfterCutscene() Object.UpdateOnAnimFinished(myID,false) Object.PlayAnimation(myID,cop_clip1,true,0.1) Object.UpdateOnReceiveMessage(myID,true) Object.SetCollected(myID,0) -- Hardcoding collector end end end