Long description: For some reasons I want to change the speed of a projectile by an INI file located at the server. For example for the RocketLauncher: I subclassed the default projectile ("SBRocketMk2"), added a new variable "ProjectileSpeed" that should be replicated and assign the value of "ProjectileSpeed" to the variable "Speed" in PostBeginPlay():
Code: Select all
class SBRocketMk2 expands RocketMk2 config(SBRocketMk2);
var config float ProjectileSpeed;
replication {
reliable if (Role == ROLE_Authority)
ProjectileSpeed;
}
simulated function logger(string msg) {
Log(msg);
broadcastmessage(msg);
}
simulated function PostNetBeginPlay() {
Logger(self $ ".PostNetBeginPlay: Speed=" $ Speed);
super.PostNetBeginPlay();
}
simulated function PostBeginPlay() {
Logger(self $ ".PostBeginPlay starting with SmokeRate=" $ SmokeRate $ ", ProjectileSpeed=" $ ProjectileSpeed $ ", Speed=" $ Speed);
Speed = ProjectileSpeed;
Super.PostBeginPlay();
logger(self $ ".PostBeginPlay finished with SmokeRate=" $ SmokeRate $ ", ProjectileSpeed=" $ ProjectileSpeed $ ", Speed=" $ Speed);
}
defaultproperties {
ProjectileSpeed=20
}
SBEightball
Code: Select all
class SBEightball expands UT_Eightball;
state FireRockets {
function BeginState() // complete copy of parent except line 87 where class'rocketmk2' is spawned
{
local vector FireLocation, StartLoc, X,Y,Z;
local rotator FireRot, RandRot;
local rocketmk2 r;
local UT_SeekingRocket s;
local ut_grenade g;
local float Angle, RocketRad;
local pawn BestTarget, PawnOwner;
local PlayerPawn PlayerOwner;
local int DupRockets;
local bool bMultiRockets;
PawnOwner = Pawn(Owner);
if ( PawnOwner == None )
return;
PawnOwner.PlayRecoil(FiringSpeed);
PlayerOwner = PlayerPawn(Owner);
Angle = 0;
DupRockets = RocketsLoaded - 1;
if (DupRockets < 0) DupRockets = 0;
if ( PlayerOwner == None )
bTightWad = ( FRand() * 4 < PawnOwner.skill );
GetAxes(PawnOwner.ViewRotation,X,Y,Z);
StartLoc = Owner.Location + CalcDrawOffset() + FireOffset.X * X + FireOffset.Y * Y + FireOffset.Z * Z;
if ( bFireLoad )
AdjustedAim = PawnOwner.AdjustAim(ProjectileSpeed, StartLoc, AimError, True, bWarnTarget);
else
AdjustedAim = PawnOwner.AdjustToss(AltProjectileSpeed, StartLoc, AimError, True, bAltWarnTarget);
if ( PlayerOwner != None )
AdjustedAim = PawnOwner.ViewRotation;
PlayRFiring(RocketsLoaded-1);
Owner.MakeNoise(PawnOwner.SoundDampening);
if ( !bFireLoad )
{
LockedTarget = None;
bLockedOn = false;
}
else if ( LockedTarget != None )
{
BestTarget = Pawn(CheckTarget());
if ( (LockedTarget!=None) && (LockedTarget != BestTarget) )
{
LockedTarget = None;
bLockedOn=False;
}
}
else
BestTarget = None;
bPendingLock = false;
bPointing = true;
FireRot = AdjustedAim;
RocketRad = 4;
if (bTightWad || !bFireLoad) RocketRad=7;
bMultiRockets = ( RocketsLoaded > 1 );
While ( RocketsLoaded > 0 )
{
if ( bMultiRockets )
Firelocation = StartLoc - (Sin(Angle)*RocketRad - 7.5)*Y + (Cos(Angle)*RocketRad - 7)*Z - X * 4 * FRand();
else
FireLocation = StartLoc;
if (bFireLoad)
{
if ( Angle > 0 )
{
if ( Angle < 3 && !bTightWad)
FireRot.Yaw = AdjustedAim.Yaw - Angle * 600;
else if ( Angle > 3.5 && !bTightWad)
FireRot.Yaw = AdjustedAim.Yaw + (Angle - 3) * 600;
else
FireRot.Yaw = AdjustedAim.Yaw;
}
if ( LockedTarget != None )
{
s = Spawn( class 'ut_SeekingRocket',, '', FireLocation,FireRot);
s.Seeking = LockedTarget;
s.NumExtraRockets = DupRockets;
if ( Angle > 0 )
s.Velocity *= (0.9 + 0.2 * FRand());
}
else
{
//r = Spawn( class'rocketmk2',, '', FireLocation,FireRot);
r = RocketMK2(Spawn(ProjectileClass,, '', FireLocation,FireRot));
r.NumExtraRockets = DupRockets;
if (RocketsLoaded>4 && bTightWad) r.bRing=True;
if ( Angle > 0 )
r.Velocity *= (0.9 + 0.2 * FRand());
}
}
else
{
g = Spawn( class 'ut_Grenade',, '', FireLocation,AdjustedAim);
g.NumExtraGrenades = DupRockets;
if ( DupRockets > 0 )
{
RandRot.Pitch = FRand() * 1500 - 750;
RandRot.Yaw = FRand() * 1500 - 750;
RandRot.Roll = FRand() * 1500 - 750;
g.Velocity = g.Velocity >> RandRot;
}
}
Angle += 1.0484; //2*3.1415/6;
RocketsLoaded--;
}
bTightWad=False;
bRotated = false;
}
function AnimEnd()
{
if ( !bRotated && (AmmoType.AmmoAmount > 0) )
{
PlayLoading(1.5,0);
RocketsLoaded = 1;
bRotated = true;
return;
}
LockedTarget = None;
Finish();
}
}
defaultproperties {
ItemName="Enhanced Rocket Launcher"
PickupMessage="You got the Enhanced Rocket Launcher."
ProjectileClass=class'SBRocketMk2'
}
Running the testmap locally all things work, but playing with client/server and INI file on server only, the client logsSBRocketMk2.ini wrote:[SBEightballV1.SBRocketMk2]
ProjectileSpeed=5000.000000
So "ProjectileSpeed" is not replicated?UnrealTournament.ini wrote:ScriptLog: TestProjectileSpeed.SBRocketMk0.PostBeginPlay starting with SmokeRate=0.000000, ProjectileSpeed=20.000000, Speed=900.000000
ScriptLog: TestProjectileSpeed.SBRocketMk0.PostBeginPlay finished with SmokeRate=10.000000, ProjectileSpeed=20.000000, Speed=20.000000
ScriptLog: TestProjectileSpeed.SBRocketMk0.PostNetBeginPlay: Speed=20.000000
Warning: New actor channel received non-open packet: 0/1/1