HLFX.Ru Forum (https://hlfx.ru/forum/index.php)
- Half-Life SDK (https://hlfx.ru/forum/forumdisplay.php?forumid=8)
-- Paranoia punch view. (https://hlfx.ru/forum/showthread.php?threadid=2672)
Отправлено supra36 05-03-2011 в 17:49:
Paranoia punch view.
Hello,
while playing paranoia i was able to see this cool punch view after shoot. I checked out client side of code but i could only see V_PunchAxis with no content in it
Do anyone have idea where to look for it or how to implement it ?
Cheers.
__________________
настоящий мужчина не нуждается в подписи.
Отправлено PLut 05-03-2011 в 18:52:
view.cpp
Near
C++ Source Code:
void V_DropPunchAngle ( float frametime, float *ev_punchangle ); |
Add
C++ Source Code:
void NewPunch ( float *ev_punchangle, float frametime ); |
Then in V_CalcNormalRefdef after line
C++ Source Code:
V_DropPunchAngle ( pparams->frametime, (float *)&ev_punchangle ); |
Add new
C++ Source Code:
NewPunch ( (float *)&ev_punchangle, pparams->frametime ); |
Below V_PunchAxis function add
C++ Source Code:
3 | PLut Client Punch From HL2 |
6 | #define PUNCH_DAMPING 9.0f // bigger number makes the response more damped, smaller is less damped |
7 | // currently the system will overshoot, with larger damping values it won't |
8 | #define PUNCH_SPRING_CONSTANT 65.0f // bigger number increases the speed at which the view corrects |
10 | #define clamp( val, min, max ) ( ((val) > (max)) ? (max) : ( ((val) < (min)) ? (min) : (val) ) ) |
14 | void NewPunch ( float *ev_punchangle, float frametime ) |
17 | float springForceMagnitude; |
19 | if ( Length(ev_punchangle) > 0.001 || Length(punch) > 0.001 ) |
21 | VectorMA(ev_punchangle, frametime, punch, ev_punchangle); |
22 | damping = 1 - (PUNCH_DAMPING * frametime); |
28 | VectorScale(punch, damping, punch); |
31 | // UNDONE: Per-axis spring constant? |
32 | springForceMagnitude = PUNCH_SPRING_CONSTANT * frametime; |
33 | springForceMagnitude = clamp(springForceMagnitude, 0, 2 ); |
35 | VectorMA(punch, -springForceMagnitude, ev_punchangle, punch); |
38 | ev_punchangle[0] = clamp( ev_punchangle[0], -7, 7 ); |
39 | ev_punchangle[1] = clamp( ev_punchangle[1], -179, 179 ); |
40 | ev_punchangle[2] = clamp( ev_punchangle[2], -7, 7 ); |
44 | void Punch( float p, float y, float r ) |
ev_hldm.cpp
Near
C++ Source Code:
void V_PunchAxis( int axis, float punch ); |
Add
C++ Source Code:
void Punch( float p, float y, float r ); |
Uses like server punch:
C++ Source Code:
Put call to Punch function in event.__________________
Base Defense on Steam, ModDB
Отправлено supra36 05-03-2011 в 19:03:
Holy shit, thanks PLut.
You should add it to tutorials sections so it can be usefull for others 
__________________
настоящий мужчина не нуждается в подписи.