backtop 17 Posted April 26, 2023 Share Posted April 26, 2023 Hey Com, does someone have the quest official like? If not can someone help me writing one? Thats all i have for now... but i dont know how to get further... quest young_heroes begin state start begin when login or levelup with pc.get_level() == 1 begin send_letter(gameforge.young_heroes.titel) end end when button or info begin say_title(gameforge.young_heroes.titel) if pc . job == 0 then say_item_vnum(21900) say_item_vnum(21903) if pc . job == 1 then say_item_vnum(21901) say_item_vnum(21902) if pc . job == 2 then say_item_vnum(21900) if pc . job == 3 then say_item_vnum(21904) say_item_vnum(21905) end end Someone know how to make a choice system for the player? Link to comment Share on other sites More sharing options...
Premium Syreldar 1875 Posted April 26, 2023 Premium Share Posted April 26, 2023 @ Mitachi "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 More sharing options...
caanmasu 312 Posted April 26, 2023 Share Posted April 26, 2023 (edited) Hi @backtop I have this quest identical to how it is seen on the official server and even improved (fixes). I can't send it to you for free but I can help you with some tips. 1. Seeing in game how the quest works is the most important part. If you realize, at level 1 they give a weapon, then at level 10, then at 20, and so on until 70. I'm not sure if when you get to level 30 (example) and you didn't claim the one from level 20, you won't be able to claim it anymore, only the one from 30 onwards. Another thing to note is that it will show you the types of weapons that the character can use. For example, the sura only uses a sword, while the ninja uses a dagger, bow and sword. 2. The way to program it. I think you're new to quest, so I'll make your life easier by making static code. (I never use static code in my quests, only dynamic code but the difficulty is much higher) I will not use a data structure in this case either, I will only declare variables as it comes out. (I always use data structure in my quests, it is a higher difficulty) You should also think about validating if the character has already claimed the weapon and sending it to the next weapon. So in this case you can use several states (each state would be each level where the weapon is claimed) or qf variables of the character that would serve as flags. In this case to make your life easier, I will do it with states (static code) 3. The interface You have said that you want it as the official one, because you have to think about how to display the inline icons and radio buttons. In this part many people get confused. About the texts, the indices of the locale texts are: 82, 84 and 85. Maybe at higher levels there are other texts like 86 but at the moment I'm not sure. Let us begin: Establish a structure for the quest. quest young_weapon_heroes begin state start begin when login begin set_state(level_1) end end state level_1 begin when letter with pc.level >= 1 and pc.level < 10 begin --limit level send_letter(locale(82)) end when button or info begin say_title(locale(82)) say(locale(84)) wait() say(locale(85)) --GUI part --in case the character has accepted a weapon, then this is done: set_state(level_10) end end --The same but with level_10 :) state level_10 begin when letter with pc.level >= 10 and pc.level < 20 begin --limit level send_letter(locale(82)) end when button or info begin say_title(locale(82)) say(locale(84)) wait() say(locale(85)) --GUI part --in case the character has accepted a weapon, then this is done: set_state(level_20) --now change here to 20 end end --Do the same until level 70. state level_70 begin when letter with pc.level >= 70 begin --limit level send_letter(locale(82)) end when button or info begin say_title(locale(82)) say(locale(84)) wait() say(locale(85)) --GUI part --in case the character has accepted a weapon, then this is done: set_state(__COMPLETE__) --This is so they don't claim infinite times the last weapon end end state __COMPLETE__ begin end end We will now do the data part. You must have listed the vnum of the weapons. The ones of level 1 go from 21900 to 21906, but you have to take into account the type of weapon to be able to show the correct ones in the corresponding races. We will create simple tables to store the weapons (level 1) that correspond to each race: local weapons = { [0] = {21900, 21903} [1] = {21900, 21901, 21902} [2] = {21900} [3] = {21904, 21905} [4] = {21906} } The indices in the table correspond to the breeds. war = 0 ninja = 1 sura = 2 shaman = 3 wolfman = 4 If you notice, the buttons are almost ready, just need to do a little fix. We will create the select: local t_select = {} for i = 1, table.getn(weapons[pc.job]) do local weapon_vnum = weapons[pc.job][i] table.insert(t_select, item_name(weapon_vnum)) end table.insert(t_select, "Close") I have simply created a table of each weapon vnum converted to its name. when button or info begin say_title(locale(82)) say(locale(84)) wait() say(locale(85)) --GUI part local weapons = { [0] = {21900, 21903} [1] = {21900, 21901, 21902} [2] = {21900} [3] = {21904, 21905} [4] = {21906} } local t_select = {} for i = 1, table.getn(weapons[pc.job]) do local weapon_vnum = weapons[pc.job][i] table.insert(t_select, item_name(weapon_vnum)) end table.insert(t_select, "Close") --in case the character has accepted a weapon, then this is done: set_state(level_10) end Not bad. We already have the buttons. Now we must activate the event when a weapon is chosen. local sel = select_table(t_select) if sel == table.getn(t_select) then return end pc.give_item2(weapons[pc.job][sel]) Note: select_table() is the same as select(), with the difference that select_table receives a table as a parameter, and in this way we make it more dynamic. I admit, I got a little dynamic on some things. In the last option (close) we go to the return so that nothing happens You may be confused in the pc.give_item2. Well, we go to the table of the weapons of our race, and the variable sel is equivalent to the position of the element. In this case, the position of the element corresponds to the weapon. Thus we have our when: when button or info begin say_title(locale(82)) say(locale(84)) wait() say(locale(85)) --GUI part local weapons = { [0] = {21900, 21903} [1] = {21900, 21901, 21902} [2] = {21900} [3] = {21904, 21905} [4] = {21906} } local t_select = {} for i = 1, table.getn(weapons[pc.job]) donde local weapon_vnum = weapons[pc.job][i] table.insert(t_select, item_name(weapon_vnum)) end table.insert(t_select, "Close") local sel = select_table(t_select) if sel == table.getn(t_select) then return end pc.give_item2(weapons[pc.job][sel]) set_state(level_10) end We are left with the interface part. For this we go to the questlib and look for this function: function say_item_vnum_inline(vnum,index,total) if index >= total then return end if total > 3 then return end raw_script("[INSERT_IMAGE image_type;item|idx;"..vnum.."|title;"..item_name(vnum).."|desc;".."".."|index;"..index.."|total;"..total.."]") end (I don't like how it's programmed but it works, we'll use it that way.) This function has the same goal as say_item, but instead of displaying a single item in the middle, this time up to 3 will be displayed on the same line. Just like in the original quest. Parameters: vnum: vnum of the item index: number of the position in the line. It starts with 0. total: maximum number of items that you are going to put in the row Example if I were a warrior: say_item_vnum_inline(21900, 0, 2) --the 2 is because we will put the sword and spear say_item_vnum_inline(21903, 1, 2) In this case, the level 1 sword and spear will be shown in a single line. Example if I were a ninja: say_item_vnum_inline(21900, 0, 3) say_item_vnum_inline(21901, 1, 3) say_item_vnum_inline(21902, 2, 3) Example if it were a surah: say_item_vnum_inline(21900, 0, 1) Do you understand the pattern? We're going to make it dynamic because for me it's the best way to do it, but if you don't understand it, go over it a bit because sometimes it's difficult the first time. local count_weapon = table.getn(weapons[pc.job]) for i = 0, count_weapon do local weapon_vnum = weapons[pc.job][i] say_item_vnum_inline(weapon_vnum, i, count_weapon) end Now we add it to our when, like this: when button or info begin say_title(locale(82)) say(locale(84)) wait() say(locale(85)) local weapons = { [0] = {21900, 21903} [1] = {21900, 21901, 21902} [2] = {21900} [3] = {21904, 21905} [4] = {21906} } local count_weapon = table.getn(weapons[pc.job]) for i = 0, count_weapon do local weapon_vnum = weapons[pc.job][i] say_item_vnum_inline(weapon_vnum, i, count_weapon) end local t_select = {} for i = 1, table.getn(weapons[pc.job]) donde local weapon_vnum = weapons[pc.job][i] table.insert(t_select, item_name(weapon_vnum)) end table.insert(t_select, "Close") local sel = select_table(t_select) if sel == table.getn(t_select) then return end pc.give_item2(weapons[pc.job][sel]) set_state(level_10) end Now just do the same with the other states. Remember to change the vnum of the weapons. Note: this code is a guide and is not tested. I have written it impromptu but I hope it will be useful. Edited April 26, 2023 by caanmasu 1 2 Link to comment Share on other sites More sharing options...
backtop 17 Posted April 27, 2023 Author Share Posted April 27, 2023 (edited) 7 hours ago, caanmasu said: Hi @backtop I have this quest identical to how it is seen on the official server and even improved (fixes). I can't send it to you for free but I can help you with some tips. 1. Seeing in game how the quest works is the most important part. If you realize, at level 1 they give a weapon, then at level 10, then at 20, and so on until 70. I'm not sure if when you get to level 30 (example) and you didn't claim the one from level 20, you won't be able to claim it anymore, only the one from 30 onwards. Another thing to note is that it will show you the types of weapons that the character can use. For example, the sura only uses a sword, while the ninja uses a dagger, bow and sword. 2. The way to program it. I think you're new to quest, so I'll make your life easier by making static code. (I never use static code in my quests, only dynamic code but the difficulty is much higher) I will not use a data structure in this case either, I will only declare variables as it comes out. (I always use data structure in my quests, it is a higher difficulty) You should also think about validating if the character has already claimed the weapon and sending it to the next weapon. So in this case you can use several states (each state would be each level where the weapon is claimed) or qf variables of the character that would serve as flags. In this case to make your life easier, I will do it with states (static code) 3. The interface You have said that you want it as the official one, because you have to think about how to display the inline icons and radio buttons. In this part many people get confused. About the texts, the indices of the locale texts are: 82, 84 and 85. Maybe at higher levels there are other texts like 86 but at the moment I'm not sure. Let us begin: Establish a structure for the quest. quest young_weapon_heroes begin state start begin when login begin set_state(level_1) end end state level_1 begin when letter with pc.level >= 1 and pc.level < 10 begin --limit level send_letter(locale(82)) end when button or info begin say_title(locale(82)) say(locale(84)) wait() say(locale(85)) --GUI part --in case the character has accepted a weapon, then this is done: set_state(level_10) end end --The same but with level_10 :) state level_10 begin when letter with pc.level >= 10 and pc.level < 20 begin --limit level send_letter(locale(82)) end when button or info begin say_title(locale(82)) say(locale(84)) wait() say(locale(85)) --GUI part --in case the character has accepted a weapon, then this is done: set_state(level_20) --now change here to 20 end end --Do the same until level 70. state level_70 begin when letter with pc.level >= 70 begin --limit level send_letter(locale(82)) end when button or info begin say_title(locale(82)) say(locale(84)) wait() say(locale(85)) --GUI part --in case the character has accepted a weapon, then this is done: set_state(__COMPLETE__) --This is so they don't claim infinite times the last weapon end end state __COMPLETE__ begin end end We will now do the data part. You must have listed the vnum of the weapons. The ones of level 1 go from 21900 to 21906, but you have to take into account the type of weapon to be able to show the correct ones in the corresponding races. We will create simple tables to store the weapons (level 1) that correspond to each race: local weapons = { [0] = {21900, 21903} [1] = {21900, 21901, 21902} [2] = {21900} [3] = {21904, 21905} [4] = {21906} } The indices in the table correspond to the breeds. war = 0 ninja = 1 sura = 2 shaman = 3 wolfman = 4 If you notice, the buttons are almost ready, just need to do a little fix. We will create the select: local t_select = {} for i = 1, table.getn(weapons[pc.job]) do local weapon_vnum = weapons[pc.job][i] table.insert(t_select, item_name(weapon_vnum)) end table.insert(t_select, "Close") I have simply created a table of each weapon vnum converted to its name. when button or info begin say_title(locale(82)) say(locale(84)) wait() say(locale(85)) --GUI part local weapons = { [0] = {21900, 21903} [1] = {21900, 21901, 21902} [2] = {21900} [3] = {21904, 21905} [4] = {21906} } local t_select = {} for i = 1, table.getn(weapons[pc.job]) do local weapon_vnum = weapons[pc.job][i] table.insert(t_select, item_name(weapon_vnum)) end table.insert(t_select, "Close") --in case the character has accepted a weapon, then this is done: set_state(level_10) end Not bad. We already have the buttons. Now we must activate the event when a weapon is chosen. local sel = select_table(t_select) if sel == table.getn(t_select) then return end pc.give_item2(weapons[pc.job][sel]) Note: select_table() is the same as select(), with the difference that select_table receives a table as a parameter, and in this way we make it more dynamic. I admit, I got a little dynamic on some things. In the last option (close) we go to the return so that nothing happens You may be confused in the pc.give_item2. Well, we go to the table of the weapons of our race, and the variable sel is equivalent to the position of the element. In this case, the position of the element corresponds to the weapon. Thus we have our when: when button or info begin say_title(locale(82)) say(locale(84)) wait() say(locale(85)) --GUI part local weapons = { [0] = {21900, 21903} [1] = {21900, 21901, 21902} [2] = {21900} [3] = {21904, 21905} [4] = {21906} } local t_select = {} for i = 1, table.getn(weapons[pc.job]) donde local weapon_vnum = weapons[pc.job][i] table.insert(t_select, item_name(weapon_vnum)) end table.insert(t_select, "Close") local sel = select_table(t_select) if sel == table.getn(t_select) then return end pc.give_item2(weapons[pc.job][sel]) set_state(level_10) end We are left with the interface part. For this we go to the questlib and look for this function: function say_item_vnum_inline(vnum,index,total) if index >= total then return end if total > 3 then return end raw_script("[INSERT_IMAGE image_type;item|idx;"..vnum.."|title;"..item_name(vnum).."|desc;".."".."|index;"..index.."|total;"..total.."]") end (I don't like how it's programmed but it works, we'll use it that way.) This function has the same goal as say_item, but instead of displaying a single item in the middle, this time up to 3 will be displayed on the same line. Just like in the original quest. Parameters: vnum: vnum of the item index: number of the position in the line. It starts with 0. total: maximum number of items that you are going to put in the row Example if I were a warrior: say_item_vnum_inline(21900, 0, 2) --the 2 is because we will put the sword and spear say_item_vnum_inline(21903, 1, 2) In this case, the level 1 sword and spear will be shown in a single line. Example if I were a ninja: say_item_vnum_inline(21900, 0, 3) say_item_vnum_inline(21901, 1, 3) say_item_vnum_inline(21902, 2, 3) Example if it were a surah: say_item_vnum_inline(21900, 0, 1) Do you understand the pattern? We're going to make it dynamic because for me it's the best way to do it, but if you don't understand it, go over it a bit because sometimes it's difficult the first time. local count_weapon = table.getn(weapons[pc.job]) for i = 0, count_weapon do local weapon_vnum = weapons[pc.job][i] say_item_vnum_inline(weapon_vnum, i, count_weapon) end Now we add it to our when, like this: when button or info begin say_title(locale(82)) say(locale(84)) wait() say(locale(85)) local weapons = { [0] = {21900, 21903} [1] = {21900, 21901, 21902} [2] = {21900} [3] = {21904, 21905} [4] = {21906} } local count_weapon = table.getn(weapons[pc.job]) for i = 0, count_weapon do local weapon_vnum = weapons[pc.job][i] say_item_vnum_inline(weapon_vnum, i, count_weapon) end local t_select = {} for i = 1, table.getn(weapons[pc.job]) donde local weapon_vnum = weapons[pc.job][i] table.insert(t_select, item_name(weapon_vnum)) end table.insert(t_select, "Close") local sel = select_table(t_select) if sel == table.getn(t_select) then return end pc.give_item2(weapons[pc.job][sel]) set_state(level_10) end Now just do the same with the other states. Remember to change the vnum of the weapons. Note: this code is a guide and is not tested. I have written it impromptu but I hope it will be useful. Thank you for your time. This really helps me out... Can you help me again? I dont know what this means Here is the Quest i tried to compile Spoiler quest young_weapon_heroes begin state start begin when login begin set_state(level_1) end end state level_1 begin when letter with pc.level >= 1 and pc.level < 10 begin --limit level send_letter("Waffen für den Junghelden") end when button or info begin say_title("Waffen für den Junghelden") local weapons = { [0] = {21900, 21903} [1] = {21900, 21901, 21902} [2] = {21900} [3] = {21904, 21905} } local count_weapon = table.getn(weapons[pc.job]) for i = 0, count_weapon do local weapon_vnum = weapons[pc.job][i] say_item_vnum_inline(weapon_vnum, i, count_weapon) end local t_select = {} for i = 1, table.getn(weapons[pc.job]) do local weapon_vnum = weapons[pc.job][i] table.insert(t_select, item_name(weapon_vnum)) end table.insert(t_select, "Close") local sel = select_table(t_select) if sel == table.getn(t_select) then return end pc.give_item2(weapons[pc.job][sel]) set_state(level_10) end end state level_10 begin when letter with pc.level >= 10 and pc.level < 20 begin --limit level send_letter("Waffen für den Junghelden") end when button or info begin say_title("Waffen für den Junghelden") local weapons = { [0] = {21910, 21913} [1] = {21910, 21911, 21912} [2] = {21910} [3] = {21914, 21915} } local count_weapon = table.getn(weapons[pc.job]) for i = 0, count_weapon do local weapon_vnum = weapons[pc.job][i] say_item_vnum_inline(weapon_vnum, i, count_weapon) end local t_select = {} for i = 1, table.getn(weapons[pc.job]) do local weapon_vnum = weapons[pc.job][i] table.insert(t_select, item_name(weapon_vnum)) end table.insert(t_select, "Close") local sel = select_table(t_select) if sel == table.getn(t_select) then return end pc.give_item2(weapons[pc.job][sel]) set_state(level_20) end end state level_20 begin when letter with pc.level >= 20 and pc.level < 30 begin --limit level send_letter("Waffen für den Junghelden") end when button or info begin say_title("Waffen für den Junghelden") local weapons = { [0] = {21920, 21923} [1] = {21920, 21921, 21922} [2] = {21920} [3] = {21924, 21925} } local count_weapon = table.getn(weapons[pc.job]) for i = 0, count_weapon do local weapon_vnum = weapons[pc.job][i] say_item_vnum_inline(weapon_vnum, i, count_weapon) end local t_select = {} for i = 1, table.getn(weapons[pc.job]) do local weapon_vnum = weapons[pc.job][i] table.insert(t_select, item_name(weapon_vnum)) end table.insert(t_select, "Close") local sel = select_table(t_select) if sel == table.getn(t_select) then return end pc.give_item2(weapons[pc.job][sel]) set_state(level_30) end end --Do the same until level 70. state level_70 begin when letter with pc.level >= 70 begin --limit level send_letter(locale(82)) end when button or info begin say_title(locale(82)) say(locale(84)) wait() say(locale(85)) --GUI part --in case the character has accepted a weapon, then this is done: set_state(__COMPLETE__) --This is so they don't claim infinite times the last weapon end end state __COMPLETE__ begin end end When i try to compile the quest i got this error: Spoiler Edited April 27, 2023 by backtop Core X - External 2 Internal Link to comment Share on other sites More sharing options...
caanmasu 312 Posted April 27, 2023 Share Posted April 27, 2023 You are welcome! Hmmm my bad. Elements in table should be splitted by comma, so: local weapons = { [0] = {21900, 21903}, [1] = {21900, 21901, 21902}, [2] = {21900}, [3] = {21904, 21905}, } Link to comment Share on other sites More sharing options...
backtop 17 Posted April 27, 2023 Author Share Posted April 27, 2023 (edited) 41 minutes ago, caanmasu said: You are welcome! Hmmm my bad. Elements in table should be splitted by comma, so: local weapons = { [0] = {21900, 21903}, [1] = {21900, 21901, 21902}, [2] = {21900}, [3] = {21904, 21905}, } Thanks quest compiled without any errors Can't choose anything and images aren't showing too My Quest: Spoiler quest young_weapon_heroes begin state start begin when login begin set_state(level_1) end end state level_1 begin when letter with pc.level >= 1 and pc.level < 10 begin send_letter("Waffen für den Junghelden") end when button or info begin say_title("Waffen für den Junghelden") local weapons = { [0] = {21900, 21903}, [1] = {21900, 21901, 21902}, [2] = {21900}, [3] = {21904, 21905}, } local count_weapon = table.getn(weapons[pc.job]) for i = 0, count_weapon do local weapon_vnum = weapons[pc.job][i] say_item_vnum_inline(weapon_vnum, i, count_weapon) end local t_select = {} for i = 1, table.getn(weapons[pc.job]) do local weapon_vnum = weapons[pc.job][i] table.insert(t_select, item_name(weapon_vnum)) end table.insert(t_select, "Close") local sel = select_table(t_select) if sel == table.getn(t_select) then return end pc.give_item2(weapons[pc.job][sel]) set_state(level_10) end end state level_10 begin when letter with pc.level >= 10 and pc.level < 20 begin send_letter("Waffen für den Junghelden") end when button or info begin say_title("Waffen für den Junghelden") local weapons = { [0] = {21910, 21913}, [1] = {21910, 21911, 21912}, [2] = {21910}, [3] = {21914, 21915}, } local count_weapon = table.getn(weapons[pc.job]) for i = 0, count_weapon do local weapon_vnum = weapons[pc.job][i] say_item_vnum_inline(weapon_vnum, i, count_weapon) end local t_select = {} for i = 1, table.getn(weapons[pc.job]) do local weapon_vnum = weapons[pc.job][i] table.insert(t_select, item_name(weapon_vnum)) end table.insert(t_select, "Close") local sel = select_table(t_select) if sel == table.getn(t_select) then return end pc.give_item2(weapons[pc.job][sel]) set_state(level_20) end end state level_20 begin when letter with pc.level >= 20 and pc.level < 30 begin send_letter("Waffen für den Junghelden") end when button or info begin say_title("Waffen für den Junghelden") local weapons = { [0] = {21920, 21923}, [1] = {21920, 21921, 21922}, [2] = {21920}, [3] = {21924, 21925}, } local count_weapon = table.getn(weapons[pc.job]) for i = 0, count_weapon do local weapon_vnum = weapons[pc.job][i] say_item_vnum_inline(weapon_vnum, i, count_weapon) end local t_select = {} for i = 1, table.getn(weapons[pc.job]) do local weapon_vnum = weapons[pc.job][i] table.insert(t_select, item_name(weapon_vnum)) end table.insert(t_select, "Close") local sel = select_table(t_select) if sel == table.getn(t_select) then return end pc.give_item2(weapons[pc.job][sel]) set_state(level_30) end end state level_30 begin when letter with pc.level >= 30 and pc.level < 40 begin send_letter("Waffen für den Junghelden") end when button or info begin say_title("Waffen für den Junghelden") local weapons = { [0] = {21930, 21933}, [1] = {21930, 21931, 21932}, [2] = {21930}, [3] = {21934, 21935}, } local count_weapon = table.getn(weapons[pc.job]) for i = 0, count_weapon do local weapon_vnum = weapons[pc.job][i] say_item_vnum_inline(weapon_vnum, i, count_weapon) end local t_select = {} for i = 1, table.getn(weapons[pc.job]) do local weapon_vnum = weapons[pc.job][i] table.insert(t_select, item_name(weapon_vnum)) end table.insert(t_select, "Close") local sel = select_table(t_select) if sel == table.getn(t_select) then return end pc.give_item2(weapons[pc.job][sel]) set_state(level_40) end end state level_40 begin when letter with pc.level >= 40 and pc.level < 50 begin send_letter("Waffen für den Junghelden") end when button or info begin say_title("Waffen für den Junghelden") local weapons = { [0] = {21940, 21943}, [1] = {21940, 21941, 21942}, [2] = {21940}, [3] = {21944, 21945}, } local count_weapon = table.getn(weapons[pc.job]) for i = 0, count_weapon do local weapon_vnum = weapons[pc.job][i] say_item_vnum_inline(weapon_vnum, i, count_weapon) end local t_select = {} for i = 1, table.getn(weapons[pc.job]) do local weapon_vnum = weapons[pc.job][i] table.insert(t_select, item_name(weapon_vnum)) end table.insert(t_select, "Close") local sel = select_table(t_select) if sel == table.getn(t_select) then return end pc.give_item2(weapons[pc.job][sel]) set_state(level_50) end end state level_50 begin when letter with pc.level >= 50 and pc.level < 60 begin send_letter("Waffen für den Junghelden") end when button or info begin say_title("Waffen für den Junghelden") local weapons = { [0] = {21950, 21953}, [1] = {21950, 21951, 21952}, [2] = {21950}, [3] = {21954, 21955}, } local count_weapon = table.getn(weapons[pc.job]) for i = 0, count_weapon do local weapon_vnum = weapons[pc.job][i] say_item_vnum_inline(weapon_vnum, i, count_weapon) end local t_select = {} for i = 1, table.getn(weapons[pc.job]) do local weapon_vnum = weapons[pc.job][i] table.insert(t_select, item_name(weapon_vnum)) end table.insert(t_select, "Close") local sel = select_table(t_select) if sel == table.getn(t_select) then return end pc.give_item2(weapons[pc.job][sel]) set_state(level_60) end end state level_60 begin when letter with pc.level >= 60 and pc.level < 70 begin send_letter("Waffen für den Junghelden") end when button or info begin say_title("Waffen für den Junghelden") local weapons = { [0] = {21960, 21963}, [1] = {21960, 21961, 21962}, [2] = {21960}, [3] = {21964, 21965}, } local count_weapon = table.getn(weapons[pc.job]) for i = 0, count_weapon do local weapon_vnum = weapons[pc.job][i] say_item_vnum_inline(weapon_vnum, i, count_weapon) end local t_select = {} for i = 1, table.getn(weapons[pc.job]) do local weapon_vnum = weapons[pc.job][i] table.insert(t_select, item_name(weapon_vnum)) end table.insert(t_select, "Close") local sel = select_table(t_select) if sel == table.getn(t_select) then return end pc.give_item2(weapons[pc.job][sel]) set_state(level_70) end end state level_70 begin when letter with pc.level >= 70 and pc.level < 80 begin send_letter("Waffen für den Junghelden") end when button or info begin say_title("Waffen für den Junghelden") local weapons = { [0] = {21970, 21973}, [1] = {21970, 21971, 21972}, [2] = {21970}, [3] = {21974, 21975}, } local count_weapon = table.getn(weapons[pc.job]) for i = 0, count_weapon do local weapon_vnum = weapons[pc.job][i] say_item_vnum_inline(weapon_vnum, i, count_weapon) end local t_select = {} for i = 1, table.getn(weapons[pc.job]) do local weapon_vnum = weapons[pc.job][i] table.insert(t_select, item_name(weapon_vnum)) end table.insert(t_select, "Close") local sel = select_table(t_select) if sel == table.getn(t_select) then return end pc.give_item2(weapons[pc.job][sel]) set_state(__COMPLETE__) end end state __COMPLETE__ begin end end But i got another problem ingame: Spoiler Edited April 27, 2023 by backtop Core X - External 2 Internal Link to comment Share on other sites More sharing options...
caanmasu 312 Posted April 27, 2023 Share Posted April 27, 2023 Put TEST_SERVER: 1 in CONFIG file from your core and check lua errors Link to comment Share on other sites More sharing options...
backtop 17 Posted April 27, 2023 Author Share Posted April 27, 2023 (edited) 16 minutes ago, caanmasu said: Put TEST_SERVER: 1 in CONFIG file from your core and check lua errors Line 116 in questlib.lua Spoiler raw_script("[INSERT_IMAGE image_type;item|idx;"..vnum.."|title;"..item_name(vnum).."|desc;".."".."|index;"..index.."|total;"..total.."]") This is my output: Spoiler Edited April 27, 2023 by backtop Core X - External 2 Internal Link to comment Share on other sites More sharing options...
PetePeter 36 Posted April 27, 2023 Share Posted April 27, 2023 I suggest you to do like that instead of create many state, as the vnum have a pattern: local item1, item2 local levelgive = math.floor((pc.get_level() - 10) / 10) * 10 if pc.get_race() == WARRIOR_M or pc.get_race() == WARRIOR_W then item1 = 21900 item2 = 21903 elseif pc.get_race() == NINJA_W or pc.get_race() == NINJA_M then item1 = 21901 item2 = 21902 elseif pc.get_race() == SURA_M or pc.get_race() == SURA_W then item1 = 21900 elseif pc.get_race() == SHAMAN_W or pc.get_race() == SHAMAN_M then item1 = 21904 item2 = 21905 end local totalitem = item2 and 2 or 1 if item1 then item1 = item1 + levelgive end if item2 then item2 = item2 + levelgive end say() if item1 then say_item_vnum_inline(item1, 0, totalitem) end if item2 then say_item_vnum_inline(item2, 1, totalitem) end Link to comment Share on other sites More sharing options...
Premium Syreldar 1875 Posted April 27, 2023 Premium Share Posted April 27, 2023 (edited) ..You really don't need that amount of code and states to make such a basic thing. define MAX_LEVEL 70 define PROG_LEVEL 10 define START_AVG_DMG 10 define PROG_AVG_DMG 3 define MAX_AVG_DMG 30 -- Needs: globals.lua, functions.lua, item.set_attribute(idx, type, value) quest young_heroes_weapons begin state start begin function IsYoungHeroLevel(pc_level) return pc_level >= PROG_LEVEL*pc.getqf("times") and pc_level <= MAX_LEVEL; end -- function function GetYoungHeroWeaponsPerJob(pc_job) local data = { [WARRIOR] = {21900, 21903}, [NINJA] = {21900, 21901, 21902}, [SURA] = {21900}, [SHAMAN] = {21904, 21905}, [WOLFMAN] = {21906} }; return data[pc_job]; end -- function when letter or levelup with young_heroes_weapons.IsYoungHeroLevel(pc.get_level()) begin send_letter("Young Heroes' Weapons"); end -- when when button or info with young_heroes_weapons.IsYoungHeroLevel(pc.get_level()) begin say_title("Young Heroes' Weapons:[ENTER]") say("Select your weapon:[ENTER]") local weapons_per_job = young_heroes_weapons.GetYoungHeroWeaponsPerJob(pc.get_job()); local choose_weapon_list_name = {}; for _, weapon_vnum in ipairs(weapons_per_job) do table.insert(choose_weapon_list_name, item_name(weapon_vnum + PROG_LEVEL*pc.getqf("times"))); end -- for table.insert(choose_weapon_list_name, "I'll choose later"); local selection = select_table(choose_weapon_list_name); if (selection == table.getn(choose_weapon_list_name)) then send_letter(letter_str); return; end -- if local weapon_to_receive = weapons_per_job[selection] + PROG_LEVEL*pc.getqf("times"); pc.give_item2_select(weapon_to_receive); -- Adds Average Damage like official. item.set_attribute(0, APPLY.NORMAL_HIT_DAMAGE_BONUS, math.min(MAX_AVG_DMG, START_AVG_DMG + PROG_AVG_DMG*pc.getqf("times"))); pc.setqf("times", pc.getqf("times")+1); q.done(); end -- when end -- state end -- quest Edited April 27, 2023 by Syreldar 1 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 More sharing options...
caanmasu 312 Posted April 27, 2023 Share Posted April 27, 2023 (edited) Hi @backtop Many times the structure of the data is complicated, and anyone would do this: --Weapons lvl 1 local weapons = { [0] = {21900, 21903}, [1] = {21900, 21901, 21902}, [2] = {21900}, [3] = {21904, 21905}, } --Weapons lvl 10 local weapons = { [0] = {21910, 21913}, [1] = {21910, 21911, 21912}, [2] = {21910}, [3] = {21914, 21915}, } --Weapons lvl 20 local weapons = { [0] = {21920, 21923}, [1] = {21920, 21921, 21922}, [2] = {21920}, [3] = {21924, 21925}, } --... To fix this problem, you need to find the pattern. You must somehow relate the vnum of the weapon to its "jump". The jump corresponds to the count of the times the reward has been collected. It will start at 0 by default and it suits us for being a qf. In my case I called it "step". 21900+step*10 I think it is understood. Regarding the type of weapon, I have "dynamized" it. On the line: local weapon_type = {{0, 3}, {0, 1, 2}, {0}, {4, 5}, {6}} The order remains the same, only when I call pc.job, I add 1 to it to match. The number that is inside each table, for example, {0, 3}, corresponds to the type of weapon, these numbers being the last digits of the weapon's vnum. In this way I have dynamized the code. There are good contributions in this thread, take the attributes of average damage and ability to complement your code. I've done a 31 line quest in case you want to review it. I must warn you that the code is not tested and most likely contains bugs. This code is a guide. But don't worry, a quest that has a lot of code or not, does not influence the server, and also nobody will be able to know it. The important thing is that things work. quest young_weapon_heroes begin state start begin when letter or levelup with pc.level >= pc.getqf("step")*10 and pc.getqf("step") <= 7 begin send_letter(locale(82)) end when button or info begin say_title(locale(82)) say(locale(84)) wait() say(locale(85)) local weapon_type = {{0, 3}, {0, 1, 2}, {0}, {4, 5}, {6}} local my_weapon_type = weapon_type[pc.job+1] local t_select = {} for i = 1, table.getn(my_weapon_type) do local weapon_vnum = 21900+pc.getqf("step")*10+my_weapon_type[i] say_item_vnum_inline(weapon_vnum, i-1, table.getn(my_weapon_type)) table.insert(t_select, item_name(weapon_vnum)) end table.insert(t_select, "Close") local sel = select_table(t_select) if sel == table.getn(t_select) then return end pc.give_item2_select(21900+pc.getqf("step")*10+my_weapon_type[sel]) pc.setqf("step", pc.getqf("step")+1) --add mean skill clear_letter() end end end Edited April 27, 2023 by caanmasu 1 1 1 Link to comment Share on other sites More sharing options...
backtop 17 Posted April 28, 2023 Author Share Posted April 28, 2023 20 hours ago, Syreldar said: ..You really don't need that amount of code and states to make such a basic thing. define MAX_LEVEL 70 define PROG_LEVEL 10 define START_AVG_DMG 10 define PROG_AVG_DMG 3 define MAX_AVG_DMG 30 -- Needs: globals.lua, functions.lua, item.set_attribute(idx, type, value) quest young_heroes_weapons begin state start begin function IsYoungHeroLevel(pc_level) return pc_level >= PROG_LEVEL*pc.getqf("times") and pc_level <= MAX_LEVEL; end -- function function GetYoungHeroWeaponsPerJob(pc_job) local data = { [WARRIOR] = {21900, 21903}, [NINJA] = {21900, 21901, 21902}, [SURA] = {21900}, [SHAMAN] = {21904, 21905}, [WOLFMAN] = {21906} }; return data[pc_job]; end -- function when letter or levelup with young_heroes_weapons.IsYoungHeroLevel(pc.get_level()) begin send_letter("Young Heroes' Weapons"); end -- when when button or info with young_heroes_weapons.IsYoungHeroLevel(pc.get_level()) begin say_title("Young Heroes' Weapons:[ENTER]") say("Select your weapon:[ENTER]") local weapons_per_job = young_heroes_weapons.GetYoungHeroWeaponsPerJob(pc.get_job()); local choose_weapon_list_name = {}; for _, weapon_vnum in ipairs(weapons_per_job) do table.insert(choose_weapon_list_name, item_name(weapon_vnum + PROG_LEVEL*pc.getqf("times"))); end -- for table.insert(choose_weapon_list_name, "I'll choose later"); local selection = select_table(choose_weapon_list_name); if (selection == table.getn(choose_weapon_list_name)) then send_letter(letter_str); return; end -- if local weapon_to_receive = weapons_per_job[selection] + PROG_LEVEL*pc.getqf("times"); pc.give_item2_select(weapon_to_receive); -- Adds Average Damage like official. item.set_attribute(0, APPLY.NORMAL_HIT_DAMAGE_BONUS, math.min(MAX_AVG_DMG, START_AVG_DMG + PROG_AVG_DMG*pc.getqf("times"))); pc.setqf("times", pc.getqf("times")+1); q.done(); end -- when end -- state end -- quest Thank you for your help But I don't have the function item.set_attribute in questlib.lua can you share this function? Link to comment Share on other sites More sharing options...
Premium Syreldar 1875 Posted April 28, 2023 Premium Share Posted April 28, 2023 8 minutes ago, backtop said: Thank you for your help But I don't have the function item.set_attribute in questlib.lua can you share this function? it's not a Lua func, hint: questlua_item.cpp "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 More sharing options...
caanmasu 312 Posted April 28, 2023 Share Posted April 28, 2023 (edited) 9 hours ago, backtop said: Thank you for your help But I don't have the function item.set_attribute in questlib.lua can you share this function? Don't bother using functions that don't exist in your source code. There is a function for that, it uses: item.set_value(index, apply_type, apply_value) Like this: item.set_value(0, 72, math.min(MAX_AVG_DMG, START_AVG_DMG + PROG_AVG_DMG*pc.getqf("times"))); Edited April 28, 2023 by caanmasu 1 Link to comment Share on other sites More sharing options...
backtop 17 Posted May 7, 2023 Author Share Posted May 7, 2023 On 4/28/2023 at 6:31 PM, caanmasu said: item.set_value(0, 72, math.min(MAX_AVG_DMG, START_AVG_DMG + PROG_AVG_DMG*pc.getqf("times"))); On 4/27/2023 at 12:35 PM, Syreldar said: item.set_attribute(0, APPLY.NORMAL_HIT_DAMAGE_BONUS, math.min(MAX_AVG_DMG, START_AVG_DMG + PROG_AVG_DMG*pc.getqf("times"))); Both Methods don't work for me... in the first quoted Methods i get an random Bonus for example strong against Devils... in the second Method i don't get an Bonus at all, i implemented the item.set_attribute in source from Pengers release Link to comment Share on other sites More sharing options...
Premium Syreldar 1875 Posted May 7, 2023 Premium Share Posted May 7, 2023 I would not post code that's not working. "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 More sharing options...
backtop 17 Posted May 7, 2023 Author Share Posted May 7, 2023 46 minutes ago, Syreldar said: I would not post code that's not working. I know you wouldn't, sorry for the misunderstanding... i just wanted to say that it don't work for me, cause i do something wrong... but i don't know what... Thats the Quest im using: Spoiler define MAX_LEVEL 70 define PROG_LEVEL 10 define START_AVG_DMG 10 define PROG_AVG_DMG 3 define MAX_AVG_DMG 30 quest young_heroes_weapons begin state start begin function IsYoungHeroLevel(pc_level) return pc_level >= PROG_LEVEL*pc.getqf("times") and pc_level <= MAX_LEVEL; end function GetYoungHeroWeaponsPerJob(pc_job) local data = { [WARRIOR] = {21900, 21903}, [NINJA] = {21900, 21901, 21902}, [SURA] = {21900}, [SHAMAN] = {21904, 21905}, [WOLFMAN] = {21906} }; return data[pc_job]; end when letter or levelup with young_heroes_weapons.IsYoungHeroLevel(pc.get_level()) begin send_letter("Young Heroes' Weapons"); end when button or info with young_heroes_weapons.IsYoungHeroLevel(pc.get_level()) begin say_title("Young Heroes' Weapons:[ENTER]") say("Select your weapon:[ENTER]") local weapons_per_job = young_heroes_weapons.GetYoungHeroWeaponsPerJob(pc.get_job()); local choose_weapon_list_name = {}; for _, weapon_vnum in ipairs(weapons_per_job) do table.insert(choose_weapon_list_name, item_name(weapon_vnum + PROG_LEVEL*pc.getqf("times"))); end -- for table.insert(choose_weapon_list_name, "I'll choose later"); local selection = select_table(choose_weapon_list_name); if (selection == table.getn(choose_weapon_list_name)) then send_letter(letter_str); return; end -- if local weapon_to_receive = weapons_per_job[selection] + PROG_LEVEL*pc.getqf("times"); pc.give_item2_select(weapon_to_receive); item.set_attribute(0, APPLY.NORMAL_HIT_DAMAGE_BONUS, math.min(MAX_AVG_DMG, START_AVG_DMG + PROG_AVG_DMG*pc.getqf("times"))); pc.setqf("times", pc.getqf("times")+1); q.done(); end end end Do i miss something? For example: On 4/27/2023 at 12:35 PM, Syreldar said: -- Needs: globals.lua, functions.lua, item.set_attribute(idx, type, value) item.set_attribute is implemented in source and in quest_functions... but i dont have globals.lua in my quest folder... Could that be the reason why i don't work? Link to comment Share on other sites More sharing options...
Morbius2 2 Posted September 15, 2023 Share Posted September 15, 2023 (edited) Hey @caanmasu thanks, It works 100% without any problem and very easy to understand. your code is very professional and clean https://metin2.download/picture/P7AJy0qttJTEI9BJ3ORypJv7oB3D5Bp4/.gif Edited September 15, 2023 by Metin2 Dev International Core X - External 2 Internal 1 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now