PDA

View Full Version : [KT] auto chi chuyển



songtu
09-01-18, 05:51 AM
Chàotoàn thể anh em thân mến!

Cho mình hỏi có cách nào làm cho nhân vật tự chạy đến vị trí cho trước không?
Ví dụ từ A–> B chẳng hạn
Mình muốn viết cái t ool nhỏ auto cho KT cho nó tự chạy tới vị trí NPC nhờ dịch chuyển sang thành khác….
Bác nào có cao kiến giúp mình với , mình vọc vạch tý ....

Cảm ơn các bác nhiều nhiều!!

__Jie__
09-01-18, 06:12 AM
1 đoạn Plugin cho bạn tham khảo cần viết sẳn các hàm di chuyển ra để khi cần chỉ việc truyền tham số cho nó





function TrainLND:DiBanRac()
local nTiemThuoc = self.TimNPC_TEN("Trương Trảm Kinh");
if nTiemThuoc then
if UiManager:WindowVisible(Ui.UI_SAYPANEL) == 1 then
for i, tbInfo in ipairs(tbAnswers) do
if string.find(tbInfo, "Dược phẩm") then
Ui(Ui.UI_SAYPANEL):OnListSel("LstSelectArray", 1);
me.Msg(tostring("<bclr=0,0,200><color=White>Chọn : <bclr><color>"..tbInfo));
end
end
elseif UiManager:WindowVisible(Ui.UI_SHOP) ~= 1 then
AutoAi.SetTargetIndex(nTiemThuoc.nIndex)
end
else
self.GoTo(29,KNpc.ClientGetNpcPos(me.GetMapTemplat eId(),3564));-- 29 ma ban do -- 3564 ID NPC
end
end
function TrainLND.GoTo(M,X,Y)
if me.GetNpc().nIsRideHorse == 0 then
me.Msg("<color=pink>Tự động lên ngựa")
Switch("horse")
end
local nMapId,nMyPosX,nMyPosY = me.GetWorldPos()
if nMapId == M and nMyPosX == X and nMyPosY == Y then
return
end
if nLastMapId ~= M or nLastMapX ~= X or nLastMapY ~= Y then
nLastMapId = M
nLastMapX = X
nLastMapY = Y
else
if me.GetNpc().nDoing == 3 then
return
end
end

if UiManager:WindowVisible(Ui.UI_SAYPANEL) == 1 then
UiManager:CloseWindow(Ui.UI_SAYPANEL);
end

local tbPos = {}
tbPos.nMapId = M
tbPos.nX = X
tbPos.nY = Y
Ui.tbLogic.tbAutoPath:GotoPos(tbPos)
end

function TrainLND.TimNPC_TEN(sName)
local tbEnemyList = {}
if not sName then
local tbNpcList = KNpc.GetAroundNpcList(me,600);
for _, pNpc in ipairs(tbNpcList) do
if AutoAi.AiTargetCanAttack(pNpc.nIndex) == 1 then
table.insert(tbEnemyList, pNpc);
end
end
if table.getn(tbEnemyList) >=1 then
return TrainLND.MucTieuGanNhat(tbEnemyList)
end
end
------------------------------------------
local tbNpcList = KNpc.GetAroundNpcList(me,600);
for _, pNpc in ipairs(tbNpcList) do
if pNpc.szName == sName then
table.insert(tbEnemyList, pNpc);
end
end
if table.getn(tbEnemyList) >=1 then
return TrainLND.MucTieuGanNhat(tbEnemyList)
end
end
function TrainLND.MucTieuGanNhat(tblistnpc)
local npcgannhat = nil
local khoanggannhat = 600
local nMyX, nMyY = me.GetNpc().GetMpsPos();
for _, pNpc in ipairs(tblistnpc) do
local Xnpc,Ynpc = pNpc.GetMpsPos();
local kc_npc = TrainLND.KhoangCach(nMyX, nMyY,Xnpc,Ynpc)
if kc_npc < khoanggannhat then
npcgannhat = pNpc
khoanggannhat = kc_npc
end
end
return npcgannhat
end
function TrainLND.KhoangCach(myX,myY,keyX,keyY)
local nDistance = 0;
nDistance = math.sqrt((myX-keyX)^2 + (myY-keyY)^2);
return nDistance;
end

songtu
09-01-18, 10:52 AM
cảm ơn bác nhiều nhiều, plugin trong game e cũng ngâm ngâm đc ít ít,,
em muốn tìm hiểu về mấy cái kiểu vùng nhớ, offset các kiểu ý bác , vs kỹ thuật auto khi mà ko active cửa sổ game ý ạ,, bác có rành món đóko ạ?