Those Simple "Source Programming Questions" Thread...

Grab your favourite IDE and tinker with the innards of game engines

Re: Those Simple "Source Programming Questions" Thread...

Postby joe_rogers_11155 on Sat Oct 11, 2014 4:50 pm

Thought I might revive this thread since I have finally decided to tackle the programming side of the house. My knowledge of C++ is very limited, as is my knowledge of how the Source engine is written in particular. Please bear with me as I ask the stupid questions and learn more.

I am trying to parent dlights to all kinds of things. Thanks to gary's help, I have successfully parented a dlight to combine orbs fired from the ar2. I am now trying to parent a dlight to the rollermine...I got it to work, sort of. It lights up when the rollermine's sparks turn on, and the light goes out when the rollermine's sparks turn off. My problem is that when the rollermine successfully attacks something, its sparks remain on but the light goes out. The code I modified to make this work is c_npc_rollermine.cpp on the client side. I am looking through some of the other files associated with rollermines to see if there is a different state the NPC enters after a successful attack, but if you guys can provide a bit of guidance because I feel sort of lost.

"Day breaks, but decay soon follows." - Ava Winona
Currently developing in radio silence... 99 Bolts
Here's another project of mine... Assault on Overwatch
Are you new to Source SDK? VDC
Joined: Wed Oct 08, 2008 11:11 pm
Location: United States

Ducking speed tutorial (repost)

Postby GreenPepper on Wed Aug 31, 2016 7:04 pm

I originally made the following post on August 4, 2015 (I happened to find that it had been cached by Google), thought it was worth bringing back:

I did manage to figure out how to change the crouch speed, it turns out I was just searching for the wrong term, it is actually called "Ducking Speed" according to the source code.

It turns out, you can change the "ducking speed" in gamemovement.cpp (surprise, surprise) under "CGameMovement::HandleDuckingSpeedCrop" at line 4306. Just modify the float fraction on line 4310.

Here's an example from my own modification's code:
Code: Select all
void CGameMovement::HandleDuckingSpeedCrop( void )
   if ( !( m_iSpeedCropped & SPEED_CROPPED_DUCK ) && ( player->GetFlags() & FL_DUCKING ) && ( player->GetGroundEntity() != NULL ) )
      float frac = 0.55f; // Modified for athec, originally set to 0.33333333f
      mv->m_flForwardMove   *= frac;
      mv->m_flSideMove   *= frac;
      mv->m_flUpMove      *= frac;
      m_iSpeedCropped      |= SPEED_CROPPED_DUCK;

Remember that whatever speed the player is moving at will be essentially divided by the "float frac" value. In other words, in my modification (Above the Catacombs), the player moves at 115, with a "float frac" of 0.55f, the ducking speed is set to 63.25. The default moving speed in Half-Life 2 is 190 I believe and the default "float frac" (as seen above) is 0.33333333f - making the default ducking speed roughly 63.33.

Kudos to this thread in some old internet archive for pointing me in the right direction:
http://hlcoders.valvesoftware.narkive.c ... ment-speed
Joined: Sun Jun 30, 2013 2:40 am

Return to Programming

Who is online

Users browsing this forum: No registered users