Allow pull weapons and items (need to fix respawn)

This commit is contained in:
mittorn 2016-03-23 20:02:25 +00:00
parent 7e37c5449b
commit e8a8fd4930
5 changed files with 82 additions and 14 deletions

View File

@ -269,9 +269,9 @@ void CGrav::Attack(void)
pusher.y = pusher.y * m_fPushSpeed;
pusher.z = pusher.z * m_fPushSpeed * 0.7;
crossent->pev->velocity = pusher+m_pPlayer->pev->velocity;
crossent->pev->avelocity.y = pev->avelocity.y*3.5 + RANDOM_FLOAT(100, -100);
crossent->pev->avelocity.x = pev->avelocity.x*3.5 + RANDOM_FLOAT(100, -100);
crossent->pev->avelocity.z = pev->avelocity.z + 3;
//crossent->pev->avelocity.y = pev->avelocity.y*3.5 + RANDOM_FLOAT(100, -100);
//crossent->pev->avelocity.x = pev->avelocity.x*3.5 + RANDOM_FLOAT(100, -100);
//crossent->pev->avelocity.z = pev->avelocity.z + 3;
}
@ -502,7 +502,7 @@ void CGrav::Pull(CBaseEntity* ent,float force)
target.z += 60;
ALERT(at_console, "%s 1 %d : %f\n", STRING(ent->pev->classname), m_iStage, ((target - VecBModelOrigin(ent->pev)).Length()));
//ALERT(at_console, "%s 1 %d : %f\n", STRING(ent->pev->classname), m_iStage, ((target - VecBModelOrigin(ent->pev)).Length()));
if( !m_iStage )
@ -538,9 +538,9 @@ void CGrav::Pull(CBaseEntity* ent,float force)
/////
ALERT(at_console, "%s 2: %f\n", STRING(ent->pev->classname), m_iStage, ent->pev->velocity.Length());
//ALERT(at_console, "%s 2: %f\n", STRING(ent->pev->classname), m_iStage, ent->pev->velocity.Length());
}
else
else if( ent->TouchGravGun(m_pPlayer, 2) )
{
ent->pev->velocity = (target - VecBModelOrigin(ent->pev))* 40;
if(ent->pev->velocity.Length()>900)
@ -549,12 +549,15 @@ void CGrav::Pull(CBaseEntity* ent,float force)
m_iStage = 2;
SetThink( &CGrav::GrabThink );
pev->nextthink = gpGlobals->time + 0.001;
ent->TouchGravGun(m_pPlayer, 2);
}
else
{
SetThink(NULL);
m_hAimentEntity = NULL;
EndAttack();
m_iStage = 0;
}
}

View File

@ -92,6 +92,7 @@ void CItem::Spawn( void )
pev->movetype = MOVETYPE_TOSS;
pev->solid = SOLID_TRIGGER;
UTIL_SetOrigin( pev, pev->origin );
m_SpawnPoint = pev->origin;
UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16));
SetTouch( &ItemTouch);
@ -149,13 +150,29 @@ CBaseEntity* CItem::Respawn( void )
SetTouch( NULL );
pev->effects |= EF_NODRAW;
UTIL_SetOrigin( pev, g_pGameRules->VecItemRespawnSpot( this ) );// blip to whereever you should respawn.
UTIL_SetOrigin( pev, m_SpawnPoint );// blip to whereever you should respawn.
SetThink( &Materialize );
pev->nextthink = g_pGameRules->FlItemRespawnTime( this );
return this;
}
float CItem::TouchGravGun( CBaseEntity *attacker, int stage)
{
if( stage == 2 )
Touch(attacker);
if( pev->movetype == MOVETYPE_FOLLOW )
return 0;
if( pev->movetype == MOVETYPE_NONE )
return 0;
if( pev->effects & EF_NODRAW )
return 0;
//if( pev->mins == pev->maxs )
//return 0;
SetThink( &Materialize );
pev->nextthink = g_pGameRules->FlItemRespawnTime( this );
return 200;
}
void CItem::Materialize( void )
{
if ( pev->effects & EF_NODRAW )
@ -165,6 +182,8 @@ void CItem::Materialize( void )
pev->effects &= ~EF_NODRAW;
pev->effects |= EF_MUZZLEFLASH;
}
else
UTIL_SetOrigin( pev, m_SpawnPoint );// blip to whereever you should respawn.
SetTouch( &ItemTouch );
}

View File

@ -15,7 +15,6 @@
#ifndef ITEMS_H
#define ITEMS_H
class CItem : public CBaseEntity
{
public:
@ -24,6 +23,8 @@ public:
void EXPORT ItemTouch( CBaseEntity *pOther );
void EXPORT Materialize( void );
virtual BOOL MyTouch( CBasePlayer *pPlayer ) { return FALSE; };
virtual float TouchGravGun( CBaseEntity *attacker, int stage);
Vector m_SpawnPoint;
};
#endif // ITEMS_H

View File

@ -476,6 +476,7 @@ void CBasePlayerItem :: FallInit( void )
pev->solid = SOLID_BBOX;
UTIL_SetOrigin( pev, pev->origin );
m_SpawnPoint = pev->origin;
UTIL_SetSize(pev, Vector( 0, 0, 0), Vector(0, 0, 0) );//pointsize until it lands on the ground.
SetTouch( &DefaultTouch );
@ -576,7 +577,7 @@ CBaseEntity* CBasePlayerItem::Respawn( void )
{
// make a copy of this weapon that is invisible and inaccessible to players (no touch function). The weapon spawn/respawn code
// will decide when to make the weapon visible and touchable.
CBaseEntity *pNewWeapon = CBaseEntity::Create( (char *)STRING( pev->classname ), g_pGameRules->VecWeaponRespawnSpot( this ), pev->angles, pev->owner );
CBaseEntity *pNewWeapon = CBaseEntity::Create( (char *)STRING( pev->classname ), m_SpawnPoint, pev->angles, pev->owner );
if ( pNewWeapon )
{
@ -1066,6 +1067,7 @@ void CBasePlayerAmmo::Spawn( void )
pev->solid = SOLID_TRIGGER;
UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16));
UTIL_SetOrigin( pev, pev->origin );
m_SpawnPoint = pev->origin;
SetTouch( &DefaultTouch );
}
@ -1075,7 +1077,7 @@ CBaseEntity* CBasePlayerAmmo::Respawn( void )
pev->effects |= EF_NODRAW;
SetTouch( NULL );
UTIL_SetOrigin( pev, g_pGameRules->VecAmmoRespawnSpot( this ) );// move to wherever I'm supposed to repawn.
UTIL_SetOrigin( pev, m_SpawnPoint );// move to wherever I'm supposed to repawn.
SetThink( &Materialize );
pev->nextthink = g_pGameRules->FlAmmoRespawnTime( this );

View File

@ -285,6 +285,23 @@ public:
// int m_iIdPrimary; // Unique Id for primary ammo
// int m_iIdSecondary; // Unique Id for secondary ammo
Vector m_SpawnPoint;
virtual float TouchGravGun( CBaseEntity *attacker, int stage)
{
if( stage == 2 )
{
Touch( attacker );
}
if( pev->movetype == MOVETYPE_FOLLOW )
return 0;
if( pev->movetype == MOVETYPE_NONE )
return 0;
if( pev->effects & EF_NODRAW )
return 0;
//if( pev->mins == pev->maxs )
//return 0;
return 200;
}
};
@ -370,6 +387,23 @@ public:
CBaseEntity* Respawn( void );
void EXPORT Materialize( void );
virtual float TouchGravGun( CBaseEntity *attacker, int stage)
{
if( stage == 2 )
{
Touch( attacker );
}
if( pev->movetype == MOVETYPE_FOLLOW )
return 0;
if( pev->movetype == MOVETYPE_NONE )
return 0;
if( pev->effects & EF_NODRAW )
return 0;
//if( pev->mins == pev->maxs )
//return 0;
return 200;
}
Vector m_SpawnPoint;
};
@ -460,6 +494,15 @@ public:
int m_rgAmmo[MAX_AMMO_SLOTS];// ammo quantities
int m_cAmmoTypes;// how many ammo types packed into this box (if packed by a level designer)
virtual float TouchGravGun( CBaseEntity *attacker, int stage)
{
if( stage == 2 )
{
Touch( attacker );
return 0;
}
return 200;
}
};
#ifdef CLIENT_DLL