print("NPC_MrBones init",position()) require "lua/entity.lua" require "lua/utilities.lua" require "lua/level_hub/npc_base.lua" require "lua/level_hub/ruinsstate.lua" npcname = "mrbones" ruins["npcPointers"][npcname] = get_object() if not ruins.mrBonesMinigameActive or RuinsState.get() > 14 then faceStartRange = 16 faceStopRange = 24 doFacing = true if RuinsState.get() == 16 then print(npcname,"don't do greet anims") else print(npcname,"do greet anims") doGreetAnim = true end end doTalkAnim = true if ruins.waitForBone2 then activeConversation = "RuinsMrBonesBoneCollect1" talk() end if ruins.waitForBone3 then activeConversation = "RuinsMrBonesBoneCollect2" talk() end map1 = object("_1_TreasureMap_Controller") map2 = object("_2_TreasureMap_Controller") map3 = object("_3_TreasureMap_Controller") bone1 = object("_1_Target_Mr_bones_Leg") bone2 = object("_2_Target_Mr_bones_Spines") bone3 = object("_3_Target_Mr_bones_Arms") if ruins.mrBonesMinigameActive then setAlphaSmooth(0,1,1) trigger.send(1,"FollowFriend") --trigger.send(4,"ActionButtonTrigger") end function selectConversation() if RuinsState.get() == 14 then if ruins.mrBonesMinigameActive then activeConversation = "RuinsMrBonesBoneRandom" .. mrBonesStage() .. "_" .. math.random(1,2) elseif not (ruins.bonesCollected or ruins.sc47Done) then activeConversation = "RuinsMrBones14_1" else state14DepartPrompt() end elseif RuinsState.get() == 15 then state15DepartPrompt() elseif RuinsState.get() == 16 then state16DepartPrompt() elseif RuinsState.get() == 17 then activeConversation = "RuinsMrBones17" elseif RuinsState.get() == 18 then activeConversation = "RuinsMrBones18" elseif RuinsState.get() == 19 then activeConversation = "RuinsMrBones19" elseif RuinsState.get() == 20 then activeConversation = "RuinsMrBones17" elseif RuinsState.get() == 22 then activeConversation = "RuinsMrBones22" else activeConversation = "RuinsMrBonesRandom" .. math.random(1,3) end end function showBone1() ruins.mrBonesMinigameActive = true map1.trigger.send(1,"ShowPath") bone1.setAlpha(1) ruins.waitForBone1 = true trigger.send(1,"FollowFriend") --trigger.send(4,"ActionButtonTrigger") conversationResultNo = function() print("Mr. Bones empty no") end end function showBone2() ruins.waitForBone1 = false map1.trigger.send(1,"HidePath") map2.trigger.send(1,"ShowPath") bone1.setAlpha(0) bone2.setAlpha(1) ruins.waitForBone2 = true print(get_object(),"spawn next mr bones") object("Mr_Bones_Arm").trigger.send() delete() end function showBone3() ruins.waitForBone2 = false map2.trigger.send(1,"HidePath") map3.trigger.send(1,"ShowPath") bone2.setAlpha(0) bone3.setAlpha(1) ruins.waitForBone3 = true print(get_object(),"spawn next mr bones") object("Mr_Bones_ArmLeg").trigger.send() delete() end --object("_1_Target_Mr_bones_Leg").setAlpha(0) --object("_2_Target_Mr_bones_Spines").setAlpha(0) --object("_3_Target_Mr_bones_Arms").setAlpha(0) --object("_2_TreasureMap_Controller").trigger.send(1,"ShowPath") --object("_3_TreasureMap_Controller").trigger.send(1,"ShowPath") --nextLevelPrompt(short,normalPrompt,shortPrompt,denialDialog,acceptDialog) function state14DepartPrompt(short) nextLevelPrompt(short,"RuinsMrBones14_3","RuinsMrBones14_3Direct","RuinsMrBones14_3_Deny",nil) end function state15DepartPrompt(short) nextLevelPrompt(short,"RuinsMrBones15","RuinsMrBones15Direct","RuinsMrBones15Deny",nil) end function state16DepartPrompt(short) nextLevelPrompt(short,"RuinsMrBones16","RuinsMrBones16Direct","RuinsMrBones16Deny",nil) end function mrBonesStage() if ruins.waitForBone1 then return 1 elseif ruins.waitForBone2 then return 2 elseif ruins.waitForBone3 then return 3 else return 4 end end while tick() do if trigger.received(1,"sc47Done") then print("Mr Bones got sc47Done") state14DepartPrompt(true) talk() end if trigger.received(1,"sc32Done") then print("Mr Bones got sc32Done") state15DepartPrompt(true) talk() end if trigger.received(1,"sc33Done") then print("Mr Bones got sc33Done") state16DepartPrompt(true) talk() end if trigger.received(1,"startMinigame") then if not ruins.mrBonesMinigameActive then showBone1() else --just in case trigger.send(1,"FollowFriend") end end if RuinsState.get() == 14 and not ruins.mrBonesMinigameActive and not ruins.hiddenBones and not ruins.sc47Done then bone1.setAlpha(0) bone2.setAlpha(0) bone3.setAlpha(0) ruins.hiddenBones = true end if ruins.waitForBone1 then thePlayer , distanceFromPlayer , distanceFromPlayer2D = getNearestPlayer( {bone1.position()} ) if distanceFromPlayer < 2.5 then print("Got Bone 1!") ruins.trigger.send(1,"playBonePickup") showBone2() end end if ruins.waitForBone2 then thePlayer , distanceFromPlayer , distanceFromPlayer2D = getNearestPlayer( {bone2.position()} ) if distanceFromPlayer < 2.5 then print("Got Bone 2!") ruins.trigger.send(1,"playBonePickup") showBone3() end end if ruins.waitForBone3 then thePlayer , distanceFromPlayer , distanceFromPlayer2D = getNearestPlayer( {bone3.position()} ) if distanceFromPlayer < 2.5 then print("Got Bone 3!") ruins.trigger.send(1,"playBonePickup") ruins.waitForBone3 = false map3.trigger.send(1,"HidePath") bone3.setAlpha(0) ruins.bonesCollected = true ruins.mrBonesMinigameActive = false object("Mr_Bones").trigger.send() ruins.trigger.send(1,"BonesMinigameComplete") delete() end end npctick(dt) end --print("NPC_MrBones dying",position())