Open J-T-de opened 4 years ago
It is possible to add UI elements which then would set the ranges that you want, but does it worth it? Resource management is part of the fun in the game. I know that this would be optional and the player could toggle it on the go, but still.
There is no reason to make it work for other players in multiplayer, it only has to work for the client. If everyone installs UCP and turns on this feature, then their client would deal with resource management. It makes no sense that the host would buy/sell in the name of the other players. It should work fine in multiplayer I suppose.
but does it worth it?
Good question, this is why this idea has its question tag. To tab out and change quantity or switching the market on/off somewhere is not what I would like to do during the game. With a fixed file, the only reasonable thing would be to sell stuff after a huge threshold (like 80 stone or so).
Resource management is part of the fun in the game
I completely agree, but the automatic marketplace (in the current version) does not completely remove this aspect, but removes some (in my opinion) annoying points, e.g. if some good is not yet there or stone just floods the stockpile. One has to manually buy stuff, if one wants to recruit, build things and so on. Also, if you are short on money and resources, you better switch it off and go to micro managing ;)
it only has to work for the client
Very nice, this is something (I think) we could adjust. Currently, it 'just' calls buy/sellGood(player1, good, quantity), so we have to get the player id and here we go.
It makes no sense that the host would buy/sell in the name of the other players
It is deterministic game. There is no host in multiplayer match in a sense you mention it. So you can't buy/sell for other players, even if you are host. You can buy and sell only for yourself, so
maybe make it run in multiplayer
will be nice public cheat for multiplayer, haha
It makes no sense that the host would buy/sell in the name of the other players
It is deterministic game. There is no host in multiplayer match in a sense you mention it. So you can't buy/sell for other players, even if you are host. You can buy and sell only for yourself, so
maybe make it run in multiplayer
will be nice public cheat for multiplayer, haha
So you mean that in multiplayer, all the things get calculated at each players machine separately, and only important information (current gold, troop positions etc.) get shared? But why can you then not play together with different patch settings?
Player don't share game data, they send commands to each other. You select 10 units - it send a command 'select units' with their IDs to other players. You move selected units - it send a command 'move selected units' with target position and so on. And since the game is deterministic those commands are processed exactly same way on all machines. When you change patch settings, you change the algorithm of how those commands are processed, that leads to desync.
Ah, okay, but then the automatic marketplace should also lead to desync if only one has patched it, right? So no "cheating" possible (except you simulate the full player input using an external program async) ?
Yes. If you calls local trade method (like you do in your script) it will lead to desync if someone try to use it in multyplayer. So if you want to get such automatic marketplace to work for players who uses UCP in multiplayer, if need to make your routines deterministic as well. That mean that every player's UCP should know that it buy wood for player1 if he has less that 15 wood, and for player2 if it less that 20, for example. The only way to bypass that is to use multyplayer 'trade' command, but that mean that player with automatic marketplace can play against player without such tool.
Thank you, that was really enlightening. I think, I know what I have to do then :)
Maybe one thing out of curiosity: If it is a deterministic game, why are there different outcomes of AI battles, if one reruns it? Some different 'seed' initialization?
Yes, the game initializes Random object with a seed at the beginning of a match. If you "override" this method and fix couple of game bugs (hehe) it will lead to the same outcome every time you start a match.
Again and again, I am amazed about this masterpiece of a game and your knowledge. Much appreciated!
@JuGGerNaunT Isn't calling the same function as the button click triggers the network message send? I am not sure if it works as you describe it.
@LordHansCapon nor sure what network message you mean, but pretty sure it calls the same function.
If it calls the same function, shouldn't it send the Buy request or Sell request over the network to the host?
No, why should it? It just send this command to all players simultaneously instead of sending it only to host.
Any updates on this?
Not really. We haven't continued working on this, the CheatEngine script is still the latest version as far as I know.
Is this still a feature everyone wants? I could add an UI
I haven't touched this in a long time, but if there is interest I'm definitely willing to pick this up again :)
An UI would definitely be helpful, as that was/is something we had no experience with
@Chaf1812 You got any platform where I can contact you? Would love to exchange some informations
Well, seems like the time has finally come. I joined the ucp discord, you can find me there as chaf
Hey guys,
@Chaf1812 and I got an automatic marketplace working.
Compatibility
At the moment, it is a CheatEngine script and therefore needs CheatEngine to run. The aim is to include it in the UCP once it is finished, but using CheatEngine we (and you) have more possibilities for testing (and porting it for the UCP is possible with some work). Currently it only works for vanilla 1.4.1 (not Exteme) and was tested in skirmish and free build mode.
Download
AutoMarketV1.CT Just remove the .txt file extension, otherwise I cannot upload it here.
How it (currently) works
Basically, we identified the buying and selling routines and wrote some assembly and Lua around it. The marketplace works currently with 4 parameters: min, max, min_var, max_var. It stocks up goods to min if number_of_goodmax+max_var. It cyles through the given list of goods and tries to buy or sell one good each large gametick (so in the same frequency as the popularity is updated).
Adaptibility
We wrote the logic in Lua, so everybody with basic programming knowledge can adapt the procedures. Just hit [CTRL] + [ALT] + L in the CheatEngine main window and you can edit it.
Roadmap
UI?
This is a collection of ideas and all are kinda scetchy, as we have no idea of actually implementing UI changes, but maybe @LordHansCapon can help us there? Maybe it is possible to make a UI by changing the trade overview in the marketplace. Display the min/max values below the good instead of the prices should be possible? Maybe make the pictures of goods clickable and wait for some kind of input to adapt the behavior ingame? Adding a sleep button for stopping the automatic marketplace?
Discussion
We want to discuss, what feels most organic in the context of Crusader: Just Stronghold 2 (sell all goods in each gametick in the given range), the current state, the current state but buy in batches, a complete copy of the AI (who had the idea, that wheat should have the same selling threshold as all other food), ... Any further thoughts and ideas? I think I covered most stuff from the old topics https://github.com/Sh0wdown/UnofficialCrusaderPatch/issues/36, https://github.com/Sh0wdown/UnofficialCrusaderPatch/issues/150, https://github.com/Sh0wdown/UnofficialCrusaderPatch/issues/465 ...
Please be patient, this stuff will take time!