Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- quest choose_bonus begin
- state start begin
- function GetBonusListPerItemSubType(subtype)
- local bonus_list = {};
- local item_class_list = {
- [1] = {
- [0] = {3, 4, 5, 6, 9, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22}, --** Sword
- [1] = {3, 4, 5, 6, 9, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22}, --** Dagger
- [2] = {3, 4, 5, 6, 9, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22}, --** Bow
- [3] = {3, 4, 5, 6, 9, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22}, --** Two-Handed Sword
- [4] = {3, 4, 5, 6, 9, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22}, --** Bell
- [5] = {3, 4, 5, 6, 9, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22}, --** Fan
- },
- [2] = {
- [0] = {1, 2, 9, 23, 24, 29, 30, 31, 32, 33, 34, 35, 36, 38, 39, 53}, --** Armor
- [1] = {7, 10, 11, 12, 17, 18, 19, 20, 21, 22, 24, 28, 35, 36, 37, 38}, --** Helmet
- [2] = {3, 4, 5, 6, 17, 18, 19, 20, 21, 22, 27, 39, 43, 44, 48, 49}, --** Shield
- [3] = {1, 2, 16, 17, 18, 19, 20, 21, 22, 23, 25, 35, 36, 37, 38, 45}, --** Armband
- [4] = {1, 2, 7, 13, 14, 15, 28, 29, 30, 31, 32, 33, 34, 43, 44}, --** Shoes
- [5] = {1, 2, 10, 11, 13, 15, 16, 24, 25, 29, 30, 31, 32, 33, 34, 43, 44}, --** Necklace
- [6] = {8, 17, 18, 19, 20, 21, 22, 25, 29, 30, 31, 32, 33, 34, 41, 45} --** Earrings
- }
- };
- local item_data = item_class_list[item_type][subtype];
- for i = 1, table.getn(item_data) do
- table.insert(bonus_list, item_data[i]);
- end -- for
- return bonus_list;
- end -- function
- function GetApplyData(value)
- local apply_data = {
- [1] = {["id"] = 1, ["str"] = "Max. HP +%d", ["value"] = 2000},
- [2] = {["id"] = 2, ["str"] = "Max. SP +%d", ["value"] = 200},
- [3] = {["id"] = 3, ["str"] = "Vitality +%d", ["value"] = 12},
- [4] = {["id"] = 4, ["str"] = "Intelligence +%d", ["value"] = 12},
- [5] = {["id"] = 5, ["str"] = "Strength +%d", ["value"] = 12},
- [6] = {["id"] = 6, ["str"] = "Dexterity +%d", ["value"] = 12},
- [7] = {["id"] = 7, ["str"] = "Attack Speed +%d%%", ["value"] = 8},
- [8] = {["id"] = 8, ["str"] = "Movement Speed +%d%%", ["value"] = 20},
- [9] = {["id"] = 9, ["str"] = "Casting Speed +%d%%", ["value"] = 20},
- [10] = {["id"] = 10, ["str"] = "HP Regeneration +%d%%", ["value"] = 30},
- [11] = {["id"] = 11, ["str"] = "MP Regeneration +%d%%", ["value"] = 30},
- [12] = {["id"] = 12, ["str"] = "Poisoning Chance +%d%%", ["value"] = 8},
- [13] = {["id"] = 13, ["str"] = "Chance for Blackout +%d%%", ["value"] = 8},
- [14] = {["id"] = 14, ["str"] = "Slowing Chance +%d%%", ["value"] = 8},
- [15] = {["id"] = 15, ["str"] = "+%d%% Chance of Critical Hit", ["value"] = 10},
- [16] = {["id"] = 16, ["str"] = "+%d%% Chance of Piercing Hit", ["value"] = 10},
- [17] = {["id"] = 17, ["str"] = "Strong against Half-Humans +%d%%", ["value"] = 10},
- [18] = {["id"] = 18, ["str"] = "Strong against Animals +%d%%", ["value"] = 20},
- [19] = {["id"] = 19, ["str"] = "Strong against Orcs +%d%%", ["value"] = 20},
- [20] = {["id"] = 20, ["str"] = "Strong against Mystics +%d%%", ["value"] = 20},
- [21] = {["id"] = 21, ["str"] = "Strong against Zombies +%d%%", ["value"] = 20},
- [22] = {["id"] = 22, ["str"] = "Strong against Devils +%d%%", ["value"] = 20},
- [23] = {["id"] = 23, ["str"] = "+%d%% damage will be absorbed by HP", ["value"] = 10},
- [24] = {["id"] = 24, ["str"] = "+%d%% damage will be absorbed by SP", ["value"] = 10},
- [25] = {["id"] = 25, ["str"] = "%d%% Chance of taking SP from the enemy", ["value"] = 10},
- [27] = {["id"] = 27, ["str"] = "+%d%% Chance to Block physical attacks", ["value"] = 15},
- [28] = {["id"] = 28, ["str"] = "+%d%% Chance of Evading Arrows", ["value"] = 15},
- [29] = {["id"] = 29, ["str"] = "+%d%% Sword Defence", ["value"] = 15},
- [30] = {["id"] = 30, ["str"] = "+%d%% Two-Handed Defence", ["value"] = 15},
- [31] = {["id"] = 31, ["str"] = "+%d%% Dagger Defence", ["value"] = 15},
- [32] = {["id"] = 32, ["str"] = "+%d%% Bell Defence", ["value"] = 15},
- [33] = {["id"] = 33, ["str"] = "+%d%% Fan Defence", ["value"] = 15},
- [34] = {["id"] = 34, ["str"] = "+%d%% Arrow resistance", ["value"] = 15},
- [35] = {["id"] = 35, ["str"] = "+%d%% Fire resistance", ["value"] = 15},
- [36] = {["id"] = 36, ["str"] = "+%d%% Lightning resistance", ["value"] = 15},
- [37] = {["id"] = 37, ["str"] = "+%d%% Magic resistance", ["value"] = 15},
- [38] = {["id"] = 38, ["str"] = "+%d%% Wind resistance", ["value"] = 15},
- [39] = {["id"] = 39, ["str"] = "+%d%% Chance to Reflect physical attacks", ["value"] = 10},
- [41] = {["id"] = 41, ["str"] = "+%d%% Poison Resistance", ["value"] = 5},
- [43] = {["id"] = 43, ["str"] = "+%d%% Chance for EXP bonus", ["value"] = 20},
- [44] = {["id"] = 44, ["str"] = "+%d%% Chance of double Yang drop", ["value"] = 20},
- [45] = {["id"] = 45, ["str"] = "+%d%% Chance of double Item drop", ["value"] = 20},
- [48] = {["id"] = 48, ["str"] = "Defence against Blackouts", ["value"] = 1},
- [49] = {["id"] = 49, ["str"] = "Defence against Slowing", ["value"] = 1},
- [53] = {["id"] = 53, ["str"] = "+%d Attack Value", ["value"] = 50}
- };
- return apply_data[value] or apply_data;
- end -- function
- when 20001.take begin
- local item_attributes = item.get_attr0();
- local item_type = item.get_type();
- local item_subtype = item.get_sub_type();
- local item_bonus_list = choose.bonus.GetBonusListPerItemSubType(item_subtype);
- say_title(string.format("%s:[ENTER]", npc.get_race()))
- if (item_type == 1 or item_type == 2) then
- say("Choose the bonus you want to modify on this item:[ENTER]")
- --[[
- Iterates through the item slots to get the bonus for each slot
- then inserts them into a table from which the player can choose which bonus has to be substituted.
- ]]
- local item_bonuses_id = {};
- local item_bonuses_str = {};
- for i = 1, 9, +2 do
- local real_apply_data = choose_bonus.GetApplyData(item_bonus_list[i]);
- if (real_apply_data ~= nil) then
- table.insert(item_bonuses_id, real_apply_data["id"]);
- table.insert(item_bonuses_str, string.format(real_apply_data["str"], real_apply_data["value"]));
- else
- table.insert(item_bonuses_str, string.format("%d. Empty or Unknown Slot", math.ceil(i/2)));
- end -- if/else
- end -- for
- table.insert(item_bonuses_str, "Nothing, close the window");
- local select_item_slot = select_table(item_bonuses_str);
- if (select_item_slot < table.getn(item_bonuses_str)) then
- say_title(string.format("%s:[ENTER]", npc.get_race()))
- say("Choose the bonus you want for this slot:[ENTER]")
- --[[
- Iterates through the all the type of bonuses that piece of equipment can handle
- then inserts them into a table from which the player can choose whatever bonus he wants to insert.
- ]]
- local new_bonus_id = 0;
- local new_bonuses_str = {};
- for i = 1, table.getn(item_bonus_list) do
- local real_apply_data = choose_bonus.GetApplyData(item_bonus_list[i]);
- if (real_apply_data ~= nil) then
- new_bonus_id = real_apply_data["id"];
- table.insert(new_bonuses_str, string.format(real_apply_data["str"], real_apply_data["value"]));
- else
- say_reward(string.format("[ERROR]: Unsupported bonus type %d.", i))
- say_reward("[ENTER]Add it to choose_bonus.GetApplyData.[ENTER]")
- return;
- end -- if
- end -- for
- table.insert(new_bonuses_str, "Nothing, close the window");
- local select_new_bonus = select_table(new_bonuses_str);
- if (select_new_bonus < table.getn(new_bonuses_str)) then
- --[[
- Check for duplicate bonus.
- ]]
- say_title(string.format("%s:[ENTER]", npc.get_race()))
- if (not table.is_in(item_bonuses_id, new_bonus_id)) then
- say("Your item's bonus has been successfully changed.[ENTER]")
- --[[
- Make a function which substitutes a determined slot and its value [value = slot_index+1]
- with new ones (item.set_attr0 does it for every single slot at once, so it's not good).
- I could always use a query but that would suck massive dick as a workaround.
- Structure Example:
- item.set_attr_by_slot(slot, new_bonus_id, new_bonus_value);
- Usage Example:
- local new_bonus = choose_bonus.GetApplyData(new_bonus_id);
- item.set_attr_by_slot(select_item_slot, new_bonus["id"], new_bonus["value"]);
- ]]
- else
- say("Your item already has that bonus type.[ENTER]")
- end -- if/else
- end -- if
- end -- if
- else
- say("I can't modify this item's bonuses.[ENTER]")
- say_item_vnum(item.get_vnum());
- end -- if
- end -- when
- end -- state
- end -- quest
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement