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

HLFX.Ru Forum (https://hlfx.ru/forum/index.php)
- XashXT (https://hlfx.ru/forum/forumdisplay.php?forumid=30)
-- Problems with compilation (https://hlfx.ru/forum/showthread.php?threadid=4392)


Отправлено CRxTRDude 11-05-2014 в 05:17:

Half-Life Problems with compilation

Hello again guys. I'm adding various features to the game, so far I added a body damage hud.

This time, I'm going to add a new feature, namely a parachute. I got this from an old tutorial for HL SDK and I want to carry it over to XashXT. I got some of the problems fixed, now the part that boggled me which brings up the question.

Here's the code for the gliding.

C++ Source Code:
1
player.cpp
2
line 1384
3
 
4
void CBasePlayer::ParaGlide( void )
5
{
6
  if (!m_fParachute) {
7
    EMIT_SOUND( "common/wpn_denyselect.wav" );
8
    return;
9
  }
10
  if (m_fParaOpen) {
11
    GetClassPtr((CBasePlayer *)pev)->m_flFallVelocity = 50;
12
    GetClassPtr((CBasePlayer *)pev)->pev->velocity = GetClassPtr((CBasePlayer *)pev)->pev->velocity - 100;
13
  }
14
}


When I compiled the cpp, this came out:

E:\Applications\Xash Source Code\Nikki\server\player.cpp(1392) : error C2666: '-' : 3 overloads have similar conversions


The code has something to do with the long velocity check: GetClassPtr((CBasePlayer *)pev)->pev->velocity = GetClassPtr((CBasePlayer *)pev)->pev->velocity - 100;

I tried to find solutions online, but there's none that helped me. I don't know if you guys can help about this. If you can, I'll truly appreciate that.

If it does matter, I used VC++ 6.0 Standard with no service packs installed for it.

__________________
CRxTRDude
-----------------------
Nikki Shore blog / XashXT Cookbook (CSM)


Отправлено Ku2zoff 11-05-2014 в 08:35:


C++ Source Code:
void [b]CBasePlayer[/b]::ParaGlide( void )

Maybe you should rewrite the code?
C++ Source Code:
GetClassPtr((CBasePlayer *)pev)

Is a piece of shit in this code, i think. You don't need for this.
C++ Source Code:
1
void CBasePlayer::ParaGlide( void )
2
{
3
  if (!m_fParachute)
4
  {
5
    EMIT_SOUND( "common/wpn_denyselect.wav" );
6
    return;
7
  }
8
 
9
  if (m_fParaOpen)
10
  {
11
    m_flFallVelocity = 50;
12
    pev->velocity = pev->velocity - 100;
13
  }
14
}

And next: pev->velocity is a vector. You cannot substract any constant values from it. You can substract values from the components of pev->velocity, such as pev->velocity.x, pev->velocity.y and pev->velocity.z:
C++ Source Code:
pev->velocity = Vector(pev->velocity.x, pev->velocity.y, pev->velocity.z - 100)

IINM
Or more simple, just:
C++ Source Code:
pev->velocity.z -= 100


Добавлено 11-05-2014 в 15:35:

Also, you can add any vector to pev->velocity:
C++ Source Code:
pev->velocity = pev->velocity + gpGlobals->v_up * 100


Отправлено Дядя Миша 11-05-2014 в 09:21:

Цитата:
CRxTRDude писал:
EMIT_SOUND( "common/wpn_denyselect.wav" );

replace with
C++ Source Code:
EMIT_SOUND( (ENT(pev), CHAN_BODY, "common/wpn_denyselect.wav", 0.8, ATTN_NORM );

__________________
My Projects: download page

F.A.Q по XashNT
Блог разработчика в телеграме

Цитата:

C:\DOCUME~1\C4C5~1\LOCALS~1\Temp\a33328if(72) : see declaration of 'size_t'


Отправлено CRxTRDude 11-05-2014 в 10:54:

Ku2zoff, Well, I didn't see that before. I just realized that I'm branching already to CBasePlayer, so there's no need to point. Thanks for the advice. BTW, can I go PM you whenever I have problems codewise?

I also want to ask if there's a way to make hud messages within CBasePlayer or any code for that matter too? I was originally intending to use a hud message if the player doesn't have a chute.

Thanks for the reply guys! I'll check this code now.

BTW,Дядя Миша , is there a rename the first post as solved?

__________________
CRxTRDude
-----------------------
Nikki Shore blog / XashXT Cookbook (CSM)


Отправлено Дядя Миша 11-05-2014 в 11:38:

Цитата:
CRxTRDude писал:
is there a rename the first post as solved?

__________________
My Projects: download page

F.A.Q по XashNT
Блог разработчика в телеграме

Цитата:

C:\DOCUME~1\C4C5~1\LOCALS~1\Temp\a33328if(72) : see declaration of 'size_t'


Отправлено CRxTRDude 12-05-2014 в 05:30:

Hey guys, I got the thing working! It took me last night and today to fix the code after Ku2zoff's fix.

I got a problem with the chute's speed. It keeps on killing me, but I modified the velocity to be halfed by 3/4 and it worked! And I implemented a fully working chute. Just a little modification to the code again to add some sprites whenever the parachute is in effect and when the player picks it up.


Here's another thing that I want to ask. This is for whenever I land on the ground with the parachute on, the parachute is still active.

What part in jump would I place the m_fParaOpen = FALSE parameter in the player.cpp? The jump is kind of convoluted and I don't know where to place.

Thanks again guys!

Добавлено 12-05-2014 в 14:30:

Yeah, i got my own attempt at it in jump, but still doesn't work. I don't have a clue where to put it.

Anyhow, I also want to know aside from disabling the parachute once the player lands on the ground, is there also a way to disable the use of the parachute while still in the ground as well? I know it has something to do with the PlayerUse function as well, since I used it as a trigger for the chute.

Sorry for this one, the edit post was disabled for my post.

__________________
CRxTRDude
-----------------------
Nikki Shore blog / XashXT Cookbook (CSM)


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

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