Source code questions for bot-based co-op server (V15)

Welcome to our Community
Wanting to join the rest of our members? Feel free to sign up today.
Sign up

AI-batt

New member
Registered
Joined
Jul 31, 2024
Messages
8
Reaction score
7
Points
3
Introduction

When a new server starts, there is always this exciting time where everyone starts on the same level. Unfortunately,
there are some people who play a lot, while others don't have as much time and get left behind. What if everyone plays only when you play?

Hi everyone,
I am working on a co-op server (V15), where one or multiple players can play vs. a large number (>>100) of bots.
Ultimately, these bots should compete among themselves (party, guilds, etc.) and create events in Madrigal that
are unique and not present in classic Flyff gameplay. There is still much to be done, but this is the current status:

Working bot features (kind of):
  • Automatic login
  • Simple leveling (up to Burudeng)
  • Basic food healing
  • Increasing stats
  • Collection drops
  • Equip better gear from inventory
TBD next:
  • Object collision (see video(s))
  • Pathfinding
Youtube

Leveling:
Collision:

Setup


I am definitely not the best programmer and don't always fully understand the code. On my day job I use only Python, so reading and writing
C++ code is a bit challenging. 😅 Therefore, I would really appreciate it if people with more experience could answer a few questions.
High-level answers are also welcome if you don't feel like writing a long text. I can hopefully figure it out then by myself. 😄

Using KetchupV15 source, I take the client code (Neuz) for the bot and trick the server into thinking that the bot is a normal player. However, many problems come up, because I removed the WinAPI
and run bots only in console for efficiency, meaning no rendering for the bot. As a result, a lot of useful stuff is missing, such as CWndMng, the general logic/main loop, etc.

Problems & Questions

Hey There!
Please login and(or) register to see this awesome content today.
Hey There!
Please login and(or) register to see this awesome content today.
Hey There!
Please login and(or) register to see this awesome content today.

I appreciate any help in resolving these issues. Thank you! 😁
 
  • Like
Reactions: Thaibboy
pwoblem 1:
Sounds like a issue with position serialization between neuz / world
pwoblem 2:
if I remember correctly, when I was reworking my pk pvp system, there is an internal source check for player level, that pk setting level isn't part of it. You just gotta find it and remove it =)
 
#1 -> Welcome to flyff, sadly you cannot really "fix" it like this.
#2 -> change PK level to 0 if you want the possibility of level 1 getting attack.
#3 -> Cannot help you for the first part, but "why is the server not checking for collisions?" depend of the version i would say, as example v21 do check collisions.
 
  • Like
Reactions: zOmbie
Thank you, guys. I think, PK is now fixable. 😁

My focus is currently on Problem #1, because its very annoying.

pwoblem 1:
Sounds like a issue with position serialization between neuz / world
pwoblem 2:
if I remember correctly, when I was reworking my pk pvp system, there is an internal source check for player level, that pk setting level isn't part of it. You just gotta find it and remove it =)
Thanks for your msg.

pwoblem 1: okay! In this context, I am not aware about the relationship between CNeuz and CWorld. I thought that CNeuz just periodically calls updates on CWorld?
By 'position serialization' you mean that the position data of objects (e.g., CMover instances) is not being properly synchronized? For me 'serialization' means converting data to a byte stream.

#1 -> Welcome to flyff, sadly you cannot really "fix" it like this.
#2 -> change PK level to 0 if you want the possibility of level 1 getting attack.
#3 -> Cannot help you for the first part, but "why is the server not checking for collisions?" depend of the version i would say, as example v21 do check collisions.
Thank you.

#1: Oh okay, do you have a rough idea where to look in the code to "fix" this? 😅
 
Problem 1: I figured out that CWorld:: Process is bound to the framerate. It means that the number of position and animation updates per call is bound to elapsed time? So far, I haven't found a suitable variable in the code that seems to handle this. I expect something like in CActionMover:: PresupposePos where there is a for-loop to iteratively increase the distance of a movement vector (vDelta.x etc.) dependent on a loop variable uTickCount. Couldn't find such a mechanism for the 'real' position updates, yet ...

My current understanding is that CActionMover:: ProcessState1 updates the CMover movement vector but without loop or time dependence. I also couldn't find such a mechanism up the call stack. Where is the movement vector applied to the current position?

Does anyone have an idea? Appreciate your help!
 
Have a look at those:


Hey There!
Please login and(or) register to see this awesome content today.

Hi devious, thanks for your suggestion. Unfortunetly, monster position updates usually arrive via
Hey There!
Please login and(or) register to see this awesome content today.
which are not based on tick counts at all. 😅

But I think that I found the solution. The synchronisation between frame rate (WinAPI) and CWorld is apparently done by using these functions:
Hey There!
Please login and(or) register to see this awesome content today.

'FST' probably stands for FrameSkippingTimer ...
These are global functions with global variables in timer.cpp (wtf). Adding this two lines allow an arbitrary amount of CWorld calls, without asynchronous world state (no Sleep() in the code).


I have yet to find out how these global variables influence the updates on CWorld, because I can't find really any reference of them in the code ...
 
Last edited:
Hi all,

for now, I consider problem #1 to be solved! :)

My next step is to get real object collisions for the bot which means to successfully load object meshes via directx device obj. (?)
This kind of problem probably doesn't come up that often for other developers, so I'll probably have to get it done without help 😅

But ...

Can anyone remember where the 3d objects of , e.g., trees, houses, fences etc. are loaded into memory? I couldn't find it yet ...
 
Hi all,

for now, I consider problem #1 to be solved! :)

My next step is to get real object collisions for the bot which means to successfully load object meshes via directx device obj. (?)
This kind of problem probably doesn't come up that often for other developers, so I'll probably have to get it done without help 😅

But ...

Can anyone remember where the 3d objects of , e.g., trees, houses, fences etc. are loaded into memory? I couldn't find it yet ...


WorldFile / World
 
  • Like
Reactions: AI-batt
Haha, I did it. Problem #3 solved! :)





WorldFile / World
Devious, thanks for the pointer! WorldFile is a good entry point. Loading 3D objects boils down to call CLandscape::LoadLandscape without errors.


Regarding the directx device: My proposed solution, in the Problem #3 spoiler tab, to manually create a directx device (w/o window) actually works, lmao. 😂
It just needed a few adjustments in CLandscape::LoadLandscape and related methods.


Pathfinding: Now, that collisions work, the leveling procedure is fucked since the bot gets stuck at objects. 😅
Thus, my next goal is to add a pathfinding algorithm. There already seem to be some nice helper functions available to do so ...
I thought about using A*, with some custom flyff-related search heuristics? Based on Flaris (World Editor), the number of collision objs outside the city is very limited, so there is a depth-first search in a straight line probably near optimal. I am not sure about the city, tho ...

Any suggestions, guys? Appreciate your help!
 
  • Like
Reactions: Thaibboy
I don't mean to hi-jack this post by any means, i saw your thread on another site and I sat here and I go this is going to kill the game.

Then I put some thought about the entire concept of this and my mind has actually shifted, I'm actually quite impressed with what you have accomplished @AI-batt

Just wanted to throw that out there for what it's worth, keep it bro (y)
 
Hi @zOmbie ,

I don't mean to hi-jack this post by any means, i saw your thread on another site and I sat here and I go this is going to kill the game.
Mhm, okay ... I would be interested to hear more about your concerns! I'm not a real friend of closed source, but I also never thought about negative consequences ... 😅 Is running a (bot) client in console a big deal? Or am I missing something here?

Yea. 😁 Initially I posted my questions on a different site, because I'm new to flyff dev and this was my only reference. Fortunately, a kind person DM'd me and told me about the lodelight forum. I haven't seen the person's username on this site yet ... 😕

Then I put some thought about the entire concept of this and my mind has actually shifted, I'm actually quite impressed with what you have accomplished @AI-batt

Just wanted to throw that out there for what it's worth, keep it bro (y)
Thank you! This means alot. 💪 It is far from finished! (not sure if this is a good or bad thing, haha)
 
  • Like
Reactions: zOmbie
Hi @zOmbie ,


Mhm, okay ... I would be interested to hear more about your concerns! I'm not a real friend of closed source, but I also never thought about negative consequences ... 😅 Is running a (bot) client in console a big deal? Or am I missing something here?

Yea. 😁 Initially I posted my questions on a different site, because I'm new to flyff dev and this was my only reference. Fortunately, a kind person DM'd me and told me about the lodelight forum. I haven't seen the person's username on this site yet ... 😕


Thank you! This means alot. 💪 It is far from finished! (not sure if this is a good or bad thing, haha)
At first glance it reminded me of that ai bot all the ph servers had, then i looked into it and seen it was way more then that and it could be proven useful in esp a dying game.

Even for localhosting, this idea even makes that less boring :cool:
 
I'm lurking here to see how much you can push your project. And while i was lurking i was like "meh, i know what he's doing right now, this idea might come from another game" and then i looked up on my old youtube playlist searching after a video that i did saw on this specific topic and about using bots server side to make a "solo" server feel like a real one. And then i found out from where i have seen this :



It comes from World of Warcraft, this solution already exist for it

So, if you have more difficulties in the futur, it might be worth to check the server code on wow, just to get an idea on how to fix X or Y problem
 
  • Like
Reactions: jotaro and zOmbie
Hey guys,

just wanted to give you a small update on current progress:



I got a first version working for pathfinding (with A*). Currently, it seems a bit clumsy. But I will work on improvements for movement smoothness, shortest path and computational efficiency. 😁
Also, the positions inside the fences are not reachable atm 😅
 
I think this is more of a project or showcase? I'm gonna move you out of this section and put you in projects, if u want it moved elsewhere let me know!

Keep up the good work :)
 
  • Like
Reactions: AI-batt
At first glance it reminded me of that ai bot all the ph servers had, then i looked into it and seen it was way more then that and it could be proven useful in esp a dying game.

Even for localhosting, this idea even makes that less boring :cool:
There was actually a server that had this system. But only to a point where the account logs in on its own moves a little bit and did some buffs and teleports to places then logs out on its own.
It actually helped make the server look alive. It was Fantasy Flyff like around 2011