Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: LAN adventure mod multiplayer  (Read 1494 times)

Victisvincimus

  • Escaped Lunatic
    • View Profile
LAN adventure mod multiplayer
« on: September 24, 2013, 07:01:19 pm »

Alright, alright, I've hit the search bar with 'multiplayer' typed in, and I've read dozens of threads on the subject in multiple forums, so I apologize in advance if this has been said before.

-Understanding that Toady has stated that Multiplayer is not something that he's interested in...
-Understanding that this is unlikely to happen in any case...
-Understanding that Toady is unlikely to release the necessary source code, and that he's probably completely right in doing so, and definitely completely within his rights to do this...

Most discussions of multiplayer come up in the sense of radical changes to the game, or real-time multiplayer with multiple fortresses (!!!). I was talking with a friend the other day about how interesting Adventure Mode was, and the idea of LAN multiplayer came up - where both players take turns according to the speed/turn order imposed by the game, and both travel in the same instance/region/whatever the proper term is, like a player and his NPC followers in the normal game.

Does anyone think this a good/moderately feasible/vaguely interesting idea?
Logged

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: LAN adventure mod multiplayer
« Reply #1 on: September 24, 2013, 09:41:26 pm »

It would be cool, but I doubt it would ever happen as a mod project, unless you somehow managed to finagle something with a memory editor like DFHack. And even then I'm 90% talking out of my ass, since I know nothing about networking and next-to-nothing about how DFHack does what it does.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: LAN adventure mod multiplayer
« Reply #2 on: September 25, 2013, 12:45:26 am »

I work on this (somewhat in secret). Biggest current problem is that all creatures have AI and we have no way to disable it for other players. E.g. your companions follow you in 3x3 area. If it at any time leaves that area, he instantly tries to get back. And there is no (easy) way to change any behavior. Memory patching would help but it requires too much time (and would require someone to repeat it on linux and mac). Here are some pictures from tests:
clicky
It's just follows random dwarf around and currently is missing some stuff like moss, grass, lower level etc...

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: LAN adventure mod multiplayer
« Reply #3 on: October 03, 2013, 02:46:43 am »

Let's see if I can make a bit of a mock-up for an idea that I had

Code: [Select]
function moveUnit()
    local inputPosTable = {x=x,y=y,z=z} -- basically figure out what these are based on unit's xyz at time of input
    local unit = unit --it's a mockup it doesn't need to work >:I
    local movementspeed = dfhack.units.computeMovementSpeed(unit)
    dfhack.timeout(((math.rand()>((movementspeed%100)/100)) and math.ceil(movementspeed/100) or math.floor(movementspeed/100)+1),'ticks',function() teleportUnit(unit,inputPosTable) end)
end

not sure if you've already tried that though

the teleportUnit function would be something like this

Code: [Select]
local function positionIsValid(x,y,z)
local occupancy = dfhack.maps.getTileBlock(x,y,z).occupancy[x%16][y%16]
local tiletype = getTileType(x,y,z)
local attrs = df.tiletype.attrs[tiletype]
return not (occupancy.building~=0 or occupancy.unit or not dfhack.maps.isValidTilePos(x,y,z) or attrs.shape == df.tiletype_shape.WALL)
end

local function teleportUnit(unit,pos)
local unitoccupancy = dfhack.maps.getTileBlock(unit.pos).occupancy[unit.pos.x%16][unit.pos.y%16]
if not positionIsValid(pos[1],pos[2],pos[3]) then return false end
unit.pos.x = pos[1]
unit.pos.y = pos[2]
unit.pos.z = pos[3]
if not unit.flags1.on_ground then unitoccupancy.unit = false else unitoccupancy.unit_grounded = false end
end

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: LAN adventure mod multiplayer
« Reply #4 on: October 03, 2013, 03:55:19 am »

you could do one better and just mess with the unit's idle position which they will walk over to.
Code: [Select]
function CompN3()
  adv=df.global.world.units.active[1]
  --for k,v in pairs(df.global.world.units.active) do
  --if adv.relations.group_leader_id==adv.id then
local sx,sy,sz
sx=adv.pos.x
sy=adv.pos.y
sz=adv.pos.z
print("Current coords:"..sx.." "..sy.." "..sz)
tx,ty,tz=sx,sy-3,sz-1
print("Warp to coords:"..tx.." "..ty.." "..tz)
adv.path.dest.x=tx
adv.path.dest.y=(ty)
adv.path.dest.z=tz
adv.idle_area.x=tx
adv.idle_area.y=ty
adv.idle_area.z=tz
--end
--end
end
set this up with a unit view finder gui and you got yourself a moveable unit.
old script.
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: LAN adventure mod multiplayer
« Reply #5 on: October 03, 2013, 05:27:57 am »

Both methods are somewhat lacking: putnam's is a bit naive, you need to program a ton of various corner cases (e.g. what if unit is standing in that place, what if it's a door, or a other building, what if it's water, what if it's too hot to step on,...) and rumrusher's is what i was talking about: your companions use idle_area only if it's 3 tiles from you, else they try to path to you and general AI usually interferes (enemies, jobs,etc...)

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: LAN adventure mod multiplayer
« Reply #6 on: October 03, 2013, 11:30:28 am »

Both methods are somewhat lacking: putnam's is a bit naive, you need to program a ton of various corner cases (e.g. what if unit is standing in that place, what if it's a door, or a other building, what if it's water, what if it's too hot to step on,...) and rumrusher's is what i was talking about: your companions use idle_area only if it's 3 tiles from you, else they try to path to you and general AI usually interferes (enemies, jobs,etc...)
well... the code comments out the part about companions and just sets the path takeover to active[1] but that doesn't excuse the other main issues of telling the Npc to not fight that monster... or not run away. for that we need to tap in what shuts down the AI for the unit in active 0... or abuse it and just write a script that rapidly switches between players in a rapid session while making a Gui viewscreen that follows the player so you don't get whip lash from the game trying to switch the camera all the time.
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes