HLFX.Ru Forum
Показать все 3 сообщений этой темы на одной странице

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:
1
/*
2
=============
3
PLut Client Punch From HL2
4
=============
5
*/
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
9
 
10
#define clamp( val, min, max ) ( ((val) > (max)) ? (max) : ( ((val) < (min)) ? (min) : (val) ) )
11
 
12
vec3_t punch;
13
 
14
void NewPunch ( float *ev_punchangle, float frametime )
15
{
16
  float damping;
17
  float springForceMagnitude;
18
 
19
  if ( Length(ev_punchangle) > 0.001 || Length(punch) > 0.001 )
20
  {
21
    VectorMA(ev_punchangle, frametime, punch, ev_punchangle);
22
    damping = 1 - (PUNCH_DAMPING * frametime);
23
 
24
    if ( damping < 0 )
25
    {
26
      damping = 0;
27
    }
28
    VectorScale(punch, damping, punch);
29
 
30
    // torsional spring
31
    // UNDONE: Per-axis spring constant?
32
    springForceMagnitude = PUNCH_SPRING_CONSTANT * frametime;
33
    springForceMagnitude = clamp(springForceMagnitude, 0, 2 );
34
 
35
    VectorMA(punch, -springForceMagnitude, ev_punchangle, punch);
36
 
37
    // don't wrap around
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 );
41
  }
42
}
43
 
44
void Punch( float p, float y, float r )
45
{
46
  punch[0] -= p * 20;
47
  punch[1] += y * 20;
48
  punch[2] += r * 20;
49
}


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:
Punch(2.5, -1.7, 0);


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

__________________
настоящий мужчина не нуждается в подписи.


Временная зона GMT. Текущее время 01:25.
Показать все 3 сообщений этой темы на одной странице

На основе vBulletin версии 2.3.0
Авторское право © Jelsoft Enterprises Limited 2000 - 2002.
Дизайн и программирование: Crystice Softworks © 2005 - 2024