I'm trying to implement a @ command that makes the character have limited autopilot capabilities like, buff or attack the nearest thing. I'm playing the game alone on my server and would like to use multiple characters...but there is a limit to how many I can play actively at a time, and it's not very fun to do it that way. I tried using a bot but it didn't work but then I realized "hey I can just make the server do it for me, even better and I get to code all the AI". Yes, I'm crazy enough to play RO as a single player game, but even then, I'm going to need a party to fight the stronger enemies :)
So I was able to add the command (and tested it actually works by outputting a message), made it get stored in a variable : sd->autopilotmode = 1;, added a new timer to unit.cpp, got as far as
// @autopilot timer
int unit_autopilot_timer(int tid, unsigned int tick, int id, intptr_t data)
{
struct block_list *bl;
struct unit_data *ud;
int target_id;
bl = map_id2bl(id);
if (!bl || bl->prev == NULL)
return 0;
ud = unit_bl2ud(bl);
if (!ud)
return 0;
if (bl->type != BL_PC) // Players are handled by map_quit
{
ShowError("Nonplayer set to autopilot!");
return 0;
}
struct map_session_data *sd = (struct map_session_data*)bl;
if (sd->status.autopilotmode==0) {
return 0;
}
// Tanking mode is set
if (sd->status.autopilotmode == 1) {
}
although this is mostly guessing so far, but here I'm stuck. How do I find the nearest enemy (or party member, for buffs) to target? Tried searching for other code parts that target monster attacks and similar but it looks way too complicated. It's hard without even knowing what each structure is for. Didn't see any Findnearest kind of functions anywhere either. In fact I don't even know how to access a list of units on the same map. I think I'm going to need to call "clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, int target_id, unsigned int tick)" to execute the action but first I need to somehow find a target.
Question
Seravy
I'm trying to implement a @ command that makes the character have limited autopilot capabilities like, buff or attack the nearest thing. I'm playing the game alone on my server and would like to use multiple characters...but there is a limit to how many I can play actively at a time, and it's not very fun to do it that way. I tried using a bot but it didn't work but then I realized "hey I can just make the server do it for me, even better and I get to code all the AI". Yes, I'm crazy enough to play RO as a single player game, but even then, I'm going to need a party to fight the stronger enemies :)
So I was able to add the command (and tested it actually works by outputting a message), made it get stored in a variable : sd->autopilotmode = 1;, added a new timer to unit.cpp, got as far as
// @autopilot timer int unit_autopilot_timer(int tid, unsigned int tick, int id, intptr_t data) { struct block_list *bl; struct unit_data *ud; int target_id; bl = map_id2bl(id); if (!bl || bl->prev == NULL) return 0; ud = unit_bl2ud(bl); if (!ud) return 0; if (bl->type != BL_PC) // Players are handled by map_quit { ShowError("Nonplayer set to autopilot!"); return 0; } struct map_session_data *sd = (struct map_session_data*)bl; if (sd->status.autopilotmode==0) { return 0; } // Tanking mode is set if (sd->status.autopilotmode == 1) { }
although this is mostly guessing so far, but here I'm stuck. How do I find the nearest enemy (or party member, for buffs) to target? Tried searching for other code parts that target monster attacks and similar but it looks way too complicated. It's hard without even knowing what each structure is for. Didn't see any Findnearest kind of functions anywhere either. In fact I don't even know how to access a list of units on the same map. I think I'm going to need to call "clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, int target_id, unsigned int tick)" to execute the action but first I need to somehow find a target.
Link to comment
Share on other sites
Top Posters For This Question
41
16
5
1
Popular Days
Feb 13
10
Feb 12
5
Jan 16
5
Jan 15
5
Top Posters For This Question
Seravy 41 posts
AnnieRuru 16 posts
LearningRO 5 posts
utofaery 1 post
Popular Days
Feb 13 2019
10 posts
Feb 12 2019
5 posts
Jan 16 2019
5 posts
Jan 15 2019
5 posts
Popular Posts
Seravy
Seravy
Thank you very much, this has worked! I made it move to the nearest enemy (outside range) when one in range to attack doesn't exist. I used path_search_long(NULL, sd2->bl.m, sd2->bl.x, sd2->b
Seravy
Either way, whether you have a way of using Git on VS 2013 for me or not, it'll take a while so here is my current entire src folder. As far as I remember I only changed like, 3 numbers related to 3 u
63 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.