Results 1 to 22 of 22
  1. #1
    Skaarj
    Join Date
    Oct 2009
    Location
    Tempe
    Posts
    12

    Question UIScene Health Datastore

    This doesn't exist. So I'm working on a Total Conversion and I need to make a UI. Seems simple enough except that there is no Data Store for health. Is there an easy way to make a new datastore for health. I've done some digging through code even though I'm not a programmer and found some things that I probably need.

    Pawn has 2 properties, Health and HealthMax. These are the values I need to relay to a data store. Health would be updated when damage is taken and HealthMax would only be updated when a player is selected.

    Pawn is parent of UTPawn, which is the parent of ATPawn, which is the base Pawn class for our game. There is also ATPlayerController, where I put
    Code:
    defaultproperties
    {
    	PlayerOwnerDataStoreClass=ATPlayerOwnerDataStore;
    }
    I also have classes ATPlayerOwnerDataStore and ATPlayerOwnerDataProvider, which I think are important for this. ATPlayerOwnerDataStore is actually a copy+pasted PlayerOwnerDataStore rather than a child, and same goes for ATPlayerOwnerDataProvider.

    Can anyone help me with creating a custom datastore for Health and HealthMax that I can access from the UIScene Data Store list?

    Thanks

  2. #2
    MSgt. Shooter Person
    Join Date
    Oct 2009
    Posts
    85

    Default

    Gosh I wish someone could help you out with this, Displaying current health using UIScene is what i'm hoping to find by searching and not starting a new thread but so far i'm way out of luck

  3. #3

  4. #4
    MSgt. Shooter Person
    Join Date
    Oct 2009
    Posts
    85

    Default

    Mr Evil I appreciate it but I have tried that and it didn't work for me, it doesn't display anything at all. I put the SPlayerReplicationInfo class file in the same Folder as PlayerReplicationInfo and copied your code but perhaps i'm putting the code into the wrong type of widget? I put it into the label under markup string and it doesn't display anything :/

  5. #5
    Boomshot
    Join Date
    Oct 2007
    Location
    UK
    Posts
    2,211

    Default

    Quote Originally Posted by shinji246 View Post
    Mr Evil I appreciate it but I have tried that and it didn't work for me, it doesn't display anything at all. I put the SPlayerReplicationInfo class file in the same Folder as PlayerReplicationInfo and copied your code but perhaps i'm putting the code into the wrong type of widget? I put it into the label under markup string and it doesn't display anything :/
    Your pawns need to actually use the modified PRI, it's not enough to merely put the file in there. The PRI to use is set in the GameInfo's default properties (you do have your own gametype?), like this:
    Code:
    PlayerReplicationInfoClass=class'SPlayerReplicationInfo'

  6. #6
    MSgt. Shooter Person
    Join Date
    Oct 2009
    Posts
    85

    Default

    Okay well now I have it displaying a zero

    However bots are now spawning invisibly and lighting had gotten wonky, whenever i erase that from my custom game type it goes back to working, any ideas?

    Also where do I place the bShouldPerformScriptTick=true?

    Could you be detailed please? I am a huge noob to doing anything not art.

    Sorry to be such a bother/pain in the rear.

  7. #7
    MSgt. Shooter Person
    Join Date
    Oct 2009
    Posts
    85

    Default

    Well I tried putting the Health directly within PlayerReplicationInfo and then I set the it within my custom gameinfo class to the normal PRI, this however caused the same exact problem of invisible bots and black weapons. Now I just erased that line altogether and left the Health within the normal PRI and it's displaying the 0 as well as bots, so i'm getting closer.

    However zero obviously isn't my health, any ideas?

  8. #8
    Boomshot
    Join Date
    Oct 2007
    Location
    UK
    Posts
    2,211

    Default

    Quote Originally Posted by shinji246 View Post
    Well I tried putting the Health directly within PlayerReplicationInfo and then I set the it within my custom gameinfo class to the normal PRI, this however caused the same exact problem of invisible bots and black weapons. Now I just erased that line altogether and left the Health within the normal PRI and it's displaying the 0 as well as bots, so i'm getting closer.

    However zero obviously isn't my health, any ideas?
    If the health is appearing as 0, then perhaps you haven't sent the value of health to the PRI. You need to do that every time the pawn's health changes. This happens in many places, the most important of which is TakeDamage, which you will need to modify to look like this:
    Code:
    function TakeDamage(int Damage, Controller EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser)
    {
    	super.TakeDamage(Damage, EventInstigator, HitLocation, Momentum, DamageType, HitInfo, DamageCauser);
    
    	SPlayerReplicationInfo(PlayerReplicationInfo).SetHealth(Health);
    }
    You will also have to do that when the pawn is initially possessed.

    Your other problems will likely be solved if you change the PRI to extend UTPlayerReplicationInfo instead of just PlayerReplicationInfo.

  9. #9
    MSgt. Shooter Person
    Join Date
    Oct 2009
    Posts
    85

    Default

    I can't find where to put this in the code, it's okay if you want to stop bothering with me, i'm no coder by any means, thanks for your time

  10. #10
    Boomshot
    Join Date
    Oct 2007
    Location
    UK
    Posts
    2,211

    Default

    Quote Originally Posted by shinji246 View Post
    I can't find where to put this in the code, it's okay if you want to stop bothering with me, i'm no coder by any means, thanks for your time
    It would need to go in your pawn class.

    If you don't have a programmer working on your project then you should get one (or go and start reading tutorials and become one yourself), otherwise you'll run into this sort of problem at every step.

  11. #11
    MSgt. Shooter Person
    Join Date
    Oct 2009
    Posts
    85

    Default

    Well I appreciate the advice about the programmer but all I need to do is get the health count working for my UIScene and I can move on to the art assets, I am currently using a Kill counter widget because I know it is actively working as I have used it within a UIScene that I open and close by walking into a trigger volume. I can't get the value to update on my HUD though, I saw your other post about trying to get some code to update on screen and I saw you said it does not work. How did you ever manage to get your Health to update constantly? Finally placing that in my pawn class (which is indeed directed to by my defaultpawnclass) is still leaving me at 0 for my value. I had tried that before asking the question but since it didn't work I had assumed I was wrong.

    It would be great to have a coder to just handle this already so that I can move on and start work on the actual assets but i lack the luxury of one. Want to be hired to do this for me?

  12. #12
    Boomshot
    Join Date
    Oct 2007
    Location
    UK
    Posts
    2,211

    Default

    Quote Originally Posted by shinji246 View Post
    Well I appreciate the advice about the programmer but all I need to do is get the health count working for my UIScene and I can move on to the art assets, I am currently using a Kill counter widget because I know it is actively working as I have used it within a UIScene that I open and close by walking into a trigger volume. I can't get the value to update on my HUD though, I saw your other post about trying to get some code to update on screen and I saw you said it does not work. How did you ever manage to get your Health to update constantly? Finally placing that in my pawn class (which is indeed directed to by my defaultpawnclass) is still leaving me at 0 for my value. I had tried that before asking the question but since it didn't work I had assumed I was wrong.

    It would be great to have a coder to just handle this already so that I can move on and start work on the actual assets but i lack the luxury of one. Want to be hired to do this for me?
    You mentioned bShouldPerformScriptTick earlier, which I think should be the last obstacle for you in this matter. Unfortunately it doesn't seem to be possible for widgets subscribing to the data store to automatically update their values (even though it is possible, it doesn't work in this case). Therefore you need to do something which you should not normally do: Update the value constantly.

    This is the relevant code from my own UIScene that displays health:
    Code:
    class SUIScene_HUD extends UDKUIScene;
    
    var transient UILabel HealthLabel;
    
    function SceneActivated(bool bInitialActivation)
    {
    	super.SceneActivated(bInitialActivation);
    
    	if(bInitialActivation)
    	{
    		HealthLabel = UILabel(FindChild('UILabel_Health', true));
    	}
    }
    
    function TickScene(float DeltaTime)
    {
    	//Forces the UILabel to read the value of health from the data store.
    	HealthLabel.RefreshSubscriberValue();
    }
    
    defaultproperties
    {
    	//This causes TickScene to be called every tick.
    	bShouldPerformScriptTick=true
    }
    And no, I don't want to be hired to do this. Well, not that I don't want to, but I can't because I'm already fully occupied.
    Last edited by Mr Evil; 03-26-2010 at 12:29 PM.

  13. #13
    MSgt. Shooter Person
    Join Date
    Oct 2009
    Posts
    85

    Default

    I'm thinking all of my problems are stemming from perhaps not having the latest version of the UDK as I do not have a UDKUIScene at all and have been having the problem of bShouldPerformScriptTick=true not being recognized this entire time. If it all comes down to just that I feel terrible because I would have had this fixed days ago and without bothering you at all. I'll try and update on how it went

  14. #14
    Boomshot
    Join Date
    Oct 2007
    Location
    UK
    Posts
    2,211

    Default

    Quote Originally Posted by shinji246 View Post
    ...I do not have a UDKUIScene...
    You can extend UTUIScene instead in that case. In fact my UIScene did just that until about 30 seconds before my last post, when I first noticed that UDKUIScene had been added.

  15. #15
    MSgt. Shooter Person
    Join Date
    Oct 2009
    Posts
    85

    Default

    Ok I FINALLY!! (Whoo Hoo) Got it updating the Kill amount as I kill bots! Still getting zero health but about to go about fixing all of that

    As for my other problems they were indeed fixed by extending to UTPlayerReplicationInfo instead of PlayerReplicationInfo

    The reason I didn't do that sooner was because I was getting "SuperClass Not Found" errors and I didn't realize that to extend it from UT i had to move SPlayerReplicationInfo to the UT Classes instead of just the normal classes.

    Thanks so much for this and I hope I will get the Health working soon so I can move on!

    I feel I have learned a ton about UnrealScript thanks to you (i have learned flash 2.0 and maya's MEL scripting before but neither resembled this language very much)
    Last edited by shinji246; 03-26-2010 at 02:58 PM.

  16. #16
    MSgt. Shooter Person
    Join Date
    Oct 2009
    Posts
    85

    Default

    Alright Got it updating the values now when I take damage and I'll just have to figure out how to handle it for when I Spawn like you mentioned, My main Problems (for anyone who comes along) is I had my player on god mode for testing purposes, since it was only updating for takedamage I was taking no damage so it stayed at zero, as soon as I took it off it started updating whenever I would get hit. Luckily I did the Kill Count Widget which I knew worked from the start so that It showed me when the UI was finally updating during play.

    Thank you so very much for your time and Help Mr. Evil, your name contradicts your kindness.

  17. #17
    MSgt. Shooter Person
    Join Date
    Oct 2009
    Posts
    85

    Default

    Okay Mr. Evil I have gotten it refreshing health within all states except for if I kill myself (by accident like damage from a rocket shot too close) and on suicide. I cannot find where UTPawn Handles this sort of damage in order to update it. I am wanting to write a tutorial on what all I have learned but I do not want to do it until I have it working 100%

    Here is my Pawn Class so far.

    Code:
    class DeceitPawn extends UTPawn;
    
    function TakeDamage(int Damage, Controller EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser)
    {
    	super.TakeDamage(Damage, EventInstigator, HitLocation, Momentum, DamageType, HitInfo, DamageCauser);
    
    	SPlayerReplicationInfo(PlayerReplicationInfo).SetHealth(Health);
    		
    
    }
    
    function PossessedBy(Controller C, bool bVehicleTransition)
    {
    	Super.PossessedBy(C, bVehicleTransition);
    
    	SPlayerReplicationInfo(PlayerReplicationInfo).SetHealth(Health);
    }
    
    simulated function EndState(name NextStateName)
    {
    	if (NextStateName != 'Dying')
    	{	
    	SPlayerReplicationInfo(PlayerReplicationInfo).SetHealth(0);
    	}
    
    }
    
    
    
    defaultproperties
    {
    }

  18. #18
    Boomshot
    Join Date
    Oct 2007
    Location
    UK
    Posts
    2,211

    Default

    I came across that exact same problem. It's because the pawn is unpossessed immediately on death, so the obvious solution is to update the health in the UnPossessed function.

  19. #19
    MSgt. Shooter Person
    Join Date
    Oct 2009
    Posts
    85

    Default

    Well I fully realize that but couldn't find unpossessed within UTPawn or even it's parent UDKPawn, only in Pawn. Ideas?

  20. #20
    MSgt. Shooter Person
    Join Date
    Nov 2009
    Posts
    341

    Default

    Declare UnPossessed in your pawn class, making sure to call Super.UnPossessed in your new UnPossessed function. Then you can update whatever you want in it.

  21. #21
    MSgt. Shooter Person
    Join Date
    Oct 2009
    Posts
    85

    Default

    Thanks so much guys I have it finally fully working, I will make a tutorial and hopefully have it up by the end of the day!

  22. #22
    MSgt. Shooter Person
    Join Date
    Oct 2009
    Posts
    85

    Default

    Tutorial is up here

    http://forums.epicgames.com/showthre...1#post27200671

    Couldn't have done it without you guys, if you'd like me to credit you in it (especially Mr. Evil) I would be happy to, just tell me how you'd like to be credited


 

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.