print("NPC_GeneralRobot init") require "lua/entity.lua" require "lua/utilities.lua" require "lua/level_hub/npc_base.lua" require "lua/level_hub/ruinsstate.lua" npcname = "generalrobot" ruins["npcPointers"][npcname] = get_object() gavePayout = global_variable_get_bool("Ruins_GeneralRobot_gavePayout",false) myConversations = { [14] = {"RuinsGeneralRobot14" , "RuinsGeneralRobotGeneric_0" , "RuinsGeneralRobotGeneric_1" }, [15] = {"RuinsGeneralRobot15" , "RuinsGeneralRobotGeneric_0" , "RuinsGeneralRobotGeneric_1" }, [16] = {"RuinsGeneralRobot16" , "RuinsGeneralRobotGeneric_0" , "RuinsGeneralRobotGeneric_1" }, [17] = {"RuinsGeneralRobotGeneric_0" , "RuinsGeneralRobotGeneric_1" }, [18] = {"RuinsGeneralRobotGeneric_0" , "RuinsGeneralRobotGeneric_1" }, [19] = {"RuinsGeneralRobotGeneric_0" , "RuinsGeneralRobotGeneric_1" }, [20] = {"RuinsGeneralRobotGeneric_0" , "RuinsGeneralRobotGeneric_1" }, [21] = {"RuinsGeneralRobot21" , "RuinsGeneralRobotGeneric_0" , "RuinsGeneralRobotGeneric_1" }, [22] = {"RuinsGeneralRobot22", "Ruins_IGC_757_09" }, } doFacing = true doGreetAnim = false doTalkAnim = true botherCounter = 0 function selectConversation() if RuinsState.get() == 11 then state11DepartPrompt() elseif RuinsState.get() == 12 then state12DepartPrompt() elseif RuinsState.get() == 13 then state13DepartPrompt() elseif RuinsState.get() == 22 and not gavePayout then activeConversation = "RuinsGeneralRobot22_1" conversationResultAll = payout elseif botherCounter >= 5 then print(npcname,"bother") activeConversation = "Ruins_IGC_757_09" botherCounter = 0 else print(npcname,"table conversation") local thisConversation = "" local state = RuinsState.get() if type(myConversations[state]) == "table" then thisConversation = myConversations[state][math.random(1,#myConversations[state])] else thisConversation = myConversations[state] end activeConversation = thisConversation botherCounter = botherCounter + 1 end end function payout() local px , py , pz = position() pz = pz + 5 print("$$$ general robot payout $$$") spawnThrownLoot( "diamond" , {px , py , pz} , 100 , 0 , 3 ) gavePayout = true global_variable_set_bool("Ruins_GeneralRobot_gavePayout",gavePayout) SaveGameProgress() conversationResultAll = function() end end function state11DepartPrompt(short) nextLevelPrompt(short,"RuinsGeneralRobot11_0","RuinsGeneralRobot11_0Direct","RuinsGeneralRobot11_Refuse",nil) end function state12DepartPrompt(short) nextLevelPrompt(short,"RuinsGeneralRobot12_0","RuinsGeneralRobot12_0Direct","RuinsGeneralRobot12_Refuse",nil) end function state13DepartPrompt(short) nextLevelPrompt(short,"RuinsGeneralRobot13_0","RuinsGeneralRobot13_0Direct","RuinsGeneralRobot13_Refuse",nil) end while tick() do if trigger.received(1,"sc25Done") then print("generalrobot got sc25Done") state11DepartPrompt(true) talk() end if trigger.received(1,"sc27Done") then print("generalrobot got sc27Done") state12DepartPrompt(true) talk() end if trigger.received(1,"sc28Done") then print("generalrobot got sc28Done") state13DepartPrompt(true) talk() end npctick(dt) end