Scripts / Can someone check over my script for me please

Author
Message
Giewevo
8
Years of Service
User Offline
Joined: 6th Aug 2016
Location:
Posted: 29th Jun 2017 01:50
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)
pointerImage = LoadImage ( "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,2)
addQuestTarget(quest,3)

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
PM
J_C
17
Years of Service
User Offline
Joined: 9th Nov 2007
Location:
Posted: 29th Jun 2017 17:16
Hi Giewevo .. I thought this was your original script but I see it is already in my scriptbank.. with other quests...

I had not tried it before so I gave your version a go...

These are the things I would point out

1. I attached the script to an always active dynamic entity.. I always use a white flower from foliage folder for this as its easy to spot.
2. In the line
quest = newQuest(1,"Greetings.... so on...) the number 1 is the entity number of the quest giver... on my test level this was changed to 2

3. in the 2 lines
addQuestTarget(quest,2)
addQuestTarget(quest,3) the 2 and 3 are the entity numbers of the 2 enemys in my test level these changed to 3 and 4

4. the line
pointerImage = LoadImage ( "stuff\\pointer.png" )
changed to
pointerImage = LoadImage ( "scriptbank\\images\\stuff\\pointer.png" )

5. the very first line of the script is wrong...
Quests = {}
should be
quests = {}

The script then worked well on my test level...
Hope this helps..
PM
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 29th Jun 2017 17:17
When posting code on the forum please use the code tags (highlight your text then click the code button in the menu) to avoid it becoming a horrible mess.

I've attached the full script from the broadcast, and the cursor image you need. You need to save the pointer into GameGuru\Files\stuff if you don't have a folder called stuff then just create one yourself.

The instructions on how to use the script are in this video:


Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.

Attachments

Login to view attachments
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 29th Jun 2017 17:25
Quote: "4. the line
pointerImage = LoadImage ( "stuff\\pointer.png" )
changed to
pointerImage = LoadImage ( "scriptbank\\images\\stuff\\pointer.png" )"


The reason your script has that line like that is probably because you have changed it yourself and moved the pointer to files\scriptbank\stuff, the original script is written so that the pointer should be in files\stuff


Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
J_C
17
Years of Service
User Offline
Joined: 9th Nov 2007
Location:
Posted: 29th Jun 2017 17:30
Yes .. when I see your post with the video.. I must have downloaded from that..
and had a bit play and then forgot all about it..
I was wondering why I had the pointer file..

Thanks for being on the ball Belidos..
PM

Login to post a reply

Server time is: 2024-12-23 00:07:57
Your offset time is: 2024-12-23 00:07:57