NewsUnrealEdFilesModsFragBULiandri Archives
BeyondUnreal Forums

Go Back   BeyondUnreal Forums > Unreal Development > Coding

Reply
 
Thread Tools Display Modes
Old 23rd Mar 2011, 12:57 PM   #1
BeefyPoopStain
Registered User
 
Join Date: Mar. 23rd, 2011
Posts: 2
Stamina system?

My friend and I are developing a zombie-survival game with UDK, and we're working on implementing some melee weapons. We would like for the player to lose some stamina when swinging a baseball bat, but we're not quite sure where that would be handled programmatically - we were thinking probably the InventoryManager class, since that interfaces with a pawn and handles the firing functions. I'm just not sure how to go about adding the functionality, and any help or a nudge in the right direction would be much appreciated.
BeefyPoopStain is offline   Reply With Quote
Old 23rd Mar 2011, 02:22 PM   #2
Angel_Mapper
Noblesse Oblige
 
Angel_Mapper's Avatar
 
Join Date: Jun. 17th, 2001
Location: Cape Suzette
Posts: 3,524
That would probably be better in the PlayerController class. As an example, you could have a float Stamina there which defaults to 1. Every Tick it checks to see if it's less than 1 and increases it by doing:
Code:
Stamina += RecoveryRate * DeltaTime;
RecoveryRate is a var you would define.

Then using:
Code:
FMin(Stamina, 1.0);
To make sure it doesn't go over 1. Then as the player uses their melee weapon it would decrease Stamina by that melee weapon's StaminaReduction (a var you would add to your melee weapon class) by doing something like:
Code:
Stamina -= MyMeleeWeaponClass(Pawn.Weapon).StaminaReduction;
MyMeleeWeaponClass would be an abstract class all your melee weapons would subclass from.

Then, before you allow the player to use a melee attack you would check to make sure Stamina was greater than a certain amount (0.0 for example).

Hope this helps!

Last edited by Angel_Mapper; 23rd Mar 2011 at 02:26 PM.
Angel_Mapper is offline   Reply With Quote
Old 23rd Mar 2011, 02:47 PM   #3
BeefyPoopStain
Registered User
 
Join Date: Mar. 23rd, 2011
Posts: 2
That does help a lot, but I'm still wondering how the firing functions are accessible in the PlayerController class. There's not a lot of documentation that we could find concerning appending functionality onto the firing procedures, and the reason we were looking at the InvManager class is because it seemed to sort of bridge the gap between the weapon and the pawn and handle the firing functions.
BeefyPoopStain is offline   Reply With Quote
Old 23rd Mar 2011, 04:07 PM   #4
Angel_Mapper
Noblesse Oblige
 
Angel_Mapper's Avatar
 
Join Date: Jun. 17th, 2001
Location: Cape Suzette
Posts: 3,524
You could put this in the Pawn class instead and work directly in the StartFire and StartAltFire functions there.

As for documentation, there is no better documentation than the source files themselves. I'd recommend reading through Object.uc, Actor.uc, GameInfo.uc and the Controller and Pawn classes to get an idea of the functionality that's available to you. Literally just sit down and read them.

Last edited by Angel_Mapper; 23rd Mar 2011 at 04:09 PM.
Angel_Mapper is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 06:32 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.

Copyright ©1998 - 2012, BeyondUnreal, Inc.
Privacy Policy | Terms of Use
Bandwidth provided by AtomicGamer