I don't need to test my programs. I have an error-correcting modem.
Difference between revisions of "User:00zX"
Line 563: | Line 563: | ||
; bSkipActorPropertyReplication : Used by [[Legacy:ReplicationInfo|ReplicationInfo]] classes that don't need to know all the Actor class properties on the clients. When set to True only the initial replication replicates the Actor class properties. | ; bSkipActorPropertyReplication : Used by [[Legacy:ReplicationInfo|ReplicationInfo]] classes that don't need to know all the Actor class properties on the clients. When set to True only the initial replication replicates the Actor class properties. | ||
; bUpdateSimulatedPosition : Whether the actor's Location, Rotation and Velocity should be updated for Simulated Proxies. | ; bUpdateSimulatedPosition : Whether the actor's Location, Rotation and Velocity should be updated for Simulated Proxies. | ||
+ | |||
+ | ===Using Replication== | ||
+ | <uscript> | ||
+ | class UT_MDI_Weapon extends UT_MDI; | ||
+ | |||
+ | /** Weapon class so we can check owner is right type and set vars */ | ||
+ | var UTWeapon Weap; | ||
+ | |||
+ | /** Gets the times from the weapons and sets them to the replicated variables */ | ||
+ | reliable server function GetWeapProps(UTWeapon W); | ||
+ | |||
+ | /** Sets the clients weapon to use the replicated variables */ | ||
+ | reliable client function SetWeapProps(UTWeapon W); | ||
+ | |||
+ | /** Make sure we have an owner and its the right type before moving on */ | ||
+ | simulated event PostBeginPlay() | ||
+ | { | ||
+ | local int i; | ||
+ | |||
+ | if(Owner == None || cUseforWeaps.length <= 0) | ||
+ | Destroy(); | ||
+ | |||
+ | Weap = UTWeapon(Owner); | ||
+ | if(Weap != None) | ||
+ | { | ||
+ | if(WorldInfo.NetMode != NM_Client) | ||
+ | GetWeapProps(Weap); | ||
+ | |||
+ | SetTimer(0.01, false, 'SetPropsTimer'); | ||
+ | } | ||
+ | else | ||
+ | Destroy(); | ||
+ | } | ||
+ | |||
+ | function SetPropsTimer() | ||
+ | { | ||
+ | SetWeapProps(Weap); | ||
+ | } | ||
+ | |||
+ | defaultproperties | ||
+ | { | ||
+ | //remove all from array | ||
+ | //cUseforWeapons(0)=none | ||
+ | |||
+ | RemoteRole=ROLE_SimulatedProxy | ||
+ | bAlwaysRelevant=True | ||
+ | } | ||
+ | </uscript><br> | ||
+ | <uscript> | ||
+ | if(Weap != None) | ||
+ | { | ||
+ | if(WorldInfo.NetMode != NM_Client) | ||
+ | GetWeapProps(Weap); | ||
+ | |||
+ | SetTimer(0.01, false, 'SetPropsTimer'); | ||
+ | } | ||
+ | </uscript><br> | ||
+ | <uscript> | ||
+ | function SetPropsTimer() | ||
+ | { | ||
+ | SetWeapProps(Weap); | ||
+ | } | ||
+ | //Sets the properties to the values from the Server on the client | ||
+ | <uscript> | ||
+ | |||
===Related Topics=== | ===Related Topics=== |
Revision as of 15:04, 30 March 2009
Contents
Contributions
Contact Me
IRC
_00zX on EnterTheGame
Other/Profiles
E-mail 00zX or on
Proposal - Noir theme with highlighter adjustments
Code Noir Redex
- stylish - userstyle -00zX 20:41, 29 March 2009 (UTC)
@-moz-document domain(wiki.beyondunreal.com) { /*================================================================================*/ /** 00zX_CODENOIR.CSS */ /*================================================================================*/ /* #bcb936 - UC3 Gold */ /* #66bcd9 - UnrealEd Blue */ /* #62613a - ol'crash */ /* #b8b634 - ol'guard */ /* #bfbe97 - paste */ /* #00c000 - Comment Green */ /* #090909 - Noir */ /* #151515 - Full Moon */ /* #8f8f8f - Grey Metal */ /* #575757 - Dark Metal */ /* #adcc63 - light green */ /* #99aadd - light blue metal / lilac */ /* #59939c - greyish blue light / teal */ /* #494949 - midish grey metal */ /* #7b749b - purple metal*/ /* #257ec2 - shell beach */ /* #fd3e1c - oraed */ /* #ffcc00 - yellow ambox */ /* #0a44aa - H2 blue deep */ /* #c4bfb2 - orange off white*/ /* #b8b634 - welloy */ /* #222222 - vert */ /* #ff6600 - orange */ /* #c3c3c3 - grey */ /* #257ec2 - moire blue*/ /*================================================================================*/ /* UE1 namespace content */ .ns-102 #content, .ns-103 #content { /*background: #eff7ff url(/w/images/UE1Background.png) top right no-repeat;*/ border-color: #66bcd9 !important; border-width: 1px !important; } .ns-102 h1, .ns-103 h1 { color: #62613a !important; border-bottom: #66bcd9 solid 1px !important; } .ns-102 h4, .ns-103 h4 { color: #66bcd9 !important; } .ns-102 #highlighted-source, .ns-103 #highlighted-source{ border: #494949 dashed 1px !important; } span.kw10{} /* UE2 namespace content */ .ns-104 #content, .ns-105 #content { border-color: #257ec2 !important; border-width: 1px !important; } .ns-104 h1, .ns-105 h1 { color:#62613a !important; border-bottom: #257ec2 solid 1px !important; } .ns-104 #portlet a:visited, .ns-105 #portlet a:visited{ background: inherit !important; border-color: #257ec2 !important; } .ns-104 #highlighted-source, .ns-105 #highlighted-source{ border: #257ec2 dashed 1px !important; } span.kw10{} /* UE3 namespace content */ /* #fd3e1c - Old Red */ .ns-106 #content, .ns-107 #content { border-color: #bcb936 !important; border-width: 1px !important; } .ns-106 h1, .ns-107 h1 { color:#62613a !important; border-bottom: #bcb936 solid 1px !important; } #portlet a:visited, #portlet a:visited{ background: inherit !important; border-color: #bcb936 !important; } .ns-106 #highlighted-source, .ns-107 #highlighted-source{ border: #bcb936 dashed 1px !important; } span.kw10{} /* Legacy namespace content */ .ns-100 #content, .ns-101 #content { border-color: #7b749b !important; border-width: 1px !important; } .ns-100 h1, .ns-101 h1 { color:#62613a !important; border-bottom: #7b749b solid 1px !important; } .ns-100 h4, .ns-101 h4 { color: #7b749b !important; } .ns-100 #highlighted-source, .ns-101 #highlighted-source{ border: #7b749b dashed 1px !important; } span.kw10{} tbody tr table tbody tr td ul li:hover{ text-decoration: none !important; } #siteNotice, #siteNotice a{ background: inherit !important; } #recent-edits, #recent-edits tbody, #recent-edits tbody tr, #recent-edits tbody tr th{ background: #494949 !important; } #recent-edits tbody tr th{ color:#090909 !important; font-family: arial, trebuchet !important; font: 100 normal 130%/100% "Arial Narrow", sans-serif !important; } span.editsection, h3 #editsection, h4 #editsection{display: none !important;} /* (codenoir) */ div#bodyContent pre{ border: #494949 dotted 1px !important; background: #090909 !important; color: #ffffff !important; } div.source-uscript pre{ border: white solid 0px !important; background: none !important; color: #ffffff !important; } /* .code{ padding-left: -0.025em !important; background: none !important; border: #222222 dotted 1px !important; color: #222222 !important; }*/ code{ border: none !important;/* background: inherit !important;*/ background: none !important; color: white !important;/*#000000*/ font: 100 normal 10pt "Segeo UI", sans-serif !important; } #highlighted-source{ border: #494949 dashed 1px !important; background: #575757 !important; color:#ffffff !important; } /* Uscript Highlighter */ /* span.kw9{} kw = keyword */ /* span.co1{} co = comment */ span.kw1{color: #66bcd9 !important;} span.kw4{color: #66bcd9 !important;} span.kw5{color: #66bcd9 !important;}/*const*/ span.kw6{color: #257ec2 !important; font-style: italic !important;} span.kw8{color: white !important;} span.kw9{color: white !important;} span.br0{color: white !important;} span.co1{color: #00c000 !important;} span.co2{color: #8f8f8f !important; font-weight: bolder !important;} span.colMULTI{color: #00c000 !important;} span.sy0{color: #ff6600 !important;} span.me1{color: #66bcd9 !important;} span.kw10{color: white !important;} /* */ html > div#bodyContent > div.highlighted-source > div.source-uscript pre{ border: none !important; } /* CSS Highlighter */ span.re0{} span.re2{color: #8f8f8f !important; font-style: italic !important;} span.re3{color: #ff6600 !important;} div#bodyContent table.list tbody{background: none !important; } tbody, table.list { background: none !important; } div#bodyContent, div#bodyContent div { background: none !important; } /*================================================================================*/ /** MONOBOOK-COMMON-NOIR.CSS */ /*================================================================================*/ a:link{ color: #99c9ff !important; text-decoration: none !important; background: none !important; line-height: 0.6em !important; } a:visited{ color: #959595 !important; font-style: italic !important;} a:hover{ color: #59939c !important; text-decoration: none !important; line-height: 0.6em !important; } b { color:#c4bfb2 !important; font-weight: 500 !important;}/*bolder*/ div { color: white !important; background: #090909 !important; } table { color: white !important; background: inherit !important; } body { font-size-adjust:none !important; font-style:normal !important; font-variant:normal !important; font-weight: 150 !important;/*normal*/ line-height:normal !important; } #pbody,#pbody a{ background: inherit !important; } #pbody a{ border: 1px solid #99aadd !important; } /*__TOC__*/ #toc { background-color: #494949 !important; border: 1px solid #59939c !important; } #toctitle{ background: none !important; font-weight: 350 !important; text-decoration: none !important; } #div.toctitle h2{background: inherit !important; text-decoration: none !important;} #content { background: #151515 !important; font-family: arial, trebuchet !important; font-size: 11pt !important;/*10*/ /*border: 0 !important;*/ } #contentSub, #bodyContent, div.content div, div.bodyContent div{ background: none !important;} div.thumb{ background: inherit !important; } div.plainlinks, div.noprint{ background: #494949 !important; } dt{ color: #bfbe97 !important;} dl dt{} dd b{ color: #59939c !important;} #navbox-header{background: #494949 !important;} /* mediawiki */ /* tabs? */ #p-cactions li.selected, #p-cactions li.selected a, #p-cactions li a:hover, #p-cactions li a:visited{background: none !important;} ul#preftoc{} #mw-headline { background: inherit !important; } h4 span.mwheadline{ text-indent: 0.1em !important;} div.searchresult, div.mw-search-result-data, div#bodyContent ul.mw-searchresults{ background: inherit !important; } table.ambox { color: #c4bfb2 !important;background: inherit !important; } #infobox{ border: #090909 solid 3px !important;} table.infobox, div.infobox { /* background: #494949 !important;*/ border: 1px solid white !important; padding: 1em; } h1, h2, h3, h4 { background: none !important; /*background: #151515 !important;*/ font-family: arial, trebuchet !important; font: 100 normal 130%/100% "Arial Narrow", sans-serif !important; border-bottom: none !important; } h1 { color: #7b749b !important; border-bottom: #7b749b solid 1px !important; font: 500 normal 160%/180% "Arial Narrow", sans-serif !important; } h2 { color:#99aadd !important; border-bottom: 1px solid #99aadd !important; font: 300 normal 140%/120% "Arial Narrow", sans-serif !important; /* line-height: 0.6em !important; letter-spacing: 0.025em !important; word-spacing: 0.4em !important;*/ } h3, h4 { padding-left: 0.24em;/*text-indent: 0.2em !important;*/ } h4 { color: #257ec2 !important; font: 100 normal 110%/100% "Arial Narrow", sans-serif !important; } h6 { color: white !important;} hr { background: #151515 !important; color: #909; margin-top: 1em; margin-bottom: 1em; } li, ul { background: inherit !important; } /*================================================================================*/ /**make a few corners round, only supported by moz/firefox/other gecko browsers for now */ /*================================================================================*/ #content { -moz-border-radius-topleft: 0.5em !important; -moz-border-radius-bottomleft: 0.5em !important; } /* div#bodyContent pre, */ table.infobox, div.infobox, #catlinks, #toc, .ambox { -moz-border-radius: 6px !important; } }
Proposal - Replication
Replication
-00zX 07:58, 28 March 2009 (UTC)
- Replication/Replication_(computer_science)
- Declaring Replication using theReplication Block
- Function Replication using the replication block?
- Booleans Declared in actor that are useful in replication
http://wiki.beyondunreal.com/Introduction_to_replication#
Replication Block
replication { reliable/unreliable if ( replication condition ) identifiers; }
- Identifiers can be of many types, certain types however arnt allowed like dynamic arrays.
UE3:Actor_(UT3) - link to replication block
- Actor Replication
- Variable Value Replication
Repnotify
- Function call replication
- Like replicated variables, the replication of a function call can be tied to certain conditions. In Unreal Engine 1 and 2 this condition is specified via the replication block and typically involves comparing the actor's Role to the value ROLE_Authority, Unreal Engine 3 provides the special function modifiers client and server instead.
- Using Network modifiers for Functions
reliable client function bool DoSomething() { return true; }
taken from controller.uc (ut3)
reliable server function ServerRestartPlayer() { if (WorldInfo.NetMode != NM_Client && Pawn != None) { ServerGivePawn(); } }
Role and RemoteRole
Definition
- The Actor class defines the NetRole enumeration and two variables, Role and RemoteRole, as follows:
enum ENetRole { ROLE_None, // No role at all. ROLE_SimulatedProxy, // Locally simulated proxy of this actor. ROLE_AutonomousProxy, // Locally autonomous proxy of this actor. ROLE_Authority, // Authoritative control over the actor. }; var ENetRole RemoteRole, Role;
usage:
if (Role == ROLE_Authority) { // This is the authorative copy of this actor, it was spawned on this machine. // It is not a guarantee that we are on the server or in single player! } if (Role < ROLE_Authortity) { // This is a non-authorative copy of this actor that was replicated // from the server. In other words, we must be on a client. }
As in the replication block of Actor.uc UT3
// Physics if( (!bSkipActorPropertyReplication || bNetInitial) && bReplicateMovement && ((RemoteRole == ROLE_SimulatedProxy) && (bNetInitial || bUpdateSimulatedPosition)) )
NetMode
Definition
- The WorldInfo (previously Level Class [ut2kx]) class defines the NetMode enumeration and two variables, Role and RemoteRole, as follows:
var enum ENetMode { NM_Standalone, // Standalone game. NM_DedicatedServer, // Dedicated server, no local client. NM_ListenServer, // Listen server, local client+server. NM_Client // Client only, no local server. } NetMode;
Standalone game
Dedicated server, no local client
Listen server, local client+server
Client only, no local server
Examples
if (WorldInfo.NetMode != NM_DedicatedServer) { // This could be offline, a listen server or a client, but we know // we have a local player on this machine, someone who can see or hear things. }
usage:
simulated event PostBeginPlay() { if(WorldInfo.NetMode != NM_DedicatedServer) { // Code here will only be executed on Listen servers and game clients. } if(WorldInfo.NetMode == NM_DedicatedServer) { // Code here will only be executed on a server. } }
Like Role and RemoteRole:
simulated event PostBeginPlay() { if (WorldInfo.NetMode < NM_DedicatedServer) { // Code here will only be executed on Listen servers and game clients. } if (WorldInfo.NetMode > NM_DedicatedServer) { // Code here will only be executed on a server or standalone client. } }
Useful Replication Properties
UT3 actor.uc
// Networking flags var const bool bNetTemporary; // Tear-off simulation in network play. var const bool bOnlyRelevantToOwner; // this actor is only relevant to its owner. If this flag is changed during play, all non-owner channels would need to be explicitly closed. var transient bool bNetDirty; // set when any attribute is assigned a value in unrealscript, reset when the actor is replicated var bool bAlwaysRelevant; // Always relevant for network. var bool bReplicateInstigator; // Replicate instigator to client (used by bNetTemporary projectiles). var bool bReplicateMovement; // if true, replicate movement/location related properties var bool bSkipActorPropertyReplication; // if true, dont replicate actor class variables for this actor var bool bUpdateSimulatedPosition; // if true, update velocity/location after initialization for simulated proxies var bool bTearOff; // if true, this actor is no longer replicated to new clients, and // is "torn off" (becomes a ROLE_Authority) on clients to which it was being replicated. var bool bOnlyDirtyReplication; // if true, only replicate actor if bNetDirty is true - useful if no C++ changed attributes (such as physics) // bOnlyDirtyReplication only used with bAlwaysRelevant actors /** Demo recording variables */ var transient bool bDemoRecording; /** set when we are currently replicating this Actor into a demo */ var transient bool bClientDemoRecording; /** set when we are recording a clientside demo */ var transient bool bRepClientDemo; /** set if remote client is recording a clientside demo */ var bool bDemoOwner; // Demo recording driver owns this actor. /** Should replicate initial rotation. This property should never be changed during execution, as the client and server rely on the default value of this property always being the same. */ var const bool bNetInitialRotation; /** If true, never replicate rotation */ var bool bNeverReplicateRotation; var bool bReplicateRigidBodyLocation; // replicate Location property even when in PHYS_RigidBody var bool bKillDuringLevelTransition; // If set, actor and its components are marked as pending kill during seamless map transitions /** whether we already exchanged Role/RemoteRole on the client, as removing then readding a streaming level * causes all initialization to be performed again even though the actor may not have actually been reloaded */ var const bool bExchangedRoles;
booleans
(Level.NetMode == NM_Client && bNetOwner)
– owner clients (special case of client where the local player is the Owner of the actor in question)
UT2004
NetUpdateFrequency
NetUpdateFrequency is another variable useful in replication. It effectively causes an otherwise relevant (not useful when the actor is not relevant) actor to be relevant NetUpdateFrequency times per second. This is useful when the data changes frequently but you only want periodic updates. For example, PlayerReplicationInfo contains a lot of data about the client. Stuff like the various player's pings may change quite frequently, and having the client keep track of such information would be quite a network hog. But since PlayerReplicationInfo has a NetUpdateFrequency of 2, it is only updated twice a second, which is much nicer for that player's bandwidth. The list of the current NetUpdateFrequency's for all UT classes are listed below:
Actor - 100 Hz (times per second)
ZoneInfo - 4 Hz
GameReplicationInfo - 4 Hz
PlayerReplicationInfo - 2 Hz
Inventory - 8 Hz
Variables only valid during replication
- bClientDemoNetFunc
- True if we're client-side demo recording and this call originated from the remote.
- bClientDemoRecording
- This machine is currently recording a clientside demo.
- bDemoRecording
- This machine is currently recording a demo.
- bNetInitial
- True during the first time all variables are replicated for this actor.
- bNetOwner
- True when the replication target is this actor's Owner. ((true if the player we are replicating to owns this actor directly. ))
Only UT
- bNetFeel
- Player collides with/feels it in network play. ((Not used anymore, never even set. - UT200x?))
- bNetHear
- Player hears it in network play.
- bNetSee
- Player sees it in network play.
- bSimulatedPawn
- True if this is a Pawn (UT) and simulated proxy. ((true if the actor is a pawn (or a pawn subclass) with Role == ROLE_SimulatedProxy. In other words, true if it's a pawn that's not the client.))
Only UT2003
- bDemoOwner
- Demo recording driver owns this actor.
- bNetDirty
- True when a property was changes since the last time it was replicated.
- bNetRelevant
- Actor is currently relevant. Only valid server side and only when replicating variables.
- bRepClientDemo
- The remote machine is currently recording a demo.
- Level.ReplicationViewer
- during replication, set to the playercontroller to which actors are currently being replicated
- Level.ReplicationViewTarget
- during replication, set to the viewtarget to which actors are currently being replicated
Only UT2004
- bNetInitial
- ((True if this is the first time this actor is being replicated across the network. Useful for variables that differ from the defaultproperties, yet will not change over the life of the actor.))
Other Useful Variables
In UT
- bClientAnim
- If True, AmbientSound and animations are replicated also to the owning client.
In UT2003
These properties are used in the Actor class replication block.
- bNoRepMesh
- Don't replicate the Mesh.
- bReplicateAnimations
- Whether SimAnim should be replicated.
- bReplicateInstigator
- Whether the Instigator should be replicated.
- bReplicateMovement
- Whether properties relevant for movement like Location, Rotation, Velocity, etc. should be replicated. Unlike bSkipActorPropertyReplication this also affects the initial replication.
- bSkipActorPropertyReplication
- Used by ReplicationInfo classes that don't need to know all the Actor class properties on the clients. When set to True only the initial replication replicates the Actor class properties.
- bUpdateSimulatedPosition
- Whether the actor's Location, Rotation and Velocity should be updated for Simulated Proxies.
=Using Replication
class UT_MDI_Weapon extends UT_MDI; /** Weapon class so we can check owner is right type and set vars */ var UTWeapon Weap; /** Gets the times from the weapons and sets them to the replicated variables */ reliable server function GetWeapProps(UTWeapon W); /** Sets the clients weapon to use the replicated variables */ reliable client function SetWeapProps(UTWeapon W); /** Make sure we have an owner and its the right type before moving on */ simulated event PostBeginPlay() { local int i; if(Owner == None || cUseforWeaps.length <= 0) Destroy(); Weap = UTWeapon(Owner); if(Weap != None) { if(WorldInfo.NetMode != NM_Client) GetWeapProps(Weap); SetTimer(0.01, false, 'SetPropsTimer'); } else Destroy(); } function SetPropsTimer() { SetWeapProps(Weap); } defaultproperties { //remove all from array //cUseforWeapons(0)=none RemoteRole=ROLE_SimulatedProxy bAlwaysRelevant=True }
if(Weap != None) { if(WorldInfo.NetMode != NM_Client) GetWeapProps(Weap); SetTimer(0.01, false, 'SetPropsTimer'); }
function SetPropsTimer() { SetWeapProps(Weap); } //Sets the properties to the values from the Server on the client <uscript> ===Related Topics=== * [[Legacy:Introduction_To_Replication|Introduction To Replication]] * [[Legacy:Replication|Replication]] * [[Legacy:Replication Block|Replication Block]] * [[Legacy:Role|Role]] and RemoteRole, and [[Legacy:NetMode|NetMode]] * [[Legacy:Netcode Idioms|Netcode Idioms]] * [[Legacy:Replication Examples|Replication Examples]] * [[Legacy:Replication_De-Obfuscation|Replication De-Obfuscation]] ==Proposal== ===stuff=== -[[User:00zX|00zX]] 21:31, 29 March 2009 (UTC) ====gogo==== [[UE3:Object_static_native_functions_(UT3)]] [[Legacy:Object_(UT3)/Operators]] [[Legacy:Operators]] [[Legacy:Scripting_Operators]] [[Legacy:Iterator]] [[Variables#Modifiers]]