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

HLFX.Ru Forum (https://hlfx.ru/forum/index.php)
- Half-Life SDK (https://hlfx.ru/forum/forumdisplay.php?forumid=8)
-- Очки за убийства монстров. (https://hlfx.ru/forum/showthread.php?threadid=797)


Отправлено NameLesS 24-07-2007 в 16:41:

Half-Life Очки за убийства монстров.

Нашол здесь тутор.Зделал как написано,токо вот компилица с ошибками может есть ошибки в коде?

"Killing Monsters: How to Award Points to Players"

В combat.cpp, найдите:

C++ Source Code:
1
void CBaseMonster :: Killed( entvars_t *pevAttacker, int iGib )
2
{
3
  unsigned int cCount = 0;
4
  BOOL fDone = FALSE;
5
  if ( HasMemory( bits_MEMORY_KILLED ) )
6
  {
7
    if ( ShouldGibMonster( iGib ) )
8
      CallGibMonster();
9
    return;
10
  }
11
  Remember( bits_MEMORY_KILLED );



// Now add this NEW CODE ----------------------------------
// Main points indicated in boldface - see details below
CBaseEntity *ep = CBaseEntity::Instance( pevAttacker );
if ( ep && ep->Classify() == CLASS_PLAYER )
{
CBasePlayer *PK = (CBasePlayer*)ep;
if (FClassnameIs(pev, "monster_hornet")) {/* no points for hornets*/}
else if (FClassnameIs(pev, "monster_alien_controller"))
{
UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s got the drop on %s ... \n",
( pevAttacker->netname && STRING(pevAttacker->netname)[0] != 0 ) ? STRING(pevAttacker->netname) : "unconnected" ), STRING(pev->classname));

PK->AddPoints(5, false);
}
else if (FClassnameIs(pev, "monster_alien_grunt"))
{
UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s eliminated %s ... \n",
( pevAttacker->netname && STRING(pevAttacker->netname)[0] != 0 ) ? STRING(pevAttacker->netname) : "unconnected" ),
STRING(pev->classname));
PK->AddPoints(5, false);
}
else if (FClassnameIs(pev, "monster_alien_slave"))
// ETC ETC. ... check as many different monsters as you like
Else { }
}

Main Points:

Instance::(pevAttacker) ... who is the attacker that killed this monster?
Classify() == CLASS_PLAYER ... is the attacker a player?
*PK ... a pointer to the player who is the attacker
FClassNameIs(pev, "monster_whatever") ... is the Class Name of pev (the killed monster) equal to "monster_whatever"?
UTIL_ClientPrintAll ... prints HUD message to all players -- e.g. "Player_Whoever got the drop on Monster_Whatever"
PK->AddPoints(x,false) ... adds x points to the killer's frag count
Else{ } ... empty default for the end, catch anything that doesn't fit the defined class names


Отправлено XaeroX 27-07-2007 в 06:50:

NameLesS у тебя какие ошибки выдало?

__________________

xaerox on Vivino


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

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