Results 1 to 37 of 37

Thread: XP System Help!

  1. #1
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Location
    Germany
    Posts
    172

    Red face XP System Help!

    Hey,

    I wanted to create a XP System for a game i'm currently working on.
    So i found this TUTORIAL.
    Evrything worked well and it's fully functional.

    But now i want to make it a bit advanced.
    I found the Algorithm of the Borderlands Levelup Increment.
    So instead of this:
    Code:
    const XP_INCREMENT = 500;
    Which means it will increase (it being the XPForNextLevelRequirement) by 500 evrytime i level up
    I want to have this
    Code:
    const XP_INCREMENT = 60*(Level^2,8-1)
    The
    Code:
    60*(Level^2,8-1)
    is the increment.

    But when i compile it doesnt want to work. Is there a special way to write Math functions like this?
    (The Error is: "a ';' is missing after '*'")
    Last edited by scrapland; 08-11-2012 at 06:30 AM.
    My Tutorials and Threads:
    Kismet Timer Tutorial: Here
    Borderlands Teleport Tunnel Effect: Here

    Check out my Website!!!! Athypo Entertainment
    ~Scrapland~

  2. #2
    MSgt. Shooter Person
    Join Date
    Aug 2011
    Location
    Germany
    Posts
    162

    Default

    what is (Level^2,8-1) supposed to do?

    If you want to write Level^2 in unrealscript then you should write Level ** 2 or Level*Level;


    but then again, the second part makes no sense, you cannot just write comma. It would make sense in a function call, but there is none. Plus there is 8-1 0o thats 7 .... always 7!

    I dont know where you found that, but it does not seem to make any sense Not to mention that XP_INCREMENT is a constant and cannot be changed.


    *EDIT: Maybe the comma is meant to be a point. then it would make sense

    I dont know if that is true, but that is what you need to do in order to make it work:

    Code:
    var float XP_INCREMENT;
    XP_INCREMENT = 60*(Level**2.8-1);
    Last edited by DennyRocket; 08-11-2012 at 08:56 AM.
    UDK Helicopter | Physics
    UDK Helicopter | Laser Guided Missile System

  3. #3
    Redeemer
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    1,559

    Default

    Since every Pawn should have XP , i'd place there a int var called XP , and that explains everything
    another one called level ,

    and on tick function , if xp = mroe than next level then level ++

    Why tuts that's so easy

  4. #4
    MSgt. Shooter Person
    Join Date
    Aug 2011
    Location
    Germany
    Posts
    162

    Default

    While your post is partially true Neongho, nobody really needs tutorials on easy topics like this(even though they seem to help beginners) , but your post does not make much sense either.

    Why would you do it in Pawn? Should every bot that moves around in your level have XP? And even more important, would you check something like this every tick for every pawn? The anwer is no, obviously.
    Something like this should aways be event based. Whenever you get XP, check if you reach next level. There is no need for that to be processed every tick. This is just a waist of cpu time.
    UDK Helicopter | Physics
    UDK Helicopter | Laser Guided Missile System

  5. #5
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Location
    Germany
    Posts
    172

    Default

    @DennyRoket Yes it was supposed to be a dot Sorry
    Well I used your Suggestion and now it gives me the error:" Error, Unexpected 'XP_INCREMENT' "
    My Tutorials and Threads:
    Kismet Timer Tutorial: Here
    Borderlands Teleport Tunnel Effect: Here

    Check out my Website!!!! Athypo Entertainment
    ~Scrapland~

  6. #6
    MSgt. Shooter Person
    Join Date
    Aug 2011
    Location
    Germany
    Posts
    162

    Default

    hav you changed const XP_INCREMENT to var float XP_INCREMENT?
    UDK Helicopter | Physics
    UDK Helicopter | Laser Guided Missile System

  7. #7
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Location
    Germany
    Posts
    172

    Default

    Yes i did:
    It looks like this:
    Code:
    var float XP_INCREMENT;
    XP_INCREMENT = 60*(Level**2.8-1);
    My Tutorials and Threads:
    Kismet Timer Tutorial: Here
    Borderlands Teleport Tunnel Effect: Here

    Check out my Website!!!! Athypo Entertainment
    ~Scrapland~

  8. #8
    MSgt. Shooter Person
    Join Date
    Aug 2011
    Location
    Germany
    Posts
    162

    Default

    where do you use

    Code:
    XP_INCREMENT = 60*(Level**2.8-1);
    ?

    you can not use it outside of functions like you did with the const.

    vars can only be changed in DefaultProperties or inside of functions.
    UDK Helicopter | Physics
    UDK Helicopter | Laser Guided Missile System

  9. #9
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Location
    Germany
    Posts
    172

    Default

    I feel so stupid :FacePalm:
    I didn't put it into the DefaultProperties. Thanks it works.

    Well the Math doesnt really but i get no Errors which is a good start.
    Now:
    The thing it should do is:
    The CurrentLevel to the power of 2.8 -1 and THEN evrything times 60.

    How do i do that?
    My Tutorials and Threads:
    Kismet Timer Tutorial: Here
    Borderlands Teleport Tunnel Effect: Here

    Check out my Website!!!! Athypo Entertainment
    ~Scrapland~

  10. #10
    MSgt. Shooter Person
    Join Date
    Aug 2011
    Location
    Germany
    Posts
    162

    Default

    well you have to use parenthesis:

    Code:
    XP_INCREMENT = 60*(Level**(2.8-1));
    but if that is really what you want, you can also write:

    Code:
    XP_INCREMENT = 60*(Level**1.8);


    BUT, if you really have to ask so simple questions, you should really go few steps back and learn the basics of programming. No offence, but I think what you are trying to achieve might be way out of your range. Problems with overambitious projects is that you can really easily lose confidence and fun when you don't make progress anymore.
    UDK Helicopter | Physics
    UDK Helicopter | Laser Guided Missile System

  11. #11
    Redeemer
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    1,559

    Default

    Then if not every pawn is having XP , wich would be realistic , just add it to player controller

  12. #12
    Redeemer
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    1,559

    Default

    Sorry for flooding or whatver is called.

    Then if not every pawn is having XP , wich would be realistic , just add it to player controller

    well yeah true no need for the tick event to proces the level up

    then how would it be ?? what do you mean wtih event based @DennyRocket please tell me i'd like to learn that : P

    What ( function event whatever ) will be triggered when you get xp if it's not through tick ? ?
    Last edited by Neongho; 08-11-2012 at 10:48 AM.

  13. #13
    Boomshot
    Join Date
    Aug 2011
    Posts
    2,281

    Default

    The original tutorial only caters for a constant xp increment value, which you're now replacing with a proper algorithm. The key thing to learn here is that variables do not do math for you. They only hold values.

    You need a function to perform the math of the algorithm and return the new value to you.

    Code:
    // Calculates xp increment based on the given level
    // Returns the result, to be added to current xp
    
    function float CalculateXPIncrement( int inLevel )
    {
        return 60 * (inLevel ** 1.8 - 1);
    }
    Next delete XP_INCREMENT from your code, to avoid any confusion.

    Finally, wherever you were using XP_INCREMENT replace with...

    Code:
    xp += CalculateXPIncrement(Level);
    @Neongho, where to put the code is not the issue. He already has working code, and just needs to modify the algorithm.

  14. #14
    Redeemer
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    1,559

    Default

    ok , jsut giving ideas , someone really learns when creates it's own stuff , and not following tuts "thats an opinion"

    However , I still want to know what event based means ?? example?¿

    If im not wong , you cannot create new events , those are only for natvie code
    Last edited by Neongho; 08-11-2012 at 11:30 AM.

  15. #15
    Boomshot
    Join Date
    Aug 2011
    Posts
    2,281

    Default

    Quote Originally Posted by Neongho View Post
    However , I still want to know what event based means ?? example?¿

    If im not wong , you cannot create new events , those are only for natvie code
    Correct, you can't create native events.

    But the concept of 'events' is a general idea and can be applied to your own scripting. Any function that is called on demand to handle a situation can be considered an event (however, proper event-based programming involves registering event handlers/listeners, which is much more involved).

    Anyway, the point is that Tick or any kind of real-time checking is unnecessary. The only time the character can level up is when xp increases, so the most optimal way to handle all conditions based on xp is with a dedicated function for adding xp.

    Code:
    // Always use: AddXP(5);
    // Instead of: XP += 5;
    
    function AddXP( float inXP )
    {
        XP += inXP;
    
        // Check for level up
        if( xp >= XPNeededForNextLevel )
        {
            LevelUp();
        }
    }
    
    
    
    // Handle the LevelUp 'event'
    
    function LevelUp()
    {
        if( Level >= LevelCap )
            return;
    
        Level++;
    
        XPNeededForNextLevel = XPNeededForNextLevel * 1.5;
    
        `log("Grats!");
    }

  16. #16
    MSgt. Shooter Person
    Join Date
    Aug 2011
    Location
    Germany
    Posts
    162

    Default

    What I am talking about is just a common design pattern in software engineering(I don't mean unreal event functions, sorry for the confusion). Go look up Observer Pattern, thats pretty much what I mean.

    With event I basically mean anything that happens in the game from time to time(not every tick). Like the LevelUp. You checked if you level up every frame, but most of the time that does not happen(less than 1%). The rest of the time you compute that for no reason.
    The right and more efficient way to this is simple. Whever you call the function that adds XP(e.g. after a kill), you can check if you have enough XP for level up. And then you just call the levelUp function.

    Edit: damn spoof was faster
    UDK Helicopter | Physics
    UDK Helicopter | Laser Guided Missile System

  17. #17
    Redeemer
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    1,559

    Default

    Oh true , so true , because i was thinking of a global variable instead of a funct and var , yeah a funct it's just perfect ... Thanks im defi.. going to do that for my skill up system

  18. #18
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Location
    Germany
    Posts
    172

    Default

    @Spoof
    Ok your Code works. But now when i levelup it gives me Negativ XP.
    So it hast to be a mistake in the CalculateFuntion.
    Code:
    private function CalculateLevelProgress()
    {
    	Local int xpToCurrentLevel;
    	
    	xpToCurrentLevel = 0.5*Level*(Level-1)*CalculateXPIncrement(Level);
    	XPGatheredForNextLevel = XP - xpToCurrentLevel;
    	XPRequiredForNextLevel = Level * CalculateXPIncrement(Level);
    }
    @DennyRoket Yes i know this might be a stupid question.
    I will look some tutorials on UnrealScript. But this question was more detailed so i didnt know where to look for!
    My Tutorials and Threads:
    Kismet Timer Tutorial: Here
    Borderlands Teleport Tunnel Effect: Here

    Check out my Website!!!! Athypo Entertainment
    ~Scrapland~

  19. #19
    Palace Guard

    Join Date
    Jul 2006
    Location
    WorldInfo_61
    Posts
    3,555
    Gamer IDs

    Gamertag: KickedWhoCares

    Default

    xpToCurrentLevel = 0.5*Level*(Level-1)* 60 * (Level ** 1.8 - 1);
    XPGatheredForNextLevel = XP - 0.5*Level*(Level-1)* 60 * (Level ** 1.8 - 1);
    XPRequiredForNextLevel = Level * 60 * (Level ** 1.8 - 1);
    If our Level is 1:

    xpToCurrentLevel = 0.5*1*(1-1)* 60 * (1 ** 1.8 - 1);
    XPGatheredForNextLevel = XP - 0.5*1*(1-1)* 60 * (1 ** 1.8 - 1);
    XPRequiredForNextLevel = 1 * 60 * (1 ** 1.8 - 1);
    So if Im correct:

    xpToCurrentLevel = 0.5*1*(0)* 60 * (0);
    XPGatheredForNextLevel = XP - 0.5*1*(0)* 60 * (0);
    XPRequiredForNextLevel = 1 * 60 * (0);
    Last edited by MonsOlympus; 08-12-2012 at 08:41 AM.
    Got UnrealScript skills?

    BeyondUnreal Wiki
    There's no formula for fun

  20. #20
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Location
    Germany
    Posts
    172

    Default

    This Part is from the Tutorial:
    Code:
    xpToCurrentLevel = 0.5*Level*(Level-1)* XP_INCREMENT;
    	XPGatheredForNextLevel = XP - xpToCurrentLevel;
    	XPRequiredForNextLevel = Level * XP_INCREMENT;
    Now i want it to INcrease by 60 times our Level to the power of 2.8 and then minus 1.
    SO
    Code:
    60*((Level^2.8)-1)
    For Example Level 10:
    Code:
    60*((10*2.8)-1) IS 37,798 (About)
    I'm not sure what the
    Code:
    xpToCurrentLevel = 0.5*Level*(Level-1)*
    does.
    My Tutorials and Threads:
    Kismet Timer Tutorial: Here
    Borderlands Teleport Tunnel Effect: Here

    Check out my Website!!!! Athypo Entertainment
    ~Scrapland~

  21. #21
    Boomshot
    Join Date
    Aug 2011
    Posts
    2,281

    Default

    Quote Originally Posted by scrapland View Post
    @Spoof
    Ok your Code works. But now when i levelup it gives me Negativ XP.
    So it hast to be a mistake in the CalculateFuntion.
    Code:
    private function CalculateLevelProgress()
    {
        Local int xpToCurrentLevel;
        
        xpToCurrentLevel = 0.5*Level*(Level-1)*CalculateXPIncrement(Level);
        XPGatheredForNextLevel = XP - xpToCurrentLevel;
        XPRequiredForNextLevel = Level * CalculateXPIncrement(Level);
    }
    @DennyRoket Yes i know this might be a stupid question.
    I will look some tutorials on UnrealScript. But this question was more detailed so i didnt know where to look for!
    As Mons points out, at level 1 those calcs will evaluate to 0 due to "*(Level-1)". However, the algorithm makes sense when you consider that you don't need any xp to get to level 1 because you start at 1.

    Your progress calc makes me dizzy . I would simplify it down to:

    Code:
    var int Level;
    var float XP;
    
    
    
    // Calculate total xp for a specific level
    function float GetXPForLevel( int inLevel )
    {
        return 60 * ((inLevel ** 2.8) - 1);
    }
    
    
    
    // Get the proportion of progress toward next level
    // Returns unit scalar, 0.0 to 1.0
    function float GetProgress()
    {
        local float current, next, required;
    
        current  = GetXPForLevel(Level);
        next     = GetXPForLevel(Level + 1);
        required = next - current;
    
        return (XP - current) / required;
    }
    
    
    
    DefaultProperties
    {
        Level = 1
    }
    And if you want the amount of xp remaining to level...

    Code:
    function float GetRemainingXP()
    {
        return GetXPForLevel(Level + 1) - XP;
    }
    And also, since we're working on the basis of a target level, the AddXP() function needs to change:

    Code:
    function AddXP( float inXP )
    {
        XP += inXP;
    
        if( XP >= GetXPForLevel(Level + 1) )
        {
            LevelUp();
        }
    }

    EDIT: GetRemainingXP() was wrong, fixed.

  22. #22
    Palace Guard

    Join Date
    Jul 2006
    Location
    WorldInfo_61
    Posts
    3,555
    Gamer IDs

    Gamertag: KickedWhoCares

    Default

    Quote Originally Posted by scrapland View Post
    For Example Level 10:
    Code:
    60*((10*2.8)-1) IS 37,798 (About)
    yes but this only works at level 10, what about level 1? 60*0=0. It ends up being XpRequired for next level is 0 also, which with the while loop in the tutorial is probably sending the whole system bonkers.
    Last edited by MonsOlympus; 08-12-2012 at 11:55 AM.
    Got UnrealScript skills?

    BeyondUnreal Wiki
    There's no formula for fun

  23. #23
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Location
    Germany
    Posts
    172

    Default

    Yes you are right about the Level 1 Thing.
    My Tutorials and Threads:
    Kismet Timer Tutorial: Here
    Borderlands Teleport Tunnel Effect: Here

    Check out my Website!!!! Athypo Entertainment
    ~Scrapland~

  24. #24
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Location
    Germany
    Posts
    172

    Default

    OK Thanks evryone!
    I have a nother question:
    "I want to create different XP Sytsmes (Health, melee, Climbing, agility, strenght etc.)."
    1.How would i trace that?
    2.Would i extend the new Class from the PlayerController class?
    3.Any Ideas?
    My Tutorials and Threads:
    Kismet Timer Tutorial: Here
    Borderlands Teleport Tunnel Effect: Here

    Check out my Website!!!! Athypo Entertainment
    ~Scrapland~

  25. #25
    Redeemer
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    1,559

    Default

    You could make structs ,

    everystruct has the skill name

    And every struct containts 2 vars xp and level

    Or begin an object in default Properties that would be your Class of the Skill system
    i dont know how to do that but it would be gret just like a pawn gets it's own player cotnroller and mesh , get it's Skill System class

    How to do that?
    Last edited by Neongho; 08-12-2012 at 04:26 PM.

  26. #26
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Location
    Germany
    Posts
    172

    Default

    Hmm ok the Idea is a good start!
    I'll look into it!
    My Tutorials and Threads:
    Kismet Timer Tutorial: Here
    Borderlands Teleport Tunnel Effect: Here

    Check out my Website!!!! Athypo Entertainment
    ~Scrapland~

  27. #27
    Redeemer
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    1,559

    Default

    Yes but i don't have freaking idea on how i would attach the XP system in the pawn spawned.

    The main idea it's attach it just like a pawn , spawns and automatically gets his default inventory, his mesh , his PlayerCotnroller or AI controller ...

  28. #28
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Location
    Germany
    Posts
    172

    Default

    Well i already have a basic System for the Pawn. (Look at the beginning of this Thread., its only for kills but maybe one can extend this?)
    Now i have to make "4 more" and make them independent from each other.
    They have to trace the kill or the action and then give Xp.
    My Tutorials and Threads:
    Kismet Timer Tutorial: Here
    Borderlands Teleport Tunnel Effect: Here

    Check out my Website!!!! Athypo Entertainment
    ~Scrapland~

  29. #29
    Redeemer
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    1,559

    Default

    That's just attaching it to the PC

    The question is make a Independent class for the skill system , so you don't make your pawns code fatter than it already is .

    Imagine if you have to set 200 vars for the skill system , because in my case i want more than 100 skills , that would make pawns class a ultra big code, and that's no good.
    Last edited by Neongho; 08-13-2012 at 10:38 AM.

  30. #30
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Location
    Germany
    Posts
    172

    Default

    Hmm you are right.
    Can any one help?
    My Tutorials and Threads:
    Kismet Timer Tutorial: Here
    Borderlands Teleport Tunnel Effect: Here

    Check out my Website!!!! Athypo Entertainment
    ~Scrapland~

  31. #31
    Redeemer
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    1,559

    Default

    That's the idea , spawna class when you spawn a pawn , and that pawn it's gona hold it

    Try this ,

    Code:
     
    
    Create a class 
    
    Class SkillSystem extends Actor; 
    
    Struct FishingSkill
    {
    var XP;
    var level; 
    }
    
    Function RaiseFishingSkill()
    {
    FishingSkill.XP=FishingSkill.XP+1;
    
    if (FishingSkill.XP==10)
    {
    FishingSkill.level=FishingSkill.level+1;
    }
    if (FishingSkill.XP==100)
    {
    FishingSkill.level=FishingSkill.level+1;
    }
    }
    
    Done , with it then
    
    in your pawn class 
    
    Var SkillSystem Skill 
    
    Event PostbeginPlay() 
    {
    Skill=Spawn(class'SkillSystem') 
    }
    
    Simulated Function SomeFunctionThatIt'sInput // i'd say start fire 
    {
    skill.xp.RaiseFishingSkill(); 
    }

  32. #32
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Location
    Germany
    Posts
    172

    Default

    aha ok.
    I will try to use this!
    Last edited by scrapland; 08-14-2012 at 07:48 AM.
    My Tutorials and Threads:
    Kismet Timer Tutorial: Here
    Borderlands Teleport Tunnel Effect: Here

    Check out my Website!!!! Athypo Entertainment
    ~Scrapland~

  33. #33
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Location
    Germany
    Posts
    172

    Default

    Hmm

    I'm not sure: Do we have to create deiffernet classes for evry skill and then use the defaultproperties for the XP and Level definition?
    My Tutorials and Threads:
    Kismet Timer Tutorial: Here
    Borderlands Teleport Tunnel Effect: Here

    Check out my Website!!!! Athypo Entertainment
    ~Scrapland~

  34. #34
    Redeemer
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    1,559

    Default

    It does work it's a independent class that gets attached to the pawn
    No you create a single class having all skills

    By default int value = 0

    Code:
     
    
    class SkillSystem Extends Actor; 
    
    var int  FishingSkillXP 
    var int  OneHandeWeaponSkillXP     //dont use structs as i sugested before , they're not that , good for this.  
    
    Var int  FisshingSillLevel;
    var Int OneHandedWeaponSkillLevel 
    ;
    //create a function that raises the skill xp and eventually if xp it's  alot level up
    
    Function RaisFishingSkill()
    {
    FishingSkilxpl=FishingSkillxp+1;
    
    if(Xp==10)
    {´
    //level up easy
    }
    }
    Then iN your Pawn class

    var SkillsSystem Skills

    .... Spawn it , and add it's function of raising the skill given an output ....
    there is nothing to do with Default Properties .... unless you want your pawn to start with some extra xp , then on skillSystem class , set the the var that you want some value added by default

  35. #35
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    With YourPawn dead you will lose all data... Best place is PlayerReplicationInfo, but PlayerController you can use too...

  36. #36
    Redeemer
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    1,559

    Default

    I still have to take a look to that "replication stuff " thing that i see everywhere , dunno it's functionality

  37. #37
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Location
    Germany
    Posts
    172

    Default

    @Neongho Ok sounds good!
    @VendorX Exactly the stats should be saved even if the pawn dies. So when he respawns he will still be "Level 5" or what ever.
    My Tutorials and Threads:
    Kismet Timer Tutorial: Here
    Borderlands Teleport Tunnel Effect: Here

    Check out my Website!!!! Athypo Entertainment
    ~Scrapland~


 

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.