Replication

Discussions about Coding and Scripting
Post Reply
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Replication

Post by Feralidragon »

So, I finished my weapon pack, but I want to make them playable online. :roll:

I already know the basics of replication, such where do you use the proxy roles and how, and the reliable and unreliable stuff. 8) (I tried to make the weapons playable online, and they work almost fine, only some effects doesn't appear, and some stuff that have to be attached to players (visible of course) are kind laggy, due to DumbProxy, but GuidedRedeemer isn't, and it's DumbProxy too (maybe are some SavedMoves stuff that I don't understand yet)

I read some tutorials about that, on Unreal Wiki and other sources, but none of them answered my biggest questions and they are very confused. :omfg:

I know, I know, that "replication" is kinda complex and confusing :omfg: , but do you know a good tutorial about replication for UT99?

:help: :help: :help: :help: :help: :help: :help:
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Replication

Post by Feralidragon »

Thanks for the links :tu:

I am currently reading one of them, and it is finally answering to some questions I had about replication stuff :wink:
User avatar
-Feint-
Skilled
Posts: 175
Joined: Sat Mar 08, 2008 1:39 pm
Personal rank: Amateur Mapper
Location: UK - Leeds

Re: may be this is a good news!

Post by -Feint- »

Testaccount wrote:Deleted.

EDIT: Please, don't quote the ads, for the forum safety, or we are forced to delete your quoted post as well. We know about these ads, and when it's 1, we delete, when it's like 10, Shade does the job - Feralidragon
Last edited by -Feint- on Thu Sep 25, 2008 5:08 pm, edited 1 time in total.
DanomanUK@i4games-Forum wrote:Nah, people bitch one way or another.
You cant win as a mapper ;)
][X][~FLuKE~][X][
Experienced
Posts: 113
Joined: Mon Mar 17, 2008 5:56 pm
Personal rank: RocketX5/6 creator

Re: Replication

Post by ][X][~FLuKE~][X][ »

replication is a pain in the ass but you can figure it out if you look around.




i have only figured replication out in the last few weeks as i really havent had to deal with it.

heres a mock example, this is not real code so dont try to compile it.


under the Exec/import, var etc add your replication info like this, before any initial code.


// REPLICATION

replication
{
reliable if ( Role == ROLE_Authority ) // as server is always ROLE_Authority, setting this way forces the server to execute the function to all clients based on function() commands, majority of things like sound function should be added here if they do not work online.
Myfunction;

unreliable if (role == ROLE_Authority) //as you see this is fine client side but server has the option to rule this out if it feels it is not required for gameplay but is used if its client only, Eg. HuD etc.
MyFunction2;

}

also

Simulated function MyFunction() instead of Function MyFunction()

forces server to read the function but if it still does not execute this function then add the function name to first example in replication list above.

im still getting used to how replication works so this may not be 100% accurate but this is the way i have made several of my mods work correct online.
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Replication

Post by Feralidragon »

Thanks Fluke, but I already know that, and a little correction: The server executes ALL the functions, I mean, every single one that is called.
Now in the client, there are several functions that aren't called. This replication stuff is a pain in the ass because it's developed to run in 28.8Kbps modems :shock:

But I already know some stuff, I am trying to figure things out too, but I read some stuff really interesting about replication in the links given above.

My problem now is in another thread: DLLs
Myth
Inhuman
Posts: 988
Joined: Tue Feb 12, 2008 5:57 pm
Personal rank: Low Poly Freak

Re: Replication

Post by Myth »

My Problems whit replication just started...
So my question is how do I not replicate actors? I keep having some actors replicated that shouldn't be replicated and they are wasting a lot of bandwidth. How can I make actors totally insignificant over netplay, while its functions are still executed on all clients, and non dedicated servers?
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Replication

Post by Feralidragon »

Myth wrote:My Problems whit replication just started...
So my question is how do I not replicate actors? I keep having some actors replicated that shouldn't be replicated and they are wasting a lot of bandwidth. How can I make actors totally insignificant over netplay, while its functions are still executed on all clients, and non dedicated servers?
What kind of actors we are talking about?
I ask this, become each kind of actor has its way to be replicated or not.
For example: if you wanna produce an effect when your projectile collides, and wanna save bandwith, you can spawn it from a simulated function (if called by another simulated function), and after spawn it (like A = Spawn(Class'Something');) you have to set its remote role to none: A.RemoteRole = ROLE_None;
But as default, the effect must have the RemoteRole=ROLE_SimulatedProxy, so it can be created both on server and client. With ROLE_None afterwards, the both server and clients won't replicate anything more from that actor/effect, and it will run independently from each ones.

Now this is just a single way from others to save bandwitch if you are calling an effect (like an explosion or something).
Myth
Inhuman
Posts: 988
Joined: Tue Feb 12, 2008 5:57 pm
Personal rank: Low Poly Freak

Re: Replication

Post by Myth »

I'm talking about actors that only affect the visual side of the game. For example an actor which displays a mesh, but has no collision whit player actors and doesn't modify the gameplay in any way except for the one case in which it reduces your visibility. Something like a floating brute in a skybox, or birds flying around, or that dripping water from the always leaky pipe.

By putting ROLE_SimulatedProxy as default and after changing it to ROLE_None, wouldn't their Spawn event still be replicated?
Can't I just mark an actor to be never replicated and always simulated on clients and non dedicated servers?
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Replication

Post by Feralidragon »

Myth wrote:I'm talking about actors that only affect the visual side of the game. For example an actor which displays a mesh, but has no collision whit player actors and doesn't modify the gameplay in any way except for the one case in which it reduces your visibility. Something like a floating brute in a skybox, or birds flying around, or that dripping water from the always leaky pipe.
Well, in a short list you can do the next depending on the situation:
- Something that you place while mapping, and it runs absolutelly no code at all: you set bStatic=True and it won't be replicated at all.
- Something that you place while mapping, but it runs some code: everything you have to remember is this: replication of variables and such only occurs when these change somehow, generally server side, and functions are only called client side if they are relevant to the clients (like almost all simulated functions). So, let's say your decoration actor is running some sort of code and it's always changing variables, and since it doesn't affect gameplay anyhow (only visual effect), you can set it's remoterole to none, as:
ROLE_None: Never replicates a thing, the actor runs independently from the server.
ROLE_DumbProxy: It's updated on the clients constantly by the server, but in a effective way, only on the change of variables.
ROLE_SimulatedProxy: For something that can be simulated independently from the server (like Physics), but still, it's not like ROLE_None, as it still gets replicated info from the server (like when it hits a wall, or another condition if fullfilled).
Myth wrote:By putting ROLE_SimulatedProxy as default and after changing it to ROLE_None, wouldn't their Spawn event still be replicated?
Yes and no. When a spawn call is executed in a simulated function that is called by another simulated function, what happens is that the spawn is called both on clients and server. And in general, the server replicates every single new actor created there to the clients during gameplay, if their remoterole is equal or above DumbProxy. So, the client would have 2 copies of the same actor (where 1 would be simply a kinda of "illusion"), so to avoid the server to send info of the new actor, we set its remote role to none, and the server won't replicate which would be the 2nd copy on the client of the same actor.
Now you may ask, so why we don't set ROLE_None by default and avoid that. The truth is, the simulated function thing is not 100% accurate, so in some functions that works (like simulated PostBeginPlay() for example), but with many functions being called from eachothers (simulated and non-simulated), if the actor has ROLE_none by default, it might never being spawned on the client, since it won't be relevant to the client and it won't be replicated from the server. Sometimes, even this won't work somehow, so I must say that replication can be a real b*tch as well.
Myth wrote: Can't I just mark an actor to be never replicated and always simulated on clients and non dedicated servers?
An actor like that would have then ROLE_None in RemoteRole.
Myth
Inhuman
Posts: 988
Joined: Tue Feb 12, 2008 5:57 pm
Personal rank: Low Poly Freak

Re: Replication

Post by Myth »

Feralidragon wrote:I must say that replication can be a real b*tch as well.
I think that the problem is that it isn't documented well enough, and because it's native, you can't just read it's code.
I'll test these tomorrow, or the day after tomorrow...
Thanks for the help mate. Whitout your help I think I've never would have learnt Uscript, or at least not this year.
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Replication

Post by Feralidragon »

Myth wrote:
Feralidragon wrote:I must say that replication can be a real b*tch as well.
I think that the problem is that it isn't documented well enough, and because it's native, you can't just read it's code.
I'll test these tomorrow, or the day after tomorrow...
Thanks for the help mate. Whitout your help I think I've never would have learnt Uscript, or at least not this year.
No problem, anytime :tu:
Post Reply