Announcement

Collapse
No announcement yet.

Simple Replace syntax problem...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Simple Replace syntax problem...

    So I'm trying to write a quick weapon replacer that will randomly select a weapon from a list in an .ini file. The idea is that each time a map starts, it will replace one of the standard UT weapons with one from an associated set. I'm new to the whole config thing, but I've got it reading in variables, but I've got some kind of syntax problem that I can't spot.

    So for example, in my.ini file I'd have these variables:

    FlakReplace=XWeapons.BioRifle
    FlakReplace=XWeapons.RocketLauncher
    FlakReplace=XWeapons.SniperRifle
    FlakReplace=XWeapons.Redeemer

    So for each mapcycle, it'll randomly replace the FlakCannon with one of those weapons.

    Here is my mutator code right now (I don't have the random select yet, but that'll be easy; In the meantime, I'm just trying to replace it with the second weapon in the list):

    class RandomReplace extends Mutator
    config(RandomReplace);

    var config class<Weapon> FlakReplace[4];

    function PostBeginPlay()
    {
    local int x;
    Super.PostBeginPlay();
    SaveConfig();
    }

    function bool CheckReplacement( Actor Other, out byte bSuperRelevant )
    {
    local int i;
    local WeaponLocker L;

    bSuperRelevant = 0;

    if ( xWeaponBase(Other) != None )
    {
    if ( string( xWeaponBase(Other).WeaponType ) ~= "XWeapons.FlakCannon" )
    {
    xWeaponBase(Other).WeaponType = FlakReplace[1];
    return false;
    }
    }
    else if ( WeaponLocker(Other) != None )
    {
    L = WeaponLocker(Other);

    for (i = 0; i < L.Weapons.Length; i++)
    {
    if ( string( L.Weapons[i].WeaponClass ) ~= "XWeapons.FlakCannon" )
    L.Weapons[i].WeaponClass = FlakReplace[1];
    }
    }

    return true;
    }

    I know the "= FlakReplace[1]" doesn't work, but I'm not quite sure how to get it to work. Should I use an array of strings instead of weapons? If so, what's the format for that?

    And/or does anybody know of a mutator out there that already does this?

    Thanks!

    #2
    Nevermind, I think.

    I changed the variables in the .ini to:

    FlakReplace[0]=Class'XWeapons.ShockRifle'
    FlakReplace[1]=Class'XWeapons.BioRifle'
    FlakReplace[2]=Class'XWeapons.SniperRifle'
    FlakReplace[3]=Class'XWeapons.Redeemer'

    and it seems to work fine now.

    Nothing like posting a question to get your head to work...

    Comment

    Working...
    X