banynavy
25-04-10, 04:50 PM
IncludeFile("config.lua")
-- C竎 bi課 to祅 c鬰:
-- C竎 h籲g Timer
TIMER_ID1 = 1000
TIMER_ID2 = 2000
TIMER_ID3 = 3000
TIMER_ID4 = 4000
TIMER_ID5 = 5000
-- C竎 h籲g th玭g s?m芻 nh
MAX_NPC = 255
MAX_OBJ = 255
OBJ_PICKUP_RANGE = 100 * 100
DATAU_RANGE = 100*100
MAX_MOVE_FRAME = 8
MAX_CHECK_LAG_TIME = 3000
-- C竎 h籲g ph輒 t総
SCK_SHORTCUT_SIT = "Switch([[sit]])"
SCK_SHORTCUT_RUN = "Switch([[run]])"
SCK_SHORTCUT_PK = "Switch([[pk]])"
SCK_SHORTCUT_HORSE = "Switch([[horse]])"
-- C竎 bi課 check lag
nOldIndex = 0
nOldHP = 0
nCount = 0
nLagIndex = 0
-- Bi課 check refresh tbBlackObjectList
nOrgPlayerX = 0
nOrgPlayerY = 0
nRefreshTime = 0
-- C竎 bi課 ghi nh薾 s?ki謓
bBoughtTownPortal = false
bBoughtMedicine = false
bDrawedMoney = false
bSavedMoney = false
bGoneBackPoint = false
bPickingUp = true
-- C竎 bi課 bi課 i ti襫 v筺
nFullMoneyValueV = nFullMoneyValue * 10000
nDrawMoneyValueV = nDrawMoneyValue * 10000
--C竎 bi課 ghi nh薾 tr筺g th竔 nhi謒 v?D?T萿
bForfeit = 0
bFinish = 0
-- C竎 table h祄
tbAuxiliary = {}
tbBasic = {}
tbRestore = {}
tbAttack = {}
tbPickUp = {}
tbCastle = {}
tbQuest = {}
-- C竎 table d?li謚
tbOrgObjectList = {}
tbBlackObjectList = {}
tbKeepItemList = {}
tbUserBlackObjectList =
{
"Th鬰 C萴 y",
}
tbHelmList =
{
"Sa Di Gi韎 C?",
"T╪g Gi韎 C?",
"Ph藅 蕁 Gi韎 C?",
"T╪g Gi?Gi韎 C?",
"Kh玭 L閏 m穙",
"L﹎ Li猲 M穙",
"Ph?Dung M穙",
"Th萴 Lu﹏ M穙",
"Ni謒 Ninh M穙",
"T?L?m穙",
"M閏 Tr﹎",
"Ho祅g Dng M閏 Tr﹎",
"C祅 Kh玭 k誸",
"Th竔 c鵦 Qu竛",
"B竧 Qu竔 C﹏",
"C祅 Kh秏 C﹏",
"Ng?Nh筩 Qu竛",
"Thng Thanh Qu竛",
"Tinh Qu竛",
"Ng?l穙 qu竛",
"Tr骳 L筽",
"Ng?L筽",
"Th萴 L?Th秓 M穙",
"Chu Tao th秓 M穙",
"Huy襫 Sa Di謓 Tr竜",
"Thanh S竧 di謓 tr竜",
"Nh﹏ B?Di謓 Tr竜",
"Ng?чc ph竧 k誸",
"B竎h чc ph竧 k誸",
"Tu La Ph竧 k誸",
"Nho C﹏",
"Ti課 Ki猲 Qu竛",
"Vi謙 M?Qu竛",
"Phi Y課 Qu竛",
"猽 Thi襫 Qu竛",
"Lang T?Qu竛",
"Anh L筩 Qu竛",
"T?Kim ph竧 Qu竛",
"Th蕋 B秓 ph竧 Qu竛",
"Th玭g Thi猲 Ph竧 Qu竛",
"уng Kh玦",
"B竛 Di謓 Kh玦",
"Song Di謓 Kh玦",
"Thi誸 Kh玦",
"Tinh уng u Kh玦",
"Cang kh玦 ",
"Ng﹏ Kh玦",
"Tinh Cang Kh玦",
"Kim Kh玦 ",
"Y觤 Nh藅 kh玦",
"Ph?B?C﹏",
"B竧 Phng C﹏",
"Ti猽 Di猽 C﹏",
"L?Thi猲 C﹏",
"B筩h Th鵦 Ho祅",
"L璾 Ly Ho祅",
"Song T莕g L璾 Ly Ho祅",
"T輓 nh韆 Ho祅",
"T譶h nh韆 Ho祅",
"Tr輈h Tinh ho祅",
"B?C﹏",
"B譶h жnh C﹏",
"B?Nh髇g C﹏",
"Nh筺 V?C﹏",
"Y T?Ph竧 Цi",
"Kim T?Qu竛",
"Chu Kh雐 Qu竛",
"Doanh Gi竎 M穙",
"T祄 T?M穙",
"?T祄 M穙",
"Th輈h Ni M穙",
"Th輈h Ni M穙",
"Th輈h Ni M穙",
"Th輈h Ni M穙",
"Thanh M穙",
"Thanh Anh M穙",
"Thi猲 Thanh M穙",
"X輈h 秐h ph竧 Qu竛",
"V?Tng Ph竝 Qu竛",
"Quan Ph竧 Qu竛",
"Ng﹏ Thoa",
"Ng﹏ Li猰 Thoa",
"Ng﹏ Li謒 Thoa",
"Ng﹏ Ho祅 Thoa",
"Kim Thoa",
"Kim Ho祅 Thoa",
"Kim B?Dao",
"Ph?Th髖 Thoa",
"Th竔 c鵦 Qu竛",
" Dng V?C鵦 qu竛",
"B譚r?",
"уng Tr?",
"Tinh уng Tr?",
"X輈h уn B?M穙",
"Th?C鑤 Tr﹎",
"T?C鑤 Tr﹎",
"Huy襫 C鑤 Tr﹎",
"H?B譊i謓 Tr竜",
"猽 B?Di謓 Tr竜",
"Huy襫 T?Di謓 Tr竜",
"Th?Thi誸 u Ho祅",
"T?Thi誸 u Ho祅",
"Ho祅g уng u Ho祅",
"L鬰 Ng鋍 u Ho祅",
"K?V?Thoa",
"Anh v?Thoa",
"B祅 X?Thoa",
"Chu Sa u Ho祅",
"Minh Ch﹗ u Ho祅",
"Long Huy誸 u ho祅",
"Vi猲 M穙",
"Л阯g M穙",
"C﹏ Qu秐 M穙",
"T?Gi竎 M穙",
"Thanh Ph鬾g Qu竛",
"Kim Ph鬾g Qu竛",
"Song Ph鬾g Tri襲 Thi猲 Qu竛",
"Ph?Th髖 Kh玦",
"Gi秈 Tr筰 Kh玦",
"Long L﹏ Kh玦",
"B?M穙",
"Vi猲 жnh M穙",
"Ph筸 V╪ M穙",
"Thanh V╪ Kh玦",
"H錸g Anh Thoa",
"X輈h Huy誸 Thoa",
"L璾 Ly Thoa",
"L閏 nh?Thoa",
"Lam Tinh Thoa",
"Thanh Tinh Thoa",
"Ho祅g B?Ph竧 Цi",
"Ho祅g B?Ph竧 Цi",
"Ho祅g B?Ph竧 Цi",
"Ho祅g B?Ph竧 Цi",
"Ho祅g уng Ph竧 Xoa",
"H錸g M?N穙 Ph竧 Xoa",
"Thanh L璾 Ly Ph竧 Xoa",
"Huy Th駓 Kh玦",
"Ph鬾g Nh穘 Kh玦",
"Kim Ph鬾g Tri觧 S?",
}
tbAmorList =
{
"Sa Di ph鬰",
"T╪g y",
"B竎h N筽 y",
"An h閕",
"U蕋 La T╪g",
"T╪g H礽 ",
"Nguy謓 B筩h C?Sa ",
"Minh T躰h C?Sa",
"Kim L?C?Sa ",
"Th蕋 B秓 C?Sa",
"Чo s?v?b祇",
"Чo s?trng b祇",
"T躰h y",
"Thanh T飊g Ph竝 b祇",
"Thi猲 s?o b祇",
"Huy襫 V?ph竝 y",
"Th蕋 B秓 H?y",
"Tam Thanh B祇",
"Thi猲 Ni猲 H筩 Sng",
"Ch﹏ V?Th竛h Y",
"C鎛 y",
"T?Tr骳 C鎛 y",
"Th輈h Kh竎h y",
"M閚g m?y",
"V?S綾 y",
"Ng?Nh蒼 y",
"Li猲 V﹏ y",
"Thi猲 M閚g y",
"V?Dung K輓h y",
"Thi猲 Nh蒼 M藅 Trang",
"Th?B?trng b祇",
"Khinh C竧 sam",
"筺 b祇 ",
"D藅 Hi謕 y",
"Nhi謒 Hi謕 ph鬰",
"L璾 Th竔 Ph鬰",
"Ng﹏ T?B祇",
"T?Kim b祇",
"H祅 Sng b祇",
"Gi竛g Sa B祇",
"T醓 T?gi竝",
"Lng Цng Kh秈",
"Minh Quang Kh秈",
"T?L﹏ gi竝",
"?Ch飝 gi竝",
"S琻 V╪ T?gi竝",
"Gi秈 Tr筰 gi竝",
"Toan Ngh?gi竝",
"T醓 T?Ho祅g Kim gi竝",
"Л阯g Ngh?gi竝",
"Lan B?y",
"Ph?th玭g C竔 y",
"竜 ╪ m祔",
"Th?Ma C竔 y",
"T莔 Ma C竔 y",
"H醓 Ma C竔 y",
"Th藀 phng C竔 y",
"B竎h k誸 C竔 y",
"Tri襫 T?Thi猲 K誸 ph鬰",
"V筺 L璾 Quy T玭g Y",
"竜 v秈 th?",
"竜 v秈 th?",
"竜 v秈 th?",
"竜 v秈 th?",
"Ho祅g C萴 畂秐 y",
"Ch鴆 gi竝 畂秐 sam",
"Huy襫 Ho祅g 畂秐 gi竝",
"B輈h Hoa B祇",
"Tng Nh?b祇",
"Tuy襫 Long b祇",
"Sa Ni ph鬰",
"T╪g b祇 ",
"B竎h N筽 y",
"An h閕",
"U蕋 La T╪g",
"T╪g H礽",
"Nguy謓 B筩h c?sa",
"Minh t躰h c?sa",
"Kim L?c?sa",
"Th蕋 B秓 c?sa ",
"N?th鴆 o y",
"Tu Ch﹏ o y",
"H醓 Ho祅 o y",
"B輈h H?o y",
"B竧 qu竔 o y",
"H祅 Mai o y",
"V?C鵦 Чo y",
"мa Duy猲 o y",
"B╪g T祄 o y",
"Long Ti猽 o y",
"Th鬰 C萴 y",
"L╪g T?y",
"C萴 Tr鋘g y",
"Linh X?y",
"Huy襫 Ly y",
"H綾 B竜 y",
"H?B?y",
"V薾 Ngh?thng",
"M?H錸 Thng",
"C鰑 V?B筩h H?trang",
"C萴 Sam",
"Kh雐 Ly sam",
"Hoa Sa sam",
"Th鬰 C萴 Sam",
"T鑞g C萴 Sam",
"V﹏ C萴 Sam",
"Thanh La sam",
"T蕋 Sa sam",
"L╪g La sam",
"Tr莔 Hng sam",
"Kh秏 Thi誸 n?gi竝",
"Thanh уng n?gi竝",
"B筩h Nh?gi竝",
"Lam Y課 Cang gi竝",
"H錸g Nh?gi竝",
"X輈h Nh筺 gi竝",
"Huy誸 уng gi竝",
"Lan Ng﹏ gi竝",
"Huy襫 Thi誸 Tuy誸 Ng﹏ gi竝",
"T輈h L辌h Kim Ph鬾g gi竝",
"Ph?Ma y",
"Ph?Mi猲 y",
"Ph?C鎛 y",
"B筩h B?y",
"Thi猲 b?y",
"Dng B?gi竝",
"Ng璾 B?gi竝",
"T?Th?y",
"Kh玦 猽 y",
"V筺 Ch髇g T?T﹎ Y",
"B筩h 謕 qu莕",
"Thanh La qu莕",
"Ch鴆 C萴 Th筩h L鵸 qu莕",
"Song 謕 T?La qu莕",
"B竎h ?qu莕",
"Nguy謙 Hoa qu莕",
"Phong V?qu莕",
"Kinh B秓 qu莕",
"B竎h Phong Tri襲 Dng qu莕",
"L璾 Ti猲 Qu莕",
"Sa Di ph鬰",
"T╪g y",
"B竎h N筽 y",
"An h閕",
"U蕋 La T╪g",
"T╪g H礽 ",
"Nguy謓 B筩h C?Sa ",
"Minh T躰h C?Sa",
"Kim L?C?Sa ",
"Th蕋 B秓 C?Sa",
"Чo s?v?b祇",
"Чo s?trng b祇",
"T躰h y",
"Thanh T飊g Ph竝 b祇",
"Thi猲 s?o b祇",
"Huy襫 V?ph竝 y",
"Th蕋 B秓 H?y",
"Tam Thanh B祇",
"Thi猲 Ni猲 H筩 Sng",
"Ch﹏ V?Th竛h Y",
"C鎛 y",
"T?Tr骳 C鎛 y",
"Th輈h Kh竎h y",
"M閚g m?y",
"V?S綾 y",
"Ng?Nh蒼 y",
"Li猲 V﹏ y",
"Thi猲 M閚g y",
"V?Dung K輓h y",
"Thi猲 Nh蒼 M藅 Trang",
"Th?B?trng b祇",
"Khinh C竧 sam",
"筺 b祇 ",
"D藅 Hi謕 y",
"Nhi謒 Hi謕 ph鬰",
"L璾 Th竔 Ph鬰",
"Ng﹏ T?B祇",
"T?Kim b祇",
"H祅 Sng b祇",
"Gi竛g Sa B祇",
"T醓 T?gi竝",
"Lng Цng Kh秈",
"Minh Quang Kh秈",
"T?L﹏ gi竝",
"?Ch飝 gi竝",
"S琻 V╪ T?gi竝",
"Gi秈 Tr筰 gi竝",
"Toan Ngh?gi竝",
"T醓 T?Ho祅g Kim gi竝",
"Л阯g Ngh?gi竝",
"Lan B?y",
"Ph?th玭g C竔 y",
"竜 ╪ m祔",
"Th?Ma C竔 y",
"T莔 Ma C竔 y",
"H醓 Ma C竔 y",
"Th藀 phng C竔 y",
"B竎h k誸 C竔 y",
"Tri襫 T?Thi猲 K誸 ph鬰",
"V筺 L璾 Quy T玭g Y",
"竜 v秈 th?",
"竜 v秈 th?",
"竜 v秈 th?",
"竜 v秈 th?",
"Ho祅g C萴 畂秐 y",
"Ch鴆 gi竝 畂秐 sam",
"Huy襫 Ho祅g 畂秐 gi竝",
"B輈h Hoa B祇",
"Tng Nh?b祇",
"Tuy襫 Long b祇",
"Sa Ni ph鬰",
"T╪g b祇 ",
"B竎h N筽 y",
"An h閕",
"U蕋 La T╪g",
"T╪g H礽",
"Nguy謓 B筩h c?sa",
"Minh t躰h c?sa",
"Kim L?c?sa",
"Th蕋 B秓 c?sa ",
"N?th鴆 o y",
"Tu Ch﹏ o y",
"H醓 Ho祅 o y",
"B輈h H?o y",
"B竧 qu竔 o y",
"H祅 Mai o y",
"V?C鵦 Чo y",
"мa Duy猲 o y",
"B╪g T祄 o y",
"Long Ti猽 o y",
"Th鬰 C萴 y",
"L╪g T?y",
"C萴 Tr鋘g y",
"Linh X?y",
"Huy襫 Ly y",
"H綾 B竜 y",
"H?B?y",
"V薾 Ngh?thng",
"M?H錸 Thng",
"C鰑 V?B筩h H?trang",
"C萴 Sam",
"Kh雐 Ly sam",
"Hoa Sa sam",
"Th鬰 C萴 Sam",
"T鑞g C萴 Sam",
"V﹏ C萴 Sam",
"Thanh La sam",
"T蕋 Sa sam",
"L╪g La sam",
"Tr莔 Hng sam",
"Kh秏 Thi誸 n?gi竝",
"Thanh уng n?gi竝",
"B筩h Nh?gi竝",
"Lam Y課 Cang gi竝",
"H錸g Nh?gi竝",
"X輈h Nh筺 gi竝",
"Huy誸 уng gi竝",
"Lan Ng﹏ gi竝",
"Huy襫 Thi誸 Tuy誸 Ng﹏ gi竝",
"T輈h L辌h Kim Ph鬾g gi竝",
"Ph?Ma y",
"Ph?Mi猲 y",
"Ph?C鎛 y",
"B筩h B?y",
"Thi猲 b?y",
"Dng B?gi竝",
"Ng璾 B?gi竝",
"T?Th?y",
"Kh玦 猽 y",
"V筺 Ch髇g T?T﹎ Y",
"B筩h 謕 qu莕",
"Thanh La qu莕",
"Ch鴆 C萴 Th筩h L鵸 qu莕",
"Song 謕 T?La qu莕",
"B竎h ?qu莕",
"Nguy謙 Hoa qu莕",
"Phong V?qu莕",
"Kinh B秓 qu莕",
"B竎h Phong Tri襲 Dng qu莕",
"L璾 Ti猲 Qu莕",
"Phong Trang",
"Kinh Thi猲 gi竝",
"Thanh Tuy謙 Y",
"Ph鬾g qu莕",
"Kh蕄 мa qu莕",
"B╪g Tinh Qu莕",
"Nh薾 竜 m韎 ",
"竜 m鮪g tu鎖 ",
"B╪g Tinh Qu莕",
"B╪g Tinh Qu莕",
}
tbBeltList =
{
"Ng璾 B?Y猽 Цi",
"Lang B?Y猽 Цi",
"?Щng Y猽 Цi",
"M穘g B?Y猽 Цi",
"Ng筩 B?Y猽 Цi",
"Tng B?Y猽 Цi",
"Sa B?Y猽 Цi",
"T?Gi竎 Y猽 Цi",
"Long L﹏ Y猽 Цi",
"Thi猲 T祄 Y猽 Цi",
"Tinh уng Y猽 Цi",
"T輈h Y猽 Цi",
"Ho祅g уng Y猽 Цi",
"Thi誸 Y猽 Цi",
"Tinh уng Y猽 Цi",
"Ng﹏ Y猽 Цi",
"M藅 Ng﹏ Y猽 Цi",
"Kim Y猽 Цi",
"?Ng﹏ Y猽 Цi",
"B筩h Kim Y猽 Цi",
}
tbBootList =
{
"Th秓 Ngoa",
"B?Ngoa",
"Thi猲 t莕g b?Ngoa",
"C竧 Ngoa",
"Thng C竧 Ngoa",
"B竎h Ni猲 Thng C竧 Ngoa",
"Tr?V?T鑞g Ngoa",
"Giao Ngoa",
"Phong V?T鑞g Ngoa",
"C鰑 Ti誸 Xng V?Ngoa",
"Ng璾 B?ngoa",
"T藅 Ngoa",
"?B?Ngoa",
"Щng M閚g Ngoa",
"Phi La Ngoa",
"L鬰 Th髖 Ngoa",
"H?B?Ngoa",
"T?B?Ngoa",
"Long L﹏ Ngoa",
"Thi猲 T祄 Ngoa",
"T?Ngoa",
"L╪g T?Ngoa",
"G蕀 h礽",
"Uy猲 Μng Ngoa",
"Toan Ngoa",
"L﹎ Ng鋍 h礽",
"Li猲 Phong Ngoa",
"Ph筸 H錸g Ngoa",
"B筩h Chu ngoa",
"Kim L?h礽",
"L閏 B?ngoa",
"K?h礽",
"Ng﹏ 筺 ngoa",
"Ph?Dung ngoa",
"H醓 Tng Ngoa",
"M鬰 V﹏ ngoa",
"Xng Ho祅 ngoa",
"Tuy誸 Doanh ngoa",
"S輓h Sa ngoa",
"Phi Ph鬾g Ngoa",
}
tbCuffList =
{
"Thanh уng Th?Tr筩",
"Luy謓 уng Th?Tr筩",
"T蕁 Thi誸 H?Uy觧",
"Ng﹏ T?Tr筩",
"Kim T?Tr筩",
"B筩h Ng鋍 Tr筩",
"Ph?Th髖 Ng鋍 Tr筩",
" Lng Ng鋍 TR筩",
"B╪g Ph竎h H祅 Ng鋍 Tr筩",
"Long Ph鬾g Huy誸 Ng鋍 Tr筩",
"Ng璾 B?H?Uy觧",
"Lang B?H?Uy觧",
"?Щng H?Uy觧",
"M穘g B?H?Uy觧",
"Ng筩 B?H?Uy觧",
"Tng B?H?Uy觧",
"Sa B?H?Uy觧",
"T?Gi竎 H?Uy觧",
"Long L﹏ H?Uy觧",
"Thi猲 T祄 H?Uy觧",
}
tbPendantList =
{
"Hu﹏ Y Hng Nang",
"M箃 L?Hng Nang",
"Nh?Hng Hng Nang",
"Lan Hoa Hng Nang",
"H頿 Hoan Hng Nang",
"T?T?Hng Nang",
"Tr莔 Уn Hng Nang",
"Ti猲 X?Hng Nang",
"Gi?Nam Hng Nang",
"Long Ti猲 Hng Nang",
"Du Di猲 Ng鋍 B閕 ",
"Kinh B筩h Ng鋍 B閕 ",
"Уo Hoa Ng鋍 B閕 ",
"Mai Hoa Ng鋍 B閕 ",
"Ng?S綾 Ng鋍 B閕 ",
"Thanh Ng鋍 Ng鋍 B閕 ",
"B輈h Ng鋍 Ng鋍 B閕 ",
"M芻 Ng鋍 Ng鋍 B閕 ",
"Ho祅g Ng鋍 Ng鋍 B閕 ",
"Dng Chi B筩h Ng鋍",
}
tbAmuletList =
{
"уng H筺g Li猲",
"Ng﹏ H筺g Li猲",
"Kim H筺g Li猲",
"B筩h Kim H筺g Li猲",
"Ng鋍 Ch﹗ H筺g Li猲",
"L鬰 T飊g Th筩h H筺g Li猲",
"Th駓 Tinh H筺g Li猲 ",
"Kh鎛g Tc Th筩h H筺g Li猲",
"Tr﹏ Ch﹗ H筺g Li猲",
"To祅 Th筩h H筺g Li猲",
"L鬰 T飊g Th筩h H?Th﹏ ph?",
"San H?H?Th﹏ ph?",
"Mi猽 Nh穘 H?Th﹏ ph?",
"H?T譶h H?Th﹏ ph?",
"Th駓 Tinh H?Th﹏ ph?",
"H?Ph竎h H?Th﹏ ph?",
"B筩h Ph?Th髖 H?Th﹏ ph?",
"H錸g Ph?Th髖 H?Th﹏ ph?",
"T?Ph?Th髖 H?Th﹏ ph?",
"L鬰 Ph?Th髖 H?Th﹏ ph?",
}
tbRingList =
{
"Ho祅g Ng鋍 Gi韎 Ch?,
"C秏 L穖 Th筩h Gi韎 Ch?,
"Ph?Dung Th筩h Gi韎 Ch?,
"Ph?Th髖 Gi韎 Ch?,
"Th髖 L鵸 Th筩h Gi韎 Ch?,
"T?M蓇 L鬰 Gi韎 Ch?,
"H秈 Lam B秓 Th筩h Gi韎 Ch?,
"H錸g B秓 Th筩h Gi韎 Ch?,
"Lam B秓 Th筩h Gi韎 Ch?,
"To祅 Th筩h Gi韎 Ch?,
}
tbWeleeWeaponList =
{
"Thi誸 Tr駓 th?",
"Cang Ki誱",
"Thanh Phong Ki誱",
"Long Tuy襫 Ki誱",
"Tr穖 M?Ki誱",
"?Kim Ki誱",
"X?Khi誴",
"Th蕋 X輈h Ki誱",
"Thi猲 Nh薾 Ki誱",
"Huy襫 Thi誸 Ki誱",
"Y猽 o",
"Кn o",
"Qu?u o",
"Nh筺 Linh o",
"Nguy謙 Nha o",
"Ph?Phong o",
"C鎛 Ch﹗ B秓 產o",
"Y觧 Nguy謙 o",
"Thanh Long o",
"Чi Phong o",
"Thi猽 H醓 C玭 ",
"T?Mi C玭 ",
"B祅 Hoa C玭 ",
"H?V?C玭 ",
"Ti猽 B鎛g",
"Can B鎛g",
"Lang Nha B鎛g",
"H鏽 Thi誸 B鎛g",
"Gi竎 H秈 B鎛g",
"Kim C?B鎛g",
"Thi誸 Thng",
"Trng Thng",
"觤 Cang Thng",
"C﹗ Li猰 Thng",
"Ho祅 t?Thng",
"B竜 v?thng",
"Nh筺 Linh Thng",
"T?C鑤 Thng",
"H醓 Nhu?Thng",
"Ph?Thi猲 K輈h",
"To竛 u ch飝",
"B竧 L╪g ch飝",
"Ng?Tinh ch飝",
"T輈h L辌h ch飝",
"Lng Ng﹏ ch飝 ",
"Lang Nha ch飝",
"Li謙 T﹎ ch飝",
"Kim Qua ch飝",
"Nghi謙 Long ch飝",
"Ph?Thi猲 ch飝",
"Nga Mi Th輈h",
"T蕁 Thi誸 Song o",
"Nguy謙 Nha Th輈h",
"H綾 B筩h Song o",
"Tuy誸 Hoa Lng Ng﹏ o",
"Uy猲 Μng o",
"Ph?Dung o",
"H?謕 Song o",
"Thu V?o",
"Th玭 Nh藅 Tr穖",
}
tbRangeWeaponList =
{
"Kim Ti襫 ti猽",
"Thi誹 L﹎ T竜 Nh﹏ Ti猽",
"Y課 t?Ti猽",
"Th藀 t?ti猽",
"Li評 Di謕 ti猽",
"Phi Ho祅g Ti猽",
"Thi誹 L﹎ Lng Ng﹏ Phi Ti猽",
"H?謕 Ti猽",
"Kim Ti猽 ",
"B?VngTi猽",
"Phi o",
"Cang Phi o",
"Li評 Di謕 o",
"Nh筺 V?o",
"Цi Y o",
"Уo Hoa o",
"Quang C竛 o",
"T﹎ ?o",
"чc C?o",
"To竔 Nguy謙 o",
"T?Ti詎",
"T骳 в Ch﹎",
"Tinh Trang T?Ti詎",
"Thanh Phong nh",
"B鑙 Trang N?",
"H祄 Sa X?秐h",
"Ph?Gi竝 N?",
"B筼 V?L?Hoa Ch﹎",
"Gia C竧 N?",
"Kh鎛g Tc Linh",
}
tbMagicAttributeList =
{
[0] = 85,
[1] = 88,
[2] = 89,
[3] = 92,
[4] = 93,
[5] = 96,
[6] = 97,
[7] = 98,
[8] = 99,
[9] = 100,
[10] = 104,
[11] = 101,
[12] = 102,
[13] = 103,
[14] = 105,
[15] = 106,
[16] = 108,
[17] = 110,
[18] = 113,
[19] = 111,
[20] = 115,
[21] = 121,
[22] = 122,
[23] = 123,
[24] = 124,
[25] = 125,
[26] = 126,
[27] = 116,
[28] = 168,
[29] = 170,
[30] = 169,
[31] = 171,
[32] = 172,
[33] = 56,
[34] = 134,
[35] = 135,
[36] = 117,
[37] = 58,
}
tbKeepMagicAttributeList =
{
43, 114, 136, 137, 138, 139, 140, 141, 142, 143, 144,
}
tbTownPortalList =
{
"H錳 th祅h ph?(nh? ",
"H錳 th祅h ph?(l韓) ",
"Th?a ph?",
}
tbPrise =
{
{"?", 1},
{"C?h閕 h駓 b?nhi謒 v?, 1},
{"甶觤 kinh nghi謒", 1},
{"An Bang B╪g Tinh Th筩h H筺g Li猲", 1},
{"An Bang C骳 Hoa Th筩h Ch?ho祅", 1},
{"An Bang 襫 Ho祅g Th筩h Ng鋍 B閕", 1},
{"An Bang K?Huy誸 Th筩h Gi韎 Ch?", 1},
{"B竎h Qu?L?", 1},
{"B祅 Nhc T﹎ Kinh", 1},
{"B╪g H祅 Кn Ch?Phi o", 1},
{"B╪g Ph遪g ho祅", 1},
{"B輈h H秈 Uy猲 Μng Li猲 Ho祅 產o", 1},
{"C竔 Bang Chng Ph竝", 1},
{"C竔 Bang C玭 ph竝", 1},
{"Cao Thi觤 ho祅", 1},
{"Cao Trung ho祅", 1},
{"C藀 Phong Tam Thanh Ph?", 1},
{"Ch?Phc Di謙 L玦 C秐h Ph?", 1},
{"Chu Sa Nguy猲 Kho竛g", 1},
{"Chung Nh?Nguy猲 Th筩h ", 1},
{"Чi L鵦 ho祅", 1},
{"мa Ph竎h H綾 Di謒 Xung Thi猲 Li猲", 1},
{"мch Kh竔 L鬰 Ng鋍 Trng", 1},
{"Di謙 Ki誱 M藅 T辌h", 1},
{"мnh Qu鑓 Ng﹏ T祄 Y猽 i", 1},
{"мnh Qu鑓 ?Sa Ph竧 Qu竛", 1},
{"мnh Qu鑓 Thanh Sa Trng Sam", 1},
{"мnh Qu鑓 T?Щng H?uy觧", 1},
{"мnh Qu鑓 X輈h Quy猲 Nhuy詎 Ngoa", 1},
{"чc Ph遪g ho祅", 1},
{"уng C鮱 Kh竛g Long H?Uy觧", 1},
{"Gia B祇 ho祅", 1},
{"H穖 T躰h thu藅.Lo筺 Ho祅 K輈h", 1},
{"Hi謕 C鑤 T譶h Ho祅", 1},
{"Hi謕 C鑤 n T﹎ Gi韎", 1},
{"Hi謕 C鑤 Thi誸 Huy誸 Sam", 1},
{"Hi謕 C鑤 T譶h ?K誸", 1},
{"H醓 Ph遪g ho祅", 1},
{"Huy襫 Thi誸 Nguy猲 Kho竛g", 1},
{"Huy襫 tinh c蕄 1", 1},
{"Huy襫 tinh c蕄 2", 1},
{"Huy襫 tinh c蕄 3", 1},
{"Huy襫 Tinh c蕄 4", 1},
{"Huy襫 Tinh c蕄 5", 1},
{"Huy襫 Tinh c蕄 6", 1},
{"Huy襫 Tinh c蕄 7", 1},
{"Huy襫 Tinh c蕄 8", 1},
{"Huy襫 Tinh Kho竛g Th筩h c蕄 4", 1},
{"Huy襫 Tinh Kho竛g Th筩h c蕄 5", 1},
{"Huy襫 Tinh Kho竛g Th筩h c蕄 6 ", 1},
{"K?Nghi謕 B玭 L玦 To祅 Long thng", 1},
{"Kh鎛g Tc Nguy猲 Th筩h ", 1},
{"Lam Th駓 Tinh", 1},
{"L玦 Khung Thi猲 мa H?ph?", 1},
{"L玦 Ph遪g ho祅", 1},
{"L鬰 Th駓 Tinh", 1},
{"L璾 Tinh. o ph竝", 1},
{"Ma Ho祅g 竛 Xu蕋 H?H筺g Khuy猲", 1},
{"Ma Th?s琻 H秈 Phi H錸g L?", 1},
{"Mai Kh玦 Hoa V?", 1},
{"M藅 Ng﹏ Nguy猲 Kho竛g", 1},
{"Minh 秓 T?S竧 чc Nh薾", 1},
{"M閚g Long Kim Ti Ch輓h H錸g C?Sa", 1},
{"Nga Mi Ph藅 Quang Chng M藅 T辌h", 1},
{"Ng?чc Chng Ph竝. Quy觧 1", 1},
{"Ng?чc o ph竝. Quy觧 2", 1},
{"Ng?чc Nhi誴 T﹎ thu藅. Quy觧 3", 1},
{"Ng?L玦 thu藅", 1},
{"Ng?Long Lng Ng﹏ B秓 產o", 1},
{"Ng?Phong thu藅", 1},
{"Ng?T﹎ thu藅", 1},
{"Nhi誴 H錸. Ch?thu藅", 1},
{"Nhu T譶h Ph鬾g Nghi Gi韎 Ch?", 1},
{"Nhu T譶h Tu?T﹎ Ng鋍 B閕", 1},
{"Nhu T譶h C﹏ Qu鑓 Ngh?Thng", 1},
{"Nhu T譶h Th鬰 N?H筺g Li猲", 1},
{"Ph竜 Hoa", 1},
{"Phi o thu藅. Nhi誴 H錸 Nguy謙 秐h", 1},
{"Phi Phong", 1},
{"Phi Ti猽 thu藅. C鰑 Cung Phi Tinh", 1},
{"Phi T鑓 ho祅", 1},
{"Ph?ч M藅 T辌h", 1},
{"Ph?Dung Nguy猲 Th筩h ", 1},
{"Ph骳 Duy猲 L?(Чi) ", 1},
{"Ph骳 Duy猲 L?(Ti觰) ", 1},
{"Ph骳 Duy猲 L?(Trung) ", 1},
{"Ph鬰 Ma T?Kim C玭", 1},
{"S﹎ Hoang Phi Tinh 箃 H錸", 1},
{"Sng Tinh Thi猲 Ni猲 H祅 Thi誸", 1},
{"T﹎ T﹎ Tng 竛h ph?", 1},
{"T葃 T駓 Kinh", 1},
{"T葃 T駓 Kinh", 1},
{"T?Ho祅g Ph鬾g Nghi 產o", 1},
{"Th竔 C鵦 Ki誱 Ph? Quy觧 2", 1},
{"Th竔 C鵦 Quy襫 Ph? Quy觧 3", 1},
{"Thi猲 Quang мnh T﹎ Ng璶g Th莕 Ph?", 1},
{"Thi猲 s琻 B秓 L?", 1},
{"Thi猲 Vng Ch飝 Ph竝. Quy觧 1", 1},
{"Thi猲 Vng o ph竝.Quy觧 3", 1},
{"Thi猲 Vng Thng ph竝. Quy觧 2", 1},
{"Thi謕 m祏", 1},
{"Thi謕 Nh??", 1},
{"Thi誸 La H竛", 1},
{"Thi誹 L﹎ C玭 ph竝. Quy觧 2", 1},
{"Thi誹 L﹎ o ph竝. Quy觧 3", 1},
{"Thi誹 L﹎ Quy襫 Ph竝. Quy觧 1", 1},
{"Th髖 Y猲 o ph竝", 1},
{"Th髖 Y猲 Song 產o", 1},
{"Ti猲 Th秓 L?", 1},
{"Ti猲 Th秓 L?", 1},
{"Tinh H錸g B秓 Th筩h", 1},
{"Tinh H錸g B秓 Th筩h", 1},
{"Trng M謓h ho祅", 1},
{"T?Kh玭g Gi竛g Ma Gi韎 產o", 1},
{"T?Th駓 Tinh", 1},
{"T?Ti詎 thu藅. B筼 V?L?Hoa", 1},
{"V﹏ Long K輈h. M﹗ ph竝", 1},
{"V?L﹎ M藅 T辌h", 1},
{"V?L﹎ M藅 T辌h", 1},
{"V?Ma H錸g Truy Nhuy詎 Th竝 h礽", 1},
{"V?Ma T葃 Tng Ng鋍 Kh蕌 ", 1},
{"V?秓 B綾 Minh Чo qu竛", 1}
}
--Lo筰 trang b?v?gi?mua tng 鴑g
tbItemType =
{
{"Nh蒼", 3, 30},
{"D﹜ chuy襫", 4, 20},
{"Ng鋍 b閕", 9, 20}
}
tbItemAttribute =
{
{"t╪g sinh l鵦", 85},
{"t╪g N閕 l鵦 ", 89},
{"t╪g th?l鵦 ", 93},
{"t╪g s鴆 m筺h", 97},
{"t╪g Th﹏ Ph竝", 98},
{"t╪g Ngo筰 C玭g", 99},
{"t╪g ph遪g c", 101},
{"t╪g ph遪g b╪g", 105},
{"t╪g ph遪g h醓", 102},
{"t╪g ph遪g l玦", 103},
{"Ph鬰 h錳 N閕 l鵦", 92},
{"Ph鬰 h錳 Sinh l鵦", 88},
{"Ph鬰 h錳 Th?l鵦", 96},
{"Gi秏 th阨 gian tr髇g c", 108},
{"Gi秏 th阨 gian cho竛g", 110},
{"Gi秏 th阨 gian ng b╪g", 106}
}
--B秐g t猲 c竎 th祅h th?
tbCity =
{
{"Phng Tng", 1},
{"Tng Dng", 78},
{"Bi謓 Kinh", 37},
{"Th祅h Й", 11},
{"Чi L?, 162},
{"Dng Ch﹗", 80},
{"L﹎ An", 76}
}
--B秐g t猲 c竎 NPC t輓h n╪g c?t猲 kh竎
tbNpcName =
{
{"g ch?dc 甶誱", "Ch?dc 甶誱 Чo Hng Th玭"},
{"g ch?dc 甶誱", "Ng?Th莕 Y"},
{"Ch?ti謒 t筽 h鉧", "g ch?t筽 h鉧"},
{"Ch?ti謒 t筽 h鉧", "T筽 H鉧"}
}
--B秐g t猲 c竎 v藅 ph萴 t╪g ph骳 duy猲
tbFuYuanItem =
{
{"Ph骳 Duy猲 L?(Ti觰)", 10},
{"Ph骳 Duy猲 L?(Trung)", 20},
{"Ph骳 Duy猲 L?(Чi)", 50}
}
--B秐g t猲 c竎 v藅 ph萴 t╪g 甶觤 kinh nghi謒
tbExpItem =
{
"Qu?Huy Ho祅g",
"Qu?Ho祅g Kim",
"B竎h Ni猲 Huy Ho祅g Qu?,
"Th藀 To祅 Чi B?Th莕 n"
}
--------------------------------------------------------------------------C竎 h祄 ph?------------------------------------------------------------
-- H祄 t譵 m竨
tbAuxiliary.FindLife = function()
local nLifeIndex, nLifePlace, nLifeX, nLifeY = 0, 0, 0, 0
local nBothIndex, nBothPlace, nBothX, nBothY = 0, 0, 0, 0
-- T譵 m竨
local nItemIndex, nPlace, nX, nY = player.GetFirstItem()
while nItemIndex ~= 0 do
if nPlace == 3 or nPlace == 7 then
local nGenre, nDetail, nParticular = item.GetKey(nItemIndex)
if nGenre == 1 and nParticular == 0 then
nLifeIndex, nLifePlace, nLifeX, nLifeY = nItemIndex, nPlace, nX, nY
elseif nGenre == 1 and nParticular == 2 then
nBothIndex, nBothPlace, nBothX, nBothY = nItemIndex, nPlace, nX, nY
end
end
-- Tho竧 kh醝 v遪g l苝 n誹 t譵 th蕐
if nLifeIndex > 0 or nBothIndex > 0 then break end
nItemIndex, nPlace, nX, nY = player.GetNextItem()
end
return nLifeIndex, nLifePlace, nLifeX, nLifeY, nBothIndex, nBothPlace, nBothX, nBothY
end
-- H祄 t譵 mana
tbAuxiliary.FindMana = function()
local nManaIndex, nManaPlace, nManaX, nManaY = 0, 0, 0, 0
local nBothIndex, nBothPlace, nBothX, nBothY = 0, 0, 0, 0
-- T譵 mana
local nItemIndex, nPlace, nX, nY = player.GetFirstItem()
while nItemIndex ~= 0 do
if nPlace == 3 or nPlace == 7 then
local nGenre, nDetail, nParticular = item.GetKey(nItemIndex)
if nGenre == 1 and nParticular == 1 then
nManaIndex, nManaPlace, nManaX, nManaY = nItemIndex, nPlace, nX, nY
elseif nGenre == 1 and nParticular == 2 then
nBothIndex, nBothPlace, nBothX, nBothY = nItemIndex, nPlace, nX, nY
end
end
-- Tho竧 kh醝 v遪g l苝 n誹 t譵 th蕐
if nManaIndex > 0 or nBothIndex > 0 then break end
nItemIndex, nPlace, nX, nY = player.GetNextItem()
end
return nManaIndex, nManaPlace, nManaX, nManaY, nBothIndex, nBothPlace, nBothX, nBothY
end
-- H祄 t譵 thu鑓 gi秈 c
tbAuxiliary.FindPoision = function()
local nPoisionIndex, nPoisionPlace, nPoisionX, nPoisionY = 0, 0, 0, 0
-- T譵 thu鑓 gi秈 c
local nItemIndex, nPlace, nX, nY = player.GetFirstItem()
while nItemIndex ~= 0 do
if nPlace == 3 or nPlace == 7 then
local nGenre, nDetail, nParticular = item.GetKey(nItemIndex)
if nGenre == 1 and nParticular == 4 then
nPoisionIndex, nPoisionPlace, nPoisionX, nPoisionY = nItemIndex, nPlace, nX, nY
end
end
-- Tho竧 kh醝 v遪g l苝 n誹 t譵 th蕐
if nPoisionIndex > 0 then break end
nItemIndex, nPlace, nX, nY = player.GetNextItem()
end
return nPoisionIndex, nPoisionPlace, nPoisionX, nPoisionY
end
-- H祄 t譵 th?a ph?
tbAuxiliary.FindSave = function()
local nSaveIndex, nSavePlace, nSaveX, nSaveY = 0, 0, 0, 0
local nSize = table.maxn(tbTownPortalList)
-- T譵 th?a ph?
local nItemIndex, nPlace, nX, nY = player.GetFirstItem()
while nItemIndex ~= 0 do
if nPlace == 3 or nPlace == 7 then
for i = 1, nSize do
local szItemName = item.GetName(nItemIndex)
if szItemName == tbTownPortalList[i] then
nSaveIndex, nSavePlace, nSaveX, nSaveY = nItemIndex, nPlace, nX, nY
break
end
end
end
-- Tho竧 kh醝 v遪g l苝 n誹 th蕐
if nSaveIndex > 0 then break end
nItemIndex, nPlace, nX, nY = player.GetNextItem()
end
return nSaveIndex, nSavePlace, nSaveX, nSaveY
end
-- H祄 s?d鬾g m竨
tbAuxiliary.UseLife = function()
local nLifeIndex, nLifePlace, nLifeX, nLifeY, nBothIndex, nBothPlace, nBothX, nBothY = tbAuxiliary.FindLife()
if nLifeIndex > 0 then
player.UseItem(nLifeIndex, nLifePlace, nLifeX, nLifeY)
elseif nBothIndex > 0 then
player.UseItem(nBothIndex, nBothPlace, nBothX, nBothY)
end
end
-- H祄 s?d鬾g mana
tbAuxiliary.UseMana = function()
local nManaIndex, nManaPlace, nManaX, nManaY, nBothIndex, nBothPlace, nBothX, nBothY = tbAuxiliary.FindMana()
if nManaIndex > 0 then
player.UseItem(nManaIndex, nManaPlace, nManaX, nManaY)
elseif nBothIndex > 0 then
player.UseItem(nBothIndex, nBothPlace, nBothX, nBothY)
end
end
-- H祄 s?d鬾g thu鑓 gi秈 c
tbAuxiliary.UsePoision = function()
local nPoisionIndex, nPoisionPlace, nPoisionX, nPoisionY = tbAuxiliary.FindPoision()
if nPoisionIndex > 0 then
player.UseItem(nPoisionIndex, nPoisionPlace, nPoisionX, nPoisionY)
end
end
-- H祄 s?d鬾g th?a ph?
tbAuxiliary.UseSave = function()
local nSaveIndex, nSavePlace, nSaveX, nSaveY = tbAuxiliary.FindSave()
if nSaveIndex > 0 then
player.UseItem(nSaveIndex, nSavePlace, nSaveX, nSaveY)
tbBasic.ExitWhenUseTownPortal()
end
end
-- H祄 check lag
tbAuxiliary.IsLagNpc = function(nNpcIndex)
if nNpcIndex == 0 then return 1 end
local nCurrHP = npc.GetLife(nNpcIndex)
local nCurrIndex = nNpcIndex
if nNpcIndex ~= nOldIndex then
nOldHP = nCurrHP
nOldIndex = nCurrIndex
nCount = os.clock() * 1000
return 0
end
if nCurrHP ~= nOldHP then
nOldHP = nCurrHP
nCount = os.clock() * 1000
return 0
end
if os.clock() * 1000 - nCount >= MAX_CHECK_LAG_TIME then
nLagIndex = nNpcIndex
return 1
end
return 0
end
-- H祄 t譵 Npc g莕 nh蕋
tbAuxiliary.SearchNpc = function(nRange)
local dLimit = nAroundPointRange * nAroundPointRange
local dMin = nRange * nRange
local nNpcIndex, nX, nY, pX, pY, dZ = 0, 0, 0, 0, 0
player.SetPeopleIndex(0)
for i = 2, MAX_NPC do
if (npc.IsExists(i) == 1) and (npc.GetKind(i) == 0) and (npc.GetLife(i) > 0) then
nX, nY = npc.GetMapPos(i)
if bAroundPoint > 0 then
-- T輓h kho秐g c竎h t?NPC n 甶觤 m鑓
local dZ = (nX - nAroundPointX) * (nX - nAroundPointX) + (nY - nAroundPointY) * (nY - nAroundPointY)
if dZ <= dLimit then
pX, pY = player.GetMapPos()
-- T輓h kho秐g c竎h t?NPC n nh﹏ v藅
dZ = (nX - pX) * (nX - pX) +( nY - pY) * (nY - pY)
if dMin > dZ and npc.GetIndex(i) ~= nLagIndex then
dMin = dZ
nNpcIndex = npc.GetIndex(i)
end
end
else
pX, pY = player.GetMapPos()
dZ = (nX - pX) * (nX - pX) +( nY - pY) * (nY - pY)
if dMin > dZ and npc.GetIndex(i) ~= nLagIndex then
dMin = dZ
nNpcIndex = npc.GetIndex(i)
end
end
end
end
return nNpcIndex
end
-- H祄 nh qu竔
tbAuxiliary.AttackNpc = function(nNpcIndex)
-- N誹 Npc lag th?tho竧
if tbAuxiliary.IsLagNpc(nNpcIndex) == 1 then return end
-- N誹 ch鋘 l猲 ng鵤 th?l猲, ch鋘 xu鑞g ng鵤 th?xu鑞g
if (nHorseType == 1 and player.IsRideHorse() == 0) or (nHorseType == 2 and player.IsRideHorse() == 1) then
player.ExecuteScript(SCK_SHORTCUT_HORSE)
timer.Sleep(500)
end
local nSkillID = player.GetLeftSkillID()
-- N誹 產ng ?tr猲 ng鵤 nh璶g skill b?gi韎 h筺 xu鑞g ng鵤
if skill.IsHorseLimit(nSkillID) == 1 and player.IsRideHorse() == 1 then
-- N誹 kh玭g ch鋘 lu玭 l猲 ng鵤 th?xu鑞g ng鵤 nh
if nHorseType ~= 1 then
player.ExecuteScript(SCK_SHORTCUT_HORSE)
timer.Sleep(500)
-- ngc l筰 tho竧
else
return
end
end
-- Thi誸 l藀 skill nh, ph筸 vi nh, r錳 nh
player.SetActiveSkillID(nSkillID)
if bHitClosed ~= 0 and nHitClosedRange > 0 then
player.SetAttackRadius(nHitClosedRange)
else
player.SetAttackRadius(skill.GetAttackRadius(nSkil lID))
end
player.SetPeopleIndex(nNpcIndex)
end
-- H祄 l蕐 Index c馻 Npc
tbAuxiliary.GetNpcIndexByName = function(szNpcName)
for i = 2, MAX_NPC do
if npc.GetKind(i) == 3 then
for j = 1, table.maxn(tbNpcName) do
if szNpcName == tbNpcName[j][1] and npc.GetName(i) == tbNpcName[j][2] then return npc.GetIndex(i) end
end
if npc.GetName(i) == szNpcName then return npc.GetIndex(i) end
end
end
return 0
end
-- H祄 i tho筰 Npc
tbAuxiliary.TalkToNpc = function(szNpcName, nType)
player.MoveToNpc(0, 0, szNpcName)
timer.Sleep(1000)
local nNpcIndex = player.GetNearestNpc(3)
if nNpcIndex > 0 then
player.DialogNpc(nNpcIndex)
while menu.IsVisible(nType) == 0 do timer.Sleep(100) end
end
end
-- H祄 c藀 nh藅 l筰 c竎 Object hi謓 c?tr猲 m苩 t
tbAuxiliary.UpdateOrgObjectList = function()
for i = 1, MAX_OBJ do
if obj.IsExists(i) == 1 then
table.insert(tbOrgObjectList, obj.GetIndex(i))
end
end
end
-- H祄 ki觤 tra m閠 Obj, Item thu閏 m閠 danh s竎h Obj, Item n祇 hay kh玭g
tbAuxiliary.BelongObjItemList = function(nObjItemIndex, tbObjItemList)
local nSize = table.maxn(tbObjItemList)
for i = 1, nSize do
if nObjItemIndex == tbObjItemList[i] then return true end
end
return false
end
-- H祄 x鉧 h誸 d?li謚 1 table
tbAuxiliary.ClearTable = function(tbTable)
while table.maxn(tbTable) ~= 0 do
table.remove(tbTable)
end
end
-- H祄 ki觤 tra m閠 Item c?ph秈 l?v?kh?ho芻 trang b?hay kh玭g
tbAuxiliary.ItemIsWeaponOrEquipment = function(nItemIndex)
local nGenre, nDetail, nParticular = item.GetKey(nItemIndex)
for i = 0, 9 do
if nGenre == 0 and nDetail == i then return true end
end
return false
end
-- H祄 ki觤 tra v藅 ph萴 c?kh玭g th醓 m穘 t蕋 c?c竎 thu閏 t輓h do gamer thi誸 l藀 khi l鋍 theo thu閏 t輓h hay kh玭g
tbAuxiliary.MissMagicAttribute = function(nItemIndex)
local nSize = table.maxn(tbKeepMagicAttributeList)
local nMagicType, nValue
-- N誹 c?c竎 thu閏 t輓h qu?hi誱 th?tr?v?false ngay
for i = 1, nSize do
for nCol = 0, 5 do
nMagicType = item.GetMagicAttrib(nItemIndex, nCol)
if tbKeepMagicAttributeList[i] == nMagicType then return false end
end
end
nSize = table.maxn(tbFilterMagicType)
-- X衪 ti誴 c竎 thi誸 l藀 thu閏 t輓h c馻 gamer
for i = 1, nSize do
for nCol = 0, 5 do
nMagicType, nValue = item.GetMagicAttrib(nItemIndex, nCol)
if tbMagicAttributeList[tbFilterMagicType[i][1]] == nMagicType and tbFilterMagicType[i][2] < nValue then return false end
end
end
return true
end
-- H祄 ki觤 tra m閠 Object c?thu閏 m閠 danh s竎h c竎 Object n祇 hay kh玭g
tbAuxiliary.BelongObjList = function(nObjIndex, tbObjList)
if obj.GetKind(nObjIndex) ~= 3 then return false end
local szObjName = obj.GetName(nObjIndex)
local nSize = table.maxn(tbObjList)
for i = 1, nSize do
if szObjName == tbObjList[i] then return true end
end
return false
end
-- H祄 ki觤 tra m閠 Object l?trang b?ho芻 v?kh?hay kh玭g
tbAuxiliary.ObjIsWeaponOrEquipment = function(nObjIndex)
if obj.GetKind(nObjIndex) ~= 3 then return false end
if tbAuxiliary.BelongObjList(nObjIndex, tbHelmList) or tbAuxiliary.BelongObjList(nObjIndex, tbAmorList) or tbAuxiliary.BelongObjList(nObjIndex, tbBeltList) or tbAuxiliary.BelongObjList(nObjIndex, tbBootList) or tbAuxiliary.BelongObjList(nObjIndex, tbCuffList) or tbAuxiliary.BelongObjList(nObjIndex, tbPendantList) or tbAuxiliary.BelongObjList(nObjIndex, tbAmuletList) or tbAuxiliary.BelongObjList(nObjIndex, tbRingList) or tbAuxiliary.BelongObjList(nObjIndex, tbWeleeWeaponList) or tbAuxiliary.BelongObjList(nObjIndex, tbRangeWeaponList) then return true end
return false
end
-- H祄 ki觤 tra m閠 Object thu閏 trang s鴆 & 1 - 4 ?m祏 hay kh玭g
tbAuxiliary.IsColorAdorn_1_4_Piece = function(nObjIndex)
if obj.GetKind(nObjIndex) ~= 3 then return false end
local bIsAdorn = tbAuxiliary.BelongObjList(nObjIndex, tbPendantList) or tbAuxiliary.BelongObjList(nObjIndex, tbAmuletList) or tbAuxiliary.BelongObjList(nObjIndex, tbRingList)
local nObjWidth, nObjHeight = obj.GetSize(nObjIndex)
local bIs_1_4_Piece = (tbAuxiliary.BelongObjList(nObjIndex, tbHelmList) or tbAuxiliary.BelongObjList(nObjIndex, tbAmorList) or tbAuxiliary.BelongObjList(nObjIndex, tbBeltList) or tbAuxiliary.BelongObjList(nObjIndex, tbBootList) or tbAuxiliary.BelongObjList(nObjIndex, tbCuffList) or tbAuxiliary.BelongObjList(nObjIndex, tbWeleeWeaponList) or tbAuxiliary.BelongObjList(nObjIndex, tbRangeWeaponList)) and nObjWidth * nObjHeight <= 4
if (bIsAdorn or bIs_1_4_Piece) and obj.GetColor(nObjIndex) ~= 0 then return true end
return false
end
-- H祄 ki觤 tra m閠 Object thu閏 v?kh?& trang b?m祏 hay kh玭g
tbAuxiliary.IsColorWeaponEquipment = function(nObjIndex)
if obj.GetKind(nObjIndex) ~= 3 then return false end
local bIsWeapon = tbAuxiliary.BelongObjList(nObjIndex, tbWeleeWeaponList) or tbAuxiliary.BelongObjList(nObjIndex, tbRangeWeaponList)
local bIsEquipment = (tbAuxiliary.BelongObjList(nObjIndex, tbHelmList) or tbAuxiliary.BelongObjList(nObjIndex, tbAmorList) or tbAuxiliary.BelongObjList(nObjIndex, tbBeltList) or tbAuxiliary.BelongObjList(nObjIndex, tbBootList) or tbAuxiliary.BelongObjList(nObjIndex, tbCuffList) or tbAuxiliary.BelongObjList(nObjIndex, tbPendantList) or tbAuxiliary.BelongObjList(nObjIndex, tbAmuletList) or tbAuxiliary.BelongObjList(nObjIndex, tbRingList))
if (bIsWeapon or bIsEquipment) and obj.GetColor(nObjIndex) ~= 0 then return true end
return false
end
-- H祄 ki觤 tra Object c?thu閏 BlackList hay kh玭g
tbAuxiliary.IsBlackObject = function(nObjIndex)
if obj.GetKind(nObjIndex) ~= 3 then return false end
local nSize = table.maxn(tbBlackObjectList)
for i = 1, nSize do
if nObjIndex == tbBlackObjectList[i] then return true end
end
return false
end
-- H祄 nh苩 v藅 ph萴 tng 鴑g ch鋘 "Kh玭g nh苩 v?kh?v?v藅 ph萴"
tbAuxiliary.PickUpObj0 = function()
-- N誹 kh玭g ch鋘 nh苩 ti襫 v?c ph萴 th?tho竧
if bMoneyItem == 0 then return end
local dMin, ndMinObjIndex
local dLimit = nPickUpObjRange * nPickUpObjRange
local nObjIndex, oX, oY, pX, pY, dZ = 0, 0, 0, 0, 0
-- Duy謙 t蕋 c?c竎 Object tr猲 t
for i = 1, MAX_OBJ do
if obj.IsExists(i) == 1 then
nObjIndex = obj.GetIndex(i)
-- N誹 Object kh玭g thu閏 c竎 danh s竎h 甧n
if not tbAuxiliary.IsBlackObject(nObjIndex) and not tbAuxiliary.BelongObjList(nObjIndex, tbUserBlackObjectList) then
-- v?th醓 甶襲 ki謓 th?x?l?
if obj.GetKind(nObjIndex) == 4 or (obj.GetKind(nObjIndex) == 3 and not tbAuxiliary.ObjIsWeaponOrEquipment(nObjIndex)) then
oX, oY = obj.GetMapPos(nObjIndex)
pX, pY = player.GetMapPos()
dZ = (oX - pX) *( oX - pX) + (oY - pY) * (oY - pY)
-- N誹 Object n籱 trong ph筸 vi nh苩 th?ti課 h祅h nh苩
if dZ <= dLimit then
-- N誹 Object thu閏 ph筸 vi game engine cho ph衟 nh苩 th?nh苩, ngc l筰 th?ti課 t韎 nh苩
if dZ <= OBJ_PICKUP_RANGE then
-- Reset bi課 ghi nh薾 kho秐g c竎h g莕 nh蕋
dMin = nil
player.PickUpObj(nObjIndex)
else
-- Ghi nh薾 Object n祇 g莕 nh﹏ v藅 nh蕋
if dMin == nil then
dMin = dZ
ndMinObjIndex = nObjIndex
elseif dMin > dZ then
dMin = dZ
ndMinObjIndex = nObjIndex
end
end
end
else
table.insert(tbBlackObjectList, nObjIndex)
end
end
end
end
if dMin ~= nil then
oX, oY = obj.GetMapPos(ndMinObjIndex)
repeat
pX, pY = player.GetMapPos()
dZ = (oX - pX) *( oX - pX) + (oY - pY) * (oY - pY)
if dZ <= OBJ_PICKUP_RANGE then break
else
player.MoveTo(oX, oY)
timer.Sleep(100)
end
until true
player.PickUpObj(ndMinObjIndex)
end
bPickingUp = false
end
-- H祄 nh苩 v藅 ph萴 tng 鴑g ch鋘 "Trang s鴆 v? 1 - 4 ?m祏"
tbAuxiliary.PickUpObj1 = function()
local dMin, ndMinObjIndex
local dLimit = nPickUpObjRange * nPickUpObjRange
local nObjIndex, oX, oY, pX, pY, dZ = 0, 0, 0, 0, 0
-- Duy謙 t蕋 c?c竎 Object tr猲 t
for i = 1, MAX_OBJ do
if obj.IsExists(i) == 1 then
nObjIndex = obj.GetIndex(i)
-- N誹 Object kh玭g thu閏 c竎 danh s竎h 甧n
if not tbAuxiliary.IsBlackObject(nObjIndex) and not tbAuxiliary.BelongObjList(nObjIndex, tbUserBlackObjectList) then
-- v?th醓 甶襲 ki謓 th?x?l?
if tbAuxiliary.IsColorAdorn_1_4_Piece(nObjIndex) or (bMoneyItem ~= 0 and (obj.GetKind(nObjIndex) == 4 or (obj.GetKind(nObjIndex) == 3 and not tbAuxiliary.ObjIsWeaponOrEquipment(nObjIndex)))) then
oX, oY = obj.GetMapPos(nObjIndex)
pX, pY = player.GetMapPos()
dZ = (oX - pX) *( oX - pX) + (oY - pY) * (oY - pY)
-- N誹 Object n籱 trong ph筸 vi nh苩 th?ti課 h祅h nh苩
if dZ <= dLimit then
-- N誹 Object thu閏 ph筸 vi game engine cho ph衟 nh苩 th?nh苩, ngc l筰 th?ti課 t韎 nh苩
if dZ <= OBJ_PICKUP_RANGE then
-- Reset bi課 ghi nh薾 kho秐g c竎h g莕 nh蕋
dMin = nil
player.PickUpObj(nObjIndex)
else
-- Ghi nh薾 Object n祇 g莕 nh﹏ v藅 nh蕋
if dMin == nil then
dMin = dZ
ndMinObjIndex = nObjIndex
elseif dMin > dZ then
dMin = dZ
ndMinObjIndex = nObjIndex
end
end
end
else
table.insert(tbBlackObjectList, nObjIndex)
end
end
end
end
if dMin ~= nil then
oX, oY = obj.GetMapPos(ndMinObjIndex)
repeat
pX, pY = player.GetMapPos()
dZ = (oX - pX) *( oX - pX) + (oY - pY) * (oY - pY)
if dZ <= OBJ_PICKUP_RANGE then break
else
player.MoveTo(oX, oY)
timer.Sleep(100)
end
until true
player.PickUpObj(ndMinObjIndex)
end
bPickingUp = false
end
-- H祄 ki觤 tra c竎 Item c?th醓 c竎 thu閏 t輓h do gamer thi誸 l藀 hay kh玭g
tbAuxiliary.CheckAttribute = function()
-- Ghi nh薾 l筰 c竎 object hi謓 c?tr猲 m苩 t
tbAuxiliary.ClearTable(tbOrgObjectList)
tbAuxiliary.UpdateOrgObjectList()
-- N衜 c竎 Item kh玭g th醓 thu閏 t輓h, ghi nh薾 c竎 Item th醓
local nItemIndex, nPlace, nX, nY = player.GetFirstItem()
while nItemIndex ~= 0 do
if nPlace == 3 then
if tbAuxiliary.ItemIsWeaponOrEquipment(nItemIndex) then
if tbAuxiliary.MissMagicAttribute(nItemIndex) then
player.MoveItem(nPlace, nX, nY, nPlace, nX, nY)
timer.Sleep(300)
player.ThrowAwayItem()
timer.Sleep(200)
elseif not tbAuxiliary.BelongObjItemList(nItemIndex, tbKeepItemList) then
table.insert(tbKeepItemList, nItemIndex)
end
end
end
nItemIndex, nPlace, nX, nY = player.GetNextItem()
end
-- C藀 nh藅 l筰 BlackList
for i = 1, MAX_OBJ do
if obj.IsExists(i) == 1 then
local nObjIndex = obj.GetIndex(i)
if not tbAuxiliary.BelongObjItemList(nObjIndex, tbOrgObjectList)then
table.insert(tbBlackObjectList, nObjIndex)
end
end
end
end
-- H祄 ph鬰 v?cho n苩 theo "V?kh?v?trang b?theo thu閏 t輓h" v?"V?kh?trang b?m祏"
tbAuxiliary.PickUpObj23 = function()
local dMin, ndMinObjIndex
local dLimit = nPickUpObjRange * nPickUpObjRange
local nObjIndex, oX, oY, pX, pY, dZ = 0, 0, 0, 0, 0
-- Duy謙 t蕋 c?c竎 Object tr猲 t
for i = 1, MAX_OBJ do
if obj.IsExists(i) == 1 then
nObjIndex = obj.GetIndex(i)
-- N誹 Object kh玭g thu閏 c竎 danh s竎h 甧n
if bPickingUp and not tbAuxiliary.IsBlackObject(nObjIndex) and not tbAuxiliary.BelongObjList(nObjIndex, tbUserBlackObjectList) then
-- v?th醓 甶襲 ki謓 th?x?l?
if tbAuxiliary.IsColorWeaponEquipment(nObjIndex) or (bMoneyItem ~= 0 and (obj.GetKind(nObjIndex) == 4 or (obj.GetKind(nObjIndex) == 3 and not tbAuxiliary.ObjIsWeaponOrEquipment(nObjIndex)))) then
oX, oY = obj.GetMapPos(nObjIndex)
pX, pY = player.GetMapPos()
dZ = (oX - pX) *( oX - pX) + (oY - pY) * (oY - pY)
-- N誹 Object n籱 trong ph筸 vi nh苩 th?ti課 h祅h nh苩
if dZ <= dLimit then
-- N誹 Object thu閏 ph筸 vi game engine cho ph衟 nh苩 th?nh苩, ngc l筰 th?ti課 t韎 nh苩
if dZ <= OBJ_PICKUP_RANGE then
-- Reset bi課 ghi nh薾 kho秐g c竎h g莕 nh蕋
dMin = nil
player.PickUpObj(nObjIndex)
else
-- Ghi nh薾 Object n祇 g莕 nh﹏ v藅 nh蕋
if dMin == nil then
dMin = dZ
ndMinObjIndex = nObjIndex
elseif dMin > dZ then
dMin = dZ
ndMinObjIndex = nObjIndex
end
end
end
else
table.insert(tbBlackObjectList, nObjIndex)
end
end
end
end
if dMin ~= nil then
oX, oY = obj.GetMapPos(ndMinObjIndex)
repeat
pX, pY = player.GetMapPos()
dZ = (oX - pX) *( oX - pX) + (oY - pY) * (oY - pY)
if dZ <= OBJ_PICKUP_RANGE then break
else
player.MoveTo(oX, oY)
timer.Sleep(100)
end
until true
player.PickUpObj(ndMinObjIndex)
end
bPickingUp = false
end
-- H祄 Nh苩 t蕋 c?v?kh?v?trang b?
tbAuxiliary.PickUpObj4 = function()
local dMin, ndMinObjIndex
local dLimit = nPickUpObjRange * nPickUpObjRange
local nObjIndex, oX, oY, pX, pY, dZ = 0, 0, 0, 0, 0
-- Duy謙 t蕋 c?c竎 Object tr猲 t
for i = 1, MAX_OBJ do
if obj.IsExists(i) == 1 then
nObjIndex = obj.GetIndex(i)
-- N誹 Object kh玭g thu閏 c竎 danh s竎h 甧n
if not tbAuxiliary.IsBlackObject(nObjIndex) and not tbAuxiliary.BelongObjList(nObjIndex, tbUserBlackObjectList) then
-- v?th醓 甶襲 ki謓 th?x?l?
if tbAuxiliary.ObjIsWeaponOrEquipment(nObjIndex) or (bMoneyItem ~= 0 and (obj.GetKind(nObjIndex) == 4 or (obj.GetKind(nObjIndex) == 3 and not tbAuxiliary.ObjIsWeaponOrEquipment(nObjIndex)))) then
oX, oY = obj.GetMapPos(nObjIndex)
pX, pY = player.GetMapPos()
dZ = (oX - pX) *( oX - pX) + (oY - pY) * (oY - pY)
-- N誹 Object n籱 trong ph筸 vi nh苩 th?ti課 h祅h nh苩
if dZ <= dLimit then
-- N誹 Object thu閏 ph筸 vi game engine cho ph衟 nh苩 th?nh苩, ngc l筰 th?ti課 t韎 nh苩
if dZ <= OBJ_PICKUP_RANGE then
-- Reset bi課 ghi nh薾 kho秐g c竎h g莕 nh蕋
dMin = nil
player.PickUpObj(nObjIndex)
else
-- Ghi nh薾 Object n祇 g莕 nh﹏ v藅 nh蕋
if dMin == nil then
dMin = dZ
ndMinObjIndex = nObjIndex
elseif dMin > dZ then
dMin = dZ
ndMinObjIndex = nObjIndex
end
end
end
else
table.insert(tbBlackObjectList, nObjIndex)
end
end
end
end
if dMin ~= nil then
oX, oY = obj.GetMapPos(ndMinObjIndex)
repeat
pX, pY = player.GetMapPos()
dZ = (oX - pX) *( oX - pX) + (oY - pY) * (oY - pY)
if dZ <= OBJ_PICKUP_RANGE then break
else
player.MoveTo(oX, oY)
timer.Sleep(100)
end
until true
player.PickUpObj(ndMinObjIndex)
end
bPickingUp = false
end
--------------------------------------------------------------------------C竎 h祄 ph?------------------------------------------------------------
---------------------------------------------------------------------------------C?B秐--------------------------------------------------------------
-- H祄 萵 c鯽 s?game
tbBasic.HideGameWindows = function()
system.HideGame(bHideGameWindows)
end
-- H祄 tho竧 khi th?a ph?
tbBasic.ExitWhenUseTownPortal = function()
if bExitWhenUseTownPortal ~= 0 then system.ExitGame() end
end
-- H祄 t総 m竬
tbBasic.ExitWindows = function()
local tbTime = os.date("!*t")
if tbTime.hour + 7 == nExitWindowsHours and tbTime.min == nExitWindowsMinute then system.ShutdownWindows() end
end
-- H祄 tho竧 game
tbBasic.ExitGame = function()
local tbTime = os.date("!*t")
if tbTime.hour + 7 == nExitGameHour and tbTime.min == nExitGameMinute then system.ExitGame() end
end
---------------------------------------------------------------------------------C?B秐--------------------------------------------------------------
-------------------------------------------------------------------------------Ph鬰 H錳--------------------------------------------------------------
-- H祄 ph鬰 h錳 s鴆 kh醗
tbRestore.AutoHeal = function()
if player.IsFightMode() == 0 then return end
if bBoughtTownPortal then bBoughtTownPortal = false end
if bDrawedMoney then bDrawedMoney = false end
if bSavedMoney then bSavedMoney = false end
if bBoughtMedicine then bBoughtMedicine = false end
if bGoneBackPoint then bGoneBackPoint = false end
-- T?s?d鬾g m竨, both
if bAutoAddLife ~= 0 and player.GetLife() < nAddLifeValue then
tbAuxiliary.UseLife()
end
-- T?s?d鬾g mana, both
if bAutoAddMana ~= 0 and player.GetMana() < nAddManaValue then
tbAuxiliary.UseMana()
end
-- T?s?d鬾g thu鑓 gi秈 c
if bUsePoision ~= 0 and player.IsPosionState() == 1 then
tbAuxiliary.UsePoision()
end
end
-- H祄 s?d鬾g m竨 theo nh k?
tbRestore.AutoUseLife = function()
if player.IsFightMode() == 0 then return end
if player.GetLife() < nAddLifeValue then
tbAuxiliary.UseLife()
end
end
-- H祄 s?d鬾g mana theo nh k?
tbRestore.AutoUseMana = function()
if player.IsFightMode() == 0 then return end
if player.GetMana() < nAddManaValue then
tbAuxiliary.UseMana()
end
end
-- H祄 d飊g th?a ph?
tbRestore.AutoTownPortal = function()
if player.IsFightMode() == 0 then return end
-- Th?мa Ph?khi m竨 th蕄
if bLifeLess ~= 0 and player.GetLife() < nLifeLessValue then
tbAuxiliary.UseSave()
return
end
-- Th?мa Ph?khi mana th蕄
if bManaLess ~= 0 and player.GetMana() < nManaLessValue then
tbAuxiliary.UseSave()
return
end
-- Th?мa Ph?khi h誸 b譶h m竨
if bEmptyLife ~= 0 then
local nLifeIndex, nLifePlace, nLifeX, nLifeY, nBothIndex, nBothPlace, nBothX, nBothY = tbAuxiliary.FindLife()
if nLifeIndex == 0 and nBothIndex == 0 then
tbAuxiliary.UseSave()
return
end
end
-- Th?мa Ph?khi h誸 b譶h mana
if bEmptyMana ~= 0 then
local nManaIndex, nManaPlace, nManaX, nManaY, nBothIndex, nBothPlace, nBothX, nBothY = tbAuxiliary.FindMana()
if nManaIndex == 0 and nBothIndex == 0 then
tbAuxiliary.UseSave()
return
end
end
-- Th?мa Ph?khi y ti襫
if bFullMoney ~= 0 and player.GetMoney(1) > nFullMoneyValueV then
tbAuxiliary.UseSave()
return
end
-- Th?мa Ph?khi y h祅h trang
if bFullBox ~= 0 then
if nFullBoxType == 0 and (player.FindFreeRoom(1, 2) == 0 or player.FindFreeRoom(2, 1) == 0) then
tbAuxiliary.UseSave()
return
end
if nFullBoxType == 1 and (player.FindFreeRoom(1, 3) == 0) then
tbAuxiliary.UseSave()
return
end
if nFullBoxType == 2 and (player.FindFreeRoom(1, 4) == 0 or player.FindFreeRoom(2, 2) == 0) then
tbAuxiliary.UseSave()
return
end
if nFullBoxType == 3 and (player.FindFreeRoom(2, 3) == 0) then
tbAuxiliary.UseSave()
return
end
end
-- Th?мa Ph?khi h?trang b?產ng m芻
if bItemDuration ~= 0 then
for i = 1, 7 do
local nItem = player.GetEquipmentItem(i)
if nItem > 0 then
local nDuration = item.GetDuration(nItem)
if nDuration > 0 and nDuration < nItemDurationValue then
tbAuxiliary.UseSave()
return
end
end
end
end
end
-------------------------------------------------------------------------------Ph鬰 H錳--------------------------------------------------------------
-------------------------------------------------------------------------------Chi課 u------------------------------------------------------------
-- H祄 t?ng nh
tbAttack.AutoAttackNpc = function()
-- Thi誸 l藀 l筰 c竎 bi課 ghi nh薾
if player.IsFightMode() == 0 then return end
if bBoughtTownPortal then bBoughtTownPortal = false end
if bDrawedMoney then bDrawedMoney = false end
if bSavedMoney then bSavedMoney = false end
if bBoughtMedicine then bBoughtMedicine = false end
if bGoneBackPoint then bGoneBackPoint = false end
-- T譵 v?nh qu竔
local nNpcIndex = tbAuxiliary.SearchNpc(nNpcSearchRange)
if nNpcIndex > 0 then tbAuxiliary.AttackNpc(nNpcIndex) end
-- Khi h誸 qu竔 trong khu v鵦 nh
if player.GetPeopleIndex() == 0 then
if nHorseType == 0 and player.IsRideHorse() == 0 then
player.ExecuteScript(SCK_SHORTCUT_HORSE)
timer.Sleep(500)
end
if bAroundPoint > 0 then
local nMapX, nMapY = player.GetMapPos()
local dZ = (nMapX - nAroundPointX) * (nMapX - nAroundPointX) + (nMapY - nAroundPointY) * (nMapY - nAroundPointY)
if dZ >= 64 * 64 then player.MoveTo(nAroundPointX, nAroundPointY) end;
end
if (player.IsRideHorse() == 0) and (player.GetDoing() == 1) and (player.GetMoveFrame() >= MAX_MOVE_FRAME) then player.ExecuteScript(SCK_SHORTCUT_SIT) end
end
end
-------------------------------------------------------------------------------Chi課 u------------------------------------------------------------
-------------------------------------------------------------------------------Nh苩 у----------------------------------------------------------------
-- H祄 t?ng nh苩
tbPickUp.AutoPickUpObj = function()
-- N誹 產ng ?trong th祅h v?kh玭g b藅 ch? nh苩 trong th祅h th?tho竧
if player.IsFightMode() == 0 and bPickUpInCity == 0 then return end
-- Ghi nh薾 產ng nh苩
bPickingUp = true
-- Refresh BlackList n誹 nh﹏ v藅 di chuy觧 xa v?tr?g鑓
local nPlayerX, nPlayerY = player.GetMapPos()
local dLimit = 4 * nPickUpObjRange * nPickUpObjRange
local dMove = (nPlayerX - nOrgPlayerX) * (nPlayerX - nOrgPlayerX) + (nPlayerY - nOrgPlayerY) * (nPlayerY - nOrgPlayerY)
if dMove > dLimit then
tbAuxiliary.ClearTable(tbBlackObjectList)
nOrgPlayerX, nOrgPlayerY = nPlayerX, nPlayerY
end
-- N誹 ch璦 ch鋘 ho芻 ch鋘 kh玭g nh苩 v?kh?v?trang b?
if nFilterObjType == -1 or nFilterObjType == 0 then
tbAuxiliary.PickUpObj0()
return
end
-- N誹 ch鋘 trang s鴆 & 1 - 4 ?m祏
if nFilterObjType == 1 then
tbAuxiliary.PickUpObj1()
return
end
-- N誹 ch鋘 nh苩 v?kh?& trang b?theo thu閏 t輓h
if nFilterObjType == 2 then
tbAuxiliary.PickUpObj23()
return
end
-- N誹 ch鋘 v?kh?& trang b?m祏
if nFilterObjType == 3 then
tbAuxiliary.PickUpObj23()
return
end
-- N誹 ch鋘 nh苩 t蕋 c?v?kh?& trang b?
if nFilterObjType == 4 then
tbAuxiliary.PickUpObj4()
return
end
end
-------------------------------------------------------------------------------Nh苩 у----------------------------------------------------------------
---------------------------------------------------------------------------------B秐 у---------------------------------------------------------------
-- H祄 s鯽
tbCastle.RepairPlayerItem = function(nMinDuration)
for i = 1, 7 do
local nItem = player.GetEquipmentItem(i)
if nItem > 0 then
local nDuration = item.GetDuration(nItem)
if nDuration > 0 and nDuration < nMinDuration then
if item.GetIntro(nItem) == "Trang b?Ho祅g Kim" then
shop.RepairItem(nItem)
timer.Sleep(500)
menu.ClickIndex(0, 1)
timer.Sleep(500)
else
shop.RepairItem(nItem)
timer.Sleep(500)
end
end
end
end
end
-- H祄 b竛
tbCastle.SellPlayerItem = function(nCondition)
local bBuyOk = 0
local nItemIndex, nPlace = player.GetFirstItem()
while nItemIndex ~= 0 do
if nPlace == 3 then
local nGenre = item.GetKey(nItemIndex)
if nGenre == nCondition and not tbAuxiliary.BelongObjItemList(nItemIndex, tbKeepItemList) then
bBuyOk = 1
shop.BuyItem(nItemIndex)
timer.Sleep(500)
end
end
if bBuyOk == 1 then
nItemIndex, nPlace = player.GetFirstItem()
bBuyOk = 0
else nItemIndex, nPlace = player.GetNextItem() end
end
end
-- H祄 mua Th?мa Ph?
tbCastle.BuyTownPortal = function(nCount)
local nItemIndex, nPlace, nX, nY = player.GetFirstItem()
while nItemIndex ~= 0 do
if nPlace == 3 or nPlace == 7 then
local nGenre, nDetail, nParticular = item.GetKey(nItemIndex)
if (nGenre == 5 and nDetail == 0 and nParticular == 0) or (nGenre == 6 and nDetail == 1 and nParticular == 1082) or (nGenre == 6 and nDetail == 1 and nParticular == 1083) then
return
end
end
nItemIndex, nPlace, nX, nY = player.GetNextItem()
end
tbAuxiliary.TalkToNpc("Ch?ti謒 t筽 h鉧", 0)
menu.ClickText(0, "Giao d辌h")
while shop.IsVisible() == 0 do timer.Sleep(100) end;
if bSellItem ~= 0 then tbCastle.SellPlayerItem(0) end
if bRepairItem ~= 0 then tbCastle.RepairPlayerItem(50) end
for i = 1, nCount do
shop.SellItem(0)
timer.Sleep(500)
end;
shop.Close()
player.CloseStatus()
player.CloseItem()
end
-- H祄 mua thu鑓
tbCastle.BuyMedicine = function(nLifeCount, nManaCount, nPoisionCount)
local nItemIndex, nPlace, nX, nY = player.GetFirstItem()
local bLife = 0
local bMana = 0
local bBoth = 0
local bPoision = 0
while nItemIndex ~= 0 do
if nPlace == 3 or nPlace == 7 then
local nGenre, nDetail, nParticular = item.GetKey(nItemIndex)
if nGenre == 1 and nParticular == 0 then bLife = 1
elseif nGenre == 1 and nParticular == 1 then bMana = 1
elseif nGenre == 1 and nParticular == 2 then bBoth = 1
elseif nGenre == 1 and nParticular == 4 then bPoision = 1
end
end
if bLife == 1 and bMana == 1 and bBoth == 1 and bPoision == 1 then return end
nItemIndex, nPlace, nX, nY = player.GetNextItem()
end
tbAuxiliary.TalkToNpc("g ch?dc 甶誱", 0)
menu.ClickText(0, "Giao d辌h")
while shop.IsVisible() == 0 do timer.Sleep(100) end
if bBoth == 0 and bLife == 0 and bBuyLife == 1 then
for i = 1, nBuyLifeValue do
shop.SellItem(nBuyLifeType)
timer.Sleep(500)
end
end
if bBoth == 0 and bMana == 0 and bBuyMana == 1 then
for i = 1, nBuyManaValue do
shop.SellItem(nBuyManaType)
timer.Sleep(500)
end
end
if bPoision == 0 and bBuyPoision == 1 then
for i = 1, nBuyPoisionValue do
shop.SellItem(nBuyPoisionType)
timer.Sleep(500)
end
end
shop.Close()
player.CloseStatus()
player.CloseItem()
end
-- H祄 甶 Xa Phu
tbCastle.GoBack = function()
local nMoney = player.GetMoney(0);
if bSaveMoney == 1 and nSaveMoneyValue > 0 and nSaveMoneyValue < nMoney and bSavedMoney == false then
player.ExchangeMoney(1, nMoney - nSaveMoneyValue)
bSavedMoney = true
end
tbAuxiliary.TalkToNpc("Xa phu", 1)
if 0 <= nGoBackPointType and nGoBackPointType <= 2 then
menu.ClickIndex(1, 1)
while menu.IsVisible(0) == 0 do timer.Sleep(100) end
menu.ClickIndex(0, nGoBackPointType)
local nCount = 0
local pOrgX, pOrgY, pOrgMapID = player.GetMapPos()
repeat
timer.Sleep(1000)
nCount = nCount + 1
local pX, pY, pMapID = player.GetMapPos()
if pX ~= pOrgX or pY ~= pOrgY or pMapID ~= pOrgMapID then return end
if nCount > 5 then return end
until true
end
if nGoBackPointType == 3 then
menu.ClickIndex(1, 3)
local nCount = 0
local pOrgX, pOrgY, pOrgMapID = player.GetMapPos()
repeat
timer.Sleep(1000)
nCount = nCount + 1
local pX, pY, pMapID = player.GetMapPos()
if pX ~= pOrgX or pY ~= pOrgY or pMapID ~= pOrgMapID then return end
if nCount > 5 then return end
until true
end
if nGoBackPointType == 4 then
menu.ClickIndex(1, 6)
while menu.IsVisible(0) == 0 do timer.Sleep(100) end
menu.ClickIndex(0, 0)
local nCount = 0
local pOrgX, pOrgY, pOrgMapID = player.GetMapPos()
repeat
timer.Sleep(1000)
nCount = nCount + 1
local pX, pY, pMapID = player.GetMapPos()
if pX ~= pOrgX or pY ~= pOrgY or pMapID ~= pOrgMapID then return end
if nCount > 5 then return end
until true
end
end
-- H祄 x?l?trong th祅h
tbCastle.ProcessInCastle = function()
timer.Sleep(2000)
if player.IsFightMode() == 1 then return end
if (player.IsRideHorse() == 0) then player.ExecuteScript(SCK_SHORTCUT_HORSE) end
if bDrawMoney == 1 and nDrawMoneyValue > 0 and bDrawedMoney == false then
player.SecureUnlockBox(nBoxPassword)
timer.Sleep(500)
player.ExchangeMoney(0, nDrawMoneyValueV)
player.LockBox()
bDrawedMoney = true
end
if bBuyTownPortal ~= 0 and nBuyTownPortalValue > 0 and bBoughtTownPortal == false then
tbCastle.BuyTownPortal(nBuyTownPortalValue)
bBoughtTownPortal = true
end
if (bBuyLife ~= 0 or bBuyMana ~= 0 or bBuyPoision ~= 0) and bBoughtMedicine == false then
tbCastle.BuyMedicine(nBuyLifeValue, nBuyManaValue, nBuyPoisionValue)
bBoughtMedicine = true
end
if bGoBackPoint ~= 0 and bGoneBackPoint == false then
tbCastle.GoBack()
bGoneBackPoint = true
end
end
---------------------------------------------------------------------------------B秐 у---------------------------------------------------------------
-------------------------------------------------------------------------------D?T萿-----------------------------------------------------------------
--Bc nh薾 nhi謒 v?
tbQuest.DoQuest = function()
tbAuxiliary.TalkToNpc("D?T萿", 0)
--L蕐 th玭g tin quest v祇 bi課 n閕 dung to祅 c鬰
szContent = quest.GetInfo()
local QuestType = tbAuxiliary.CheckQuestType()
menu.ClickIndex(0, 0)
if QuestType == 0 then
tbQuest.GetPrise()
end
if QuestType == 1 then
if nQuestWeaponType == 0 then tbQuest.Weapon() end
if nQuestWeaponType == 1 then tbQuest.OnFinished() end
if nQuestWeaponType == 2 then tbQuest.Forfeit() end
end
if QuestType == 2 then
if nQuestLetterType == 0 then tbQuest.Letter() end
if nQuestLetterType == 1 then tbQuest.OnFinished() end
if nQuestLetterType == 2 then tbQuest.Forfeit() end
end
if QuestType == 3 then
if nQuestExpType == 0 then tbQuest.Exp() end
if nQuestExpType == 1 then tbQuest.OnFinished() end
if nQuestExpType == 2 then tbQuest.Forfeit() end
end
if QuestType == 4 then
if nQuestReputeType == 0 then tbQuest.Repute() end
if nQuestReputeType == 1 then tbQuest.OnFinished() end
if nQuestReputeType == 2 then tbQuest.Forfeit() end
end
if QuestType == 5 then
if nQuestFuYuanType == 0 then tbQuest.FuYuan() end
if nQuestFuYuanType == 1 then tbQuest.OnFinished() end
if nQuestFuYuanType == 2 then tbQuest.Forfeit() end
end
if QuestType == 6 then
if nQuestPKValueType == 0 then tbQuest.PKValue() end
if nQuestPKValueType == 1 then tbQuest.OnFinished() end
if nQuestPKValueType == 2 then tbQuest.Forfeit() end
end
if QuestType == 7 then
if nQuestTongJinType == 0 then tbQuest.TongJin() end
if nQuestTongJinType == 1 then tbQuest.OnFinished() end
if nQuestTongJinType == 2 then tbQuest.Forfeit() end
end
end
--Nhi謒 v?trang b?
tbQuest.Weapon = function()
local tPlace, tName, tSeries, tType, tAttType, tMinAtt, tMaxAtt = tbAuxiliary.GetQuestItemInfo()
--T譵 mua ?ti謒 t筽 h鉧 NPC
if tPlace ~= nil then
local bInCity = tbAuxiliary.InCity()
tbAuxiliary.TalkToNpc("Xa phu", bInCity)
if bInCity == 1 then
menu.ClickIndex(bInCity, 2)
else
menu.ClickIndex(bInCity, 1)
end
while menu.IsVisible(bInCity) == 0 do timer.Sleep(100) end;
for i = 0, menu.GetCount() - 1 do
if string.match(menu.GetText(0, i), tPlace) ~= nil then menu.ClickIndex(0, i) end
end
timer.Sleep(500)
tbAuxiliary.TalkToNpc("Ch?ti謒 t筽 h鉧", 0)
menu.ClickText("Giao d辌h", 0)
while shop.IsVisible() == 0 do timer.Sleep(100) end
for i = 0, shop.GetItemCount() - 1 do
local iIndex = shop.GetItemIndex(i)
if string.match(item.GetName(iIndex), tName) ~= nil and string.match(item.GetSeries(iIndex), tSeries) ~= nil and item.GetPrice(iIndex) < player.GetMoney(1) then
shop.SellItem(i)
end
end
timer.Sleep(500)
shop.Close()
player.CloseStatus()
player.CloseItem()
tbQuest.GetPrise()
return
end
--T譵 to祅 b?c竎 stall ?th蕋 i th祅h th? mua trang b?c莕 thi誸 (L璾 ?c竎 shop b竛 nv ch??khu v鵦 g莕 D?T萿)
for i = 1, table.maxn(tbCity) do
if player.GetMapName() ~= tbCity[i][1] then
local bInCity = tbAuxiliary.InCity()
tbAuxiliary.TalkToNpc("Xa phu", bInCity)
if bInCity == 1 then
menu.ClickIndex(bInCity, 2)
else
menu.ClickIndex(bInCity, 1)
end
while menu.IsVisible(0) == 0 do timer.Sleep(100) end
menu.ClickIndex(0, tbAuxiliary.GetDialogIndex(0, tbCity[i][1]))
while player.GetMapName() ~= tbCity[i][1] do timer.Sleep(100) end
end
player.MoveToNpc(0, 0, "D?T萿")
local pX, pY = player.GetMapPos()
for i = 2, MAX_NPC do
if npc.IsExists(i) == 1 and npc.GetKind(i) == 1 and npc.IsStall(i) == 1 then
local sX, sY = npc.GetMapPos(i)
local dZ = (sX - pX)*(sX - pX) + (sY - pY)*(sY - pY)
if dZ <= DATAU_RANGE then
player.MoveTo(sX, sY)
timer.Sleep(1000)
player.OpenStall(i)
while stall.IsVisible() == 0 do timer.Sleep(100) end
timer.Sleep(1000)
for i = 0, stall.GetItemCount() - 1 do
local iIndex = stall.GetItemIndex(i)
if iIndex > 0 and tbAuxiliary.CheckQuestItem(iIndex) == 1 then
for j = 1, table.maxn(tbItemType) do
if nDetail == tbItemType[j][2] and stall.GetItemPrice(i) < tbItemType[j][3] and player.GetMoney(1) >= stall.GetItemPrice(i) then
stall.SellItem(i)
timer.Sleep(1000)
stall.Close()
tbQuest.GetPrise()
end
end
end
end
stall.Close()
end
end
end
end
return
end
--Nhi謒 v? ch?
tbQuest.Letter = function()
--N誹 trong ngi kh玭g c?Th?мa Ph?th?甶 mua
local nSaveIndex, nSavePlace, nSaveX, nSaveY = tbAuxiliary.FindSave()
if nSaveIndex == 0 then
tbAuxiliary.TalkToNpc("Ch?ti謒 t筽 h鉧", 0)
menu.ClickText(0, "Giao d辌h")
while shop.IsVisible(0) == 0 do timer.Sleep(100) end
shop.SellItem(0)
timer.Sleep(500)
shop.Close()
player.CloseStatus()
player.CloseItem()
end
local nCurrentMap = player.GetMapName()
local bInCity = tbAuxiliary.InCity()
tbAuxiliary.TalkToNpc("Xa phu", bInCity)
menu.ClickText(bInCity, " n n琲 l祄 nhi謒 v?D?T萿")
while menu.IsVisible(bInCity) == 0 do timer.Sleep(100) end;
menu.ClickIndex(0, 0)
while player.GetMapName() == nCurrentMap do timer.Sleep(100) end
local IsDone = tbAuxiliary.IsFinishedQuest()
while (IsDone == 0) do
timer.Sleep(1000)
IsDone = tbAuxiliary.IsFinishedQuest()
if player.IsFightMode() == 0 then return 0 end
end
tbRestore.AutoTownPortal()
nCurrentMap = player.GetMapName()
while player.GetMapName() == nCurrentMap do timer.Sleep(100) end
tbQuest.GetPrise()
return 1
end
--Nhi謒 v?kinh nghi謒
tbQuest.Exp = function()
local nQuestExp = tbAuxiliary.GetQuestExp()
local nMinExp, nMaxExp = player.GetExperience()
local nLevel = player.GetLevel()
local nExp
if (nMinExp + nQuestExp) >= nMaxExp then
nExp = nQuestExp - (nMaxExp - nMinExp)
nLevel = nLevel + 1
else
nExp = nMinExp + nQuestExp
end
while (player.GetExperience() < nExp and player.GetLevel() == nLevel) or player.GetLevel() < nLevel do
local bUseItem = tbAuxiliary.UseExpItem()
if bUseItem == 0 then return 0 end
end
tbQuest.GetPrise()
return 1
end
--Nhi謒 v?danh v鋘g
tbQuest.Repute = function()
local nRepute = 0
local nQuestRepute = tbAuxiliary.GetQuestRepute()
while nRepute < nQuestRepute do
if player.GetMapName() ~= "Dng Ch﹗" then
local bInCity = tbAuxiliary.InCity()
tbAuxiliary.TalkToNpc("Xa phu", bInCity)
if bInCity == 1 then
menu.ClickIndex(bInCity, 2)
else
menu.ClickIndex(bInCity, 1)
end
while menu.IsVisible(0) == 0 do timer.Sleep(100) end
menu.ClickIndex(0, tbAuxiliary.GetDialogIndex(0, "Dng Ch﹗"))
while player.GetMapName() ~= "Dng Ch﹗" do timer.Sleep(100) end
end
tbAuxiliary.TalkToNpc("D辌h tr筸 d辌h quan", 1)
menu.ClickText(1, "Ta mu鑞 v?tri襲 nh g鉷 ch髏 s鴆 l鵦.")
while menu.IsVisible(1) == 0 do timer.Sleep(100) end
menu.ClickText(1, "Ta b籲g l遪g!")
timer.Sleep(500)
local bInCity = tbAuxiliary.InCity()
tbAuxiliary.TalkToNpc("Xa phu", bInCity)
menu.ClickText(bInCity, " n琲 c bi謙 l祄 Nhi謒 v?T輓 S?)
while menu.IsVisible(0) == 0 do timer.Sleep(100) end
menu.ClickText(0, "Mu鑞")
while player.GetMapName() == "Dng Ch﹗" do timer.Sleep(100) end
tbAuxiliary.TalkToNpc("D辌h quan", 1)
menu.ClickIndex(1, 0)
tbAuxiliary.TalkToNpc("C竛h tr緉g", 1)
menu.ClickIndex(1, 1)
while menu.IsVisible(1) == 0 do timer.Sleep(100) end
menu.ClickIndex(1, 0)
tbAuxiliary.TalkToNpc("D辌h quan", 1)
menu.ClickIndex(1, 1)
while player.GetMapName() ~= "Bi謓 Kinh" do timer.Sleep(100) end
tbAuxiliary.TalkToNpc("D辌h quan", 1)
menu.ClickText(1, "Ta mu鑞 v?tri襲 nh g鉷 ch髏 s鴆 l鵦.")
while menu.IsVisible(1) == 0 do timer.Sleep(100) end
menu.ClickText(1, "Ta n giao nhi謒 v?T輓 s?)
nRepute = nRepute + 2
end
tbQuest.GetPrise()
return
end
--Nhi謒 v?ph骳 duy猲
tbQuest.FuYuan = function()
local nFuYuan = 0
local nQuestFuYuan = tbAuxiliary.GetQuestFuYuan()
if player.GetMapName() ~= "Phng Tng" then
local bInCity = tbAuxiliary.InCity()
tbAuxiliary.TalkToNpc("Xa phu", bInCity)
if bInCity == 1 then
menu.ClickIndex(bInCity, 2)
else
menu.ClickIndex(bInCity, 1)
end
while menu.IsVisible(0) == 0 do timer.Sleep(100) end
menu.ClickIndex(0, tbAuxiliary.GetDialogIndex(0, "Phng Tng"))
while player.GetMapName() ~= "Phng Tng" do timer.Sleep(100) end
end
tbAuxiliary.TalkToNpc("V?L﹎ truy襫 nh﹏", 1)
menu.ClickText(1, "Th阨 gian t輈h l騳 i 甶觤 ph骳 duy猲")
while menu.IsVisible(0) == 0 do timer.Sleep(100) end
menu.ClickIndex(0, 0)
nFuYuan = nFuYuan + 2
while nFuYuan < nQuestFuYuan do
local bUseItem = tbAuxiliary.UseFuYuanItem()
if bUseItem == 0 then return 0 end
end
tbQuest.GetPrise()
return 1
end
--Nhi謒 v?tr?PK
tbQuest.PKValue = function()
return
end
--Nhi謒 v?T鑞g Kim
tbQuest.TongJin = function()
return
end
--H祄 nh薾 thng
tbQuest.GetPrise = function()
tbAuxiliary.TalkToNpc("D?T萿", 0)
local QuestType = tbAuxiliary.CheckQuestType()
menu.ClickText(0, "ta ho祅 th祅h nhi謒 v?l莕 n祔, xin h穣 ki觤 tra l筰!")
if QuestType == 1 then
local nIndex, nPlace, nX, nY = player.GetFirstItem()
while nIndex ~= 0 and nPlace == 3 do
if tbAuxiliary.CheckQuestItem(nIndex) == 1 then
player.MoveItem(nPlace, nX, nY, 0, 0, 0)
timer.Sleep(500)
player.MoveItem(12,0,0, 0,0,0)
timer.Sleep(500)
player.AcceptGiveItem(1)
timer.Sleep(500)
break
end
nIndex, nPlace, nX, nY = player.GetNextItem()
end
end
--Lng gi?ph莕 thng
local p0, p1, p2 = quest.GetPriceInfo()
local temp0, temp1, temp2 = 0, 0, 0
for i = 1, table.maxn(tbPrise) do
if string.match(p0, tbPrise[i][1]) ~= nil then temp0 = tbPrise[i][2] end
if string.match(p1, tbPrise[i][1]) ~= nil then temp1 = tbPrise[i][2] end
if string.match(p2, tbPrise[i][1]) ~= nil then temp2 = tbPrise[i][2] end
end
if math.max(temp0, temp1, temp2) == temp0 then
quest.ChoosePrice(0)
elseif math.max(temp0, temp1, temp2) == temp1 then
quest.ChoosePrice(1)
else
quest.ChoosePrice(2)
end
tbAuxiliary.TalkToNpc("D?T萿", 0)
menu.ClickIndex(0, 0)
while menu.IsVisible(0) == 0 do timer.Sleep(100) end
menu.ClickIndex(0, 0)
bFinish = 1
end
--H祄 h駓 nhi謒 v?
tbQuest.Forfeit = function()
tbAuxiliary.TalkToNpc("D?T萿", 0)
menu.ClickIndex(0, 2)
while menu.IsVisible(0) == 0 do timer.Sleep(100) end;
--Check nh﹏ v藅 kh玭g c遪 c?h閕 h駓 b?nhi謒 v?v?h駓 nhi謒 v?b籲g 100 m秐h S琻 H?X?T綾 (n誹 c?
if string.match(menu.GetText(0, 2), "Uhm! в ta suy ngh?l筰 ") ~= nil then
menu.ClickIndex(0, 1)
while menu.IsVisible(0) == 0 do timer.Sleep(100) end;
menu.ClickIndex(0, 0)
return
else
while menu.IsVisible(0) == 0 do timer.Sleep(100) end;
menu.ClickIndex(0, 0)
return
end
timer.Sleep(1000)
bForfeit = 1
end
--H祅h ng khi k誸 th骳 nhi謒 v?
tbQuest.OnFinished = function()
if nStopTaskType == 0 then
return
end
if nStopTaskType == 1 then
system.ExitGame()
return
end
--Hi謓 t筰 lo筰 n祔 ch璦 x竎 nh, set nh d蕌
if nStopTaskType == 2 then
return
end
--Hi謓 t筰 lo筰 n祔 ch璦 x竎 nh, set nh d蕌
if nStopTaskType == 3 then
return
end
if nStopTaskType == 4 then
player.OfflineLive()
while menu.IsVisible(1) == 0 do timer.Sleep(100) end
menu.ClickIndex(1, 2)
return
end
if nStopTaskType == 5 then
player.OfflineLive()
while menu.IsVisible(1) == 0 do timer.Sleep(100) end
menu.ClickIndex(1, 0)
return
end
end
--H祄 ki觤 tra lo筰 nhi謒 v?
tbAuxiliary.CheckQuestType = function()
--X衪 ri猲g trng h頿 cho nhi謒 v?t譵 m秐h S琻 H?X?T綾
if string.match(szContent, "S琻 H?X?T綾") ~= nil then
return 0
elseif string.match(szContent, "甶 t譵 m鉵") ~= nil then
return 1
elseif string.match(szContent, "мa у") ~= nil or string.match(szContent, "M藅 ch?) ~= nil then
return 2
--Nh鱪g nhi謒 v?n祔 ch璦 t?th鵦 hi謓 頲 n猲 set s?d鬾g sau
elseif string.match(szContent, "kinh nghi謒") ~= nil then
return 3
elseif string.match(szContent, "Danh v鋘g") ~= nil then
return 4
elseif string.match(szContent, "Ph骳 Duy猲") ~= nil then
return 5
elseif string.match(szContent, "甶觤 PK") ~= nil then
return 6
elseif string.match(szContent, "T鑞g Kim") ~= nil then
return 7
end
end
--H祄 x衪 甶襲 ki謓 ho祅 th祅h nhi謒 v?t譵 ch?
tbAuxiliary.IsFinishedQuest = function()
local tmpStr = quest.GetStatus()
local value1, value2
--Ph﹏ t輈h c竎 th祅h ph莕 trong tr筺g th竔 quest
for i = 1, string.len(tmpStr) - 47 do
if string.sub(tmpStr, i, i + 17) == "t譵 <color=yellow>" then value1 = string.sub(tmpStr, i + 18, i + 20) end
if string.sub(tmpStr, i + 18, i + 45) == "thu th藀 頲 <color=yellow>" then
value2 = string.sub(tmpStr, i + 46, i + 47)
break
end
end
if value1 ~= nil and value1 == value2 then
return 1
else
return 0
end
end
--H祄 l蕐 th玭g tin quest item t?l阨 tho筰 NPC D?T萿
tbAuxiliary.GetQuestItemInfo = function()
local tmpStr = szContent
local tPlace, tName, tSeries, tType, tAttType, tMinAtt, tMaxAtt
--L蕐 v?tr?l祄 nhi謒 v?
for i = 1, table.maxn(tbCity) do
if string.match(tmpStr, tbCity[i][1]) then tPlace = tbCity[i][1] end
end
--Ng?h祅h v?t猲 c馻 trang b?
for i = 1, string.len(tmpStr) - 14 do
if string.sub(tmpStr, i, i + 13) == "Mua gi髉 ta " then tName = string.sub(tmpStr, i + 14, string.len(tmpStr)) end
if string.sub(tmpStr, i, i + 10) == "m鉵 n祔: " then
tName = string.sub(tmpStr, i + 11, string.len(tmpStr))
if string.match(tName, "1 c竔") then tName = string.sub(tName, 9, string.len(tName)) end
end
end
if tName ~= nil then
for i = 1, string.len(tName) do
if string.sub(tName, i, i) == "(" then
if string.sub(tName, i + 1, i + 3) == "Kim" then tSeries = 0 end
if string.sub(tName, i + 1, i + 3) == "M閏" then tSeries = 1 end
if string.sub(tName, i + 1, i + 4) == "Th駓" then tSeries = 2 end
if string.sub(tName, i + 1, i + 3) == "H醓" then tSeries = 3 end
if string.sub(tName, i + 1, i + 3) == "Th? then tSeries = 4 end
tName = string.sub(tName, 1, i - 2)
end
end
for i = 1, string.len(tName) do
if string.sub(tName, i, i) == "," then tName = string.sub(tName, 1, i - 2) end
end
end
--L蕐 th玭g s?thu閏 t輓h trang b?
for i = 1, string.len(tmpStr) - 22 do
if string.sub(tmpStr, i, i + 11) == "nh?nh蕋: " then
if string.sub(tmpStr, i + 13, i + 13) == "," then
tMinAtt = tonumber(string.sub(tmpStr, i + 12, i + 12))
elseif string.sub(tmpStr, i + 14, i + 14) == "," then
tMinAtt = tonumber(string.sub(tmpStr, i + 12, i + 13))
else
tMinAtt = tonumber(string.sub(tmpStr, i + 12, i + 14))
end
end
if string.sub(tmpStr, i + 11, i + 22) == "l韓 nh蕋: " then
if string.sub(tmpStr, i + 24, i + 24) == "!" then
tMaxAtt = tonumber(string.sub(tmpStr, i + 23, i + 23))
elseif string.sub(tmpStr, i + 25, i + 25) == "!" then
tMaxAtt = tonumber(string.sub(tmpStr, i + 23, i + 24))
else
tMaxAtt = tonumber(string.sub(tmpStr, i + 23, i + 25))
end
break
end
end
--L蕐 t猲 v?lo筰 trang b?
if string.match(tmpStr, "甶 t譵 m鉵 n祔:") ~= nil then
for i = 1, table.maxn(tbItemType) do
if string.match(tmpStr, tbItemType[i][1]) ~= nil then tType = tbItemType[i][2] end
end
end
for i = 1, table.maxn(tbItemAttribute) do
if string.match(tmpStr, tbItemAttribute[i][1]) ~= nil then tAttType = tbItemAttribute[i][2] end
end
return tPlace, tName, tSeries, tType, tAttType, tMinAtt, tMaxAtt
end
--H祄 l蕐 th玭g tin nhi謒 v?甶觤 kinh nghi謒
tbAuxiliary.GetQuestExp = function()
tbAuxiliary.TalkToNpc("D?T萿", 0)
local tmpStr = quest.GetInfo()
menu.ClickIndex(0, 0)
for i = 1, string.len(tmpStr) do
if string.sub(tmpStr, i, i + 11) == "kinh nghi謒 " then
local nExp = tonumber(string.sub(tmpStr, i + 12, string.len(tmpStr) - 1))
return nExp
end
end
end
--H祄 l蕐 th玭g tin nhi謒 v?甶觤 danh v鋘g
tbAuxiliary.GetQuestRepute = function()
tbAuxiliary.TalkToNpc("D?T萿", 0)
local tmpStr = quest.GetInfo()
menu.ClickIndex(0, 0)
for i = 1, string.len(tmpStr) do
if string.sub(tmpStr, i, i + 9) == "Danh v鋘g " then
local nRepute = tonumber(string.sub(tmpStr, i + 10, string.len(tmpStr) - 1))
return nRepute
end
end
end
--H祄 l蕐 th玭g tin nhi謒 v?甶觤 ph骳 duy猲
tbAuxiliary.GetQuestFuYuan = function()
tbAuxiliary.TalkToNpc("D?T萿", 0)
local tmpStr = quest.GetInfo()
menu.ClickIndex(0, 0)
for i = 1, string.len(tmpStr) do
if string.sub(tmpStr, i, i + 10) == "Ph骳 Duy猲 " then
local nFuYuan = tonumber(string.sub(tmpStr, i + 11, string.len(tmpStr) - 1))
return nFuYuan
end
end
end
--H祄 ki觤 tra v藅 ph萴 th醓 m穘 nhi謒 v?t譵 trang b?
tbAuxiliary.CheckQuestItem = function(iIndex)
local tPlace, tName, tSeries, tType, tAttType, tMinAtt, tMaxAtt = tbAuxiliary.GetQuestItemInfo()
local nGenre, nDetail, nParticular = item.GetKey(iIndex)
if tName == item.GetName(iIndex) and (tSeries == item.GetSeries(iIndex) or tSeries == nil) then
return 1
elseif nDetail == tType or tType == nil then
for j = 1, table.maxn(tbItemType) do
for k = 0, 5 do
local iMagicType, iMagicValue = item.GetMagicAttrib(iIndex, k)
if tMinAtt ~= nil and iMagicType == tAttType and iMagicValue >= tMinAtt and iMagicValue <= tMaxAtt then
return 1
end
end
end
else
return 0
end
end
--Ki觤 tra v?s?d鬾g item t╪g ph骳 duy猲 trong ngi nh﹏ v藅 n誹 c?
tbAuxiliary.UseFuYuanItem = function()
local nIndex, nPlace, nX, nY = player.GetFirstItem()
while nIndex ~= 0 do
if nPlace == 3 or nPlace == 7 then
for i = 1, table.maxn(tbFuYuanItem) do
if item.GetName() == tbFuYuanItem[i][1] then
player.UseItem(nIndex, nPlace, nX, nY)
return 1
end
end
end
nIndex, nPlace, nX, nY = player.GetNextItem()
end
return 0
end
--Ki觤 tra v?s?d鬾g item t╪g 甶觤 kinh nghi謒 trong ngi nh﹏ v藅 n誹 c?
tbAuxiliary.UseExpItem = function()
local nIndex, nPlace, nX, nY = player.GetFirstItem()
while nIndex ~= 0 do
if nPlace == 3 or nPlace == 7 then
for i = 1, table.maxn(tbExpItem) do
if item.GetName() == tbExpItem[i] then
player.UseItem(nIndex, nPlace, nX, nY)
return 1
end
end
end
nIndex, nPlace, nX, nY = player.GetNextItem()
end
return 0
end
--Ki觤 tra xem ngi ch琲 c?trong th祅h th?hay kh玭g
tbAuxiliary.InCity = function()
for i = 1, table.maxn(tbCity) do
if player.GetMapID() == tbCity[i][2] then return 1 end
end
return 0
end
--H祄 l蕐 index tng 鴑g trong theo n閕 dung
tbAuxiliary.GetDialogIndex = function(nType, szText)
for i = 0, menu.GetCount(nType) - 1 do
if string.match(menu.GetText(nType, i), szText) ~= nil then
return i
end
end
return -1
end
-------------------------------------------------------------------------------D?T萿-----------------------------------------------------------------
function OnTimer(nTimerID)
if (nTimerID == TIMER_ID1) then
-- T?ng nh
if bAutoAttackNpc ~= 0 then tbAttack.AutoAttackNpc() end
-- T?ng nh苩
if bAutoPickUpObj ~= 0 then
-- Refresh BlackList theo nh k?
nRefreshTime = nRefreshTime + 500
if nRefreshTime >=150000 then
nRefreshTime = 0
if not bPickingUp then tbAuxiliary.ClearTable(tbBlackObjectList) end
end
tbPickUp.AutoPickUpObj()
end
elseif nTimerID == TIMER_ID5 then
if player.IsFightMode() == 1 and bAutoPickUpObj ~= 0 and nFilterObjType == 2 then tbAuxiliary.CheckAttribute() end
elseif nTimerID == TIMER_ID2 then
-- Tu Tho Dia Phu + kiem tra thoat game khi Tho Dia Phu
if bLifeLess ~= 0 or bManaLess ~= 0 or bEmptyLife ~= 0 or bEmptyMana ~= 0 or bFullBox ~= 0 or bFullMoney ~= 0 or bItemDuration ~= 0 then tbRestore.AutoTownPortal() end
-- Hen gio tat may
if bExitWindows ~= 0 and (0 <= nExitWindowsHours and nExitWindowsHours <= 23) and (0 <= nExitWindowsMinute and nExitWindowsMinute <= 59) then tbBasic.ExitWindows() end
-- Hen gio thoat game
if bExitGame ~= 0 and (0 <= nExitGameHour and nExitGameHour <= 23) and (0 <= nExitGameMinute and nExitGameMinute <= 59) then tbBasic.ExitGame() end
-- Tu dong phuc hoi
if bAutoAddLife ~= 0 or bAutoAddMana ~= 0 or bUsePoision ~= 0 then tbRestore.AutoHeal() end
-- Xu ly trong thanh
if bTurnBack ~= 0 then tbCastle.ProcessInCastle() end
--L苝 l筰 nhi謒 v?D?T萿
if bForfeit == 1 or bFinish == 1 then
bForfeit = 0
bFinish = 0
tbQuest.DoQuest()
end
elseif nTimerID == TIMER_ID3 then
-- Tang mau theo dinh ky
tbRestore.AutoUseLife()
elseif nTimerID == TIMER_ID4 then
-- Tang mana theo dinh ky
tbRestore.AutoUseMana()
end
end
function StopTimer()
timer.Stop(TIMER_ID1)
timer.Stop(TIMER_ID2)
timer.Stop(TIMER_ID3)
timer.Stop(TIMER_ID4)
timer.Stop(TIMER_ID5)
end
function main()
-- Ghi nh薾 v?tr?ban u c馻 nh﹏ v藅
nOrgPlayerX, nOrgPlayerY = player.GetMapPos()
-- Thi誸 l藀 c竎 skill
if nLeftSkillId > 0 then player.SetLeftSkillID(nLeftSkillId) end
if nLeftSkillId > 0 then player.SetRightSkillID(nRightSkillId) end
if nAuraSkillId1 > 0 then skill.SetAutoBuff(nAuraSkillId1, 1) end
if nAuraSkillId2 > 0 then skill.SetAutoBuff(nAuraSkillId2, 1) end
if nAuraSkillId3 > 0 then skill.SetAutoBuff(nAuraSkillId3, 1) end
-- K輈h ho箃 c竎 timer
timer.Start(TIMER_ID1, 200)
timer.Start(TIMER_ID2, 2000)
timer.Start(TIMER_ID5, 1000)
if bAutoAddLife ~= 0 and nAddLifeValue > 0 and nAddLifeTime > 0 then timer.Start(TIMER_ID3, nAddLifeTime * 1000) end
if bAutoAddMana ~= 0 and nAddManaValue > 0 and nAddManaTime > 0 then timer.Start(TIMER_ID4, nAddManaTime * 1000) end
if bAutoQuest ~= 0 then tbQuest.DoQuest() end
Powered by vBulletin® Version 4.2.0 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.