#Multiplayer Mod

158 messages · Page 1 of 1 (latest)

undone lintel
#

I was thinking that a multiplayer versus mod could be a great addition to Balatro (idk if it has already been proposed).

The idea is that you have a button which you can enter a queue by pressing it and it will search a player to play with you on the same seed & deck, the goal is to survive longer than your opponent. (with addition like being able to look at your opponent's jokers & deck, ranking, chat ...)

If you are interested in this idea, feel free to mod it.

Sorry if my english can be bad, it's not my first language.
Have a great day ! balatrojoker

lament shale
#

Using a secondary code outside the seed might be good for private matches.
Other than that, all that would be needed is a way to send the information(maybe through a webhook for small p2p packets updating every so often), and a way to set up private matches via code or something and that'd be perfect.
and a check to make sure mods are the same bc that'd create some issues

I'm just throwing ideas in, since I have zero clue how this would go together, but the brainstorm is the current phase right now anyway

hoary bridge
#

I wonder if there's potential for a more direct vs mode, for example, high scoring rounds that go significantly above their ante provide a debuff or negative effect to the other player.

Maybe even show both games side to side, Tetris style

gloomy trout
#

i feel like a multiplayer mode where two people have the same seed shops and blinds then instead of boss blinds they fight each other for the best hands

idle verge
#

Why not make the other player the final boss instead of just a boss

zinc crow
#

the ante 8 elite just being that you have to score higher than your opponent would be cool, also if you could see your opponent's build it would be funny to have a shop option you can buy to change their next boss blind on the first seven

undone lintel
#

I think at first the goal is to make it the minimalist at possible and then add change one by one. So in the first time the goal is to create a button that enter you in a queue for a match, in-game visuals to know if you win/loose, a time limit for each round, a leave match button and in the home page two indicators, one for how many people are online with the mod and the other one for how many person are currently waiting in a queue for a match.

frail sun
#

i’ve been trying to figure out how to make this work for ages and the solutions i've come up with all require some sort of paid service for the server

whole light
#

Maybe use the room system and "overlay" the queue? As in, you check if there are public rooms available, if yes - join one, if not - create one. That means there is a whole new room screen with players, with a way to choose deck and stake
I was thinking of a Steam friends integration, but I don't know if that's possible

frail sun
#

the issue is the actual implementation side of things

#

the best option i’ve found is using udp hole punching to establish a p2p connection, but it still requires a server to make the matches in the first place, unless two people are willing to just share ip addresses with each other

#

in regards to steam implementation, all of that is done with steam api, and i’m not sure if there are legal repercussions to just using it in a mod

modern hemlock
#

I mean you could make a lan/hosted server implementation and then people can port forward or smth

#

I have seen other mods use the steam api for multiplayer before

frail sun
#

wait i think i'm onto something regarding steam api

#

i found some actual docs

#

can someone test this mod on steam and see if it lists all of your steam friends as debug messages? (steamodded)

frail wharf
#

i don't see it?

frail sun
#

that's weird

frail wharf
#

supposed to be in the steamodded console thing yeah?

frail sun
#

yeah i think so

frail wharf
#

let me remove all my other mods and test again

frail sun
#

i don't use steamodded debug messages often, it could be a stupid mistake

frail wharf
#

my brain is so fried i just started a different game

frail sun
frail wharf
frail sun
#

wait no nvm i'm an idiot

#

sorry about that

frail wharf
#

lmao its cool

#

this is all it does i think, i might've missed it earlier since i had way more mods on

#

i wonder why it doesn't detect my steam

frail sun
#

yeah, hmm

#

i might need a moment to figure this out

#

i did not expect it to work first try btw

frail wharf
#

i am using lovely for steamodded fyi, not sure if that could mess with it

#

so real

frail sun
#

it shouldn’t

frail wharf
#

@ me when you need another test subject, if i don't reply i'm probably asleep

frail sun
frail wharf
#

downloading now

#

at least that probably means it could tell i'm on steam?

#

@frail sun acknowledged?

frail sun
#

progress!

modern hemlock
#

For some reason, it seems that theres only these values on st.friends

setRichPresence
getFriendPersonaName
activateGameOverlay
activateGameOverlayToWebPage
#

its missing both getFriendCount, getFriendByIndex

#

Ah figured it out.

#

those methods were added on febuary 1st this year

#

so its probbaly an older version of the lib

#

Was able to get it to print my name though

#

I think this is fine still

frail sun
#

ohhhhh makes sense

#

tysm

#

erm well then

modern hemlock
#

theres a big example at the bottom

frail sun
#

yea but that means we’ll probably have to drop the steam friends idea

modern hemlock
#

no nessicarily

#

you should be able to set the rich presence so people can join using it

#

also I'm not sure, but there should be some way to invite user's using the steam overlay

#

oh yeah there is an invite to gasme thing

frail sun
#

huh neat

#

i don’t use steam overlay for anything so i dont really know how it works

#

i will investigate

modern hemlock
#

let me whoop us something rq

frail sun
#

so apparently steam api has an interface called isteamnetworkingmessages that's literally exactly what i need but luasteam doesn't have it implemented

modern hemlock
#

my steam is being annoying

#

let me restart steam and see if it shows up properly

frail sun
#

can you explain what steam overlay and rich presence are?

modern hemlock
#

Steam overlay is just the thing that is shift + tab

#

rich presences lets games give info to steam (like how my friend's game has 1m under it)

#

However, rich presence also allows this

frail sun
#

oh, cool

#

never used that before

modern hemlock
#

and i think on their end it also adds a join button

frail sun
#

ok

modern hemlock
#

but anyways the join thing, we should be able to use to let people join each other

frail sun
modern hemlock
frail sun
#

doesn't that just set the bit of text under their username?

modern hemlock
#

in the friend list

#

no that sends them an invite in the steam chat

frail sun
#

ok

#

it might take me a while to understand this sry

modern hemlock
#

no problem

#

I've not used steam's rich presence but I've messed with some others before

#

so anyways when I invite them, they get the option to join.

frail sun
#

so does that exist already, or did you add that in?

modern hemlock
#

I added this

frail sun
#

ok got it

modern hemlock
frail sun
#

so just to get this out of the way, would it be better to use server-client (where the initiator acts as the server) or p2p?

modern hemlock
#

not sure

#

this is what happens when you invite someone

frail sun
#

nice!

modern hemlock
#

yeah

#

looks like the client server model is only for if you have known ips (aka a deticated server) where p2p is for just running multiplayer

frail sun
#

ok, so we'll use p2p then

modern hemlock
#

I wonder how hard it is to get a super simple connecting going

frail sun
#

unfortunately this means we can't just copy paste the example directly into the mod

#

what code do you have so far btw?

modern hemlock
#

I think the api is the same for both, just connecitng is different

#
function initSteamTest()
    print(G.STEAM.friends.getFriendPersonaName(G.STEAM.user.getSteamID()))
    G.STEAM.friends.setRichPresence("status", "Hi mom")
    G.STEAM.friends.setRichPresence("connect", "connectstring")
end
#

I'm using lovely to inject it cause I figured it would make it eaiser and also would make getting values of the game live late way eaiserr

#
[manifest]
version = "1.0.0"
dump_lua = true
priority = 0

[[patches]]
[patches.pattern]
target = "main.lua"
pattern = "G.STEAM = st"
position = "after"
payload = 'initSteamTest()'
match_indent = true
overwrite = false

[[patches]]
[patches.copy]
target = "main.lua"
position = "append"
sources = [
    "core.lua",
]
frail sun
#

sorry i have to go for a sec, i'll be back soon

modern hemlock
#

okay

frail sun
#

but yeah this is making sense

modern hemlock
#

oh actually this is even older than I thought

#

imma see if I can get lovely to load a newer version instead

modern hemlock
#

well I replaced the luasteam dll that was in balatro's folder with a newer one but whenever it loads the game just crashes

#

¯_(ツ)_/¯

frail sun
#

it seems like we'll definitely need to figure out a way to get the updated version working, bc i think we'll need friends.onGameRichPresenceJoinRequested to actually do something when the other person accepts the invite

undone lintel
#

Multiplayer Mod

rose leaf
#

you could probably proxy the new luastream dll

#

create a dummy dll with the same export ordinals as the old version, tie those into the exports of the new one

#

it's reliant on the ABI being relatively similar though

modern hemlock
#

Im not really sure how that works, but why wouldn't the new DLL not work? As far as I can tell, all the methods the game calls are the same

rose leaf
#

could you send me the old and new one? I'll investigate

modern hemlock
rose leaf
#

interesting

modern hemlock
#

yeah I was getting smth like that

rose leaf
#

the luastream distributed with the game is version 1.2.0, built around ~2021. there are breaking changes from 1.2.0 -> 3.1.0, so I don't think it'll be possible to slot it in without a compatibility layer

modern hemlock
#

I was looking at the changelogs and I think what balatro uses doesn't change (plus it seems to be crashing on the init which for sure isn't changed)

#

looking at the diff, 2.0 only changed stuff in steam input, which balatro didn't use and 3.0 just changed the function signature for user.getAuthSessionTicket which balatro also doesn't use

#

so it should be compatible

rose leaf
#

gotcha, my fault for not looking at the codebase harold

#

it's weird because the new version has an import for SteamInternal_SteamApi_Init and the old one does not

#

neither of them export that function

frail sun
rose leaf
#

I mean that was my lazy opinion

#

my non-lazy opinion is still a "maybe"

frail sun
#

hmmmm

rose leaf
# rose leaf

I'll work on figuring out a way around this first

modern hemlock
#

that would be nice

#

tbh I know very little about how lua loads modules and stuff

frail sun
#

this might be stupid but would it be an option to load two separate luasteams, the old one that the game uses and then the new one packaged with the mod and only used by it?

modern hemlock
#

probably not

#

but if the version of lua steam is fundimentally incompatible, we could replace all instances that the game uses of it, and handle everything ourselves

rose leaf
#

it should actually work

#

maube

#

you would need to patch the game to call your code instead of the OG luastream, but you should be able to load it via require

frail sun
# rose leaf

do you know what this error means btw? bc i don't

stark venture
#

I have no clue how to do any of this, but I just wanna say great job, and I hope this works. lol

frail sun
#

honestly me neither

stark venture
#

Just tested this with a friend, loads of fun!

frail sun
#

i'm wondering if something like this would work, where the new luasteam is separately loaded in a different local variable. can someone test this and see what happens?

frail sun
#

i think i might work on the frontend a little and wait until some smarter people can help me out with the package loading and socket connection

frail sun
stark venture
#

Unfortunate

frozen nimbus
#

coop mode

gilded kite