-- Script to handle a tokyo monster -- -- Falls over and trigger collect target when the player gets close function InitTokyoMonster () print("initing TokyoMonster") print("Loading all my models...") if(Male_Ped_Clip3 == nil) then Male_Ped_Clip3 = Anim.LoadAnimation("Animations/Pedestrians/man_idle.bac") Male_Ped_Clip4 = Anim.LoadAnimation("Animations/Pedestrians/man_idle2.bac") Male_Ped_RagDoll = Anim.LoadAnimation("Animations/Ragdoll/maleped_ragdoll.bac") end end function CreateTokyoMonster (myID) Object.CreateRagdoll(myID) Object.CreateRagdollAnimationManager(myID,3) return coroutine.create(UpdateTokyoMonster) end function UpdateTokyoMonster(myID) local dt=0 local reason=0 local collected = false local TokyoMonsterCharacter = Object.LoadCharacter("Tokyo/TOK6") Object.SetCharacterSwitchOffDistance(TokyoMonsterCharacter,50) Object.SetCharacter(myID,TokyoMonsterCharacter) Object.PlayAnimation(myID,Male_Ped_Clip4,false,1.0) Object.CreateSphereTouchfield(myID,0,0,0,1) Object.UpdateOnSphereTouchfield(myID,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("Tok_Zilla",Object.GetPosition(myID)) Object.UpdateOnAnimFinished(myID,false) Object.StopMovingToTarget(myID) Object.UpdateOnSphereTouchfield(myID,false) Object.StopAnimation(myID) Object.AttachRagdoll(myID,Male_Ped_RagDoll) Object.SetUpdateRate(myID,2) Object.SetCollected(myID,Object.GetLastTouchfieldDriver(myID)) dt,reason = coroutine.yield() print("Ragdoll gone!") Object.DetachRagdoll(myID) 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,Male_Ped_Clip3,false,0.2) else Object.PlayAnimation(myID,Male_Ped_Clip4,false,1.0) end end end end