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

UT2004RPG.RPGPlayerDataObject


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
//RPGPlayerDataObject is used for saving player data. Using PerObjectConfig objects over arrays of structs is faster
//because native code can do the name search. Additionally, structs have a 1024 character limit when converted
//to text for .ini saving, which is not an issue for objects since they are not stored on one line.
class RPGPlayerDataObject extends Object
    config(UT2004RPG)
    PerObjectConfig;

//Player name is the object name
var config string OwnerID; //unique PlayerID of person who owns this name ("Bot" for bots)

var config int Level, Experience, WeaponSpeed, HealthBonus, AdrenalineMax, Attack, Defense, AmmoMax,
           PointsAvailable, NeededExp;
var config float ExperienceFraction; // when player gets EXP less than a full point, it gets added up here until it's >= 1.0

//these two should really be a struct but can't be since they need to be able to be put into RPGPlayerData struct
//and structs inside structs are not supported
var config array<class<RPGAbility> > Abilities;
var config array<int> AbilityLevels;

//AI related
var config class<RPGAbility> BotAbilityGoal; //Bot is saving points towards this ability
var config int BotGoalAbilityCurrentLevel; //Bot's current level in the ability it wants (so don't have to search for it)

//This struct is used for the data when it needs to be replicated, since an Object cannot be
struct RPGPlayerData
{
    var int Level, Experience, WeaponSpeed, HealthBonus, AdrenalineMax;
    var int Attack, Defense, AmmoMax, PointsAvailable, NeededExp;
    var array<class<RPGAbility> > Abilities;
    var array<int> AbilityLevels;
};

//adds a fractional amount of EXP
//the mutator and our owner's PRI are passed in for calling CheckLevelUp() if we've reached a whole number
function AddExperienceFraction(float Amount, MutUT2004RPG RPGMut, PlayerReplicationInfo MessagePRI)
{
    ExperienceFraction += Amount;
    if (Abs(ExperienceFraction) >= 1.0)
    {
        Experience += int(ExperienceFraction);
        ExperienceFraction -= int(ExperienceFraction);
        RPGMut.CheckLevelUp(self, MessagePRI);
    }
}

function CreateDataStruct(out RPGPlayerData Data, bool bOnlyEXP)
{
    Data.Level = Level;
    Data.Experience = Experience;
    Data.NeededExp = NeededExp;
    Data.PointsAvailable = PointsAvailable;
    if (bOnlyEXP)
        return;

    Data.WeaponSpeed = WeaponSpeed;
    Data.HealthBonus = HealthBonus;
    Data.AdrenalineMax = AdrenalineMax;
    Data.Attack = Attack;
    Data.Defense = Defense;
    Data.AmmoMax = AmmoMax;
    Data.Abilities = Abilities;
    Data.AbilityLevels = AbilityLevels;
}

function InitFromDataStruct(RPGPlayerData Data)
{
    Level = Data.Level;
    Experience = Data.Experience;
    NeededExp = Data.NeededExp;
    PointsAvailable = Data.PointsAvailable;
    WeaponSpeed = Data.WeaponSpeed;
    HealthBonus = Data.HealthBonus;
    AdrenalineMax = Data.AdrenalineMax;
    Attack = Data.Attack;
    Defense = Data.Defense;
    AmmoMax = Data.AmmoMax;
    Abilities = Data.Abilities;
    AbilityLevels = Data.AbilityLevels;
}

function CopyDataFrom(RPGPlayerDataObject DataObject)
{
    OwnerID = DataObject.OwnerID;
    Level = DataObject.Level;
    Experience = DataObject.Experience;
    NeededExp = DataObject.NeededExp;
    PointsAvailable = DataObject.PointsAvailable;
    WeaponSpeed = DataObject.WeaponSpeed;
    HealthBonus = DataObject.HealthBonus;
    AdrenalineMax = DataObject.AdrenalineMax;
    Attack = DataObject.Attack;
    Defense = DataObject.Defense;
    AmmoMax = DataObject.AmmoMax;
    Abilities = DataObject.Abilities;
    AbilityLevels = DataObject.AbilityLevels;
    BotAbilityGoal = DataObject.BotAbilityGoal;
    BotGoalAbilityCurrentLevel = DataObject.BotGoalAbilityCurrentLevel;
}

defaultproperties
{
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Sat 15/7/2006 17:15:14.000 - Creation time: Wed 7/2/2007 19:16:50.281 - Created with UnCodeX