Forum posts

Posted 2 years ago2021-10-26 17:48:57 UTC
in Setting Player view direction (c++) Post #346009
As someone who's main experience with programming comes from Javascript, I honestly mainly just looked at how stuff like this: VectorAdd ( pparams->viewangles, (float *)&ev_punchangle, pparams->viewangles); was set up and tried to mimic it just to get it to compile properly, I'm not really familiar with working with pointers. Reading up on the * operator though I think I have a better idea of why that's odd.

I figured diving into the HL SDK and attempting to change some stuff would be interesting to try though!
Posted 2 years ago2021-10-26 13:54:32 UTC
in Setting Player view direction (c++) Post #346007
Thanks so much! Got it working.

It's probably not the best method, since I'm extremely unfamiliar with C++, but here's how I ended up doing it:

Define new Vector in view.cpp
Vector ev_permpunchangle;

Create a new function in view.cpp
void V_PermPunchAxis(int axis, float punch) {
ev_permpunchangle[ axis ] = punch;
}

Reference it and use it in ev_hldm.cpp
void V_PermPunchAxis(int axis, float punch);
...
V_PermPunchAxis(0, -5.0);

Add the vectors to cl_viewangles within view.cpp (just stuck this in under the other view kick parts)
VectorAdd ( pparams->cl_viewangles, (float *)&ev_permpunchangle, pparams->cl_viewangles);
*ev_permpunchangle = (0.0, 0.0, 0.0);

Had to zero out the permpunchangle after using it though as otherwise it'd constantly re-add the values and vertically rotate the camera endlessly. Interestingly enough, that still happens for horizontal movement, so I'll need to look into that some more. I also initially made the mistake of trying to add the vector to viewangles, which instead of moving your actual aim point, instead just adds a permanent offset between your aim point and the camera view center.

Thanks again for the help! Definitely would've got stuck on trying to do it server-side.
Posted 2 years ago2021-10-26 08:11:26 UTC
in Setting Player view direction (c++) Post #346005
Think I might be misunderstanding this still. I've set fixangle to 1, which definitely is now allowing the view angle to be modified in some way (thanks!), but I'm getting some odd results.

In weapon firing function
m_pPlayer->pev->fixangle = 1;
m_pPlayer->pev->v_angle.x += 5;

My naïve assumption would be that I would grab the current view x direction and add (or subtract) an arbitrary offset to it. The effect of this in-game however seems to be that it alternates between positive and negative X angles (above / below the horizon line), slowly averaging out to a zero X angle each time the firing function is called.
Posted 2 years ago2021-10-26 06:35:54 UTC
in Setting Player view direction (c++) Post #346003
Hey everyone,

Was messing around with the HL source code for the first time and was digging around in the weapons coding. I managed to modify the amount of view kick the weapon has, which was easy enough, but I got completely hung up on setting a permanent adjustment to the player's viewing angle, rather than just a temporary camera animation. I put in a break point on:

m_pPlayer->pev->v_angle;

and that seems to have the relevant angles, but modifying this vector doesn't seem to have any effect. Anyone got any ideas on where I'm going wrong?