Jump to content
  • 0

Showing Quest Progress


Rizta

Question


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  109
  • Reputation:   5
  • Joined:  08/12/17
  • Last Seen:  

Hello everyone.

Today i have a new question (and need support for becaus im newbie :P).

I want to create a question progression function/script that'll interact with some quests npc(or every single one). Course this progression i want its only for mob hunting and item collect.

I found a script that made quest and have the @checkquest command(i want a command too) but unfortunately the script have some limitations and obviously i dont have the knowledge to modify it and a plus, it is in SQL(i know nothing in SQL).

Here's the code:

// Custom atcommand: @checkquest
bindatcmd "checkquest","QuestSysEvents::OnPCLoginEvent";
set $@QSys,1; // Quest System loaded
end;
}

-	script	QuestSysEvents	-1,{

OnNPCKillEvent:
if(!$@q_tab) end;
set .KilledMob,killedrid;
// Player in Party?
if(getcharid(1) != 0)
	addrid(2,1,getcharid(1));
if(getarraysize(@quest_mobid) < 1) 
	query_sql "SELECT `mob_id` , `mob_am` , `req_am` , `npc_id` , `quest_id` FROM `quest_player` WHERE `char_id` = '"+getcharid(0)+"'",@quest_mobid,@quest_mobam,@quest_mobreq,@quest_npcid,@quest_qid;

for ( set .@m,0; .@m < getarraysize(@quest_mobid); set .@m,.@m + 1)
	if(@quest_mobid[.@m] == killedrid)
		if(@quest_mobam[.@m] < @quest_mobreq[.@m]) {
			set @quest_mobam[.@m],@quest_mobam[.@m] + 1;
			query_sql "SELECT `npc_name` , `npc_map` FROM `quest_npc` WHERE `npc_id` = '"+@quest_npcid[.@m]+"'",.@n_name$,.@n_map$;
			dispbottom .@n_name$+"@"+.@n_map$+": Caça - "+getmonsterinfo(killedrid,MOB_NAME)+" : "+@quest_mobam[.@m]+"/"+@quest_mobreq[.@m],0x00FF00;
		} else if(@quest_mobam[.@m] >= @quest_mobreq[.@m])
			continue;
end;

OnPCLogoutEvent:
for ( set .@m,0; .@m < getarraysize(@quest_mobid); set .@m,.@m + 1)
	query_sql "UPDATE `quest_player` SET `mob_am` = '"+@quest_mobam[.@m]+"' WHERE `npc_id` = '"+@quest_npcid[.@m]+"' AND `mob_id` = '"+@quest_mobid[.@m]+"' AND `quest_id` = '"+@quest_qid[.@m]+"'";
end;

OnPCLoginEvent:
if(!$@q_tab) end;
query_sql "SELECT DISTINCT `quest_id` , `npc_id` FROM `quest_player` WHERE `char_id` = '"+getcharid(0)+"'",.@q_id,.@n_id;
set .@n$,"[Quest System]";
if(getarraysize(.@q_id) < 1) {
	dispbottom .@n$+": Você não tem missões ativas.";
	end;
}
dispbottom .@n$+": Você tem"+getarraysize(.@q_id)+" Missões ativas.";
dispbottom .@n$+": Eu vou agora listá-los por NPC com as informações sobre o NPC:";
// Updating SQL Entries for Monster Hunting before displaying Quest Progress
for ( set .@m,0; .@m < getarraysize(@quest_mobid); set .@m,.@m + 1)
	query_sql "UPDATE `quest_player` SET `mob_am` = '"+@quest_mobam[.@m]+"' WHERE `npc_id` = '"+@quest_npcid[.@m]+"' AND `mob_id` = '"+@quest_mobid[.@m]+"' AND `quest_id` = '"+@quest_qid[.@m]+"' AND `char_id` = '"+getcharid(0)+"'";

// Displaying Quest Progress
for ( set .@l,0; .@l < getarraysize(.@q_id); set .@l,.@l + 1) {
	set .@q_name$,0;
	set .@q_type,0;
	deletearray .@req1[0],getarraysize(.@req1);
	deletearray .@req2[0],getarraysize(.@req2);
	query_sql "SELECT `quest_name` , `quest_type` FROM `quest_list` WHERE `npc_id` = '"+.@n_id[.@l]+"' AND `quest_id` = '"+.@q_id[.@l]+"'",.@q_name$,.@q_type;
	dispbottom "  [* ====== Quest - "+.@q_name$+" - Progress: ====== *]  ";
	dispbottom "  >  Type: "+( (.@q_type == 1)?"Caça":"Item Coletar");
	if(.@q_type == 1)
		query_sql "SELECT `mob_id` , `mob_am` FROM `quest_list` WHERE `npc_id` = '"+.@n_id[.@l]+"' AND `quest_id` = '"+.@q_id[.@l]+"'",.@req1,.@req2;
	else
		query_sql "SELECT `item_id` , `item_am` FROM `quest_list` WHERE `npc_id` = '"+.@n_id[.@l]+"' AND `quest_id` = '"+.@q_id[.@l]+"'",.@req1,.@req2;
	
	for ( set .@p,0; .@p < getarraysize(.@req1); set .@p,.@p + 1)
		if(.@q_type == 1) {
			query_sql "SELECT `mob_am` FROM `quest_player` WHERE `npc_id` = '"+.@n_id[.@l]+"' AND `quest_id` = '"+.@q_id[.@l]+"' AND `char_id` = '"+getcharid(0)+"' AND `mob_id` = '"+.@req1[.@p]+"'",.@m_got;
			dispbottom "  >  Mob#"+(.@p+1)+": "+getmonsterinfo(.@req1[.@p],MOB_NAME)+" - "+.@m_got+"/"+.@req2[.@p];
		} else 
			dispbottom "  >  Item#"+(.@p+1)+": "+getitemname(.@req1[.@p])+" - "+countitem(.@req1[.@p])+"/"+.@req2[.@p];
	
	query_sql "SELECT `npc_name` , `npc_map` , `npc_x` , `npc_y` FROM `quest_npc` WHERE `npc_id` = '"+.@n_id[.@l]+"'",.@n_name$,.@n_map$,.@n_x,.@n_y;
	dispbottom "  >  From "+.@n_name$+", located at: "+.@n_map$+", X: "+.@n_x+", Y: "+.@n_y;
}
end;
}

i have o idea how to reproduce the SQL parts of the code in to a normal code.

Thanks for everyone that read this and try to help me.

 

NPC: Quest System SQL

by: llchrisll

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  109
  • Reputation:   5
  • Joined:  08/12/17
  • Last Seen:  

Bump this because i have a new doubt related. 

i got this script that do what i want.:

OnNPCKillEvent:
	if (getarraysize($dq_id) > .freeloop_size_active)
		.@free = freeloop(true);

	for(.@i = 0; .@i < getarraysize($dq_id); .@i++)
	{
		.@close = false;
		.@min_lv = getd("$dq_req_lv_" + $dq_id[.@i]);
		.@max_lv = getd("$dq_max_lv_" + $dq_id[.@i]);

		if (.@max_lv < BaseLevel && .@max_lv > 0)
			continue;

		if (.@min_lv > BaseLevel && .@min_lv > 0)
			continue;
		
		switch($dq_type[.@i])
		{
			// Global
			case 1:
				.@qs_type$ = "#dq_";

				deletearray .@tmp_values$;
				explode(.@tmp_values$, getd("$dq_" + $dq_id[.@i] + "_info$"), ":");

				.@tmp_value = atoi(.@tmp_values$[1]);
				.@tmp_delay = atoi(.@tmp_values$[2]);
				.@tmp_accept = atoi(.@tmp_values$[3]);

				deletearray .@tmp_values$;
				explode(.@tmp_values$, getd(.@qs_type$ + $dq_id[.@i] + "_info$"), ":");

				.@player_accept = atoi(.@tmp_values$[3]);
			break;

			// Account
			case 2:
				.@qs_type$ = "#dq_";

				deletearray .@tmp_values$;
				explode(.@tmp_values$, getd(.@qs_type$ + $dq_id[.@i] + "_info$"), ":");

				.@tmp_value = atoi(.@tmp_values$[1]);
				.@tmp_delay = atoi(.@tmp_values$[2]);
				.@tmp_accept = atoi(.@tmp_values$[3]);
			break;

			// Character
			case 3:
				.@qs_type$ = "dq_";

				deletearray .@tmp_values$;
				explode(.@tmp_values$, getd(.@qs_type$ + $dq_id[.@i] + "_info$"), ":");

				.@tmp_value = atoi(.@tmp_values$[1]);
				.@tmp_delay = atoi(.@tmp_values$[2]);
				.@tmp_accept = atoi(.@tmp_values$[3]);
			break;
		}

		if ($dq_type[.@i] == 1)
		{
			if (.@player_accept == false && .dq_player_accept == true)
				continue;

			if (.@tmp_delay > 0 && .@tmp_delay < gettimetick(2) && .@delay != -1 && .@tmp_accept == false)
				.@tmp_accept = true;
		}

		if (.dq_player_accept == true)
		{
			if (.@tmp_accept == false)
				continue;
		}
		else
		{
			if (.@tmp_accept == false && $dq_type[.@i] == 1)
				continue;
		}

		.@delay = getd("$dq_delay_" + $dq_id[.@i]);

		if (.@tmp_value >= $dq_count[.@i] && $dq_count[.@i] > 0)
		{
			if (.@tmp_delay > 0 && .@tmp_delay > gettimetick(2) && .@delay != -1)
				continue;
			else if (.@delay == -1)
				continue;
		}

		setarray .@hunting_array$[0], "$dq_hunting_id_" + $dq_id[.@i], "$dq_hunting_amount_" + $dq_id[.@i];
		.@tmp_var$ = .@qs_type$ + $dq_id[.@i] + "_hunting_count$";

		deletearray .@tmp_kill$;
		explode(.@tmp_kill$, getd(.@tmp_var$), ",");

		.@tmp_size = getarraysize(.@tmp_kill$);

		for(.@j = 0; .@j < getarraysize(getd(.@hunting_array$[0])); .@j++)
		{
			.@hunting_id = getd(.@hunting_array$[0] + "[" + .@j + "]");
			.@hunting_kill = getd(.@hunting_array$[1] + "[" + .@j + "]");

			if (.@hunting_id != killedrid)
				continue;

			.@found = false;
			setd .@tmp_var$, "";

			for(.@k = 0; .@k < .@tmp_size; .@k++)
			{
				deletearray .@tmp_values$;
				explode(.@tmp_values$, .@tmp_kill$[.@k], ":");

				.@tmp_id = atoi(.@tmp_values$[0]);
				.@tmp_count = atoi(.@tmp_values$[1]);

				if (.@tmp_count < .@hunting_kill && .@hunting_id == .@tmp_id)
				{
					if (.@k > 0)
						setd .@tmp_var$, getd(.@tmp_var$) + "," + .@tmp_id + ":" + (.@tmp_count + 1);
					else
						setd .@tmp_var$, .@tmp_id + ":" + (.@tmp_count + 1);

					if (.dq_display_hunt == true)
						dispbottom .npc_name$[1] + ": [" + $dq_name$[.@i] + "] - " + strmobinfo(1, .@tmp_id) + " [" + (.@tmp_count + 1) + "/" + .@hunting_kill + "].";

					if (.@close == false)
						.@close = true;
				}
				else
				{
					if (.@k > 0)
						setd .@tmp_var$, getd(.@tmp_var$) + "," + .@tmp_id + ":" + .@tmp_count;
					else
						setd .@tmp_var$, .@tmp_id + ":" + .@tmp_count;
				}

				if (.@hunting_id == .@tmp_id)
				{
					if (.@found == false)
						.@found = true;
				}
			}

			if (.@found == false)
			{
				if (.@tmp_size >= 1)
					setd .@tmp_var$, getd(.@tmp_var$) + "," + .@hunting_id + ":" + 1;
				else
					setd .@tmp_var$, .@hunting_id + ":" + 1;

				if (.dq_display_hunt == true)
					dispbottom .npc_name$[1] + ": [" + $dq_name$[.@i] + "] - " + strmobinfo(1, .@hunting_id) + " [" + 1 + "/" + .@hunting_kill + "].";

				if (.@close == false)
					.@close = true;
			}
			
			if (.@close == true)
				break;
		}
	}

	if (.@free == true)
		.@free = freeloop(false);

	end;

but unfortunately, cant support party kills and i dont know how to add.

I figure i can do it with:

	if(getcharid(1) != 0)
		addrid(2,1,getcharid(1));

 

And now my question is: where i can put this code to work with party members?
I tried this on start and work, but i got new bugs:

  1. If party members are in different maps, still counting.
  2. The party count only began after you kill a quest mob 1 time(and it sucks if you arent a killer).
  3. After killing a mob, every single mob(even one not in the quest request) count +1 (ex: killing a poring count as +1 quest progress for everyone in the party).

Probably there r more bugs. What can i do?

Edited by Rizta
Link to comment
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
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  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.

×
×
  • Create New...