Difference between revisions of "RoM Auto repair"
Line 16: | Line 16: | ||
e.g. '5-7_bugs_repair.xml' | e.g. '5-7_bugs_repair.xml' | ||
<source lang="xml"><waypoints> | <source lang="xml"><waypoints> | ||
− | <!-- Thats a demo to interact with the NPC | + | <!-- Thats a demo to interact with the NPC Tracy --> |
− | |||
<!-- # 1 --><waypoint x="-12282" z="11183"></waypoint> | <!-- # 1 --><waypoint x="-12282" z="11183"></waypoint> | ||
<!-- # 2 --><waypoint x="-12391" z="10982"></waypoint> | <!-- # 2 --><waypoint x="-12391" z="10982"></waypoint> | ||
<!-- # 3 --><waypoint x="-12529" z="10941"></waypoint> | <!-- # 3 --><waypoint x="-12529" z="10941"></waypoint> | ||
<!-- # 4 --><waypoint x="-808" z="-6067"> | <!-- # 4 --><waypoint x="-808" z="-6067"> | ||
− | |||
player:merchant("Tracy"); | player:merchant("Tracy"); | ||
− | |||
load_paths("5-7_bugs_repair_back"); | load_paths("5-7_bugs_repair_back"); | ||
</waypoint> | </waypoint> | ||
</waypoints></source> | </waypoints></source> | ||
− | + | The bot will use the waypoint file '5-7_bugs_repair_back' to find back the way to the original boting place. | |
You now have to insert some code into your boting waypoint file (in this example into the file '5-7_bugs.xml'), to give the bot the information when to repair. | You now have to insert some code into your boting waypoint file (in this example into the file '5-7_bugs.xml'), to give the bot the information when to repair. | ||
+ | |||
+ | It could be based on the duration of your items:<source lang="xml"><!-- # 1 --><waypoint x="13752" z="6726"> | ||
+ | if( player.free_flag1 == true ) then | ||
+ | player.free_flag1 = false; | ||
+ | loadPaths("5-7_bugs_repair.xml); | ||
+ | end | ||
+ | </waypoint> | ||
+ | </source> | ||
+ | |||
+ | As you see, we don't check the duration directly in the waypoint file. Simply because the duration is dependent from your armor and by that, dependend from your character. Hence we check the duration in our characters profile and set just a flag, if we should go for repairing. | ||
+ | |||
+ | <source lang="xml"><onLeaveCombat> | ||
+ | local dura = inventory:getMainHandDurability(); | ||
+ | printf("Durability:%s\n", dura); | ||
+ | if( dura < 0.9 ) then | ||
+ | player.free_flag1 = true; | ||
+ | end | ||
+ | </onLeaveCombat></source> | ||
+ | |||
It could be fight based:<source lang="xml"> <!-- #16 --><waypoint x="-12364" z="10939"> | It could be fight based:<source lang="xml"> <!-- #16 --><waypoint x="-12364" z="10939"> | ||
Line 49: | Line 65: | ||
</waypoint> | </waypoint> | ||
</source> | </source> | ||
+ | |||
+ | You also could combine some of that methods. |
Revision as of 21:01, 9 October 2009
For using the autorepair ingame, you need normaly to press the 'repair' button. You can install the ingame addon Streamline. Streamline will automaticly repair if you open a dialog window with a merchant and it will automaticly deliver quests, if you open a dialog with a quest NPC.
You can also doing that by using the function
player:merchant( npc_name );
It will try to target the nearest NPC's and find the NPC by name. After that, the bot will open the dialog window, autorepair and buy consumables depending from your profile options. It will also work while using multiple bots.
If you only want to target a NPC and do the further stuff by yourself you can use the function:
player:target_NPC( npc_name );
Now you have to create a waypoint file, which leads your character to the repair NPC
e.g. '5-7_bugs_repair.xml'
<waypoints>
<!-- Thats a demo to interact with the NPC Tracy -->
<!-- # 1 --><waypoint x="-12282" z="11183"></waypoint>
<!-- # 2 --><waypoint x="-12391" z="10982"></waypoint>
<!-- # 3 --><waypoint x="-12529" z="10941"></waypoint>
<!-- # 4 --><waypoint x="-808" z="-6067">
player:merchant("Tracy");
load_paths("5-7_bugs_repair_back");
</waypoint>
</waypoints>
The bot will use the waypoint file '5-7_bugs_repair_back' to find back the way to the original boting place.
You now have to insert some code into your boting waypoint file (in this example into the file '5-7_bugs.xml'), to give the bot the information when to repair.
<!-- # 1 --><waypoint x="13752" z="6726">
if( player.free_flag1 == true ) then
player.free_flag1 = false;
loadPaths("5-7_bugs_repair.xml);
end
</waypoint>
As you see, we don't check the duration directly in the waypoint file. Simply because the duration is dependent from your armor and by that, dependend from your character. Hence we check the duration in our characters profile and set just a flag, if we should go for repairing.
<onLeaveCombat>
local dura = inventory:getMainHandDurability();
printf("Durability:%s\n", dura);
if( dura < 0.9 ) then
player.free_flag1 = true;
end
</onLeaveCombat>
<!-- #16 --><waypoint x="-12364" z="10939">
if( player.Fights-player.free_counter1 > 300 ) then
player.free_counter1 = player.Fights;
load_paths("5-7_bugs_repair.xml");
end
</waypoint>
<!-- #16 --><waypoint x="-12364" z="10939">
if(player.free_counter1 == 0) then player.free_counter1 = os.time(); end;
if( os.difftime(os.time(), player.free_counter1) > 3600 )
player.free_counter1 = player.BotStartTime_nr;
load_paths("5-7_bugs_repair.xml");
end
</waypoint>
You also could combine some of that methods.