Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

UnrealGame.CustomBotConfig


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
class CustomBotConfig extends Object
    abstract
    config;

var localized string FavoriteWeapon, NoPreference;

struct CustomConfiguration
{
    var config string CharacterName;        // name of character (from UPL) to modify
    var config string PlayerName;           // name to change playername to.
    var config string CustomVoice;
    var config GameProfile.EPlayerPos CustomOrders;
    var() config string FavoriteWeapon;
    var() config float Aggressiveness;      // 0 to 1 (0.3 default, higher is more aggressive)
    var() config float Accuracy;            // -1 to 1 (0 is default, higher is more accurate)
    var() config float CombatStyle;     // 0 to 1 (0= stay back more, 1 = charge more)
    var() config float StrafingAbility; // -1 to 1 (higher uses strafing more)
    var() config float Tactics;         // -1 to 1 (higher uses better team tactics)
    var() config float ReactionTime;        // -1 to 1
    var() config float Jumpiness;       // 0 to 1
    var config bool bJumpy;             // OBSOLETE
};

var config array<CustomConfiguration> ConfigArray;

/* Used to configure custom bot AI parameters
*/
static function Customize(RosterEntry R)
{
    local int i;

    for ( i=0; i<Default.ConfigArray.Length; i++ )
        if ( R.PlayerName ~= Default.ConfigArray[i].CharacterName )
        {
            R.ModifiedPlayerName = Default.ConfigArray[i].PlayerName;
            if ( Default.ConfigArray[i].FavoriteWeapon == "" )
                R.FavoriteWeapon = None;
            else
                R.FavoriteWeapon = class<Weapon>(DynamicLoadObject(Default.ConfigArray[i].FavoriteWeapon, class'Class'));
            R.Aggressiveness = Default.ConfigArray[i].Aggressiveness;
            R.Accuracy = Default.ConfigArray[i].Accuracy;
            R.CombatStyle = Default.ConfigArray[i].CombatStyle;
            R.StrafingAbility = Default.ConfigArray[i].StrafingAbility;
            R.Tactics = Default.ConfigArray[i].Tactics;
            R.ReactionTime = Default.ConfigArray[i].ReactionTime;
            R.Jumpiness = Default.ConfigArray[i].Jumpiness;
            R.VoiceTypeName = Default.ConfigArray[i].CustomVoice;
            R.SetOrders(Default.ConfigArray[i].CustomOrders);
            return;
        }
}

// Copied from xUtil - used for custom configurations
final simulated static function string GetFavoriteWeaponFor(CustomConfiguration CC)
{
local class<Weapon> WeaponClass;

    if ( CC.FavoriteWeapon != "" )
    {
        WeaponClass = class<Weapon>(DynamicLoadObject(CC.FavoriteWeapon, class'Class'));
        if (WeaponClass != None)
            return Default.FavoriteWeapon@WeaponClass.default.ItemName;
    }

    return Default.NoPreference;
}

final simulated static function int RatingModifier(string CharacterName)
{
    local int Hash;

    Hash = Asc(CharacterName);
    if ( Hash == 2 )
        Hash = 1;
    return ( Hash%5 - 2);
}

final simulated static function int AccuracyRating(CustomConfiguration CC)
{
    if ( 2 * CC.Accuracy < -1 )
        return ( 55 + 8 * FMax(-7,2 * CC.Accuracy) );
    if ( 2 * CC.Accuracy == 0 )
        return ( 75 - RatingModifier(CC.CharacterName) );
    if ( 2 * CC.Accuracy < 1 )
        return ( 75 + 20 * 2 * CC.Accuracy - 0.5 * RatingModifier(CC.CharacterName) );
    return Min(100, 95 + 2 * CC.Accuracy );
}

final simulated static function int AgilityRating(CustomConfiguration CC)
{
    local float Add;

    Add = 3 * CC.Jumpiness;
    if ( CC.StrafingAbility < -1 )
        return ( Add + 58 + 8 * FMax(-7,CC.StrafingAbility) );
    if ( (Add == 0) && (CC.StrafingAbility == 0) )
        return ( 75 + 0.5 * RatingModifier(CC.CharacterName) );
    if ( CC.StrafingAbility < 1 )
        return ( Add + 75 + 17 * CC.StrafingAbility - 0.5 * RatingModifier(CC.CharacterName) );
    return Min(100, Add + 92 + CC.StrafingAbility );
}

final simulated static function int TacticsRating(CustomConfiguration CC)
{
    if ( CC.Tactics < -1 )
        return ( 55 + 8 * FMax(-7,CC.Tactics) );
    if ( CC.Tactics == 0 )
        return ( 75 + RatingModifier(CC.CharacterName) );
    if ( CC.Tactics < 1 )
        return ( 75 + 20 * CC.Tactics + 0.5 * RatingModifier(CC.CharacterName) );
    return Min(100, 95 + CC.Tactics );
}

final simulated static function int AggressivenessRating(CustomConfiguration CC)
{
    return Clamp(73 + 25 * (CC.Aggressiveness + CC.CombatStyle) + 0.5 * RatingModifier(CC.CharacterName),0,100);
}

static function int IndexFor(string PlayerName)
{
    local int i;

    for (i=0; i<Default.ConfigArray.Length; i++)
        if (PlayerName ~= Default.ConfigArray[i].CharacterName)
            return i;

    return -1;
}

defaultproperties
{
     FavoriteWeapon="Favorite Weapon:"
     NoPreference="No Weapon Preference"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Fr 30.3.2007 08:43:40.000 - Creation time: Mo 16.4.2007 11:20:45.968 - Created with UnCodeX