I'm trying to create a full set of waypoints for all the starting zones, and I've come across a few quests where you are required to capture a particular mob rather than kill it. Most of these quests need you to do enough damage to the mob to get it below a certain percentage of health before using a quest item to capture it. I'm guessing that there will need to be quite a bit of extra coding to check the mob's health level, stop using any attack skills and then use the quest item to complete the quest.
I don't mind figuring all this out myself, but if someone has already done so, then I would rather use a function that's already written.
How to Capture a Mob?
- Bill D Cat
- Posts: 555
- Joined: Sat Aug 10, 2013 8:13 pm
- Location: Deep in the Heart of Texas
Re: How to Capture a Mob?
I remember times when I've done such quests (manually, not botting) and I found myself doing too much damage to successfully use the item before the mob died. I would have to disarm myself and/or use white damage only and/or take some clothing off that contributes to the damage and/or select certain skills that did less damage. Of course if you are starting a new character and you get to that quest at the right level then it shouldn't be a problem.
I've never botted such a quest but my guess is you could do something in the onskillcast of your profile. The problem is you would only want to do it for that waypoint file so I would change the onskillcast in the onload of the waypoint file.What this does is set up onskillcast to check the mobs hp and if it is below the correct percent then use the item. You need to set the mob and item name and the correct percent.
It's untested.
I've never botted such a quest but my guess is you could do something in the onskillcast of your profile. The problem is you would only want to do it for that waypoint file so I would change the onskillcast in the onload of the waypoint file.
Code: Select all
<onload>
local oldOnSkillCast
if type(settings.profile.events.onSkillCast) == "function" then
oldOnSkillCast = settings.profile.events.onSkillCast
end
function settings.profile.events.onSkillCast(arg1)
if oldOnSkillCast then
oldOnSkillCast(arg1) -- Run original function from profile
end
local mob = player:getTarget()
if mob and mob.Name == "mob name" and -- Or you could use the mob id
50 > (mob.HP/mob.MaxHP*100) then -- Change the percent you need
inventory:useItem("item name") -- Change to item name
end
end
</onload>It's untested.
- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:- “They say hard work never hurt anybody, but I figure, why take the chance.”
- Ronald Reagan
- Bill D Cat
- Posts: 555
- Joined: Sat Aug 10, 2013 8:13 pm
- Location: Deep in the Heart of Texas
Re: How to Capture a Mob?
Untested or not, this worked perfectly. I'll be able to reuse this for the other quests that need me to capture a mob.
Re: How to Capture a Mob?
You could also put it into a userfunction.
Then you could just call it in the onload of a waypoint file. Note, the changes to onskillcast remain in effect until you reload the profile eg. "loadProfile()" which shouldn't be a problem unless you chain another quest targeting these mobs following this quest.
Code: Select all
-- Sets up onskill cast to check the targets hp and use
-- an item if the hp is lower than the given percentage.
function CatchMobSetup(mobNameOrId, percentHP, itemNameOrId)
local oldOnSkillCast
if type(settings.profile.events.onSkillCast) == "function" then
oldOnSkillCast = settings.profile.events.onSkillCast
end
function settings.profile.events.onSkillCast(arg1)
if oldOnSkillCast then
oldOnSkillCast(arg1) -- Run original function from profile
end
local mob = player:getTarget()
if mob and (mob.Name == mobNameOrId or mob.Id == mobNameOrId) and
percentHP > (mob.HP/mob.MaxHP*100) then
inventory:useItem(itemNameOrId)
end
end
end- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:- “They say hard work never hurt anybody, but I figure, why take the chance.”
- Ronald Reagan
- Bill D Cat
- Posts: 555
- Joined: Sat Aug 10, 2013 8:13 pm
- Location: Deep in the Heart of Texas
Re: How to Capture a Mob?
Here's what I finally came up with as a not-so-perfect solution to capturing mobs for quests. I switch to only doing white damage so that I don't kill the mob before I capture it. The main issues I had was bleeds and DoTs killing the mob part way through the cast time of the capture, or just flat out one-shot kills using leveled up skills. Switching to white damage eliminates those issues at the cost of forcing a caster class to beat on the mob with a wand or staff until it is weak enough to capture. This also allows higher level characters on the Nexon private server to still complete the quests without having to swap gear or remove their weapon.
If anyone can improve upon this, I'd be open to suggestions.
If anyone can improve upon this, I'd be open to suggestions.
Code: Select all
--==[ Sets up onPreSkillCast to check the targets hp and use an item if the hp is lower than the given percentage. ]==--
-- mobNameOrId = Name or ID of mob to catch
-- percentHP = HP level at which to attempt to catch the mob
-- itemNameOrId = Name or ID of quest item used to catch the mob
-- questNameOrId = ID of quest requiring capture so we can check if it is complete
function CatchMobSetup(mobNameOrId, percentHP, itemNameOrId, questNameOrId)
if mobNameOrId == 0 then
print("Clearing the mob capture settings.")
else
if type(tonumber(mobNameOrId)) == "number" then
targetName = GetIdName(tonumber(mobNameOrId))
else
targetName = mobNameOrId
end
if type(tonumber(itemNameOrId)) == "number" then
toolName = GetIdName(tonumber(itemNameOrId))
else
toolName = itemNameOrId
end
print("We will attempt to catch " .. targetName .. " using " .. toolName .. " at " .. percentHP .."% HP.")
end
local oldOnPreSkillCast
if type(settings.profile.events.onPreSkillCast) == "function" then
oldOnPreSkillCast = settings.profile.events.onPreSkillCast
end
function settings.profile.events.onPreSkillCast(arg1)
local mob = player:getTarget()
if mob and (mob.Name == mobNameOrId or mob.Id == mobNameOrId) and (getQuestStatus(questNameOrId) ~= "complete") then
if percentHP > math.ceil(mob.HP/mob.MaxHP*100) then
print("Target weakened, attempting capture.")
player:breakFight()
player:moveTo(CWaypoint(mob.X, mob.Z), true)
yrest(500)
inventory:useItem(itemNameOrId)
yrest(5000)
return false;
else
Attack();
return false;
end
elseif oldOnPreSkillCast then
oldOnPreSkillCast(arg1) -- Run original function from profile
end
end
end
Re: How to Capture a Mob?
The problem is on some characters it will not be enough so you might need to disarm and on others it will be too much and they could die. Maybe you should do a level check and decide what you will do based on level difference. Of course it depends on gear too but most of these type of quests are low level quests so you're not likely to have any OP gear yet. Either way it might be better than nothing.
- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:- “They say hard work never hurt anybody, but I figure, why take the chance.”
- Ronald Reagan
- Bill D Cat
- Posts: 555
- Joined: Sat Aug 10, 2013 8:13 pm
- Location: Deep in the Heart of Texas
Re: How to Capture a Mob?
Doing the full re-write of my Yrvandis Hollows waypoints has let me rethink the way I handled this. Now my custom function effectively replaces the defaults for both onSkillCast and onPreSkillCast. This is nice in that I can now allow the mage and warlock classes to cut loose on a mob to get it's health down below 50% before I restrict their damage to only white damage.
I've tested it with Mage, Priest and Warlock classes (who use a wand as starter weapon) and they all managed to capture the required number of mobs in the first loop of waypoints that I set up. I still check to see if the quests are complete, and send you around again if needed, but so far the return trip hasn't been necessary. Of course. if there are multiple players in the area killing the mobs you are trying to capture, this could be a needed step just to be sure you can turn in the quest.
I'll release this and a few other functions in a separate userfunction file when I finish the Yrvandis Hollows files. I'd like to have my kiteElite() function working by then as well.
I've tested it with Mage, Priest and Warlock classes (who use a wand as starter weapon) and they all managed to capture the required number of mobs in the first loop of waypoints that I set up. I still check to see if the quests are complete, and send you around again if needed, but so far the return trip hasn't been necessary. Of course. if there are multiple players in the area killing the mobs you are trying to capture, this could be a needed step just to be sure you can turn in the quest.
I'll release this and a few other functions in a separate userfunction file when I finish the Yrvandis Hollows files. I'd like to have my kiteElite() function working by then as well.