replication problem with this code?

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

GlassBoy

Nano-augmented Modder
Jan 6, 2004
169
0
0
I'm Making a mutator that makes weapons' beams and shots reflect off walls. as well as a few other bells and whistles. The problem i'm having is that it is not testing online successfully. My tests are showing that the mutator settings are not correctly affecting client side default properties like they should, but i don't know how to solve the problem.

Here is my Mutator class:

Code:
//======================================================
// MUTATOR FILE
//======================================================
class ReflectiveWeaponMutator extends Mutator;
//Display text-----------------
var localized string
DispShockRifle, DispLightningGun, DispRocketLauncher, DispLinkGun, DispFlakCannon,
DispRocketGravity, DispFlakGravity, DispFlaksTrailColor, DispFlaksTrailLength,
DispFlakCharged,
DispBeamDamage, DispEnergyDamage, DispSolidDamage,
DispRN_Solid, DispRN_Energy, DispRN_Beam,
//Hint Text--------------------
HintShockRifle, HintLightningGun, HintRocketLauncher, HintLinkGun, HintFlakCannon,
HintRocketGravity, HintFlakGravity, HintFlaksTrailColor, HintFlaksTrailLength,
HintFlakCharged,
HintBeamDamage, HintEnergyDamage, HintSolidDamage,
HintRN_Solid, HintRN_Energy, HintRN_Beam;
//Booleans---------------------
var config bool
bShockRifle, bLightningGun, bRocketLauncher, bLinkGun, bFlakCannon,
bRocketsIgnoreGravity, bFlaksIgnoreGravity, bFlakCharged;
//Numbers----------------------
var config byte
RN_Energy, RN_Solid, RN_Beam,
DF_Energy, DF_Solid, DF_Beam;
var config float FlaksTrailLength;
//Strings-----------------------
var config string FlaksTrailColor;
var string FlakColorOptions;
//Color-------------------------
var color ColorToSet;

//============================================
//WEAPON REPLACEMENT PROCESS
//============================================
function bool CheckReplacement (Actor Other, out byte bSuperRelevant)
{
    local int i;
    local xWeaponBase B;
    local string S;
    local WeaponLocker L;

    if (xWeaponBase(other) != None)  // don't want to access non-weapons bases
    {
        B = xWeaponBase(Other);
        if (B.weaponType == class'ShockRifle' && bShockRifle)              B.WeaponType = class'ReflectiveShockRifle';
        else if (B.weaponType == class'SniperRifle' && bLightningGun)      B.WeaponType = class'ReflectiveSniperRifle';
        else if (B.weaponType == class'RocketLauncher' && bRocketLauncher) B.WeaponType = class'ReflectiveRocketLauncher';
        else if (B.weaponType == class'LinkGun' && bLinkGun)               B.WeaponType = class'ReflectiveLinkGun';
        else if (B.weaponType == class'FlakCannon' && bFlakCannon)         B.WeaponType = class'ReflectiveFlakCannon';
        else                                                               return true;
    }
    else if (WeaponPickup(other) != None)
    {
        S = string(other.class);
        if (S == "xWeapons.ShockRiflePickup" && bShockRifle)              ReplaceWith(Other, "ReflectiveWeapons.ReflectiveShockRiflePickup");
        else if (S == "xWeapons.SniperRiflePickup" && bLightningGun)      ReplaceWith(Other, "ReflectiveWeapons.ReflectiveSniperRiflePickup");
        else if (S == "xWeapons.RocketLauncherPickup" && bRocketLauncher) ReplaceWith(Other, "ReflectiveWeapons.ReflectiveRocketLauncherPickup");
        else if (S == "xWeapons.LinkGunPickup" && bLinkGun)               ReplaceWith(Other, "ReflectiveWeapons.ReflectiveLinkGunPickup");
        else if (S == "xWeapons.FlakCannonPickup" && bFlakCannon)         ReplaceWith(Other, "ReflectiveWeapons.ReflectiveFlakCannonPickup");
        else                                                              return true;
    }
    else if ( WeaponLocker(Other) != None )
    {
	L = WeaponLocker(Other);
	for (i = 0; i < L.Weapons.Length; i++)
	    if (L.Weapons[i].WeaponClass == class'ShockRifle' && bShockRifle)              L.Weapons[i].WeaponClass = class'ReflectiveShockRifle';
	    else if (L.Weapons[i].WeaponClass == class'SniperRifle' && bLightningGun)      L.Weapons[i].WeaponClass = class'ReflectiveSniperRifle';
	    else if (L.Weapons[i].WeaponClass == class'RocketLauncher' && bRocketLauncher) L.Weapons[i].WeaponClass = class'ReflectiveRocketLauncher';
	    else if (L.Weapons[i].WeaponClass == class'LinkGun' && bLinkGun)               L.Weapons[i].WeaponClass = class'ReflectiveLinkGun';
	    else if (L.Weapons[i].WeaponClass == class'FlakCannon' && bFlakCannon)         L.Weapons[i].WeaponClass = class'ReflectiveFlakCannon';
	return true;
    }
    else
        return true;
    return false;
}

//============================================
//ADDING MUTATOR-CONFIGUREABLE SETTINGS
//============================================
static function FillPlayInfo(PlayInfo PI)
{
    Super.FillPlayInfo(PI);
    //Replace Weapons
    PI.AddSetting(default.RulesGroup, "bLightningGun", default.DispLightningGun, 0, 1, "Check");
    PI.AddSetting(default.RulesGroup, "bShockRifle", default.DispShockRifle, 0, 1, "Check");
    PI.AddSetting(default.RulesGroup, "bRocketLauncher", default.DispRocketLauncher, 0, 1, "Check");
    PI.AddSetting(default.RulesGroup, "bLinkGun", default.DispLinkGun, 0, 1, "Check");
    PI.AddSetting(default.RulesGroup, "bFlakCannon", default.DispFlakCannon, 0, 1, "Check");
    //Gravity
    PI.AddSetting(default.RulesGroup, "bRocketsIgnoreGravity", default.DispRocketGravity, 0, 1, "Check");
    PI.AddSetting(default.RulesGroup, "bFlaksIgnoreGravity", default.DispFlakGravity, 0, 1, "Check");
    //ChargedFire
    PI.AddSetting(default.RulesGroup, "bFlakCharged", default.DispFlakCharged, 0, 1, "Check");
    //Damage Dampening
    PI.AddSetting(default.RulesGroup, "DF_Beam", default.DispBeamDamage, 0, 0, "Text", "15;5:75");
    PI.AddSetting(default.RulesGroup, "DF_Solid", default.DispSolidDamage, 0, 0, "Text", "15;5:75");
    PI.AddSetting(default.RulesGroup, "DF_Energy", default.DispEnergyDamage, 0, 0, "Text", "15;5:75");
    //Reflection Adjustment
    PI.AddSetting(default.RulesGroup, "RN_Beam", default.DispRN_Beam, 0, 0, "Text", "5;1:10");
    PI.AddSetting(default.RulesGroup, "RN_Solid", default.DispRN_Solid, 0, 0, "Text", "5;1:10");
    PI.AddSetting(default.RulesGroup, "RN_Energy", default.DispRN_Energy, 0, 0, "Text", "5;1:10");
    //Other
    PI.AddSetting(default.RulesGroup, "FlaksTrailLength", default.DispFlaksTrailLength, 0, 0, "Text", "0.40;0.20:0.80");
    PI.AddSetting(default.RulesGroup, "FlaksTrailColor", default.DispFlaksTrailColor, 0, 1, "Select", Default.FlakColorOptions);

}
//============================================
// SET VARIABLE VALUES IN CLASSES
//============================================
simulated function PreBeginPlay()
{
        local float fDF_Solid, fDF_Beam, fDF_Energy;  //fDF stands for float Dampening Factor
        local byte i;
        
        //Float Adjustments
        fDF_Solid = Float(DF_Solid) / Float(100);
        fDF_Beam = Float(DF_Beam) / Float(100);
        fDF_Energy = Float(DF_Energy) / Float(100);

        ColorToSet = AssignColor(ColorToSet);

        //================================================================
        //Damage Dampening Factors
        class'ReflectiveRocketProj'.default.DampeningFactor      = fDF_Solid;
        class'ReflectiveSniperFire'.default.DampeningFactor      = fDF_Beam;
        class'ReflectiveLinkProjectile'.default.DampeningFactor  = fDF_Energy;
        class'ReflectiveShockBeamFire'.default.DampeningFactor   = fDF_Beam;
        class'ReflectiveShockProjectile'.default.DampeningFactor = fDF_Energy;
        class'ReflectiveFlakChunk'.default.DampeningFactor       = fDF_Solid;
        //================================================================
        //Gravity
        class'ReflectiveRocketProj'.default.bIgnoreGravity = bRocketsIgnoreGravity;
        class'ReflectiveFlakChunk'.default.bIgnoreGravity  = bFlaksIgnoreGravity;
        //================================================================
        //Color and Trail Length
        //for (i = 0; i <= 1; i++)
        //    class'ReflectiveFlakTrail'.default.mLifeRange[i]      = FlaksTrailLength;
        class'ReflectiveFlakFire'.default.TrailColor              = FlaksTrailColor;
        class'ReflectiveFlakAltFire'.default.TrailColor           = FlaksTrailColor;
        class'ReflectiveFlakAltChargedFire'.default.TrailColor    = FlaksTrailColor;
        class'ReflectiveFlakTrail'.default.TrailColor             = FlaksTrailColor;
        for (i = 0; i < 2; i++)
            class'ReflectiveFlakTrail'.default.mColorRange[i]= ColorToSet;
        //================================================================
        //Reflection Settings
        class'ReflectiveRocketProj'.default.ReflectMaxNum      = RN_Solid;
        class'ReflectiveSniperFire'.default.ReflectMaxNum      = RN_Beam;
        class'ReflectiveShockBeamFire'.default.ReflectMaxNum   = RN_Beam;
        class'ReflectiveShockProjectile'.default.ReflectMaxNum = RN_Energy;
        class'ReflectiveLinkProjectile'.default.ReflectMaxNum  = RN_Energy;
        class'ReflectiveFlakChunk'.default.ReflectMaxNum       = RN_Solid;
        //================================================================
        //FlakShell Charged Fire
        if (bFlakCharged)
            class'ReflectiveFlakCannon'.default.FireModeClass[1] = class'ReflectiveFlakAltChargedFire';
        else
            class'ReflectiveFlakCannon'.default.FireModeClass[1] = class'ReflectiveFlakAltFire';
        class'ReflectiveFlakCannon'.default.bChargeEnabled   = bFlakCharged;
        class'ReflectiveFlakCannon'.default.bShowChargingBar = bFlakCharged;
}

//============================================
//TOOLTIPS
//============================================
static event string GetDescriptionText(string PropName)
{
	switch (PropName)
	{
                case "bLightningGun":	        return default.HintLightningGun;   // Lightning Gun
		case "bShockRifle":	        return default.HintShockRifle;     // Shock Rifle
		case "bRocketLauncher":	        return default.HintRocketLauncher; // Rocket Launcher
		case "bLinkGun":  	        return default.HintLinkGun;        // Link gun
                case "bFlakCannon":             return default.HintFlakCannon;     // Flak Cannon

                case "bRocketsIgnoreGravity":   return default.HintRocketGravity;  // Rocket gravity
                case "bFlaksIgnoreGravity":     return default.HintFlakGravity;    // Flak chunk gravity

                case "FlaksTrailColor":         return default.HintFlaksTrailColor;  // Flak's Trail color
                case "FlaksTrailLength":        return default.HintFlaksTrailLength; // Flak's Trail length
                
                case "bFlakCharged":            return default.HintFlakCharged;    // Charged speed for flak shell

                case "DF_Beam":                 return default.HintBeamDamage;     // Beam
                case "DF_Solid":                return default.HintSolidDamage;    // Solid Projectiles
                case "DF_Energy":               return default.HintEnergyDamage;   // Energy Projectiles

                case "RN_Beam":                 return default.HintRN_Beam;        // Beams
                case "RN_Solid":                return default.HintRN_Solid;       // Solid Projectiles
                case "RN_Energy":               return default.HintRN_Energy;      // Energy Projectiles
        }
	return Super.GetDescriptionText(PropName);
}

simulated function Color AssignColor(Color C)
{
    Switch(FlaksTrailColor)
    {
         case "Ice Blue":    C.R = 100;  C.G = 200;  C.B = 255;  Return C;
         case "Neon Violet": C.R = 175;              C.B = 255;  Return C;
         case "Neon Green":  C.R = 150;  C.G = 255;  C.B = 50;   Return C;
         case "Neon Red":    C.R = 255;  C.G = 100;  C.B = 50;   Return C;
         case "Violet":      C.R = 100;              C.B = 255;  Return C;
         case "Silver":      C.R = 175;  C.G = 175;  C.B = 175;  Return C;
         case "Red":         C.R = 255;                          Return C;
         case "Blue":                                C.B = 255;  Return C;
         case "Green":                   C.G = 255;              Return C;
         case "Yellow":      C.R = 255;  C.G = 200;              Return C;
         case "Orange":      C.R = 255;  C.G = 125;              Return C;
         case "Brown":       C.R = 100;  C.G = 50;               Return C;
         Default:/*Ghost*/   C.R = 255;  C.G = 255;  C.B = 255;  C.A = 120;  Return C;
    }
}

//============================================
//DEFAULT PROPERTIES
//============================================
defaultProperties
{
    DispShockRifle=     "Weapon - Shock Rifle"
    DispLightningGun=   "Weapon - Lightning Gun"
    DispRocketLauncher= "Weapon - Rocket Launcher"
    DispLinkGun=        "Weapon - Link Gun"
    DispFlakCannon=     "Weapon - Flak Cannon"
    DispEnergyDamage=  "Damage Dampening - Energy Projectiles"
    DispBeamDamage=    "Damage Dampening - Instant Hit Beams"
    DispSolidDamage=   "Damage Dampening - Solid Projectiles"
    DispRocketGravity=    "Ignore Gravity - Rockets"
    DispFlakGravity=      "Ignore Gravity - Flak Chunks"
    DispFlaksTrailLength= "Other - Flak Trail Length"
    DispFlaksTrailColor=  "Other - Flak Trail Color"
    DispFlakCharged=      "Charged Fire - Flak Shells"
    DispRN_Beam=   "Reflections - Instant Hit Beams"
    DispRN_Solid=  "Reflections - Solid Projectiles"
    DispRN_Energy= "Reflections - Energy Projectiles"

    HintShockRifle=     "Enable Reflective Shock Rifle."
    HintLightningGun=   "Enable Reflective Lightning Gun."
    HintRocketLauncher= "Enable Reflective Rocket Launcher.  REFLECTIVE ROCKETS ON ALT-FIRE."
    HintLinkGun=        "Enable Reflective Link Gun."
    HintFlakCannon=     "Enable Reflective Flak Cannon."
    HintBeamDamage=  "Exponential decay: Instant-hit beams loose this % damage per bounce."
    HintEnergyDamage="Exponential decay: Energy projectiles loose this % damage per bounce."
    HintSolidDamage= "Exponential decay: Solid projectiles loose this % damage per bounce."
    HintRocketGravity="Reflected rockets ignore gravity, for direct straight-line reflections off walls.  Uncheck to make rockets affected by gravity."
    HintFlakGravity=  "Flak chunks ignore gravity and maintain velocity.  Uncheck to make chunks loose velocity and fall after bouncing."
    HintFlaksTrailLength= "Adjust the length of the tracers following the flak chunks."
    HintFlaksTrailColor=  "Ohhh! Puuurdy!  Adjust the color of flak chunk tracers."
    HintFlakCharged=   "Flak Cannon Alt-fire charges speed and distance of the flak shell."
    HintRN_Energy=   "MAX # of reflections for energy projectiles.  Projectiles can still expire prematurely if lifespans run out first."
    HintRN_Solid=    "MAX # of reflections for solid projectiles.  Projectiles can still expire prematurely if lifespans run out first."
    HintRN_Beam=     "MAX # of reflections for instant-hit beams.  Beams can still expire prematurely if maximum range has been reached."

    FlakColorOptions = "Random(Mix);Random(Mix);Random(Group);Random(Group);Ice Blue;Ice Blue;Neon Violet;Neon Violet;Neon Green;Neon Green;Neon Red;Neon Red;Silver;Silver;Red;Red;Blue;Blue;Green;Green;Violet;Violet;Yellow;Yellow;Orange;Orange;Brown;Brown;Ghost White;Ghost White"
    FlaksTrailColor = "Random(Mix)"
    FlaksTrailLength = 0.400000
    ColorToSet = (R=0,G=0,B=0,A=255)

    bLightningGun=True
    bShockRifle=True
    bRocketLauncher=True
    bLinkGun=True
    bFlakCannon=True
    bRocketsIgnoreGravity=True
    bFlaksIgnoreGravity=True
    bFlakCharged=True

    RN_Beam   = 5
    RN_Solid  = 5
    RN_Energy = 5

    DF_Beam = 15
    DF_Solid = 15
    DF_Energy = 15

    Description = "Replaces some weapons with reflective weapons!"
    FriendlyName= "Reflective Weapons"
    
    bAlwaysRelevant = True
}
 
Last edited:

Mychaeel

New Member
GlassBoy said:
But as soon as i put it online it acts like the client side doesn't know what the mutator prebeginplay has done to the weapons and projectiles' default properties.
...because that's exactly what's happening: Changes to class property defaults aren't replicated to clients.

You'll have to replicate your values separately and then execute code on each client which sets the class property defaults client-side the way you want them to be.
 

GlassBoy

Nano-augmented Modder
Jan 6, 2004
169
0
0
Mychaeel said:
...because that's exactly what's happening: Changes to class property defaults aren't replicated to clients.

You'll have to replicate your values separately and then execute code on each client which sets the class property defaults client-side the way you want them to be.

That's the part that i don't know how to do. I do know how a replication block looks, but i don't know what reliable if conditions to use, bNetInitial or Role== RoleAuthority or both.

How do i excecute the code on each client side?
 
Last edited:

GlassBoy

Nano-augmented Modder
Jan 6, 2004
169
0
0
punk129 said:
i've read that, several times. I'm still confused on how to make certain stuff replicated, Many of the things i try to replicate are inherited, and it says at compile time that they are bad expressions when i try to replicate them.

There are several things on that page that i DO understand, but several things that just plain confuse me.
 
Last edited:

Mr Evi1

New Member
Mar 22, 2002
336
0
0
UK
come.to
Your mutator's PreBeginPlay will surely never be called client-side because you haven't set RemoteRole=ROLE_SimulatedProxy.
 

GlassBoy

Nano-augmented Modder
Jan 6, 2004
169
0
0
I tried it out, and a lot of the errors are fixed now. thanks.

I didn't know you could set roles like that. I thought there was a strict rule against it.
 
Last edited:

Mychaeel

New Member
/me dons his moderator's hat...

The forums are there to serve as an archive of past (solved) problems for others as well as a way to get answers. Please don't cripple and "re-use" your threads when you've received an answer to your original question -- just create a new thread. It's a lot less trouble for you as well.
 
Last edited:

GlassBoy

Nano-augmented Modder
Jan 6, 2004
169
0
0
Mychaeel said:
/me dons his moderator's hat...

The forums are there to serve as an archive of past (solved) problems for others as well as a way to get answers. Please don't cripple and "re-use" your threads when you've received an answer to your original question -- just create a new thread. It's a lot less trouble for you as well.
Alright, i reposted the problem, and am making a new thread for the problem that was put in it's place. Please help.
 
Last edited: