mirror of
https://github.com/ENSL/NS.git
synced 2024-11-10 07:11:38 +00:00
o Fixed hive +use
o Redemption prioritises hives under attack last. git-svn-id: https://unknownworlds.svn.cloudforge.com/ns1@436 67975925-1194-0748-b3d5-c16f83f1a3a1
This commit is contained in:
parent
96709be82c
commit
0c118de14d
2 changed files with 122 additions and 47 deletions
|
@ -92,6 +92,7 @@
|
|||
#include "game.h"
|
||||
#include "common/hltv.h"
|
||||
#include "mod/AvHNetworkMessages.h"
|
||||
#include "util/MathUtil.h"
|
||||
|
||||
// #define DUCKFIX
|
||||
|
||||
|
@ -1778,30 +1779,66 @@ void CBasePlayer::PlayerUse ( void )
|
|||
|
||||
UTIL_MakeVectors ( pev->v_angle );// so we know which way we are facing
|
||||
|
||||
while ((pObject = UTIL_FindEntityInSphere( pObject, pev->origin, PLAYER_SEARCH_RADIUS )) != NULL)
|
||||
{
|
||||
|
||||
if (pObject->ObjectCaps() & (FCAP_IMPULSE_USE | FCAP_CONTINUOUS_USE | FCAP_ONOFF_USE))
|
||||
if ( AvHGetIsAlien(this->pev->iuser3) ) {
|
||||
while ((pObject = UTIL_FindEntityInSphere( pObject, pev->origin, PLAYER_SEARCH_RADIUS*3)) != NULL)
|
||||
{
|
||||
// !!!PERFORMANCE- should this check be done on a per case basis AFTER we've determined that
|
||||
// this object is actually usable? This dot is being done for every object within PLAYER_SEARCH_RADIUS
|
||||
// when player hits the use key. How many objects can be in that area, anyway? (sjb)
|
||||
vecLOS = (VecBModelOrigin( pObject->pev ) - (pev->origin + pev->view_ofs));
|
||||
|
||||
// This essentially moves the origin of the target to the corner nearest the player to test to see
|
||||
// if it's "hull" is in the view cone
|
||||
vecLOS = UTIL_ClampVectorToBox( vecLOS, pObject->pev->size * 0.5 );
|
||||
|
||||
flDot = DotProduct (vecLOS , gpGlobals->v_forward);
|
||||
if (flDot > flMaxDot )
|
||||
{// only if the item is in front of the user
|
||||
pClosest = pObject;
|
||||
flMaxDot = flDot;
|
||||
// ALERT( at_console, "%s : %f\n", STRING( pObject->pev->classname ), flDot );
|
||||
if ( pObject->pev->iuser3 != AVH_USER3_HIVE ) {
|
||||
vec3_t objectLocation;
|
||||
vec3_t playerLocation;
|
||||
AvHSHUGetEntityLocation(pObject->entindex(), objectLocation);
|
||||
AvHSHUGetEntityLocation(this->entindex(), playerLocation);
|
||||
if ( VectorDistance(objectLocation, playerLocation) > PLAYER_SEARCH_RADIUS )
|
||||
continue;
|
||||
}
|
||||
if (pObject->ObjectCaps() & (FCAP_IMPULSE_USE | FCAP_CONTINUOUS_USE | FCAP_ONOFF_USE))
|
||||
{
|
||||
// !!!PERFORMANCE- should this check be done on a per case basis AFTER we've determined that
|
||||
// this object is actually usable? This dot is being done for every object within PLAYER_SEARCH_RADIUS
|
||||
// when player hits the use key. How many objects can be in that area, anyway? (sjb)
|
||||
vecLOS = (VecBModelOrigin( pObject->pev ) - (pev->origin + pev->view_ofs));
|
||||
|
||||
// This essentially moves the origin of the target to the corner nearest the player to test to see
|
||||
// if it's "hull" is in the view cone
|
||||
vecLOS = UTIL_ClampVectorToBox( vecLOS, pObject->pev->size * 0.5 );
|
||||
|
||||
flDot = DotProduct (vecLOS , gpGlobals->v_forward);
|
||||
if (flDot > flMaxDot )
|
||||
{// only if the item is in front of the user
|
||||
pClosest = pObject;
|
||||
flMaxDot = flDot;
|
||||
// ALERT( at_console, "%s : %f\n", STRING( pObject->pev->classname ), flDot );
|
||||
}
|
||||
// ALERT( at_console, "%s : %f\n", STRING( pObject->pev->classname ), flDot );
|
||||
}
|
||||
// ALERT( at_console, "%s : %f\n", STRING( pObject->pev->classname ), flDot );
|
||||
}
|
||||
}
|
||||
else {
|
||||
while ((pObject = UTIL_FindEntityInSphere( pObject, pev->origin, PLAYER_SEARCH_RADIUS )) != NULL)
|
||||
{
|
||||
|
||||
if (pObject->ObjectCaps() & (FCAP_IMPULSE_USE | FCAP_CONTINUOUS_USE | FCAP_ONOFF_USE))
|
||||
{
|
||||
// !!!PERFORMANCE- should this check be done on a per case basis AFTER we've determined that
|
||||
// this object is actually usable? This dot is being done for every object within PLAYER_SEARCH_RADIUS
|
||||
// when player hits the use key. How many objects can be in that area, anyway? (sjb)
|
||||
vecLOS = (VecBModelOrigin( pObject->pev ) - (pev->origin + pev->view_ofs));
|
||||
|
||||
// This essentially moves the origin of the target to the corner nearest the player to test to see
|
||||
// if it's "hull" is in the view cone
|
||||
vecLOS = UTIL_ClampVectorToBox( vecLOS, pObject->pev->size * 0.5 );
|
||||
|
||||
flDot = DotProduct (vecLOS , gpGlobals->v_forward);
|
||||
if (flDot > flMaxDot )
|
||||
{// only if the item is in front of the user
|
||||
pClosest = pObject;
|
||||
flMaxDot = flDot;
|
||||
// ALERT( at_console, "%s : %f\n", STRING( pObject->pev->classname ), flDot );
|
||||
}
|
||||
// ALERT( at_console, "%s : %f\n", STRING( pObject->pev->classname ), flDot );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pObject = pClosest;
|
||||
|
||||
// Found an object
|
||||
|
|
|
@ -5979,42 +5979,80 @@ bool AvHPlayer::Redeem()
|
|||
AvHTeam* theTeam = this->GetTeamPointer();
|
||||
if(theTeam && (theTeam->GetNumActiveHives() > 0))
|
||||
{
|
||||
vector<int> theSafeHives;
|
||||
vector<int> theAttackedHives;
|
||||
// Bring player back
|
||||
if(this->GetTeamPointer()->GetNumActiveHives() > 0)
|
||||
{
|
||||
|
||||
// Loop through the hives for this team, look for the farthest one (hives under attack take precedence)
|
||||
FOR_ALL_ENTITIES(kesTeamHive, AvHHive*)
|
||||
if(theEntity->pev->team == this->pev->team)
|
||||
{
|
||||
bool theHiveIsUnderAttack = GetGameRules()->GetIsEntityUnderAttack(theEntity->entindex());
|
||||
// allow teleport to any built hive, or unbuilt hives under attack.
|
||||
if(!theEntity->GetIsSpawning())
|
||||
{
|
||||
if ( theHiveIsUnderAttack )
|
||||
theAttackedHives.push_back(theEntity->entindex());
|
||||
else
|
||||
theSafeHives.push_back(theEntity->entindex());
|
||||
|
||||
}
|
||||
}
|
||||
END_FOR_ALL_ENTITIES(kesTeamHive)
|
||||
|
||||
}
|
||||
vector<int> *tmpPtr=&theSafeHives;
|
||||
if ( theSafeHives.size() == 0 )
|
||||
tmpPtr=&theAttackedHives;
|
||||
|
||||
int teleportHiveIndex=-1;
|
||||
if ( tmpPtr->size() > 0 ) {
|
||||
int index=RANDOM_LONG(0, tmpPtr->size()-1);
|
||||
teleportHiveIndex=(*tmpPtr)[index];
|
||||
}
|
||||
|
||||
// If we have a valid hive index, jump the player to it
|
||||
if(teleportHiveIndex != -1)
|
||||
{
|
||||
// Play redeem effect where it happened so attackers know it happened
|
||||
PLAYBACK_EVENT_FULL(0, this->edict(), gStartCloakEventID, 0, this->pev->origin, (float *)&g_vecZero, this->GetAlienAdjustedEventVolume(), 0.0, /*theWeaponIndex*/ 0, 0, 0, 0 );
|
||||
|
||||
edict_t* theNewSpawnPoint = GetGameRules()->SelectSpawnPoint(this);
|
||||
if(!FNullEnt(theNewSpawnPoint))
|
||||
{
|
||||
//// Create building here to test getting stuck
|
||||
//const int kOffset = 20;
|
||||
//Vector theBaseOrigin = theNewSpawnPoint->v.origin;
|
||||
//Vector theRandomOffset(theBaseOrigin.x + RANDOM_LONG(-kOffset, kOffset), theBaseOrigin.y + RANDOM_LONG(-kOffset, kOffset), theBaseOrigin.z + RANDOM_LONG(-kOffset, kOffset));
|
||||
//AvHSUBuildTechForPlayer(ALIEN_BUILD_MOVEMENT_CHAMBER, theRandomOffset, this);
|
||||
|
||||
// Move him to it!
|
||||
AvHHive* theHive = NULL;
|
||||
AvHSUGetEntityFromIndex(teleportHiveIndex, theHive);
|
||||
if(theHive)
|
||||
{
|
||||
CBaseEntity* theSpawnEntity = GetGameRules()->GetRandomHiveSpawnPoint(this, theHive->pev->origin, theHive->GetMaxSpawnDistance());
|
||||
if(theSpawnEntity)
|
||||
{
|
||||
Vector theMinSize;
|
||||
Vector theMaxSize;
|
||||
this->GetSize(theMinSize, theMaxSize);
|
||||
|
||||
theNewSpawnPoint = GetGameRules()->SelectSpawnPoint(this);
|
||||
if(!FNullEnt(theNewSpawnPoint))
|
||||
{
|
||||
if(this->GetIsDigesting())
|
||||
{
|
||||
this->StopDigestion(false);
|
||||
}
|
||||
int theOffset = AvHMUGetOriginOffsetForUser3(AvHUser3(this->pev->iuser3));
|
||||
Vector theOriginToSpawn = theSpawnEntity->pev->origin;
|
||||
theOriginToSpawn.z += theOffset;
|
||||
|
||||
mTimeOfLastRedeem = gpGlobals->time;
|
||||
if(AvHSUGetIsEnoughRoomForHull(theOriginToSpawn, AvHMUGetHull(false, this->pev->iuser3), this->edict()))
|
||||
{
|
||||
this->SetPosition(theOriginToSpawn);
|
||||
this->pev->velocity = Vector(0, 0, 0);
|
||||
if(this->GetIsDigesting())
|
||||
{
|
||||
this->StopDigestion(false);
|
||||
}
|
||||
|
||||
// Respawn player normally
|
||||
this->InitPlayerFromSpawn(theNewSpawnPoint);
|
||||
|
||||
PLAYBACK_EVENT_FULL(0, this->edict(), gStartCloakEventID, 0, this->pev->origin, (float *)&g_vecZero, this->GetAlienAdjustedEventVolume(), 0.0, /*theWeaponIndex*/ 0, 0, 0, 0 );
|
||||
}
|
||||
|
||||
theSuccess = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
mTimeOfLastRedeem = gpGlobals->time;
|
||||
theSuccess = true;
|
||||
|
||||
// Play teleport sound before and after
|
||||
PLAYBACK_EVENT_FULL(0, this->edict(), gStartCloakEventID, 0, this->pev->origin, (float *)&g_vecZero, this->GetAlienAdjustedEventVolume(), 0.0, /*theWeaponIndex*/ 0, 0, 0, 0 ); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return theSuccess;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue