Making Jump take away Aux Power?

Please don't post here unless its in response to an existing topic. New discussion is to be shared in the other forums.

Making Jump take away Aux Power?

Postby Wildfire » Mon Dec 04, 2006 4:40 pm

I was wondering how I could make it so jumping takes away some of the player's stamina (hev auxillary power) and if the player is out of stamina he can't jump until it fills up to the necessary level.
-Wild
Wildfire
New Blood
 
Posts: 35
Joined: Mon Dec 04, 2006 4:36 pm
Location: NM, USA

Postby Bob » Mon Dec 04, 2006 6:01 pm

Bob
Site Admin
 
Posts: 252
Joined: Mon Nov 20, 2006 12:24 am
Location: San Jose California

Postby Wildfire » Fri Dec 08, 2006 10:12 pm

There aren't any functions in that file that look like they are related to jump.

I think a starting point for this might be in gamemovement.cpp in the function bool CGameMovement::CheckJumpButton( void ), but I'm not sure how I can get it to A) check to see if the player has a certain amount of suit power before jumping and B) decrease suit power by fixed amount when player jumps
-Wild
Wildfire
New Blood
 
Posts: 35
Joined: Mon Dec 04, 2006 4:36 pm
Location: NM, USA

Postby Loco » Sat Dec 09, 2006 3:18 pm

edited, my suggestion was crap
Loco
 

my suggestion

Postby Bob » Sat Dec 09, 2006 4:12 pm

In my previous post i directed you to the code associated with how something is using the aux power. In posting those links you were supposed to look at the code and see further into how things like sprinting or the flash light use the aux power.

Most of this is driven by motivation. If you want to make your game come to fruition you cant just follow tutorials and hope it kinda works. You have to put some time into the things you want for your game.
Bob
Site Admin
 
Posts: 252
Joined: Mon Nov 20, 2006 12:24 am
Location: San Jose California

Postby Baer » Sun Dec 10, 2006 7:52 am

I was looking into this earlier this year. What I thought the best way was to use the jump code from the sdk and not hl2mp. In sdk code jump is defined seperately, much like sprinting and flashlight. In mp jump is integrated into the whole codebase. Again this was just my thought and not a final answer. The deal with coding, you review the code, think of different ways it could possibly be changed and then make backups and try it.
Who Me??? I am just nobody.
Baer
Forum Moderator
 
Posts: 18
Joined: Thu Nov 30, 2006 3:02 pm
Location: AR, USA

Postby Wildfire » Sun Dec 10, 2006 11:02 pm

I understand that motivation and effort is required, that is not the problem. I'm not asking for anyone to do this for me, but I am hoping that someone can point me in the right direction and generally make things easier for me.

I only recently learned C, and I'm new to C++, so I don't know a whole lot about classes yet. The code that relates to suit power in c_hl2mp_player.cpp can't be applied to the jump code in gamemovement.cpp. I've spent hours trying different things with it, but the compiler gives me some errors about suitpower not being part of the game movement class.

I have no idea how I would go about putting anything relating to suitpower into gamemovement.cpp where all the jump stuff is. Baer's suggestion seems to make sense though, I will take a look at the from-scratch SDK jump code and see what I can do with that.
-Wild
Wildfire
New Blood
 
Posts: 35
Joined: Mon Dec 04, 2006 4:36 pm
Location: NM, USA

Postby Bob » Sun Dec 10, 2006 11:58 pm

I am pretty swamped at the moment, but i can begin looking into this to help you out. At first glace there are functions in the player class that are handing off the jumping to the movement so it might be a good place to start.

Ill b back in a little bit, once im done posting my filecreator app on the wiki
Bob
Site Admin
 
Posts: 252
Joined: Mon Nov 20, 2006 12:24 am
Location: San Jose California

Postby Bob » Mon Dec 11, 2006 1:44 pm

=(

Sorry i didnt get back to you last night, i was caught up in debugging an app and i didnt get any time to do the searching i needed to. I have an exam tonight so i probably wont do a whole lot of anything tonight either, but i will get on this when i get a chance.

Bear with me.
Bob
Bob
Site Admin
 
Posts: 252
Joined: Mon Nov 20, 2006 12:24 am
Location: San Jose California

Postby Wildfire » Mon Dec 11, 2006 5:01 pm

I've been at it again and found something...

First I included HL2_Player.h for the server dll, then I added this to CGameMovement::CheckJumpButton
Code: Select all
#ifndef CLIENT_DLL
   //don't jump without enough stamina -wildfire
   CBasePlayer *pPlayer = UTIL_PlayerByIndex(1);
   CHL2_Player *pHLPlayer = assert_cast<CHL2_Player*>( pPlayer );

   if ( pHLPlayer->SuitPower_GetCurrentPercentage() > 30 )
      pHLPlayer->SuitPower_Drain( 25 );
   else
      return false;
#endif

It's a little awkward, but so far this will stop you from making a full jump (it still bounces you up a little) if your suitpower is less than or equal 30%, and takes away 25% every time you jump.

This is probably a horrible way to do it, and I'm not really sure if making it server side only will make it not work for clients.
-Wild
Wildfire
New Blood
 
Posts: 35
Joined: Mon Dec 04, 2006 4:36 pm
Location: NM, USA

Postby Bob » Mon Dec 11, 2006 10:20 pm

thats got networking backing it, so no worries i don't think.

Ill be around in a little bit and ill look into it further, but i have to get the stances moved over to the player... ill explain later.
Bob
Site Admin
 
Posts: 252
Joined: Mon Nov 20, 2006 12:24 am
Location: San Jose California

Postby Wildfire » Tue Dec 12, 2006 12:41 pm

Alright, I'm pretty satisfied with the way it works, except for the bouncy client thing.

I'm guessing that when another player jumps without enough stamina, it will show on your screen that he didn't jump, but on his screen, it will look like he bounces up really quick and makes the footsteps sounds even though he's not actually taking off the ground.

If I can get rid of that, I'll be happy with it. We just need to find out where in the client code it detects when the jump key is pressed and does that annoying bounce.
-Wild
Wildfire
New Blood
 
Posts: 35
Joined: Mon Dec 04, 2006 4:36 pm
Location: NM, USA

Postby Wildfire » Tue Dec 12, 2006 10:38 pm

I looked all night and wasn't able to find anything... :(
-Wild
Wildfire
New Blood
 
Posts: 35
Joined: Mon Dec 04, 2006 4:36 pm
Location: NM, USA

Postby Wildfire » Wed Dec 20, 2006 11:58 am

Thanks to Winston from the VERC Coding forums, I have it working exactly how I want it.

At the beginning of gamemovement.cpp:
Code: Select all
#ifndef CLIENT_DLL
#include "HL2_Player.h"
#else
#include "c_basehlplayer.h"
#endif


Then inside CheckJumpButton() function:
Code: Select all
   //don't jump without enough stamina -wildfire
#ifndef CLIENT_DLL
   CHL2_Player *pHLPlayer = assert_cast<CHL2_Player*>( player );

   if ( pHLPlayer->SuitPower_GetCurrentPercentage() > 30 )
      pHLPlayer->SuitPower_Drain( 25 ); //drain stamina for the jump
   else
      return false;
#else
   C_BaseHLPlayer *pHLPlayer = assert_cast<C_BaseHLPlayer*>( player );

   if ( pHLPlayer->m_HL2Local.m_flSuitPower > 30 )
      pHLPlayer->m_HL2Local.m_flSuitPower = max( pHLPlayer->m_HL2Local.m_flSuitPower - 25, 0 ); //drain stamina for the jump
   else
      return false;
#endif


There are a few more things you can do to visually improve the aux power meter so it turns red when you can't jump and shows Stamina instead of Aux Power, so I think I will put up a tutorial on the Wiki soon.
-Wild
Wildfire
New Blood
 
Posts: 35
Joined: Mon Dec 04, 2006 4:36 pm
Location: NM, USA

Postby Bob » Wed Dec 20, 2006 12:09 pm

Thats great news. You guys may have noticed that i haven't moved the prone tutorial over yet...

Wait until my stances are finished.
Bob
Site Admin
 
Posts: 252
Joined: Mon Nov 20, 2006 12:24 am
Location: San Jose California

Postby Wildfire » Wed Dec 20, 2006 5:57 pm

-Wild
Wildfire
New Blood
 
Posts: 35
Joined: Mon Dec 04, 2006 4:36 pm
Location: NM, USA

Postby Loco » Sat Dec 23, 2006 5:01 pm

Where can you change how faster it recharges?
Loco
 


Return to Unsorted Old Posts

Who is online

Users browsing this forum: No registered users and 1 guest

cron