Jump to content
Sign in to follow this  
SoundX

Mark quests as "COMPLETE" in quest log (1.3x server files)

Recommended Posts

Hi all. I am posting this here as it took me some time to figure it out and maybe someone else wants to use it as well.

 

- What we want to achieve:

xm5lwMC.png

 

Mission shows a "[Completed]" flag in the quest log when we have collected all items - killed all mobs

 

- In directory `/resource/script/MisSdk/`

 

1. File: ScriptSdk.lua:

We will start a variable called `MissionSid    = {}` in global variables definition, line ~=16 (below `Mission` variable):
 

Spoiler

 


-- Scripting system - Global Variables

Page       = {}				-- global variable definition: NPC dialog Information
Exchange  = {}
ExchangeX = {}
FuncList  = {}
Trade     = {}				-- global variable definition: NPC Transaction Information 
Goods	 = {}				-- global variable definition: NPC Cargo Transaction Information
Mission    = {}				-- global variable definition: All mission information
MissionSid	= {}			-- global variable definition: Mission ID corresponding to Task ID
MisLogList = {}				-- global variable definition: Mission information saved to logs

 

 

 

 

and in function `DefineMission` we will cal the MissionSid with a misid index:
 

Spoiler

 


-- Register  task profile
function DefineMission( id, name, misid, show, mistp )
	LG( "mission", "ID: "..id, " Name:"..name, " MisID:"..misid )
	-- Set task profile
	MissionSid[misid] = id
	Mission[id] = {}
	Mission[id].id = misid		-- Task Identification ID
	Mission[id].sid = id 		-- Script Task Index ID
	Mission[id].name = name

 

 

 

1. File: MissionSdk.lua:

Here we will use the function `RefreshCompleteFlag` (used normally by random class quests, "A hunter's life" etc).

 

First in the `RefreshCompleteFlag` function itself: The function defines a local called: `local mission`. We will start this local with the value of `Mission[sid]`, so replace `local mission` with `local mission = Mission[sid]`:

 

Spoiler

-- Refresh task status if is completed
function RefreshCompleteFlag( character, sid )
	PRINT( "RefreshCompleteFlag" )
	if sid == nil or Mission[sid] == nil then
		PRINT( "RefreshCompleteFlag:incorrect quest script ID number,sid = "..sid )
		SystemNotice( character, "RefreshCompleteFlag:incorrect quest script ID number,sid = "..sid )
		return LUA_FALSE
	end

	local mission = Mission[sid]
	if Mission[sid].tp == NOMAL_MISSION then
		mission = Mission[sid]
	elseif Mission[sid].tp == RAND_MISSION then
		-- Random task has been accepted, check if can be deliver

 

 

Then we need to use the `RefreshCompleteFlag` function in the `AddNextFlag` function: ( we added the line `RefreshCompleteFlag(character,MissionSid[id])` ):

 

Spoiler

function AddNextFlag( character, id, startflag, count )
	if id == nil or startflag == nil or count == nil then
		SystemNotice( character, "AddNextFlag:Function parameter error!" )
	end
	local num = 0
	for i = 1, count, 1 do
		local ret = IsFlag( character, id, startflag + num )
		if ret == LUA_FALSE then
			PRINT( "AddNextFlag: flag = ", startflag + num )
			ret = SetFlag( character, id, startflag + num )
			RefreshCompleteFlag(character,MissionSid[id])

 

 

I hope this can help someone. Sorry for my English and if there are mistakes/bad scripting/better way, please let me know

Edited by SoundX
  • Like 4

Share this post


Link to post
Share on other sites

As two people have asked this, maybe this help the guide to be more complete:

 

If you have custom quests in your server, and you don't register this quest on the client, you usually see the "Unknown quest" in an "Invalid type" section within the quest log:

 

1wMTntl.jpg

 

If you use the tweak described above, in some server files this might also reveal the Mission ID and see this as "Unknown Quest name ID [140]". This can be avoided easily though by adding the quest name to the client:

 

Tales of Pirates Online\scripts\lua\mission\missioninfo.lua

 

Add the quest name and type (1, normal, 2, story quest):

 

-- AddMisData( <QUEST ID>	,	<QUEST NAME>,	<QUEST TYPE 1 or 2>)
AddMisData( 140	,	"Revenge of the shrubs ",	1)

 

And this should solve the problem

u6WVnJi.jpg

Share this post


Link to post
Share on other sites

In the OP, it would be easier to read if you used a brighter color for the keywords/files, as it looks fairly difficult to read on the dark background. Otherwise, great guide.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...