-- Script to handle a tokyo school girl -- -- Falls over and trigger collect target when the player gets close function InitTokyoSchoolGirl () print("initing TokyoSchoolGirl") print("Loading all my models...") if(Female_Ped_Clip3 == nil) then Female_Ped_Clip3 = Anim.LoadAnimation("Animations/Pedestrians/woman_idle.bac") Female_Ped_Clip4 = Anim.LoadAnimation("Animations/Pedestrians/woman_idle2.bac") Female_Ped_RagDoll = Anim.LoadAnimation("Animations/Ragdoll/femaleped_sit_trike.bac") end end function CreateTokyoSchoolGirl (myID) Object.CreateRagdoll(myID) Object.CreateRagdollAnimationManager(myID,3) return coroutine.create(UpdateTokyoSchoolGirl) end function UpdateTokyoSchoolGirl(myID) local dt=0 local reason=0 local collected = false local TokyoSchoolGirlCharacter = Object.LoadCharacter("Tokyo/TOK5") Object.SetCharacterSwitchOffDistance(TokyoSchoolGirlCharacter,50) Object.SetCharacter(myID,TokyoSchoolGirlCharacter) Object.PlayAnimation(myID,Female_Ped_Clip4,false,1.0) Object.CreateSphereTouchfield(myID,0,0,0,1) Object.UpdateOnSphereTouchfield(myID,true) Object.UpdateOnPlayerCrash(myID, 0, true) -- Update now... Object.SetUpdateRate(myID,0.001) dt,reason = coroutine.yield() Object.SetUpdateRate(myID,0) Object.UpdateOnAnimFinished(myID,true) local x,y,z,ny local b=0 local cheering=false x,y,z = Object.GetPosition(myID) print("Loaded") while true do dt,reason = coroutine.yield() if reason == 1 then -- Blimey, that bike is a bit close eh? -- Stop what I'm doing Sound.PlayLua3DSoundOneShot("NYmale_ped_hit",Object.GetPosition(myID)) Object.UpdateOnAnimFinished(myID,false) Object.StopMovingToTarget(myID) Object.UpdateOnSphereTouchfield(myID,false) Object.StopAnimation(myID) Object.AttachRagdollPassenger(myID,Female_Ped_RagDoll) Object.SetUpdateRate(myID,2) Object.SetCollected(myID,Object.GetLastTouchfieldDriver(myID)) Pedestrian.AllowPedestrialRagdoll(false) Object.UpdateOnReceiveMessage(myID,true) reason = 0 while ( reason ~= 5 and reason ~= 14) do -- and reason ~=16 ) do dt,reason = coroutine.yield() if reason == 16 then Object.FreeRagdollPassengerFromConstraints(myID) end --if reason == 12 then -- hit by a ragdoll - if not crashing then tell the spawner and it can decide what to do -- driver = GetViewportDriver(0) -- if IsDriverCrashing(driver) == false then -- Object.SetDestroyed(myID,Object.GetLastTouchfieldDriver(myID)) -- end --end end print("Ragdoll gone!") Object.DetachRagdollPassenger(myID) Object.UpdateOnReceiveMessage(myID,false) Object.UpdateOnAnimFinished(myID,true) Object.UpdateOnSphereTouchfield(myID,true) Pedestrian.AllowPedestrialRagdoll(true) --Object.SetUpdateRate(myID,0) --Object.ClearCharacter(myID) --Object.Deactivate(myID) -- We are stationary elseif reason == 2 then -- Lets hang around a bit more... if math.random(3)~=1 then Object.PlayAnimation(myID,Female_Ped_Clip3,false,0.2) else Object.PlayAnimation(myID,Female_Ped_Clip4,false,1.0) end end end end