include("pawn.lua"); include("player.lua"); local _timexx, _firsttimes, target, smsg, partyleader, leaderobj, leaderpawn, stop function icontarget(address) -- looks for icon I on mobs local pawn = CPawn(address); local icon = pawn:GetPartyIcon() pawn:update() if icon == 1 then return true end end function PartyTable() if _timexx == nil then _timexx = os.time() end partymemberpawn={} local partymemberName={} local partymemberObj={} table.insert(partymemberName,1, player.Name) -- need to insert player name. table.insert(partymemberObj,1, player:findNearestNameOrId(player.Name)) table.insert(partymemberpawn,1, CPawn(player.Address)) for i = 1, 5 do if _firsttimes == nil then -- post party names when bot started if GetPartyMemberName(i) ~= nil then cprintf(cli.yellow,"Party member "..i.." has the name of ") cprintf(cli.red, GetPartyMemberName(i).."\n") _firsttimes = true end end if os.time() - _timexx >= 60 then --only post party names every 60 seconds if GetPartyMemberName(i) ~= nil then cprintf(cli.yellow,"Party member "..i.." has the name of ") cprintf(cli.red, GetPartyMemberName(i).."\n") _timexx = os.time() end end if GetPartyMemberName(i) then table.insert(partymemberName,i + 1, GetPartyMemberName(i)) table.insert(partymemberObj,i + 1, player:findNearestNameOrId(partymemberName[i + 1])) if partymemberObj[i + 1] then table.insert(partymemberpawn,i + 1, CPawn(partymemberObj[i + 1].Address)) end end end end function Party(heal) eventParty("start") _timexx = os.time() while(true) do if memoryReadBytePtr(getProc(),addresses.loadingScreenPtr, addresses.loadingScreen_offset) ~= 0 then repeat printf("loading screen has appeared, waiting for it to end.\n") yrest(1000) until memoryReadBytePtr(getProc(),addresses.loadingScreenPtr, addresses.loadingScreen_offset) == 0 end PartyTable() yrest(200) player:update() local selficon = player:GetPartyIcon() if not player.Mounted then player:checkSkills(true); player:checkPotions(); if selficon and selficon >= 4 then --=== If character has icon 4,5,6,7 or 8 then ===-- --=== Kill leaders target ===-- local mob = getTarget(getPartyLeaderName()) if mob and mob.Type == PT_MONSTER then player:target(mob.Address) player:fight(); end end if heal then for i,v in ipairs(partymemberpawn) do player:target(partymemberpawn[i]) player:update() partymemberpawn[i]:update() partymemberpawn[i]:updateBuffs() target = player:getTarget(); if target.HP/target.MaxHP*100 > 10 then player:checkSkills(true); end end else if not selficon or 4 > selficon then player:target(player:findEnemy(nil, nil, evalTargetDefault, player.IgnoreTarget)); if player:haveTarget() then player:fight(); end end end end if (not player.Battling) then local Lootable = player:findEnemy(nil, nil, evalTargetLootable) if not Lootable then getNameFollow() else player:target(Lootable) player:update() if player.TargetPtr ~= 0 then player:lootAll() end end end partyCommands() end end function getPartyLeaderpawn() partyleader = getPartyLeaderName() leaderobj = player:findNearestNameOrId(partyleader) if leaderobj then leaderpawn = CPawn(leaderobj.Address) end end function getNameFollow() if stop then return end local function Mount() local mounted getPartyLeaderpawn() if partyleader and leaderobj then local attackableFlag = memoryReadRepeat("int", getProc(), leaderobj.Address + addresses.pawnAttackable_offset) or 0; mounted = bitAnd(attackableFlag, 0x10000000) if not player.Mounted then if mounted then player:mount() end end if not mounted then if player.Mounted then player:dismount() end end end end if ( settings.profile.options.PARTY_FOLLOW_NAME ) then for i = 1,5 do if GetPartyMemberName(i) == settings.profile.options.PARTY_FOLLOW_NAME then RoMScript("FollowUnit('party"..i.."');"); Mount() return end end RoMScript("FollowUnit('party1');"); else RoMScript("FollowUnit('party1');"); end Mount() end function checkparty(_dist) local proc = getProc(); local partyX, partyZ local _dist = _dist or 200 PartyTable() local _go = true local partynum = RoMScript("GetNumPartyMembers()") if partynum == #partymemberpawn then player:update() for i = 2,#partymemberpawn do partyX = memoryReadRepeat("float", proc, partymemberpawn[i].Address + addresses.pawnX_offset) or partymemberpawn[i].X partyZ = memoryReadRepeat("float", proc, partymemberpawn[i].Address + addresses.pawnZ_offset) or partymemberpawn[i].Z if partyX ~= nil then if distance(partyX,partyZ,player.X,player.Z) > _dist then _go = false end else _go = false end end else _go = false end return _go end function checkEventParty() repeat local time, moreToCome, name, msg = EventMonitorCheck("pm1", "4,1") if msg and name ~= player.Name then return msg, name end until msg == nil end function eventParty(_startstop) if _startstop == "stop" then print("Party Monitor stopped.") EventMonitorStop("pm1") else print("Party Monitor started.") EventMonitorStart("pm1", "CHAT_MSG_PARTY") end end function sendPartyChat(_msg) RoMScript("SendChatMessage('".._msg.."', 'PARTY')") cprintf(cli.blue,_msg.."\n") end function getPartyLeaderName() local name = memoryReadString(getProc(), 0x9FBF18) -- change to addresses.lua later if( bot.ClientLanguage == "RU" ) then name = utf82oem_russian(name) else name = utf8ToAscii_umlauts(name) end return name end function getTarget(name) local ll = player:findNearestNameOrId(name) if ll then leader = CPawn(ll.Address) end if leader then local target = CPawn(leader.TargetPtr) return target end end function getQuestNameStatus(_name) i = 0 repeat i = i + 1 local index, catalogID, name, track, level, daily, bDaily_num, iQuestType, questID, completed, QuestGroup = RoMScript("GetQuestInfo("..i..")") if name ~= nil then if string.find(string.lower(name),string.lower(_name)) then return name, completed end end until name == nil return nil end function partyCommands() local _message , _name = checkEventParty() if _message then --=== check type of command ===-- local _npc, _quest, _command, _choice _quest = string.match(_message,"quest\"(.*)\"") _npc = string.match(_message,"npc\"(.*)\"") _command = string.match(_message,"com\"(.*)\"") _choice = string.match(_message,"choice\"(.*)\"") if _quest then local quest, status = getQuestNameStatus(_quest) if quest == nil then sendPartyChat("no quest with that name") else if status then sendPartyChat("quest: "..quest.." ,completed") else sendPartyChat("quest: "..quest.." ,incomplete") end end elseif _npc == "sell" then local npc = getTarget(_name) if npc then player:merchant(npc.Name) sendPartyChat("finished with NPC") else sendPartyChat("npc: No target") end elseif _npc == "accept" or _npc == "complete" then local npc = getTarget(_name) if npc then player:target_NPC(npc.Name) CompleteQuestByName() player:target_NPC(npc.Name) AcceptQuestByName() sendPartyChat("finished with NPC") else sendPartyChat("npc: No target") end elseif _command == "nofollow" then keyboardPress(settings.hotkeys.MOVE_FORWARD.key); stop = true sendPartyChat("stopped following") elseif _command == "follow" then stop = false sendPartyChat("following") elseif _choice then local npc = getTarget(_name) if npc then player:target_NPC(npc.Name) if ChoiceOptionByName(_choice) then sendMacro('StaticPopup_OnClick(StaticPopup1, 1);') waitForLoadingScreen(10) sendPartyChat("ok choice option done") else sendPartyChat("no option available by that name") end end end end end function PartyHeals() -- backward compatible Party(true) end function PartyDPS() -- backward compatible Party() end