Jump to content
  • 0

How to find nearest enemy/obtain a list of units on the same map, etc...


Seravy

Question


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.02
  • Content Count:  176
  • Reputation:   60
  • Joined:  01/11/19
  • Last Seen:  

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

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  53
  • Topics Per Day:  0.01
  • Content Count:  411
  • Reputation:   260
  • Joined:  04/25/12
  • Last Seen:  

I do not think its a good idea make map-serv handle this kind of "hard" IA byself. Maybe a new module (login, char, map and the new one, ia_handler) that will only send the packets to map-server after calculated what to do.

Edited by Zell
  • Like 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.02
  • Content Count:  176
  • Reputation:   60
  • Joined:  01/11/19
  • Last Seen:  

Wouldn't that mean you have access to less variables and thus the AI has to be dumber? Either way that's beyond my ability and unnecessary for a server only a single person is playing on - maybe once the feature is complete, someone else can improve it.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.02
  • Content Count:  176
  • Reputation:   60
  • Joined:  01/11/19
  • Last Seen:  

I think it might be a good idea to make the AI sit down when the party leader does the same to help recover SP. I did find pc_forcestand but what do I call to make one sit down?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

there is a script command *sit for it
so search (sit) inside the map/script.cpp file

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.02
  • Content Count:  176
  • Reputation:   60
  • Joined:  01/11/19
  • Last Seen:  

I have a new question :

-Is there a procedure I can call if I want a character to say something in public or party chat? It would be nice if the AI could give a warning if a character is low on SP or overweight.

And something for the future but might as well ask in advance, what procedure do I call to equip different arrows? The AI can already tell what enemy is weak or strong against which element, so might as well take advantage of that for the hunter class as well. I haven't yet tried but I'm guessing it's won't be the same call as using a consumable item.

btw roughly half the second/rebirth classes are done, so "only" the other half, then 3rd classes and extended classes left to do...

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

4 hours ago, Seravy said:

-Is there a procedure I can call if I want a character to say something in public or party chat? It would be nice if the AI could give a warning if a character is low on SP or overweight.

if the player received too much damage (from battle.c or status.c ... dunno where you want it)
do /hp emotion or /help emotion .... I mean "/help" emotion ... stupid forum conversion ... I hate IPB4
or perform unittalk script command ... by now you should understand how to copy part of the code from src/map/script.cppas

 

4 hours ago, Seravy said:

And something for the future but might as well ask in advance, what procedure do I call to equip different arrows? The AI can already tell what enemy is weak or strong against which element, so might as well take advantage of that for the hunter class as well. I haven't yet tried but I'm guessing it's won't be the same call as using a consumable item.

LOL this was just asked in this topic
https://rathena.org/board/topic/118155-caseclosed-gunslinger-target-traps-browedit-group-edit-key-and-storage-command/?do=findComment&comment=357268

yes there is *equip script command, just use them

btw if you can also make "@homunattack" or something like that would be cool, since we can't install custom AI anymore
https://rathena.org/board/topic/118141-q-mercenaries-autoattack-and-clones-aspd-bonuses/?do=findComment&comment=357133y

 

Edited by AnnieRuru
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.02
  • Content Count:  176
  • Reputation:   60
  • Joined:  01/11/19
  • Last Seen:  

Thanks, was able to make characters talk. The one I found in script didn't work well though, but party_send_message did. Finding it was a bit of a pain though.

Haven't tested swapping arrows yet but did find the equip procedure. Should work in theory, we'll see soon.

Wait, homunculus AI is no longer a thing? That's sad... well I guess I can do the same for homunculus, but there has to be some sort of existing AI for them somewhere, right? Otherwise they'd just never do anything at all... so I'll need to replace/improve that one I guess? We'll see once I reach the alchemist class...

Right now I've implemented Dispell, made it target boss enemies only for now. I'm not really sure what buffs there are that monsters use and what is actually worth removing, If you have some specific ones in mind, do let me know, I could use more ideas. For now I added Assumptio but for some reason, skill.cpp contains

					case SC_ASSUMPTIO:
						if( bl->type == BL_MOB )
							continue;
						break;

According to my understanding that means it can't be dispelled from mobs, only...everything else. Is this official? I don't see it mentioned on the list of undispellable things in irowiki.  If official, I need to decide if I want to overrule it for my server or not... considering it's PVE only, Dispell has to be able to remove at least a relevant amount of mob buffs, but I have no idea what else it can remove. I already know it can't remove NPC_POWERUP either but that one is probably fine. I think that was the main thing I had to dispel last time I actually played online, but it was like, 6-7 years ago...

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

can you make video for your custome AI?

i really want to see ?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  228
  • Reputation:   19
  • Joined:  10/27/12
  • Last Seen:  

On 2/10/2019 at 7:53 PM, AnnieRuru said:

btw if you can also make "@homunattack" or something like that would be cool, since we can't install custom AI anymore
https://rathena.org/board/topic/118141-q-mercenaries-autoattack-and-clones-aspd-bonuses/?do=findComment&comment=357133y

 

5 hours ago, Seravy said:

Wait, homunculus AI is no longer a thing? That's sad... well I guess I can do the same for homunculus, but there has to be some sort of existing AI for them somewhere, right? Otherwise they'd just never do anything at all... so I'll need to replace/improve that one I guess? We'll see once I reach the alchemist class...

Actually about this part, I was thinking if anyone could make homunculus share or inherit or take parts of ai from the "slaveclone" ai to make it auto attack any hostiles enemy.

since slaveclone will use any skill and attack any hostile enemy automatically so it should theoretically work but need modification.

 

5 hours ago, Seravy said:

According to my understanding that means it can't be dispelled from mobs, only...everything else. Is this official? I don't see it mentioned on the list of undispellable things in irowiki.  If official, I need to decide if I want to overrule it for my server or not... considering it's PVE only, Dispell has to be able to remove at least a relevant amount of mob buffs, but I have no idea what else it can remove. I already know it can't remove NPC_POWERUP either but that one is probably fine. I think that was the main thing I had to dispel last time I actually played online, but it was like, 6-7 years ago...

Dispell remove all positive buff on player according with test against monster 1751 which cast dispell a lot of time

but ratemyserver.net says it remove all buff

Cancel all magical effects on target. Success chance based on skill level and enemy MDEF with a base chance of (50+10*SkillLV)%. Requires 1 Yellow Gemstone to use.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

6 hours ago, Seravy said:

Thanks, was able to make characters talk. The one I found in script didn't work well though, but party_send_message did. Finding it was a bit of a pain though.

why not ?

 src/map/pc.cpp | 8 ++++++++
 src/map/pc.hpp | 1 +
 2 files changed, 9 insertions(+)

diff --git a/src/map/pc.cpp b/src/map/pc.cpp
index 5aace7ecb..e7145e110 100755
--- a/src/map/pc.cpp
+++ b/src/map/pc.cpp
@@ -1356,6 +1356,8 @@ bool pc_authok(struct map_session_data *sd, uint32 login_id2, time_t expiration_
 
 	// Request all registries (auth is considered completed whence they arrive)
 	intif_request_registry(sd,7);
+
+	sd->spam_help = (int)time(NULL);
 	return true;
 }
 
@@ -7637,6 +7639,12 @@ void pc_damage(struct map_session_data *sd,struct block_list *src,unsigned int h
 
 	if(battle_config.prevent_logout_trigger&PLT_DAMAGE)
 		sd->canlog_tick = gettick();
+
+	if ( pc_readparam( sd, SP_HP ) * 100 / pc_readparam( sd, SP_MAXHP ) < 25 && sd->spam_help + 10 <= (int)time(NULL) ) {
+		clif_disp_overhead( &sd->bl, "I need Healing !!" );
+		clif_emotion( &sd->bl, ET_HELP );
+		sd->spam_help = (int)time(NULL);
+	}
 }
 
 TIMER_FUNC(pc_close_npc_timer){
diff --git a/src/map/pc.hpp b/src/map/pc.hpp
index ea5465bc8..78bf4a009 100644
--- a/src/map/pc.hpp
+++ b/src/map/pc.hpp
@@ -730,6 +730,7 @@ struct map_session_data {
 	uint32* hatEffectIDs;
 	uint8 hatEffectCount;
 #endif
+	int spam_help;
 };
 
 extern struct eri *pc_sc_display_ers; /// Player's SC display table

 

6 hours ago, Seravy said:

Wait, homunculus AI is no longer a thing? That's sad... well I guess I can do the same for homunculus, but there has to be some sort of existing AI for them somewhere, right? Otherwise they'd just never do anything at all... so I'll need to replace/improve that one I guess? We'll see once I reach the alchemist class...

I tested on older client, it still works, newer client no longer working

google search "homunculus AI download", you can find some custom AI

 

for the dispel, no idea, this skill is mostly use for PvP only, rarely use on PvM
don't even care about Assuptio on monster ... because we don't cast dispel on monsters hahaha
what a waste of yellow gemstone ...

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.02
  • Content Count:  176
  • Reputation:   60
  • Joined:  01/11/19
  • Last Seen:  

For some reason the first thing I found only displayed the message for the person saying it which wasn't useful. Well, there are dozens or functions that display messages so it simply wasn't the right one I guess.

I actually was planning to make a video, I already have the replays saved. Which do you want, Magma dungeon or the White Lady MVP?

Quote

Homunculus cannot auto attack

Wait, what? If they don't attack, what are they good for? It's not like all types are support... oh they mean it can attack but you have to manually order them to for every single enemy, right? That's a pain, even PETS do better than that. Yes, giving them server side AI can definitely help with it... ah, there is so much to do...

Edited by Seravy
  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

9 minutes ago, Seravy said:

I actually was planning to make a video, I already have the replays saved. Which do you want, Magma dungeon or the White Lady MVP?

 

both of them ?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

3 hours ago, Seravy said:

 

 

oh my god, that really really cool ?
but its not like command @autoattack , it's like mercenary coz only follow and support the leader.....
but still amazing job!!

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.02
  • Content Count:  176
  • Reputation:   60
  • Joined:  01/11/19
  • Last Seen:  

Well, actually, AI set to Tank mode can seek out enemies on their own, but I was playing the only character with that role this time so you didn't see any of that.  It's also possible to make the Tank AI lead the party but then you have to make sure you are properly following, they won't wait for you if you don't ?

It's safer to lead yourself though, especially on maps that have bosses.

Edited by Seravy
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.02
  • Content Count:  176
  • Reputation:   60
  • Joined:  01/11/19
  • Last Seen:  

I'm wondering what to do with skills that cause significant knockback like Spear Stab and Shield Charge.

On one hand, allowing Tank mode to use these at low health to reduce damage taken sounds like a good idea but on the other, it comes with the risk of knocking enemies out of range of skills used by others, or worse, pushes them towards their direction.

Also, what is Brandish Spear good for? I'm thinking but can't really come up with a reason why the AI would want to use it instead of other skills. Bowling Bash does more damage and is AOE, and while the area might be smaller, the enemies will move to 1 distance of you anyway if you are the tank. Casting time is equal, and BB has no additional restrictions either. I'm not very experienced with the Knight class but I feel this skill might just be one of those useless ones?

Edited by Seravy
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

AI sux at using knockback, trust me
human eyes can visualize an area, but bots can only read coordinate in numbers
even if you calculate the range from the tank/leader, it still has some other problems like
1. obstacles in the area
2. walls that prevent knockback
3. position of the healer/tank cause the party out of formation
4. direction of the knockback
-> a good knockback can use on monsters with high HP to delay "this monster meant to kill later"
-> a bad knockback can push the monsters inside the party formation and immediately kills your healer

 

if my memory serve me right, I would go for brandish spear,
I still remember brandish spear can knockback the mobs and potentially lose less HP while tanking mobs, whereas bowling bash just

after some testing yeah, bowling bash seems better choice in rathena

https://forums.warpportal.com/index.php?/topic/83889-bowling-bash-or-brandish-spear/
https://oldforums.irowiki.org/index.php?topic=16731.0

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.02
  • Content Count:  176
  • Reputation:   60
  • Joined:  01/11/19
  • Last Seen:  

Thanks! Halfway done with LK though only the coding, everything is still untested.

I've made Frenzy and Spear Dynamo optional sub-modes for tanking as they are important enough to be used but not the kind of stuff the AI can tell when to use. I remember LKs used to ask me to dispel their frenzy to avoid some of the drawbacks, is that still a thing? What would be a good trigger to do that, at low health with no enemies left around?

Head Crush - Does Bleeding work on monsters? Is the damage percentage based? If yes, I can see this being useful against very high HP enemies, otherwise useless.

Joint Beat - this seems useless? Reducing soft defense isn't really all that great, even reducing hard defense would only be useful against very powerful enemies like bosses. Movement is irrelevant because we are tanking the monster, it won't move. ASPD or ATK reduction is useful but the chance of landing exactly that effect is small.

Charge attack - this would be a great skill to get close to the enemy faster which is very useful for tanking mode, except...it pushes the target away which completely defeats the purpose of the skill. What were they thinking? Still it helps the tank get ahead of the other players and possible teleport into a group of enemies so might be useful as is? I'm tempted to change this skill and remove the knockback but I'm worried that might actually be TOO effective. Wait there is a cast time, so it's only a little bit better than walking, yes, might as well remove the knockback. Seems to be equally useful for the AI either way if I set it to only be used when the nearest target is far away.

After LK, there are only 4 more 2nd job classes left, the most problematic ones.

Stalkers... Chase Walk I don't even know how this works, it doesn't seem you can attack in that status, not even with Backstab and Raid but then why does it boost STR? Makes no sense? Generally hiding and attacking that way would function as a nontanking DPS  so in theory it would be possible to tell the AI to hide, go behind a monster and backstab them then hide again when set to "skill" mode. Strip, this might be actually useful to against bosses, but reducing their VIT and DEF would make Acid Demonstration deal less damage to them? So should only be used if there is no Creator in the party? But the chance of success is very low and the amount of reduction isn't that great either. I might need to consider changing these skills to work better in PVE. Plagirize should in theory already work because it's a passive that only enables the character to "learn" other skills.

Snipers, using various ranged DPS skills should be pretty straightfoward but traps might be difficult. As far as I remember they weren't all that useful either, except for the Snare.

Whitesmith actually isn't so bad, Cart Termination will be a separate option the player can enable. However the buffs breaking party equipment is a problem, as the AI can't reequip them, even if I manage to make the smith fix them. I think the latest kro update removed some (maybe all?) equipment breaking though so that might help.

Alchemist is what I'm most worried about, both the homunculus and the fact most of their attacks cost items so it is a problem if the AI wastes them on unworthy targets.

Edited by Seravy
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

frenzy is use as a last ditch effort when run out of potions (or wish to save them), and want to kill the last batch of monsters at hand
or just want to run away in a no-teleport map (can't use wing of fly/butterfly)
if play as a team (your project) it not so useful, but when play solo, this skill is extremely useful to save potions

I always on Concentration ... just a personal preference
because it reduce defence and not flee, Agi build lord knight has more advantage than Vit build when using this skill
increase 50 hit is useful if you always miss something

head crush and joint beat is totally useless in PvM, even spam pierce has higher damage than any of these
joint beat is useful in PvP, some status ailment like curse/fear/blind is useful in pvp situation ... joint beat needs 3 points from head crush

Charge attack, a must learn skill for PvP, immediately close in wizard/hunter from far away
PvM ? I found spear boomerang more useful to draw hate ... in a team PvM fight should always keep the formation in tact

btw there are 2 common lord knight builds,
1 vit build - spear skill tree
2. agi build - two hand sword skill tree

 

don't ask me about any of the 3rd job skill, I didn't play RO for a very long time too

 

EDIT:

stalkers are useless in PvM ... this class is highly demand in PvP situation though
yeah only the double strafe is useful in PvM

chasewalk vs hide ... is a very debate topic
chasewalk walk faster than hide <-- perhaps is the only thing useful in PvM
if want to use backstab, use hide, then walk slowly behind the target, backstab, lots of damage

sniper ... up agi dex luk = killing machine
or dex+int = falcon assault build

whitesmith ... weapon breaking buff is no problem, can repair broken weapon on the field

creator ... berserk pitcher and potion pitcher skill is highly useful in PvM

Edited by AnnieRuru
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.02
  • Content Count:  176
  • Reputation:   60
  • Joined:  01/11/19
  • Last Seen:  

The problem with broken weapon is that even if repaired automatically, it stays in the inventory, and I can't make the AI equip itself because it might equip the wrong items if there is more than one in inventory. However, I guess I can do the poor man's solution and make the AI complain in chat if they don't have anything equipped in one of the slots, like "omg, I'm not wearing any armor!" . In fact I probably should because monsters can break or strip them as well...

Alternately maybe the AI could store the index of the equipped item in inventory to reequip the same thing. But that can only work if the index in the inventory never changes when picking up or dropping other items, not sure if that's the case. Depends on how inventory is implemented...

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.02
  • Content Count:  176
  • Reputation:   60
  • Joined:  01/11/19
  • Last Seen:  

I'm unsure how to handle the tanking mode. So far I have tried two options but each had problems.

1. If the tank targets the enemy nearest to the leader, it can react to approaching threats better because all non-tank characters stay near the leader. However, this also causes a lot of needless switching of targets and moving back/forth, actually pulling the monsters on the party. If the tank is on one side of the party and a monster approaches from the other side, eventually it'll be closer than the current target, and so the tank moves to the other side to engage it, pulling the previous monster with him (and through the rest of the party). Even if the monster doesn't actually move, the leader might move away from the tanked monster, and closer to another one.

2. If the tank targets the enemy nearest to itself, it will never pull monsters on the party and will be much more effective and gathering mobs on himself due to generally staying further away from the party than the previous method - but then they won't be able to do anything about monsters attacking other party members, unless they have a skill that has AI coded to to draw monster attention which currently includes Provoke and Throw Stone only, limiting this to thief and swordsmen classes. Other classes don't have such a skill available or at least none are coded to be used for that purpose.

(In both cases the target has to be in X range from the leader, to ensure the tank doesn't leave the party. Unless the tank is also the leader, in which case others will follow him so it's fine.)

So far I think option 2 was maybe slightly superior, but maybe someone has a better idea?

Edited by Seravy
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

1. if the weapon is broken, and use *repairall script command, the equipment will stay in its own index
so its fine to immediately repair it, and immediately re-equip it
well, no idea how you going to code the auto-equip though

 

solution 2 is better, like I said, spear boomerang and shield boomerang are the best skill to draw hate from a distance -> always (best) keep the party in wedge formation
and never use provoke to draw hate ... if the sniper/wizard already engage monster automatically, using provoke will likely put them in danger

... can throw stone even draw hate from sniper/wizard ?? I highly doubt it ...

 

EDIT: by the way... do you play Dungeon Siege ? that game also has some kind of ... party control vs mobs

Edited by AnnieRuru
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.02
  • Content Count:  176
  • Reputation:   60
  • Joined:  01/11/19
  • Last Seen:  

Wait if Provoke is not good for drawing monsters, what is it even for?

Pretty much any skill that deals damage can change the monster's target, whether it does or not depends on how the monster is configured I think. But I assume Provoke also changes the target for monsters that don't otherwise do so.

I can make the two Boomerang skills have the same triggers as Provoke in addition to their normal uses, but higher priority than it, so 2nd job characters will then no longer use Provoke. I guess this is one of those things I have to figure out while actually playing,  too bad I don't have a swordsmen class character yet. (on the bright side, it's good to be further ahead in AI coding than my actual player characters available...)

No, I don't play Dungeon Siege.

Edited by Seravy
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.02
  • Content Count:  176
  • Reputation:   60
  • Joined:  01/11/19
  • Last Seen:  

There is probably a serious bug in the code that moves characters. I've always noticed how the game has a hard time  moving to and attacking moving enemies, often walking to the tile they used to be then turning around and going back to the new position the monster meanwhile moved to. I always assumed that is some sort of a position lag thing between the client and server but... the AI is entirely server based and it still does this.

I don't understand the code for walking and attacking very well, with all the timers and stepaction stuff it seems crazy overcomplicated for what feels like it should be a really simple thing but I do see that walktobl, if the unit is already busy, stores a timer that calls walktoblsub to do it later, but walktoblsub does a walktoxysub instead of an actual walktobl. Which basically means if this happens, then moving to a bl will instead do a move to an xy position which is no longer the same thing as it no longer follows the movement of the bl  (if walktobl even does that in the first place, it should but I have no idea).

Now so far this is just speculation but some evidence - two pieces of code I used and what they actually did.

unit_attack(&sd->bl, foundtargetID, 1);

This orders the unit to attack the target continuously. What actually happens with this code...the unit starts moving towards the target. If nothing else happens and they reach it, everything works as intended. However, if I shoot an arrow at the monster then my AI turns around and returns to my position, almost as if it was targeting the target position of the monster's movement (which is me) instead of the monster itself. Basically, positions are like this : Me.....AI.......Enemy. Once the arrow hits the enemy, the AI moves towards me. This of course makes it them meet the enemy much later than if they were moving correctly. So I tried a different code, the one I used for "cautious" movement elsewhere before :

if ((sd->battle_status.rhw.range >= targetdistance)) {
				unit_attack(&sd->bl, foundtargetID, 1);
			} else
			{	struct walkpath_data wpd1;
				if (path_search(&wpd1, sd->bl.m, bl->x, bl->y, targetbl->x, targetbl->y, 0, CELL_CHKWALL))
					newwalk(&sd->bl, bl->x + dirx[wpd1.path[0]], bl->y + diry[wpd1.path[0]], 8);
				return 0;
			}

What this does is, it orders the attack if and only if the enemy is already in range to attack, and if they aren't, then orders them to take a single step of the walkpath that leads to that enemy. In theory this should do the exact same thing as the previous one (move towards monster and attack), but without relying on the default code to follow the enemy. With this code, however, my tank does not turn around and keeps heading to the monster and attacks it, even if I shoot an arrow at them. Which proves the characters failing to properly engange moving monsters is not a lag issue but a major serverside bug.  As I changed absolutely nothing else, it also proves the bug isn't in my AI code elsewhere - if there was something in the AI making these buggy moves, it would still happen even with the newer code - the two should be functionally equivalent afterall.

I remember you mentioning walktobl has problems, but it's more than that - following enemies in general is affected. I'm tempted to think this issue is the exact same problem but for ranged attacks : https://github.com/rathena/rathena/issues/1602

It appears to be still unfixed after two years. Any chance someone will fix this in a reasonably short amount of time? (Days preferred... personally I would say hours but I know that's not realistic :P)

If not, I'd like to fix it myself but I most definitely need help in doing that. I don't really understand how the existing code works... and by that I mean I haven't really figured out where attacks trigger and how they get turned into a walk if the enemy is outside range. That's probably where the issue is whether it's walktobl or somewhere else, idk.

Of course, first I'd like to clarify that this is indeed a bug and not just my misunderstanding of something? ( I haven't actually tested on a human controlled character this time but I do remember having problems engaging a moving target in the past)

 

Edit : here is a video of what I mean :

 

Edited by Seravy
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

there are 2 path-finding bug I'm currently aware of ... in rathena

1. if you ask me when rathena implement the unitwalk with event labels
https://github.com/rathena/rathena/commit/730311e009c8078ecc21f679c425de944b293faf#diff-5961416799718de4529b20c1de23b440R6970
it was 3~4 years ago
and if they have to change the path-finding to implement this ... event label, then its clearly has been broken before that commit

 

2. or maybe the problem you are addressing is ...

prontera,147,174,5	script	asdfasdf	402,{
	warp "prontera",155,185;
}

click on this npc, and you walk to npc despite there is no unitwalk script command ...
if you are talking about this, this bug also happens on Hercules, this one I have no idea how to fix

 

and sorry, I also not having enough knowledge to fix either of these
.... and... I think this is a bug, definitely not happen on official server

 

 


EDIT: Provoke is mainly use to lower the DEF of monsters, because of risking making the monster ATK higher, this skill is situational
... mainly use on high DEF and low ATK low HIT monsters

Edited by AnnieRuru
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.02
  • Content Count:  176
  • Reputation:   60
  • Joined:  01/11/19
  • Last Seen:  

Wasn't able to reproduce the above bug with a non-AI character. Instead I got cases where the character walked to the monster I clicked, properly following it after it moved away, then upon reaching it, not attacking. Eh. This whole movement code is a mess.

Edit : nevermind, I don't think I can fix this, I don't understand enough about how it should work.

I'll just make sure in the future the AI doesn't try to walk-to-attack ever, and wherever possible, moves one tile at a time.

Edited by Seravy
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...