quests = {} questTargets = {} questCounter = 0 maxTargets = 10 currentQuest = 0 pointerImage = 0 pointerSprite = 0 mouseOn = 0 haveBuiltQuests = 0 questBuildDelay = 0 --[[ Quest modes: inactive offer active returning handingIn complete --]] function killquests_init(e) --[[ -- My changes file = io.open("test20230403.txt", "w"); -- sets the default output file io.output(file) io.write("\n") io.close(file) -- le fichier est créé dans: -- D:\steam\steamapps\common\Game Guru\Files -- end of my changes --]] -- My wrong line -- pointerImage = LoadImage ( "pointer.png" ) -- correction pointerImage = LoadImage ( "scriptbank\\stuff\\pointer.png" ) pointerSprite = CreateSprite ( pointerImage ) SetSpriteSize ( pointerSprite , 5 , -1 ) SetSpriteOffset ( pointerSprite , 2, 0) end function killquests_main(e) if haveBuiltQuests == 0 then questBuildDelay = questBuildDelay + 1 if questBuildDelay > 1 then haveBuiltQuests = 1 quest = newQuest(1,"Greetings, I am Bernard II of Lardtown. Son of Bernard I of Potato." , "There are soldiers to the north east bothering me," , "Please kill them for me, I will pay you well." , "Thank you, You have done this land a great service" , "Now, about your reward...", "I'm afraid I may of slightly oversold the whole rewards thing, sorry.") addQuestTarget(quest,3) addQuestTarget(quest,4) [[-- quest = newQuest(7,"Hello there adventurer, I am Boris, brother of Bernard II" , "I am heading west but some nasty looking zombies block my path." , "You look like you could take care of them. Would you help me?." , "You have my eternal thanks for your bravery." , "If I had any money I would certainly pay you well.", "Unfortunately all I can offer is my thanks. Farewell.") addQuestTarget(quest,8) addQuestTarget(quest,9) addQuestTarget(quest,10) addQuestTarget(quest,11) quest = newQuest(127,"Hello, please kill the annoying wizard guys" , "I am just a zombie who is hungry" , "I like Star Wars." , "Thank you, those guys were very annoying" , "Now I can go kill everyone in the town", "Merry Christmas") addQuestTarget(quest,125) addQuestTarget(quest,126) ]] end end if mouseOn == 1 then SetSpritePosition ( pointerSprite , g_MouseX , g_MouseY ) else SetSpritePosition ( pointerSprite , 200 , 200 ) end if currentQuest > 0 then checkQuest() end if currentQuest == 0 or quests[currentQuest]['mode'] == "returning" then for c = 1, questCounter do if quests[c]['mode'] == "inactive" or quests[c]['mode'] == "returning" then if GetPlayerDistance(quests[c]['giver']) < 100 then Prompt ( "Press E To talk") RotateToPlayer(quests[c]['giver']) if g_KeyPressE == 1 then if quests[c]['mode'] == "inactive" then quests[c]['mode'] = "offer" else quests[c]['mode'] = "handingIn" end currentQuest = 0 ActivateMouse() mouseOn = 1 end end elseif quests[c]['mode'] == "offer" then HideHuds() SetPlayerWeapons(0) Panel(25,40,75,60) TextCenterOnXColor(50,45,1,quests[c]['text1'],100,255,100) TextCenterOnXColor(50,50,1,quests[c]['text2'],100,255,100) TextCenterOnXColor(50,55,1,quests[c]['text3'],100,255,100) Panel(30,60,40,70) Panel(60,60,70,70) buttonOver = 0 if g_MouseX > 30 and g_MouseX < 40 and g_MouseY > 60 and g_MouseY < 70 then TextCenterOnXColor(35,65,1,"Accept",255,255,0) buttonOver = 1 else TextCenterOnXColor(35,65,1,"Accept",150,150,0) end if g_MouseX > 60 and g_MouseX < 70 and g_MouseY > 60 and g_MouseY < 70 then TextCenterOnXColor(65,65,1,"Decline",255,0,0) buttonOver = 2 else TextCenterOnXColor(65,65,1,"Decline",150,0,0) end if g_MouseClick == 1 then ShowHuds() SetPlayerWeapons(1) if buttonOver == 1 then quests[c]['mode'] = "active" DeactivateMouse() mouseOn = 0 currentQuest = c end if buttonOver == 2 then quests[c]['mode'] = "inactive" DeactivateMouse() mouseOn = 0 end end elseif quests[c]['mode'] == "handingIn" then HideHuds() SetPlayerWeapons(0) currentQuest = 0 Panel(25,40,75,60) TextCenterOnXColor(50,45,1,quests[c]['text4'],100,255,100) TextCenterOnXColor(50,50,1,quests[c]['text5'],100,255,100) TextCenterOnXColor(50,55,1,quests[c]['text6'],100,255,100) Panel(45,60,55,70) buttonOver = 0 if g_MouseX > 45 and g_MouseX < 55 and g_MouseY > 60 and g_MouseY < 70 then TextCenterOnXColor(50,65,1,"Complete",255,255,0) buttonOver = 1 else TextCenterOnXColor(50,65,1,"Complete",150,150,0) end if g_MouseClick == 1 then ShowHuds() SetPlayerWeapons(1) if buttonOver == 1 then quests[c]['mode'] = "complete" DeactivateMouse() mouseOn = 0 end end end end end end function checkQuest() count = 0 for c = 1, maxTargets do if questTargets[currentQuest][c] ~= nil then if g_Entity[questTargets[currentQuest][c]]['health'] > 0 then count = count + 1 end end end Panel ( 5 , 5 , 25 , 15) if count == 0 then TextCenterOnXColor(15,10,1,"Return to quest giver",255,255,0) if quests[currentQuest]['mode'] == "active" then quests[currentQuest]['mode'] = "returning" end else TextCenterOnXColor(15,10,1, count .. " targets remain",255,100,100) end end function newQuest( questGiver , text1, text2, text3, text4 , text5, text6) questCounter = questCounter + 1 quests[questCounter] = {} quests[questCounter]['mode'] = "inactive" quests[questCounter]['giver'] = questGiver quests[questCounter]['text1'] = text1 quests[questCounter]['text2'] = text2 quests[questCounter]['text3'] = text3 quests[questCounter]['text4'] = text4 quests[questCounter]['text5'] = text5 quests[questCounter]['text6'] = text6 return questCounter end function addQuestTarget(questID , targetID) if questTargets[questID] == nil then questTargets[questID] = {} end for c = 1, maxTargets do if questTargets[questID][c] == nil then questTargets[questID][c] = targetID return end end end function setActiveQuest(questID) end function setActiveQuestMode(questID) end