I'm a doctor, not a mechanic

Difference between revisions of "User:00zX"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
Line 11: Line 11:
  
 
===Replication===
 
===Replication===
-[[User:00zX|00zX]] 06:24, 31 March 2009 (UTC)<br>
+
-[[User:00zX|00zX]] 20:49, 3 April 2009 (UTC)<br>
 
:[[Replication]]/[[Replication_(computer_science)]]
 
:[[Replication]]/[[Replication_(computer_science)]]
 
:Concept of servers and clients.(NetMode/Relevancy/Reliability)
 
:Concept of servers and clients.(NetMode/Relevancy/Reliability)
Line 21: Line 21:
 
*NetMode (concept)
 
*NetMode (concept)
 
*Replication Block
 
*Replication Block
**Using the Replication Block
 
 
**Actor Replication (bools bnetinitial eg)
 
**Actor Replication (bools bnetinitial eg)
**Variable Value Replication
+
**Variable Value Replication (using block)
 +
***Repnotify / ReplicatedEvents
 
**Function call replication(UT2004)
 
**Function call replication(UT2004)
 
*Function call replication(UT3)
 
*Function call replication(UT3)
 
*Reliability
 
*Reliability
*Relevance
+
*Relevance (actor replication??)
 
**Role and RemoteRole
 
**Role and RemoteRole
 
 
*Info
 
*Info
 
**ReplicationInfo
 
**ReplicationInfo
 
***GameReplicationInfo (GRI)
 
***GameReplicationInfo (GRI)
 
***PlayerReplicationInfo (PRI)
 
***PlayerReplicationInfo (PRI)
***TeamInfo
 
 
***LinkedReplicationInfo (LRI)
 
***LinkedReplicationInfo (LRI)
 
<div class="hidden-block"><span class="hint"></span><div class="hidden">
 
<div class="hidden-block"><span class="hint"></span><div class="hidden">
Line 62: Line 60:
 
can loose sync! it is possible to crosscheck dynamic arrays but it would come at a cost.
 
can loose sync! it is possible to crosscheck dynamic arrays but it would come at a cost.
  
====Using the Replication Block====
+
[[http://wiki.beyondunreal.com/Dynamic_array|Dynamic Array]]
 +
'''Unlike any other data type in UnrealScript, dynamic arrays have absolutely no support for replication. Attempting to replicate a dynamic array variable will have no effect on the remote instance of that variable. Attempting to use a dynamic array as parameter of a [[replicated function]] will result in the parameter being empty when the function is executed on the remote side.'''
  
 +
====Actor Replication====
  
=====Actor Replication=====
+
====Variable Value Replication====
 
+
=====Variable Value Replication=====
+
 
+
 
<uscript>
 
<uscript>
 
var() float NewEquipTime;
 
var() float NewEquipTime;
Line 80: Line 77:
 
</uscript>
 
</uscript>
  
**Repnotify
+
====Repnotify and Replicated Events====
 +
This is new in Unreal Engine 3 and is not available in previous versions.
 +
<uscript>
 +
simulated event ReplicatedEvent(name VarName); // Called when a variable with the property flag "RepNotify" is replicated
  
*Function call replication*
+
/** adds/removes a property from a list of properties that will always be replicated when this Actor is bNetInitial, even if the code thinks
[[http://wiki.beyondunreal.com/Dynamic_array|Dynamic Array]]
+
* the client has the same value the server already does
'''Unlike any other data type in UnrealScript, dynamic arrays have absolutely no support for replication. Attempting to replicate a dynamic array variable will have no effect on the remote instance of that variable. Attempting to use a dynamic array as parameter of a [[replicated function]] will result in the parameter being empty when the function is executed on the remote side.'''
+
* This is a workaround to the problem where an LD places an Actor in the level, changes a replicated variable away from the defaults,
 +
* then at runtime the variable is changed back to the default but it doesn't replicate because initial replication is based on class defaults
 +
* Only has an effect when called on bStatic or bNoDelete Actors
 +
* Only properties already in the owning class's replication block may be specified
 +
* @param PropToReplicate the property to add or remove to the list
 +
* @param bAdd true to add the property, false to remove the property
 +
*/
 +
native final function SetForcedInitialReplicatedProperty(Property PropToReplicate, bool bAdd);
 +
</uscript>
 +
=====usage:=====
 +
[[UE3:DroppedPickup_(UT3)]]
 +
<uscript>
 +
var repnotify class<Inventory> InventoryClass; // Class of the inventory object to pickup
 +
var repnotify bool bFadeOut;
  
 +
replication
 +
{
 +
if( Role==ROLE_Authority )
 +
InventoryClass, bFadeOut;
 +
}
 +
 +
simulated event ReplicatedEvent(name VarName)
 +
{
 +
if( VarName == 'InventoryClass' )
 +
{
 +
SetPickupMesh( InventoryClass.default.DroppedPickupMesh );
 +
SetPickupParticles( InventoryClass.default.DroppedPickupParticles );
 +
}
 +
else if ( VarName == 'bFadeOut' )
 +
{
 +
GotoState('Fadeout');
 +
}
 +
else
 +
{
 +
super.ReplicatedEvent(VarName);
 +
}
 +
}
 +
 +
defaultproperties
 +
{
 +
bOnlyDirtyReplication=true
 +
NetUpdateFrequency=8
 +
RemoteRole=ROLE_SimulatedProxy
 +
}
 +
</uscript>
 +
====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.
 
: 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.
  
Line 274: Line 318:
 
PlayerReplicationInfo - 2 Hz<br>
 
PlayerReplicationInfo - 2 Hz<br>
 
Inventory - 8 Hz<br>
 
Inventory - 8 Hz<br>
 
===Using Replication===
 
<uscript>
 
class UT_MDI_Weapon extends UT_MDI;
 
 
/** How long does it take to Equip this weapon */
 
var() repnotify float NewEquipTime;
 
 
/** How long does it take to put this weapon down */
 
var() repnotify float NewPutDownTime;
 
 
/** Weapon class so we can check owner is right type and set vars */
 
var UTWeapon Weap;
 
 
/** Replication Block */
 
replication
 
{
 
if(bNetDirty && (Role == ROLE_Authority) && bNetInitial)
 
NewEquipTime, NewPutDownTime;
 
}
 
 
/** Gets the times from the weapons and sets them to the replicated variables */
 
reliable server function GetWeapProps(UTWeapon W)
 
{
 
NewEquipTime = W.default.EquipTime * 0.68;
 
NewPutDownTime = W.default.PutDownTime * 0.70;
 
}
 
 
/** Sets the clients weapon to use the replicated variables */
 
reliable client function SetWeapProps(UTWeapon W)
 
{
 
W.EquipTime = NewEquipTime;
 
W.PutDownTime = NewPutDownTime;
 
}
 
 
/** 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 14:49, 3 April 2009

Proposal - Noir theme with highlighter adjustments

Code Noir Redex

stylish - userstyle -00zX 01:50, 3 April 2009 (UTC)
[Monobook - noir]


Proposal - Replication

Replication

-00zX 20:49, 3 April 2009 (UTC)

Replication/Replication_(computer_science)
Concept of servers and clients.(NetMode/Relevancy/Reliability)
  • 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#

  • NetMode (concept)
  • Replication Block
    • Actor Replication (bools bnetinitial eg)
    • Variable Value Replication (using block)
      • Repnotify / ReplicatedEvents
    • Function call replication(UT2004)
  • Function call replication(UT3)
  • Reliability
  • Relevance (actor replication??)
    • Role and RemoteRole
  • Info
    • ReplicationInfo
      • GameReplicationInfo (GRI)
      • PlayerReplicationInfo (PRI)
      • LinkedReplicationInfo (LRI)

Proposal

Foo

-00zX 21:31, 29 March 2009 (UTC)

Bar

UE3:Object_static_native_functions_(UT3)
Legacy:Object_(UT3)/Operators
Legacy:Operators
Legacy:Scripting_Operators
Legacy:Iterator
Variables#Modifiers


Wiki

Contributions

Contact Me

IRC

_00zX on EnterTheGame

Other/Profiles

E-mail 00zX or on