Browse Source

Lock spawnpoints to maps, new interface, touch menu

hlzbot-dirty
mittorn 8 years ago
parent
commit
aa34fcb8c1
  1. 39
      dlls/client.cpp
  2. 1
      dlls/gamerules.cpp
  3. 51
      dlls/h_export.cpp
  4. 5
      dlls/items.cpp
  5. 26
      dlls/multiplay_gamerules.cpp
  6. 24
      dlls/player.cpp
  7. 1
      dlls/player.h
  8. 4
      dlls/subs.cpp
  9. 80
      dlls/triggers.cpp

39
dlls/client.cpp

@ -207,6 +207,7 @@ void ClientPutInServer( edict_t *pEntity )
pPlayer->pev->iuser1 = 0; pPlayer->pev->iuser1 = 0;
pPlayer->pev->iuser2 = 0; pPlayer->pev->iuser2 = 0;
g_engfuncs.pfnQueryClientCvarValue2( pEntity, "touch_enable", 111 );
} }
@ -375,7 +376,6 @@ void Host_Say( edict_t *pEntity, int teamonly )
} }
} }
/* /*
=========== ===========
ClientCommand ClientCommand
@ -503,6 +503,31 @@ void ClientCommand( edict_t *pEntity )
if ( mp_coop.value ) if ( mp_coop.value )
UTIL_CleanSpawnPoint( pev->origin, 150 ); UTIL_CleanSpawnPoint( pev->origin, 150 );
} }
else if( FStrEq(pcmd, "m1"))
{
#define MENU_STR(VAR) (#VAR)
CLIENT_COMMAND( pEntity,
MENU_STR(touch_addbutton "_coops" "*black" "" 0.15 0.1 0.4 0.72 0 0 0 128 334\ntouch_addbutton "_coopst" "#COOP MENU" "" 0.16 0.11 0.41 0.3 0 255 0 255 78 1.5\nm2\n)
);
}
else if( FStrEq(pcmd, "m2"))
{
CLIENT_COMMAND( pEntity,
MENU_STR(touch_addbutton "_coops1" "#1. Join coop" "menuselect 1;touch_hide _coops*" 0.16 0.21 0.39 0.3 255 255 255 255 334 1.5\ntouch_addbutton "_coops2" "#2. Become spectator" "menuselect 2;touch_hide _coops*" 0.16 0.31 0.39 0.4 255 255 255 255 334 1.5\nm3\n)
);
}
else if( FStrEq(pcmd, "m3"))
{
CLIENT_COMMAND( pEntity,
MENU_STR(touch_addbutton "_coops3" "#" "menuselect 3;touch_hide _coops*" 0.16 0.41 0.39 0.5 255 255 255 255 335 1.5\ntouch_addbutton "_coops4" "#" "menuselect 4;touch_hide _coops*" 0.16 0.51 0.39 0.6 255 255 255 255 335 1.5\nm4\n)
);
}
else if( FStrEq(pcmd, "m4"))
{
CLIENT_COMMAND( pEntity,
MENU_STR(touch_addbutton "_coops5" "#" "menuselect 5;touch_hide _coops*" 0.16 0.61 0.39 0.7 255 255 255 255 335 1.5;wait;slot10\n)
);
}
else else
{ {
// tell the user they entered an unknown command // tell the user they entered an unknown command
@ -1812,6 +1837,18 @@ void CreateInstancedBaselines ( void )
//UTIL_Remove( pc ); //UTIL_Remove( pc );
} }
void CvarValue2( const edict_t *pEnt, int requestID, const char *cvarName, const char *value )
{
if( pEnt && requestID == 111 && FStrEq( cvarName , "touch_enable" ) && atoi( value) )
{
CBasePlayer *player = (CBasePlayer * ) CBaseEntity::Instance( (edict_t*)pEnt );
player->m_fTouchMenu = !!atof( value );
CLIENT_COMMAND((edict_t*)pEnt, "touch_addbutton \"_coopm\" \"*black\" \"coopmenu\" 0 0.77 0.15 0.83 0 0 0 128 335\ntouch_addbutton \"_coopmt\" \"#COOP MENU\" \"\" 0 0.77 0.16 0.83 255 255 127 255 79 2\nm1\n");
}
}
/* /*
================================ ================================
InconsistentFile InconsistentFile

1
dlls/gamerules.cpp

@ -93,6 +93,7 @@ edict_t *CGameRules::GetPlayerSpawnSpot( CBasePlayer *pPlayer )
pPlayer->pev->velocity = g_vecZero; pPlayer->pev->velocity = g_vecZero;
pPlayer->pev->angles = VARS( pentSpawnSpot )->angles; pPlayer->pev->angles = VARS( pentSpawnSpot )->angles;
pPlayer->pev->punchangle = g_vecZero; pPlayer->pev->punchangle = g_vecZero;
if( !(pPlayer->pev->flags & FL_SPECTATOR ) )
if( mp_coop_changelevel.value && !CoopRestorePlayerCoords( pPlayer, &pPlayer->pev->origin, &pPlayer->pev->angles )) if( mp_coop_changelevel.value && !CoopRestorePlayerCoords( pPlayer, &pPlayer->pev->origin, &pPlayer->pev->angles ))
CoopGetSpawnPoint( &pPlayer->pev->origin, &pPlayer->pev->angles ); CoopGetSpawnPoint( &pPlayer->pev->origin, &pPlayer->pev->angles );
pPlayer->pev->fixangle = TRUE; pPlayer->pev->fixangle = TRUE;

51
dlls/h_export.cpp

@ -55,3 +55,54 @@ extern "C" void DLLEXPORT EXPORT2 GiveFnptrsToDll( enginefuncs_t *pengfuncsFromE
memcpy( &g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t) ); memcpy( &g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t) );
gpGlobals = pGlobals; gpGlobals = pGlobals;
} }
int ShouldCollide( edict_t *pentTouched, edict_t *pentOther )
{
return 1;
}
void OnFreeEntPrivateData(edict_s *pEdict)
{
#if 0
if(pEdict && pEdict->pvPrivateData)
{
((CBaseEntity*)pEdict->pvPrivateData)->~CBaseEntity();
}
#endif
}
void GameShutdown(void)
{
}
void CvarValue( const edict_t *pEnt, const char *value )
{
}
void CvarValue2( const edict_t *pEnt, int requestID, const char *cvarName, const char *value );
NEW_DLL_FUNCTIONS gNewDLLFunctions =
{
OnFreeEntPrivateData, //pfnOnFreeEntPrivateData
GameShutdown, //pfnGameShutdown
ShouldCollide, //pfnShouldCollide
CvarValue,
CvarValue2
};
extern "C" int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion)
{
if(!pFunctionTable || *interfaceVersion != NEW_DLL_FUNCTIONS_VERSION)
{
*interfaceVersion = NEW_DLL_FUNCTIONS_VERSION;
return FALSE;
}
memcpy(pFunctionTable, &gNewDLLFunctions, sizeof(gNewDLLFunctions));
return TRUE;
}

5
dlls/items.cpp

@ -261,11 +261,14 @@ class CItemSuit : public CItem
if( !mp_coop.value && pPlayer->pev->weapons & ( 1<<WEAPON_SUIT ) ) if( !mp_coop.value && pPlayer->pev->weapons & ( 1<<WEAPON_SUIT ) )
return FALSE; return FALSE;
// no sounds in coop
if( !mp_coop.value )
{
if( pev->spawnflags & SF_SUIT_SHORTLOGON ) if( pev->spawnflags & SF_SUIT_SHORTLOGON )
EMIT_SOUND_SUIT( pPlayer->edict(), "!HEV_A0" ); // short version of suit logon, EMIT_SOUND_SUIT( pPlayer->edict(), "!HEV_A0" ); // short version of suit logon,
else else
EMIT_SOUND_SUIT( pPlayer->edict(), "!HEV_AAx" ); // long version of suit logon EMIT_SOUND_SUIT( pPlayer->edict(), "!HEV_AAx" ); // long version of suit logon
}
pPlayer->pev->weapons |= ( 1 << WEAPON_SUIT ); pPlayer->pev->weapons |= ( 1 << WEAPON_SUIT );
return TRUE; return TRUE;
} }

26
dlls/multiplay_gamerules.cpp

@ -121,6 +121,7 @@ void SpawnPlayer( CBasePlayer *pPlayer )
pPlayer->pev->flags &= ~FL_SPECTATOR; pPlayer->pev->flags &= ~FL_SPECTATOR;
pPlayer->pev->movetype = MOVETYPE_WALK; pPlayer->pev->movetype = MOVETYPE_WALK;
pPlayer->Spawn(); pPlayer->Spawn();
CLIENT_COMMAND( pPlayer->edict(), "touch_show _coopm*\n" );
} }
@ -128,6 +129,20 @@ extern int gmsgShowMenu;
void ShowMenu( CBasePlayer *pPlayer, const char *title, int count, const char **slot, signed char time = -1 ) void ShowMenu( CBasePlayer *pPlayer, const char *title, int count, const char **slot, signed char time = -1 )
{ {
if( pPlayer->m_fTouchMenu)
{
char buf[256];
#define MENU_STR(VAR) (#VAR)
sprintf( buf, MENU_STR(slot10\ntouch_hide _coops*\ntouch_show _coops\ntouch_addbutton "_coopst" "#%s" "" 0.16 0.11 0.41 0.3 0 255 0 255 78 1.5\n), title);
CLIENT_COMMAND( pPlayer->edict(), buf);
for( int i = 0; i < count; i++ )
{
sprintf( buf, MENU_STR(touch_settexture _coops%d "#%d. %s"\ntouch_show _coops%d\n), i+1, i+1, slot[i], i + 1 );
CLIENT_COMMAND( pPlayer->edict(), buf);
}
}
else
{
char buf[128], *pbuf = buf; char buf[128], *pbuf = buf;
short int flags = 1<<9; short int flags = 1<<9;
pbuf += sprintf( pbuf, "^2%s:\n", title ); pbuf += sprintf( pbuf, "^2%s:\n", title );
@ -142,7 +157,8 @@ void ShowMenu( CBasePlayer *pPlayer, const char *title, int count, const char **
WRITE_BYTE( 0 ); // need more WRITE_BYTE( 0 ); // need more
WRITE_STRING( buf ); WRITE_STRING( buf );
MESSAGE_END(); MESSAGE_END();
CLIENT_COMMAND( pPlayer->edict(), "exec touch_default/numbers.cfg\n"); }
//CLIENT_COMMAND( pPlayer->edict(), "exec touch_default/numbers.cfg\n");
} }
void CoopMenu( CBasePlayer *pPlayer ); void CoopMenu( CBasePlayer *pPlayer );
@ -229,11 +245,14 @@ BOOL CHalfLifeMultiplay::ClientCommand( CBasePlayer *pPlayer, const char *pcmd )
if( imenu == 1 ) if( imenu == 1 )
{ {
SpawnPlayer( pPlayer ); SpawnPlayer( pPlayer );
pPlayer->m_state = STATE_SPAWNED;
} }
if( imenu == 2 ) if( imenu == 2 )
{ {
pPlayer->m_state = STATE_SPECTATOR; pPlayer->m_state = STATE_SPECTATOR;
CLIENT_COMMAND( pPlayer->edict(), "touch_show _coopm*\n" );
} }
break;
case STATE_SPAWNED: case STATE_SPAWNED:
if( g_iMenu ) if( g_iMenu )
{ {
@ -242,6 +261,7 @@ BOOL CHalfLifeMultiplay::ClientCommand( CBasePlayer *pPlayer, const char *pcmd )
} }
if( imenu == 1 ) if( imenu == 1 )
{ {
pPlayer->RemoveAllItems( TRUE );
SpawnPlayer( pPlayer ); SpawnPlayer( pPlayer );
} }
if( imenu == 2 ) if( imenu == 2 )
@ -252,6 +272,7 @@ BOOL CHalfLifeMultiplay::ClientCommand( CBasePlayer *pPlayer, const char *pcmd )
{ {
pPlayer->RemoveAllItems( TRUE ); pPlayer->RemoveAllItems( TRUE );
BecomeSpectator( pPlayer ); BecomeSpectator( pPlayer );
pPlayer->m_state = STATE_SPECTATOR;
} }
if( imenu == 4 ) if( imenu == 4 )
{ {
@ -726,7 +747,7 @@ void CHalfLifeMultiplay::PlayerThink( CBasePlayer *pPlayer )
pPlayer->m_afButtonReleased = 0; pPlayer->m_afButtonReleased = 0;
} }
} }
extern EHANDLE g_pLastSpawn;
//========================================================= //=========================================================
//========================================================= //=========================================================
void CHalfLifeMultiplay::PlayerSpawn( CBasePlayer *pPlayer ) void CHalfLifeMultiplay::PlayerSpawn( CBasePlayer *pPlayer )
@ -737,6 +758,7 @@ void CHalfLifeMultiplay::PlayerSpawn( CBasePlayer *pPlayer )
if( pPlayer->m_state == STATE_CONNECTED ) if( pPlayer->m_state == STATE_CONNECTED )
{ {
pPlayer->m_state = STATE_SPECTATOR_BEGIN; pPlayer->m_state = STATE_SPECTATOR_BEGIN;
pPlayer->RemoveAllItems( TRUE );
BecomeSpectator( pPlayer ); BecomeSpectator( pPlayer );
return; return;
} }

24
dlls/player.cpp

@ -2684,8 +2684,19 @@ edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer )
while( pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_start" ) ) while( pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_start" ) )
{ {
TraceResult tr; TraceResult tr;
if( FNullEnt( pSpot ) )
continue;
// only spawnpoints from current map are valid
if( !FStrEq( STRING( pSpot->pev->netname ), STRING( gpGlobals->mapname ) ) )
continue;
// check if it is placed in wall
UTIL_TraceHull( pSpot->pev->origin, pSpot->pev->origin , missile, human_hull, NULL, &tr ); UTIL_TraceHull( pSpot->pev->origin, pSpot->pev->origin , missile, human_hull, NULL, &tr );
if( !tr.fStartSolid && !tr.fAllSolid && !FNullEnt( pSpot ) ) if( tr.fStartSolid || tr.fAllSolid )
continue;
// trace down to find if there is no floor
UTIL_TraceHull( pSpot->pev->origin, pSpot->pev->origin - Vector( 0, 0, -200 ) , missile, human_hull, NULL, &tr );
if( tr.vecEndPos.z - pSpot->pev->origin.z < -190 )
continue;
goto ReturnSpot; goto ReturnSpot;
} }
} }
@ -2869,9 +2880,12 @@ void CBasePlayer::RenewItems( void )
int CBasePlayer::Restore( CRestore &restore ) int CBasePlayer::Restore( CRestore &restore )
{ {
if( !CBaseMonster::Restore( restore ) ) if( !CBaseMonster::Restore( restore ) )
return 0; return 0;
int status = restore.ReadFields( "PLAYER", this, m_playerSaveData, ARRAYSIZE( m_playerSaveData ) ); int status = restore.ReadFields( "PLAYER", this, m_playerSaveData, ARRAYSIZE( m_playerSaveData ) );
SAVERESTOREDATA *pSaveData = (SAVERESTOREDATA *)gpGlobals->pSaveData; SAVERESTOREDATA *pSaveData = (SAVERESTOREDATA *)gpGlobals->pSaveData;
@ -2926,6 +2940,14 @@ int CBasePlayer::Restore( CRestore &restore )
// Barring that, we clear it out here instead of using the incorrect restored time value. // Barring that, we clear it out here instead of using the incorrect restored time value.
m_flNextAttack = UTIL_WeaponTimeBase(); m_flNextAttack = UTIL_WeaponTimeBase();
#endif #endif
// restored player has some bugs untill respawned
if( mp_coop_changelevel.value )
{
m_state = STATE_CONNECTED;
SetThink( &CBasePlayer::Spawn );
pev->nextthink = gpGlobals->time + 0.5;
}
return status; return status;
} }

1
dlls/player.h

@ -321,6 +321,7 @@ public:
virtual float TouchGravGun( CBaseEntity *attacker, int stage ); virtual float TouchGravGun( CBaseEntity *attacker, int stage );
float m_flSpawnTime; float m_flSpawnTime;
PlayerState m_state; PlayerState m_state;
bool m_fTouchMenu;
}; };
#define AUTOAIM_2DEGREES 0.0348994967025 #define AUTOAIM_2DEGREES 0.0348994967025

4
dlls/subs.cpp

@ -68,6 +68,10 @@ class CBasePlayerStart : public CPointEntity
public: public:
// prevent transition as FCAP_ACROSS_TRANSITION does not help // prevent transition as FCAP_ACROSS_TRANSITION does not help
//virtual int ObjectCaps( void ) { return CPointEntity::ObjectCaps() | FCAP_DONT_SAVE; } //virtual int ObjectCaps( void ) { return CPointEntity::ObjectCaps() | FCAP_DONT_SAVE; }
void Spawn()
{
pev->netname = gpGlobals->mapname;
}
private: private:
}; };

80
dlls/triggers.cpp

@ -1425,27 +1425,6 @@ void CChangeLevel::Spawn( void )
//ALERT( at_console, "TRANSITION: %s (%s)\n", m_szMapName, m_szLandmarkName ); //ALERT( at_console, "TRANSITION: %s (%s)\n", m_szMapName, m_szLandmarkName );
} }
void CChangeLevel::UpdateColor( void )
{
Vector origin = VecBModelOrigin(pev);
Vector point, angles;
CBaseEntity *pPlayer;
pev->nextthink = gpGlobals->time + 30;
if( !m_fIsBack && (pPlayer = UTIL_FindEntityByClassname( NULL, "info_player_start" )) )
if( (origin - pPlayer->pev->origin).Length() < 500 )
m_fIsBack = true;
if( !m_fIsBack && CoopGetSpawnPoint( &point, &angles ) )
if( (origin - point).Length() < 500 )
m_fIsBack = true;
pev->rendercolor.x = 0;
if( m_fIsBack )
pev->rendercolor.z = 255;
else
pev->rendercolor.y = 255;
}
void CChangeLevel::ExecuteChangeLevel( void ) void CChangeLevel::ExecuteChangeLevel( void )
{ {
MESSAGE_BEGIN( MSG_ALL, SVC_CDTRACK ); MESSAGE_BEGIN( MSG_ALL, SVC_CDTRACK );
@ -1642,6 +1621,34 @@ public:
}; };
GlobalMenu g_GlobalMenu; GlobalMenu g_GlobalMenu;
void CChangeLevel::UpdateColor( void )
{
Vector origin = VecBModelOrigin(pev);
Vector point, angles;
CBaseEntity *pPlayer;
pev->nextthink = gpGlobals->time + 30;
if( !m_fIsBack && (pPlayer = UTIL_FindEntityByClassname( NULL, "info_player_start" )) )
if( (origin - pPlayer->pev->origin).Length() < 500 )
m_fIsBack = true;
if( !m_fIsBack && CoopGetSpawnPoint( &point, &angles ) )
if( (origin - point).Length() < 500 )
m_fIsBack = true;
pev->rendercolor = g_vecZero;
if( m_fIsBack )
pev->rendercolor.z = 255;
else
pev->rendercolor.y = 255;
if( gpGlobals->time - g_GlobalMenu.m_flTime > 30 )
{
g_iMenu = 0;
g_GlobalMenu.m_iConfirm = 0;
}
}
void CoopVoteMenu( CBasePlayer *pPlayer ) void CoopVoteMenu( CBasePlayer *pPlayer )
{ {
int count = 0; int count = 0;
@ -1746,12 +1753,14 @@ bool CoopGetSpawnPoint( Vector *origin, Vector *angles)
if( g_SavedCoords.trainsaved ) if( g_SavedCoords.trainsaved )
{ {
CBaseEntity *train = UTIL_FindEntityByString( NULL, "globalname", g_SavedCoords.trainglobal ); CBaseEntity *train = UTIL_FindEntityByString( NULL, "globalname", g_SavedCoords.trainglobal );
if( !train ) train = UTIL_FindEntityByString( NULL, "classname", g_SavedCoords.trainglobal );
if( train ) if( train )
{ {
*angles = g_SavedCoords.triggerangles; *angles = g_SavedCoords.triggerangles;
*origin = VecBModelOrigin(train->pev) + g_SavedCoords.trainoffset; *origin = VecBModelOrigin(train->pev) + g_SavedCoords.trainoffset;
return true; return true;
} }
ALERT( at_console, "Failed to get train %s (map design error?)\n", g_SavedCoords.trainglobal );
} }
Vector point = g_SavedCoords.triggerorigin; Vector point = g_SavedCoords.triggerorigin;
*angles = g_SavedCoords.triggerangles; *angles = g_SavedCoords.triggerangles;
@ -1769,11 +1778,13 @@ bool CoopGetSpawnPoint( Vector *origin, Vector *angles)
{ {
g_SavedCoords.triggerorigin = tr.vecEndPos; g_SavedCoords.triggerorigin = tr.vecEndPos;
g_SavedCoords.validspawnpoint = true; g_SavedCoords.validspawnpoint = true;
if( tr.pHit && FClassnameIs( tr.pHit, "func_door" ) )
tr.pHit->v.solid = SOLID_NOT;
} }
else else
{ {
g_SavedCoords.valid = false; g_SavedCoords.valid = false;
ALERT( at_console, "CoopGetSpawnPoint: trace failed"); ALERT( at_console, "CoopGetSpawnPoint: trace failed\n");
return false; return false;
} }
} }
@ -1807,12 +1818,17 @@ void CoopSaveTrain( CBaseEntity *pPlayer, SavedCoords *coords)
CBaseEntity *train = CoopGetPlayerTrain(pPlayer); CBaseEntity *train = CoopGetPlayerTrain(pPlayer);
if( !train ) if( !train )
{
ALERT( at_console, "^1NO TRAIN!\n");
return; return;
}
ALERT( at_console, "^1TRAIN IS %s", STRING( train->pev->classname ) );
strcpy( coords->trainglobal, STRING(train->pev->globalname) ); strcpy( coords->trainglobal, STRING(train->pev->globalname) );
coords->trainoffset = pPlayer->pev->origin - VecBModelOrigin(train->pev); coords->trainoffset = pPlayer->pev->origin - VecBModelOrigin(train->pev);
coords->trainsaved = true; coords->trainsaved = true;
} }
void BecomeSpectator( CBasePlayer *pPlayer );
void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator ) void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator )
{ {
edict_t *pentLandmark; edict_t *pentLandmark;
@ -1922,6 +1938,11 @@ void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator )
if( m_fIsBack ) if( m_fIsBack )
{ {
if( gpGlobals->time - g_GlobalMenu.m_flTime > 30 )
{
g_iMenu = 0;
g_GlobalMenu.m_iConfirm = 0;
}
if( g_iMenu != 1 ) if( g_iMenu != 1 )
{ {
g_GlobalMenu.ConfirmMenu( this, m_szMapName ); g_GlobalMenu.ConfirmMenu( this, m_szMapName );
@ -2014,6 +2035,19 @@ void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator )
//ALERT( at_console, "Level touches %d levels\n", ChangeList( levels, 16 ) ); //ALERT( at_console, "Level touches %d levels\n", ChangeList( levels, 16 ) );
ALERT( at_console, "CHANGE LEVEL: %s %s\n", st_szNextMap, st_szNextSpot ); ALERT( at_console, "CHANGE LEVEL: %s %s\n", st_szNextMap, st_szNextSpot );
// loop through all clients, count number of players
for( int i = 1; i <= gpGlobals->maxClients; i++ )
{
CBasePlayer *plr = (CBasePlayer*)UTIL_PlayerByIndex( i );
// reset all players state
if( plr )
{
plr->m_state = STATE_CONNECTED;
plr->RemoveAllItems( TRUE );
BecomeSpectator( plr );
}
}
CHANGE_LEVEL( st_szNextMap, st_szNextSpot ); CHANGE_LEVEL( st_szNextMap, st_szNextSpot );
} }

Loading…
Cancel
Save