Results 1 to 7 of 7
  1. #1

    Default Problem with XP System

    Hello i got one big problem with my team game xp system

    first of all all the code credits goes to mktwo

    homewhever im triying to implement SkillPoints to the XP System

    at the start all goes well i spawn with my skillpoints But once i level up appareantly they dont get updated

    Every level up the player should get 1 skill point a thing that he isnt getting

    first i copied the method of how the xp gets calculated every level up and added my skillpoints var

    then i added a debug exec function that letted me add skillpoints while in-game to see if my Skillpoints counter was working well

    But now even using the function doesnt change the skillpoints counter at all no matter what i do

    anyway if someone can help me heres the code im using

    class ParkourController extends UTPlayerController;

    var bool bSprinting;
    var class<UTFamilyInfo> CharacterClass;
    const MAX_LEVEL = 99;
    const XP_INCREMENT = 300; // Amount of XP that is added to the amount of XP required for a level, after each level progression
    const SkillPointsVar = 1;
    var int SkillPoints;
    var bool LevelUp;
    var int XP; // Total amount of gathered XP
    var int Level; // Current level
    var int XPGatheredForNextLevel; // Amount of XP gathered for the next level
    var int XPRequiredForNextLevel; // Amount of XP required for the next level

    var int Money;
    var int WeaponValue;


    simulated function PostBeginPlay()
    {
    super.PostBeginPlay();

    // Calculate XP-related properties at the start of the game
    CalculateLevelProgress();
    }

    // The function that is called from Kismet
    public function AddXP(SeqAct_GiveXP action)
    {
    GiveXP(action.Amount); // Give the player the amount of XP specified in the Kismet action
    }

    public function GiveXP(int amount)
    {
    self.XP += amount;


    CalculateLevelProgress();

    while (self.XPGatheredForNextLevel >= self.XPRequiredForNextLevel && self.Level < MAX_LEVEL)
    {
    self.Level++;


    // Recalculate level progress after leveling up
    CalculateLevelProgress();
    }
    }

    exec function GiveSkillPoints(int amount)
    {
    self.SkillPoints += amount;

    }


    private function CalculateLevelProgress()
    {
    local int xpToCurrentLevel; // Total amount of XP gathered with current and previous levels

    xpToCurrentLevel = XP_INCREMENT * (self.Level - 1);
    self.XPGatheredForNextLevel = self.XP - xpToCurrentLevel;
    self.XPRequiredForNextLevel = self.Level * XP_INCREMENT;
    self.SkillPoints = SkillPointsVar;

    }
    //Here we create our SetSoldierClass Function and also we add the exec so its accesible trough a gfx movie
    exec function SetSoldierClass()
    {


    //referencing to the player pawn
    local Pawn p;


    p = Pawn;

    //unposses and destroy the pawn
    UnPossess();
    p.Destroy();

    //spawn a new one with our specified class and posses it
    p = Spawn( class'HeavyPawn',,,Location );
    Possess( P, false );
    CharacterClass=class'UTFamilyInfo_Liandri_Male';
    ServerSetCharacterClass(CharacterClass);


    }

    //we use this function to be able to change the value of our money




    //Springting Code

    exec function StartSprint22()
    {



    ConsoleCommand("Sprint");
    Pawn.GroundSpeed = 490;
    bSprinting = true;


    StopFiring();

    }


    simulated function StopSprint()
    {

    Pawn.Groundspeed = 440;
    bSprinting = true;

    }




    defaultproperties
    {
    Level = 1;
    XP = 0;
    SkillPoints = 0;


    }
    any help or hints are very appreciated!

  2. #2

    Default

    and as i expected i fixed the problem i just had to delete some stuff and move some stuff

  3. #3
    MSgt. Shooter Person
    Join Date
    Feb 2010
    Location
    Bulgaria
    Posts
    442

    Default

    indent your code, its difficult to read as it is
    Code:
    private function CalculateLevelProgress()
    {
        // Total amount of XP gathered with current and previous levels
        local int xpToCurrentLevel; 
    
        xpToCurrentLevel = XP_INCREMENT * (Level - 1);
        XPGatheredForNextLevel = XP - xpToCurrentLevel;
        XPRequiredForNextLevel = Level * XP_INCREMENT;
        //self.SkillPoints = SkillPointsVar;
        // should be + 
        SkillPoints += SkillPointsVar;
    }

  4. #4

    Default

    actually i only had to add
    while (self.XPGatheredForNextLevel >= self.XPRequiredForNextLevel && self.Level < MAX_LEVEL && self.SkillPoints < SkillPointsVar)
    {
    self.Level++;
    self.SkillPoints++;

  5. #5
    MSgt. Shooter Person
    Join Date
    Nov 2009
    Location
    Belgium, Bruges
    Posts
    416

    Default

    I remember reading that using "Self." uses extra CPU.
    Technical Artist at Octane Games

  6. #6
    MSgt. Shooter Person
    Join Date
    Mar 2010
    Posts
    341

    Default

    Quote Originally Posted by The Wanderer View Post
    I remember reading that using "Self." uses extra CPU.
    Maybe but it's completely negligible.

  7. #7
    Veteran
    Join Date
    May 2007
    Location
    Above KillZ, Below StallZ
    Posts
    9,953

    Default

    It is useless, anytime you access "self.something" to get to a var, it's going to take (at least?) 3-4 times the amount of time to access it than if you just used the local var.
    http://www.ericbla.de http://www.dungeondefenders.com http://en.wikipedia.org/wiki/Warm_Gun http://www.rekoil.com http://www.groundbranch.com

    - Please don't send me private messages asking programming questions, those would be better asked on the Programming forum here. Thanks


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.