Jump to content

Recommended Posts

Hi, what's wrong with this quest, i nearly tried everything but can't find a solution 😃

It says " Error occured on compile skill_npc.quest " everytime when i compile the quests.

quest skill_npc begin
	state start begin
			when 9006.chat."Take Skills" begin
				local race = select("Warrior","Ninja,"Sura","Shaman")
				if race == 1 then
					local warrior_job = select("first","second")
					if warrior_job == 1 then
						pc.set_skillgroup(1)
						pc.set_skill_level(1, 59)
						pc.set_skill_level(2, 59)
						pc.set_skill_level(3, 59)
						pc.set_skill_level(4, 59)
						pc.set_skill_level(5, 59)
					elseif warrior_job ==2 then
						pc.set_skillgroup(2)
						pc.set_skill_level(16, 59)
						pc.set_skill_level(17, 59)
						pc.set_skill_level(18, 59)
						pc.set_skill_level(19, 59)
						pc.set_skill_level(20, 59)
					end
					return false
				elseif race == 2 then
					local ninja_job = select("first", "second")
					if ninja_job == 1 then
						pc.set_skillgroup(1)
						pc.set_skill_level(31, 59)
						pc.set_skill_level(32, 59)
						pc.set_skill_level(33, 59)
						pc.set_skill_level(34, 59)
						pc.set_skill_level(35, 59)
					elseif ninja_job == 2 then
						pc.set_skillgroup(2)
						pc.set_skill_level(46, 59)
						pc.set_skill_level(47, 59)
						pc.set_skill_level(48, 59)
						pc.set_skill_level(49, 59)
						pc.set_skill_level(50, 59)
					end
					return false
				elseif race == 3 then
					local sura_job = select("first","second")
					if sura_job == 1 then
						pc.set_skillgroup(1)
						pc.set_skill_level(61, 59)
						pc.set_skill_level(62, 59)
						pc.set_skill_level(63, 59)
						pc.set_skill_level(64, 59)
						pc.set_skill_level(65, 59)
						pc.set_skill_level(66, 59)
					elseif sura_job == 2 then
						pc.set_skillgroup(2)
						pc.set_skill_level(76, 59)
						pc.set_skill_level(77, 59)
						pc.set_skill_level(78, 59)
						pc.set_skill_level(79, 59)
						pc.set_skill_level(80, 59)
						pc.set_skill_level(81, 59)
					end
					return false
				elseif race == 4 then
					local shaman_job = select("first","second")
					if shaman_job == 1 then
						pc.set_skillgroup(1)
						pc.set_skill_level(91, 59)
						pc.set_skill_level(92, 59)
						pc.set_skill_level(93, 59)
						pc.set_skill_level(94, 59)
						pc.set_skill_level(95, 59)
						pc.set_skill_level(96, 59)
					elseif shaman_job == 2 then
						pc.set_skillgroup(2)
						pc.set_skill_level(106, 59)
						pc.set_skill_level(107, 59)
						pc.set_skill_level(108, 59)
						pc.set_skill_level(109, 59)
						pc.set_skill_level(110, 59)
						pc.set_skill_level(111, 59)
					end
					return false
				return false
				end
			end
	end
end

 

Edited by tugberk
Link to comment
Share on other sites

  • Premium
3 minutes ago, tugberk said:

how couldn't i see it , much thanks.

 

 

Use notepad++ and set colors as you prefer.

 

Btw

local race = select("Warrior","Ninja","Sura","Shaman","Exit")

You forgot the exit button, otherwise you are forced to click a race, not good.

(The code can be made more more smarter, but it's a nice begin) see ya.

  • Good 1
Link to comment
Share on other sites

  • Premium

A few advices:

1. If you're trying to make the player select their skill-group, there's no reason to select the race.

2. This is not a function, "return false" means and does nothing here; "return" also means nothing since you're using if and else, nesting can be improved but that's about it.

3. Loops are your friends, use them.

 

Useful data you can add to your questlib or a Global var file:

NO_SKILL_GROUP             = 0;
BASE_SKILL_LEVEL           = 1;
MASTER_SKILL_LEVEL         = 20;
GRAND_MASTER_SKILL_LEVEL   = 30;
PERFECT_MASTER_SKILL_LEVEL = 40;

-- Essentially, pc.get_job()'s output.
WARRIOR  = 0;
NINJA    = 1;
ASSASSIN = NINJA;
SURA     = 2;
SHAMAN   = 3;
LYCAN    = 4;
WOLFMAN  = LYCAN;

-- Essentially, pc.get_skill_group()'s output.
DOCTRINE_1 = 1;
DOCTRINE_2 = 2;

WARRIOR_BODY_FORCE   = DOCTRINE_1;
WARRIOR_MENTAL_FIGHT = DOCTRINE_2;

NINJA_BLADE_FIGHT    = DOCTRINE_1;
NINJA_ARCHERY        = DOCTRINE_2;

SURA_WEAPONRY        = DOCTRINE_1;
SURA_BLACK_MAGIC     = DOCTRINE_2;

SHAMAN_DRAGON_FORCE  = DOCTRINE_1;
SHAMAN_HEALING_FORCE = DOCTRINE_2;

LYCAN_INSTINCT       = DOCTRINE_1;


-- A list of class names.
DOCTRINE_NAME_LIST = {
	[WARRIOR] = {
		[WARRIOR_BODY_FORCE] = "Body-Force",
		[WARRIOR_MENTAL_FIGHT] = "Mental-Fight"
	},
	[NINJA] = {
		[NINJA_BLADE_FIGHT] = "Blade-Fight",
		[NINJA_ARCHERY] = "Archery"
	},
	[SURA] = {
		[SURA_WEAPONRY] = "Weaponry",
		[SURA_BLACK_MAGIC] = "Black Magic"
	},
	[SHAMAN] = {
		[SHAMAN_DRAGON_FORCE] = "Dragon Force",
		[SHAMAN_HEALING_FORCE] = "Healing Force"
	},
	[LYCAN] = {
		[LYCAN_INSTINCT] = "Instinct",
	}
};

 

Quest file:

Spoiler
quest skill_npc begin
	state start begin
		when 9006.chat."Take Skills" begin
			say_title(string.format("%s:[ENTER]", mob_name(npc.get_race())))
			say("Choose your path:[ENTER]")
			
			local pc_job = pc.get_job();
			local selection_table = DOCTRINE_NAME_LIST[pc_job];
			table.insert(selection_table, "I'll choose later");
			
			local selection = select_table(selection_table);
			if (selection >= table.getn(selection_table)) then
				return;
			end -- if

			pc.clear_skill();
			pc.set_skill_group(selection);
			
			local index_start = 1 + 30*pc_job + 15*(selection-1);
			for i = 1, 6 do
				pc.set_skill_level(index_start+i, PERFECT_MASTER_SKILL_LEVEL);
			end -- for
		end -- when
	end -- state
end -- quest

 

 

Edited by Syreldar
  • Love 1

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

4 hours ago, Syreldar said:

A few advices:

1. If you're trying to make the player select their skill-group, there's no reason to select the race.

2. This is not a function, "return false" means and does nothing here; "return" also means nothing since you're using if and else, nesting can be improved but that's about it.

3. Loops are your friends, use them.

 

Useful data you can add to your questlib or a Global var file:

NO_SKILL_GROUP             = 0;
BASE_SKILL_LEVEL           = 1;
MASTER_SKILL_LEVEL         = 20;
GRAND_MASTER_SKILL_LEVEL   = 30;
PERFECT_MASTER_SKILL_LEVEL = 40;

-- Essentially, pc.get_job()'s output.
WARRIOR  = 0;
NINJA    = 1;
ASSASSIN = NINJA;
SURA     = 2;
SHAMAN   = 3;
LYCAN    = 4;
WOLFMAN  = LYCAN;

-- Essentially, pc.get_skill_group()'s output.
DOCTRINE_1 = 1;
DOCTRINE_2 = 2;

WARRIOR_BODY_FORCE   = DOCTRINE_1;
WARRIOR_MENTAL_FIGHT = DOCTRINE_2;

NINJA_BLADE_FIGHT    = DOCTRINE_1;
NINJA_ARCHERY        = DOCTRINE_2;

SURA_WEAPONRY        = DOCTRINE_1;
SURA_BLACK_MAGIC     = DOCTRINE_2;

SHAMAN_DRAGON_FORCE  = DOCTRINE_1;
SHAMAN_HEALING_FORCE = DOCTRINE_2;

LYCAN_INSTINCT       = DOCTRINE_1;


-- A list of class names.
DOCTRINE_NAME_LIST = {
	[WARRIOR] = {
		[WARRIOR_BODY_FORCE] = "Body-Force",
		[WARRIOR_MENTAL_FIGHT] = "Mental-Fight"
	},
	[NINJA] = {
		[NINJA_BLADE_FIGHT] = "Blade-Fight",
		[NINJA_ARCHERY] = "Archery"
	},
	[SURA] = {
		[SURA_WEAPONRY] = "Weaponry",
		[SURA_BLACK_MAGIC] = "Black Magic"
	},
	[SHAMAN] = {
		[SHAMAN_DRAGON_FORCE] = "Dragon Force",
		[SHAMAN_HEALING_FORCE] = "Healing Force"
	},
	[LYCAN] = {
		[LYCAN_INSTINCT] = "Instinct",
	}
};

 

Quest file:

  Hide contents
quest skill_npc begin
	state start begin
		when 9006.chat."Take Skills" begin
			say_title(string.format("%s:[ENTER]", mob_name(npc.get_race())))
			say("Choose your path:[ENTER]")
			
			local pc_job = pc.get_job();
			local selection_table = DOCTRINE_NAME_LIST[pc_job];
			table.insert(selection_table, "I'll choose later");
			
			local selection = select_table(selection_table);
			if (selection >= table.getn(selection_table)) then
				return;
			end -- if

			pc.clear_skill();
			pc.set_skill_group(selection);
			
			local index_start = 1 + 30*pc_job + 15*(selection-1);
			for i = 1, 6 do
				pc.set_skill_level(index_start+i, PERFECT_MASTER_SKILL_LEVEL);
			end -- for
		end -- when
	end -- state
end -- quest

 

 

thanks a lot 👍

your example improved my way of think much more

  • Good 1
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.