Example #1
0
short PEXPORT Kpp__ResetFunc(LPFUNC lpFunc)
{
    if (! (FLAGS(lpFunc) & CBODY))
    {
        /* first delete the list of variables */
        if (VARS(lpFunc) != NULLID)
        {
            KppClearVarList(VARS(lpFunc));
            KppClearList(VARS(lpFunc), VAR);
            KppDeleteList(VARS(lpFunc));
            VARS (lpFunc) = NULLID;
        }

        /* then delete the body */
        if (BODY(lpFunc) != NULLID)
        {
            KppDeleteExp(BODY(lpFunc));
            BODY(lpFunc) = NULLID;
        }
    }
    
    return TRUE;
}
Example #2
0
void CGib :: SpawnHeadGib( entvars_t *pevVictim, const char* szGibModel )
{
	CGib *pGib = GetClassPtr( (CGib *)NULL );

	pGib->Spawn( szGibModel );// throw one head
	pGib->pev->body = 0;

	if ( pevVictim )
	{
		pGib->pev->origin = pevVictim->origin + pevVictim->view_ofs;
		
		edict_t		*pentPlayer = FIND_CLIENT_IN_PVS( pGib->edict() );
		
		if ( RANDOM_LONG ( 0, 100 ) <= 5 && pentPlayer )
		{
			// 5% chance head will be thrown at player's face.
			entvars_t	*pevPlayer;

			pevPlayer = VARS( pentPlayer );
			pGib->pev->velocity = ( ( pevPlayer->origin + pevPlayer->view_ofs ) - pGib->pev->origin ).Normalize() * 300;
			pGib->pev->velocity.z += 100;
		}
		else
		{
			pGib->pev->velocity = Vector (RANDOM_FLOAT(-100,100), RANDOM_FLOAT(-100,100), RANDOM_FLOAT(200,300));
		}


		pGib->pev->avelocity.x = RANDOM_FLOAT ( 100, 200 );
		pGib->pev->avelocity.y = RANDOM_FLOAT ( 100, 300 );

		// copy owner's blood color
		pGib->m_bloodColor = (CBaseEntity::Instance(pevVictim))->BloodColor();
	
		if ( pevVictim->health > -50)
		{
			pGib->pev->velocity = pGib->pev->velocity * 0.7;
		}
		else if ( pevVictim->health > -200)
		{
			pGib->pev->velocity = pGib->pev->velocity * 2;
		}
		else
		{
			pGib->pev->velocity = pGib->pev->velocity * 4;
		}
	}
	pGib->LimitVelocity();
}
Example #3
0
void AddNodeEntity(const Vector &origin, int effects)
{
   edict_t *pNode = CREATE_ENTITY();
   if (g_fIsMetamod) {
      CALL_GAME_ENTITY(PLID, "info_node", VARS(pNode));
   } else {
      info_node(VARS(pNode));
   }

   pNode->v.classname = MAKE_STRING("info_node");
   SET_ORIGIN(pNode, origin);
   pNode->v.rendercolor.x = 255;
   pNode->v.rendercolor.y = 255;
   pNode->v.rendercolor.z = 0;
   pNode->v.rendermode = kRenderTransAdd;
   pNode->v.movetype = MOVETYPE_NONE;
   pNode->v.solid = SOLID_TRIGGER;
   SET_SIZE(ENT(&pNode->v), Vector(-8, -8, -8), Vector(8, 8, 8));
   pNode->v.renderfx = kRenderFxNoDissipation;
   pNode->v.renderamt = 255;
   pNode->v.scale = 0.2;
   SET_MODEL(ENT(pNode), "sprites/glow02.spr");
   pNode->v.effects = effects;
}
Example #4
0
FUNCID __CopyFunc(LPFUNC lpOldFunc, ITEMID idName)
{
    FUNCID      idFunc;
    LPFUNC      lpFunc;
    LPEXP       lpBody;
    EXPID       idBody;

    if (GetFunc(idName) != NULLID)
        return NULLID;
    
    idFunc = KppAddItemAndName (FUNC, (LPLPSTR)&lpFunc, idName);
    if (!idFunc)
        return NULLID;
    NAME(lpFunc) = idName;
    FLAGS(lpFunc) = NULL;
    NUMVARS(lpFunc) = NUMVARS(lpOldFunc);
    if (! (FLAGS(lpFunc) & CBODY))
    {
        VARS(lpFunc) = KppDeepListCopy(VARS(lpOldFunc), Kpp__CopyVar, idFunc);
        if (BODY(lpOldFunc) == NULLID)
            idBody = NULLID;
        else
        {
            idBody = BODY(lpFunc) = KppCopyExp(BODY(lpOldFunc),
                                        (LPLPSTR)&lpBody, kPERMMODE);
            KppReleaseExp(idBody);
        }
    }

    KppReleaseItem(FUNC, idFunc);

    /* Add to KnowledgeTools */
    KppAddItemCB (FUNC, 1);

    return idFunc;
}
Example #5
0
void DecalGunshot( TraceResult *pTrace, int iBulletType )
{
	// Is the entity valid
	if ( !UTIL_IsValidEntity( pTrace->pHit ) )
		return;

	if ( VARS(pTrace->pHit)->solid == SOLID_BSP || VARS(pTrace->pHit)->movetype == MOVETYPE_PUSHSTEP )
	{
		CBaseEntity *pEntity = NULL;
		// Decal the wall with a gunshot
		if ( !FNullEnt(pTrace->pHit) )
			pEntity = CBaseEntity::Instance(pTrace->pHit);

		switch( iBulletType )
		{
		case BULLET_PLAYER_9MM:
		case BULLET_MONSTER_9MM:
		case BULLET_PLAYER_MP5:
		case BULLET_MONSTER_MP5:
		case BULLET_PLAYER_BUCKSHOT:
		case BULLET_PLAYER_357:
		default:
			// smoke and decal
			UTIL_GunshotDecalTrace( pTrace, DamageDecal( pEntity, DMG_BULLET ) );
			break;
		case BULLET_MONSTER_12MM:
			// smoke and decal
			UTIL_GunshotDecalTrace( pTrace, DamageDecal( pEntity, DMG_BULLET ) );
			break;
		case BULLET_PLAYER_CROWBAR:
			// wall decal
			UTIL_DecalTrace( pTrace, DamageDecal( pEntity, DMG_CLUB ) );
			break;
		}
	}
}
Example #6
0
int DispatchCreate( edict_t *pent, const char *szName )
{
	if( FNullEnt( pent ) || FStringNull( szName ))
		return -1;

	int istr = ALLOC_STRING( szName );

	// handle virtual entities here
	if( !strncmp( szName, "weapon_", 7 ))
	{
		CBasePlayerWeapon *pWeapon = GetClassPtr((CBasePlayerWeapon *)VARS( pent ));
		if( !pWeapon ) return -1;
		pWeapon->pev->netname = istr; 
		return 0;
	}
	else if( !strncmp( szName, "item_", 5 ) || !strncmp( szName, "ammo_", 5 ))
	{
		CItem *pItem = GetClassPtr((CItem *)VARS( pent ));
		if( !pItem ) return -1;
  		pItem->pev->netname = istr; 
		return 0;
	}
	return -1;
}
Example #7
0
void CTripmineGrenade :: BeamBreakThink( void  )
{
	BOOL bBlowup = 0;

	TraceResult tr;

	// HACKHACK Set simple box using this really nice global!
	gpGlobals->trace_flags = FTRACE_SIMPLEBOX;
	UTIL_TraceLine( pev->origin, m_vecEnd, dont_ignore_monsters, ENT( pev ), &tr );

	// ALERT( at_console, "%f : %f\n", tr.flFraction, m_flBeamLength );

	// respawn detect. 
	if ( !m_pBeam )
	{
		MakeBeam( );
		if ( tr.pHit )
			m_hOwner = CBaseEntity::Instance( tr.pHit );	// reset owner too
	}

	if (fabs( m_flBeamLength - tr.flFraction ) > 0.001)
	{
		bBlowup = 1;
	}
	else
	{
		if (m_hOwner == NULL)
			bBlowup = 1;
		else if (m_posOwner != m_hOwner->pev->origin)
			bBlowup = 1;
		else if (m_angleOwner != m_hOwner->pev->angles)
			bBlowup = 1;
	}

	if (bBlowup)
	{
		// a bit of a hack, but all CGrenade code passes pev->owner along to make sure the proper player gets credit for the kill
		// so we have to restore pev->owner from pRealOwner, because an entity's tracelines don't strike it's pev->owner which meant
		// that a player couldn't trigger his own tripmine. Now that the mine is exploding, it's safe the restore the owner so the 
		// CGrenade code knows who the explosive really belongs to.
		pev->owner = m_pRealOwner;
		pev->health = 0;
		Killed( VARS( pev->owner ), GIB_NORMAL );
		return;
	}

	pev->nextthink = gpGlobals->time + 0.1;
}
Example #8
0
edict_t *ParaSpawnItem( edict_t *pent )
{
	// Spawns the parachute on the ground that people can pick up to "get" a parachute
	// item_parachute

	edict_t *pent2 = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
	entvars_t *pev = VARS( pent2 );
	
	if (pent) {

		pev->origin = pent->v.origin;
		pev->angles = pent->v.angles;
	}

	SET_ORIGIN( pent2 , pev->origin );

	// for now don't take damage
	pev->takedamage = DAMAGE_NO;
	pev->max_health = 20;
	pev->health = 20;
	//pev->owner = pent;
	
	// Call the SPAWN routine to set more stuff
	KeyValueData	kvd;

	kvd.fHandled = FALSE;
	kvd.szClassName = NULL;
	kvd.szKeyName = "classname";
	kvd.szValue = "item_avparachute";
	(*other_gFunctionTable.pfnKeyValue)( pent2, &kvd );
	kvd.fHandled = FALSE;
	
	pev->movetype = MOVETYPE_TOSS;
	pev->solid = SOLID_TRIGGER;
	pev->effects &= ~EF_NODRAW;
	pev->iuser1 = 1;

	DROP_TO_FLOOR( pent2 );

	
	SET_MODEL(pent2, "models/w_longjump.mdl");
	UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16));

	pev->nextthink = gpGlobals->time + 0.1;	

	return pent2;

}
void CHalfLifeTeamplay::ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib )
{
	int damageFlags = DMG_GENERIC;
	int clientIndex = pPlayer->entindex();

	if ( !bGib )
	{
		damageFlags |= DMG_NEVERGIB;
	}
	else
	{
		damageFlags |= DMG_ALWAYSGIB;
	}

	if ( bKill )
	{
		// kill the player,  remove a death,  and let them start on the new team
		m_DisableDeathMessages = TRUE;
		m_DisableDeathPenalty = TRUE;

		entvars_t *pevWorld = VARS( INDEXENT(0) );
		pPlayer->TakeDamage( pevWorld, pevWorld, 900, damageFlags );

		m_DisableDeathMessages = FALSE;
		m_DisableDeathPenalty = FALSE;
	}

	// copy out the team name from the model
	if (pPlayer->m_szTeamName != pTeamName)
		strncpy(pPlayer->m_szTeamName, pTeamName, TEAM_NAME_LENGTH);

	g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "model", pPlayer->m_szTeamName );
	g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "team", pPlayer->m_szTeamName );

	// notify everyone's HUD of the team change
	MESSAGE_BEGIN( MSG_ALL, gmsgTeamInfo );
		WRITE_BYTE( clientIndex );
		WRITE_STRING( pPlayer->m_szTeamName );
	MESSAGE_END();

	MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo );
		WRITE_BYTE( clientIndex );
		WRITE_SHORT( pPlayer->pev->frags );
		WRITE_SHORT( pPlayer->m_iDeaths );
		WRITE_SHORT( 0 );
		WRITE_SHORT( g_pGameRules->GetTeamIndex( pPlayer->m_szTeamName ) + 1 );
	MESSAGE_END();
}
Example #10
0
void UTIL_PrecacheOther( const char *szClassname )
{
	edict_t	*pent;

	pent = CREATE_NAMED_ENTITY( MAKE_STRING( szClassname ) );
	if ( FNullEnt( pent ) )
	{
		ALERT ( at_console, "NULL Ent in UTIL_PrecacheOther\n" );
		return;
	}
	
	CBaseEntity *pEntity = CBaseEntity::Instance (VARS( pent ));
	if (pEntity)
		pEntity->Precache( );
	REMOVE_ENTITY(pent);
}
Example #11
0
// find a viable entity
int CCineMonster::FindEntity(void)
{
	edict_t *pentTarget;

	pentTarget            = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_iszEntity));
	m_hTargetEnt          = NULL;
	CBaseMonster *pTarget = NULL;

	while(!FNullEnt(pentTarget))
	{
		if(FBitSet(VARS(pentTarget)->flags, FL_MONSTER))
		{
			pTarget = GetMonsterPointer(pentTarget);
			if(pTarget && pTarget->CanPlaySequence(FCanOverrideState(), SS_INTERRUPT_BY_NAME))
			{
				m_hTargetEnt = pTarget;
				return TRUE;
			}
			ALERT(at_console, "Found %s, but can't play!\n", STRING(m_iszEntity));
		}
		pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(m_iszEntity));
		pTarget    = NULL;
	}

	if(!pTarget)
	{
		CBaseEntity *pEntity = NULL;
		while((pEntity = UTIL_FindEntityInSphere(pEntity, pev->origin, m_flRadius)) != NULL)
		{
			if(FClassnameIs(pEntity->pev, STRING(m_iszEntity)))
			{
				if(FBitSet(pEntity->pev->flags, FL_MONSTER))
				{
					pTarget = pEntity->MyMonsterPointer();
					if(pTarget && pTarget->CanPlaySequence(FCanOverrideState(), SS_INTERRUPT_IDLE))
					{
						m_hTargetEnt = pTarget;
						return TRUE;
					}
				}
			}
		}
	}
	pTarget      = NULL;
	m_hTargetEnt = NULL;
	return FALSE;
}
Example #12
0
void CGrenade::Explode(TraceResult *pTrace, int bitsDamageType)
{
	pev->model = 0;
	pev->solid = SOLID_NOT;
	pev->takedamage = DAMAGE_NO;

	if (pTrace->flFraction != 1)
		pev->origin = pTrace->vecEndPos + (pTrace->vecPlaneNormal * (pev->dmg - 24) * 0.6);

	int iContents = UTIL_PointContents(pev->origin);
	CSoundEnt::InsertSound(bits_SOUND_COMBAT, pev->origin, NORMAL_EXPLOSION_VOLUME, 3);
	entvars_t *pevOwner;

	if (pev->owner)
		pevOwner = VARS(pev->owner);
	else
		pevOwner = NULL;

	pev->owner = NULL;
	RadiusFlash(pev->origin, pev, pevOwner, 4);

	if (RANDOM_FLOAT(0, 1) < 0.5)
		UTIL_DecalTrace(pTrace, DECAL_SCORCH1);
	else
		UTIL_DecalTrace(pTrace, DECAL_SCORCH2);

	float flRndSound = RANDOM_FLOAT(0, 1);

	switch (RANDOM_LONG(0, 1))
	{
		case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/flashbang-1.wav", 0.55, ATTN_NORM); break;
		case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/flashbang-2.wav", 0.55, ATTN_NORM); break;
	}

	pev->effects |= EF_NODRAW;
	SetThink(&CGrenade::Smoke);
	pev->velocity = g_vecZero;
	pev->nextthink = gpGlobals->time + 0.3;

	if (iContents != CONTENTS_WATER)
	{
		int sparkCount = RANDOM_LONG(0, 3);

		for (int i = 0; i < sparkCount; i++)
			Create("spark_shower", pev->origin, pTrace->vecPlaneNormal, NULL);
	}
}
Example #13
0
void CHostageImprov::ClearPath()
{
	Vector start;
	Vector end;
	TraceResult result;

	if (!m_clearPathTimer.IsElapsed())
		return;

	m_clearPathTimer.Start(RANDOM_FLOAT(0.3f, 0.5f));

	const Vector eye = GetEyes();
	start = eye;

	UTIL_MakeVectors(m_hostage->pev->angles);
	end = gpGlobals->v_forward * 64 + start;

	UTIL_TraceLine(start, end, ignore_monsters, dont_ignore_glass, m_hostage->edict(), &result);

	if (result.flFraction == 1.0f)
		return;

	if (result.pHit != NULL)
	{
		entvars_t *entity = VARS(result.pHit);

		if (FClassnameIs(entity, "func_door") || FClassnameIs(entity, "func_door_rotating"))
		{
			CBaseEntity *pObject = CBaseEntity::Instance(entity);

			if (pObject != NULL)
			{
				pObject->Touch(m_hostage);
			}
		}
		else if (FClassnameIs(entity, "func_breakable") && entity->takedamage == DAMAGE_YES)
		{
			CBaseEntity *pObject = CBaseEntity::Instance(entity);

			if (pObject != NULL)
			{
				pObject->TakeDamage(m_hostage->pev, m_hostage->pev, 9999.9, DMG_BULLET);
			}
		}
	}
}
Example #14
0
void CDecal :: StaticDecal( void )
{
	TraceResult trace;
	int			entityIndex, modelIndex;

	UTIL_TraceLine( pev->origin - Vector(5,5,5), pev->origin + Vector(5,5,5),  ignore_monsters, ENT(pev), &trace );

	entityIndex = (short)ENTINDEX(trace.pHit);
	if ( entityIndex )
		modelIndex = (int)VARS(trace.pHit)->modelindex;
	else
		modelIndex = 0;

	g_engfuncs.pfnStaticDecal( pev->origin, (int)pev->skin, entityIndex, modelIndex );

	SUB_Remove();
}
Example #15
0
void DispatchKeyValue( edict_t *pentKeyvalue, KeyValueData *pkvd )
{
	if ( !pkvd || !pentKeyvalue )return;

	EntvarsKeyvalue( VARS(pentKeyvalue), pkvd );

	// if the key was an entity variable, or there's no class set yet,
	// don't look for the object, it may not exist yet.
	if( pkvd->fHandled || pkvd->szClassName == NULL )
		return;

	// Get the actualy entity object
	CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentKeyvalue);

	if( !pEntity ) return;
	pEntity->KeyValue( pkvd );
}
Example #16
0
void ApplyMultiDamage(entvars_t *pevInflictor, entvars_t *pevAttacker )
{
	Vector		vecSpot1;//where blood comes from
	Vector		vecDir;//direction blood should go
	TraceResult	tr;
	
	if ( !gMultiDamage.pEntity )
		return;

	if (UTIL_IsPlayer(gMultiDamage.pEntity))
		UTIL_TakeDamage(gMultiDamage.pEntity, pevInflictor, pevAttacker, gMultiDamage.amount, gMultiDamage.type );
	else if (gMultiDamage.pEntity->v.euser4 != NULL)
	{
		CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(gMultiDamage.pEntity));
		pMonster->TakeDamage(pevInflictor, pevAttacker, gMultiDamage.amount, gMultiDamage.type );
	}
}
Example #17
0
void CFuncVehicle::Blocked(CBaseEntity *pOther)
{
	entvars_t *pevOther = pOther->pev;

	if ((pevOther->flags & FL_ONGROUND) && VARS(pevOther->groundentity) == pev)
	{
		pevOther->velocity = pev->velocity;
		return;
	}

	pevOther->velocity = (pevOther->origin - pev->origin).Normalize() * pev->dmg;
	pevOther->velocity.z += 300;
	pev->velocity = pev->velocity * 0.85;

	ALERT(at_aiconsole, "TRAIN(%s): Blocked by %s (dmg:%.2f)\n", STRING(pev->targetname), STRING(pOther->pev->classname), pev->dmg);
	UTIL_MakeVectors(pev->angles);

	Vector forward, right, vOrigin;
	Vector vFrontLeft = (gpGlobals->v_forward * -1) * (m_length * 0.5);
	Vector vFrontRight = (gpGlobals->v_right * -1) * (m_width * 0.5);

	Vector vBackLeft = pev->origin + vFrontLeft - vFrontRight;
	Vector vBackRight = pev->origin - vFrontLeft + vFrontRight;

	float minx = Q_min(vBackLeft.x, vBackRight.x);
	float miny = Q_min(vBackLeft.y, vBackRight.y);
	float maxx = Q_max(vBackLeft.x, vBackRight.x);
	float maxy = Q_max(vBackLeft.y, vBackRight.y);

	float minz = pev->origin.z;
#ifdef REGAMEDLL_FIXES
	float maxz = pev->origin.z + (2 * Q_abs(pev->mins.z - pev->maxs.z));	
#else
	float maxz = pev->origin.z + (2 * Q_abs(int(pev->mins.z - pev->maxs.z)));
#endif

	if (pOther->pev->origin.x < minx
		|| pOther->pev->origin.x > maxx
		|| pOther->pev->origin.y < miny
		|| pOther->pev->origin.y > maxy
		|| pOther->pev->origin.z < pev->origin.z
		|| pOther->pev->origin.z > maxz)
	{
		pOther->TakeDamage(pev, pev, 150, DMG_CRUSH);
	}
}
Example #18
0
WORD PEXPORT KppEvalFunc(ITEMID idFunc, LISTID idArgList)
{
    LPFUNC lpFunc = (LPFUNC) KppGetItem(FUNC, idFunc);
    ATOMID idName;
    LPEXP lpBody;
    EXPID idBody;
    LISTID idVarList;
    GLOBALHANDLE hBody;
    WORD i;

    if (!lpFunc)
        return KppRegisterKappaMessage(hResThisDll, IDE_ERRORINFUNC,
                                       lpIDs->idError, NULLID, NULLID);

    if (NUMVARS(lpFunc) != KppListLen(idArgList))
    {
        idName = NAME(lpFunc);
        KppReleaseItem (FUNC, idFunc);
        return KppRegisterKappaMessage(hResThisDll, IDE_BADNUMARG, idName,
                                       NULLID, NULLID);
    }

    idVarList = VARS(lpFunc);
    idBody = BODY(lpFunc);
    KppReleaseItem(FUNC, idFunc);

    if (!idBody)
        KappaReturnAtom(lpIDs->idNull);

    UnwindProtect(cleanup);
    if (lpKALView && lpKALView->bActive)
        (*lpKALView->PushFn)(idName);
    lpBody = KppCopyTempExp(idBody, (GLOBALHANDLE FAR *)&hBody);
    Kpp__LoadArgs(lpBody, idVarList, idArgList);
    
    i = Kpp_EvalExp(lpBody);
  cleanup:    
    KppReleaseTempExp(hBody, i);
    KppUnbindVars(idVarList);
    if (lpKALView && lpKALView->bActive)
        (*lpKALView->Pop)(TRUE);
    EndProtect();
    
    return i;
}
Example #19
0
void AvHSpit::SpitTouch(CBaseEntity* pOther)
{
	// Never hit the player who fired it
	if(pOther != CBaseEntity::Instance(this->pev->owner))
	{
		float theScalar = 1.0f;
		if(GetGameRules()->CanEntityDoDamageTo(this, pOther, &theScalar) || (pOther->pev->team == TEAM_IND))
		{
			float theDamage = this->mDamage*theScalar;

			// Apply damage to receiver
			pOther->TakeDamage(this->pev, VARS(this->pev->owner), theDamage, DMG_ACID);
		}

		// Kill it off
		this->SpitDeath();
	}
}
Example #20
0
void CSunOfGod::Animate( void )
{
	entvars_t *pevOwner = VARS( pev->owner );

	if ( UTIL_PointContents(pev->origin) == CONTENT_WATER )
	{
		FX_Trail( pev->origin, entindex(), PROJ_SUNOFGOD_DETONATE_WATER );
		::RadiusDamage( pev->origin, pev, pevOwner, pev->dmg/3, pev->dmg/3, CLASS_NONE, DMG_NUKE | DMG_NEVERGIB);
		UTIL_Remove( this );
		return;
	}

	::RadiusDamage( pev->origin, pev, pevOwner, pev->dmg/50, 180, CLASS_NONE, DMG_NUKE | DMG_NEVERGIB);
	pev->frags--;

	if (pev->frags <= 0)
	Detonate( );
	pev->nextthink = gpGlobals->time + 0.1;
}
Example #21
0
/* <36b5fa> ../cstrike/dlls/bot/cs_bot_manager.cpp:415 */
void CCSBotManager::__MAKE_VHOOK(ClientDisconnect)(CBasePlayer *pPlayer)
{
	if (!pPlayer || !pPlayer->IsBot())
		return;

	CCSBot *pBot = static_cast<CCSBot *>(pPlayer);
	entvars_t *temp = VARS(pPlayer->edict());

	pBot->Disconnect();

	if (pPlayer->pev->classname)
		RemoveEntityHashValue(pPlayer->pev, STRING(pPlayer->pev->classname), CLASSNAME);

	FREE_PRIVATE(pPlayer->edict());

	CBasePlayer *player = GetClassPtr((CBasePlayer *)temp);
	AddEntityHashValue(player->pev, STRING(player->pev->classname), CLASSNAME);
	player->pev->flags = FL_DORMANT;
}
Example #22
0
// Find an entity that I'm interested in and precache the sounds he'll need in the sequence.
void CCineMonster::Activate(void)
{
	edict_t *     pentTarget;
	CBaseMonster *pTarget;

	// The entity name could be a target name or a classname
	// Check the targetname
	pentTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_iszEntity));
	pTarget    = NULL;

	while(!pTarget && !FNullEnt(pentTarget))
	{
		if(FBitSet(VARS(pentTarget)->flags, FL_MONSTER))
		{
			pTarget = GetMonsterPointer(pentTarget);
		}
		pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(m_iszEntity));
	}

	// If no entity with that targetname, check the classname
	if(!pTarget)
	{
		pentTarget = FIND_ENTITY_BY_CLASSNAME(NULL, STRING(m_iszEntity));
		while(!pTarget && !FNullEnt(pentTarget))
		{
			pTarget    = GetMonsterPointer(pentTarget);
			pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(m_iszEntity));
		}
	}
	// Found a compatible entity
	if(pTarget)
	{
		void *pmodel;
		pmodel = GET_MODEL_PTR(pTarget->edict());
		if(pmodel)
		{
			// Look through the event list for stuff to precache
			SequencePrecache(pmodel, STRING(m_iszIdle));
			SequencePrecache(pmodel, STRING(m_iszPlay));
		}
	}
}
Example #23
0
void CBMortar::Touch( CBaseEntity *pOther )
{
	TraceResult tr;
	int		iPitch;

	// splat sound
	iPitch = RANDOM_FLOAT( 90, 110 );

	EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "bullchicken/bc_acid1.wav", 1, ATTN_NORM, 0, iPitch );	

	switch ( RANDOM_LONG( 0, 1 ) )
	{
	case 0:
		EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "bullchicken/bc_spithit1.wav", 1, ATTN_NORM, 0, iPitch );	
		break;
	case 1:
		EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "bullchicken/bc_spithit2.wav", 1, ATTN_NORM, 0, iPitch );	
		break;
	}

	if ( pOther->IsBSPModel() )
	{

		// make a splat on the wall
		UTIL_TraceLine( pev->origin, pev->origin + pev->velocity * 10, dont_ignore_monsters, ENT( pev ), &tr );
		UTIL_DecalTrace(&tr, DECAL_MOMMASPLAT);
	}
	else
	{
		tr.vecEndPos = pev->origin;
		tr.vecPlaneNormal = -1 * pev->velocity.Normalize();
	}
	// make some flecks
	MortarSpray( tr.vecEndPos, tr.vecPlaneNormal, gSpitSprite, 24 );

	entvars_t *pevOwner = NULL;
	if ( pev->owner )
		pevOwner = VARS(pev->owner);

	RadiusDamage( pev->origin, pev, pevOwner, gSkillData.bigmommaDmgBlast, gSkillData.bigmommaRadiusBlast, CLASS_NONE, DMG_ACID );
	UTIL_Remove( this );
}
Example #24
0
void CHornet::DieTouch ( CBaseEntity *pOther )
{
	if ( pOther && pOther->pev->takedamage )
	{// do the damage

		switch (RANDOM_LONG(0,2))
		{// buzz when you plug someone
			case 0:	EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_hornethit1.wav", 1, ATTN_NORM);	break;
			case 1:	EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_hornethit2.wav", 1, ATTN_NORM);	break;
			case 2:	EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_hornethit3.wav", 1, ATTN_NORM);	break;
		}
			
		pOther->TakeDamage( pev, VARS( pev->owner ), pev->dmg, DMG_BULLET );
	}

	pev->modelindex = 0;// so will disappear for the 0.1 secs we wait until NEXTTHINK gets rid
	pev->solid = SOLID_NOT;

	SetThink(&CBaseEntity::SUB_Remove);
	pev->nextthink = gpGlobals->time + 1;// stick around long enough for the sound to finish!
}
Example #25
0
WORD _EvalFunc(ITEMID idFunc, LPEXP lpArgList, WORD nArg)
{
    LPFUNC lpFunc = (LPFUNC) KppGetItem(FUNC, idFunc);
    WORD i = FALSE;
    ATOMID idName;
    EXPID idBody;
    LPEXP lpBody;
    LISTID idVarList;
    GLOBALHANDLE hBody;

    if (!lpFunc)
        return KppRegisterKappaMessage(hResThisDll, IDE_ERRORINFUNC,
                                       lpIDs->idError, NULLID, NULLID);

    if (NUMVARS(lpFunc) != nArg)
    {
        idName = NAME(lpFunc);
        KppReleaseItem(FUNC, idFunc);
        return KppRegisterKappaMessage(hResThisDll, IDE_BADNUMARG,
                                       idName, NULLID, NULLID);
    }

    idVarList = VARS(lpFunc);
    idBody = BODY(lpFunc);
    KppReleaseItem(FUNC, idFunc);

    if (idBody == NULLID)
        KappaReturnAtom(lpIDs->idNull);

    lpBody = KppCopyTempExp(idBody, (GLOBALHANDLE FAR *)&hBody);
    Kpp___LoadArgs(lpBody, idVarList, lpArgList);
    UnwindProtect (cleanup);
    i = Kpp_EvalExp(lpBody);
  cleanup:
    KppReleaseTempExp (hBody, i);
    KppUnbindVars(idVarList);
    EndProtect();

    return i;
}
Example #26
0
short PEXPORT Kpp__SetupFunc(LPFUNC lpFunc, LISTID idAtomList, EXPID idBody)
{
    LISTID idVarList = KppMakeList(0);

    if (idAtomList && idAtomList != lpIDs->idNull)
    {
        LIST_LOOP loop;
        ATOMID idItem;
        
        kpc_init_loop(idAtomList, &loop);
        while (idItem = KppNextListElement(&loop)) {
            LPVAR lpVar;
            VARID idVar = KppAddItem(VAR, (LPLPSTR) &lpVar);
            
            VARNAME(lpVar) = idItem;
            BINDINGS(lpVar) = NULLID;
            VARCLASS(lpVar) = NULLID;
            VARPREV(lpVar) = NULLID;
            KppReleaseItem(VAR, idVar);
            KppAppendElem(idVarList, idVar);
        }
    }
    KppDeleteList(idAtomList);

    NUMVARS(lpFunc) = KppListLen(idVarList);
    if (!idBody)
        idBody = KppBuildNullExp();
    else
        KppResetBoundFlag(idBody);
    BODY(lpFunc) = idBody;
    VARS(lpFunc) = idVarList;
    if (NUMVARS(lpFunc))
    {
        KppClearVarList(idVarList);
        KppBindVars(idVarList, idBody);
    }
    
    return TRUE;
}
Example #27
0
void CCrossbowBolt::ExplodeThink( void )
{
	int iContents = UTIL_PointContents ( pev->origin );
	int iScale;
	
	pev->dmg = 40;
	iScale = 10;

	MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin );
		WRITE_BYTE( TE_EXPLOSION);		
		WRITE_COORD( pev->origin.x );
		WRITE_COORD( pev->origin.y );
		WRITE_COORD( pev->origin.z );
		if (iContents != CONTENTS_WATER)
		{
			WRITE_SHORT( g_sModelIndexFireball );
		}
		else
		{
			WRITE_SHORT( g_sModelIndexWExplosion );
		}
		WRITE_BYTE( iScale  ); // scale * 10
		WRITE_BYTE( 15  ); // framerate
		WRITE_BYTE( TE_EXPLFLAG_NONE );
	MESSAGE_END();

	entvars_t *pevOwner;

	if ( pev->owner )
		pevOwner = VARS( pev->owner );
	else
		pevOwner = NULL;

	pev->owner = NULL; // can't traceline attack owner if this is set

	::RadiusDamage( pev->origin, pev, pevOwner, pev->dmg, 128, CLASS_NONE, DMG_BLAST | DMG_ALWAYSGIB );

	UTIL_Remove(this);
}
Example #28
0
// Precaches the weapon and queues the weapon info for sending to clients
void UTIL_PrecacheOtherWeapon( const char *szClassname )
{
	edict_t	*pent;

	pent = CREATE_NAMED_ENTITY( MAKE_STRING( szClassname ) );
	if ( FNullEnt( pent ) )
	{
		ALERT ( at_console, "NULL Ent in UTIL_PrecacheOtherWeapon\n" );
		return;
	}
	
	CBaseEntity *pEntity = CBaseEntity::Instance (VARS( pent ));

	if (pEntity)
	{
		ItemInfo II;
		pEntity->Precache( );
		memset( &II, 0, sizeof II );
		if ( ((CBasePlayerItem*)pEntity)->GetItemInfo( &II ) )
		{
			CBasePlayerItem::ItemInfoArray[II.iId] = II;

			if ( II.pszAmmo1 && *II.pszAmmo1 )
			{
				AddAmmoNameToAmmoRegistry( II.pszAmmo1 );
			}

			if ( II.pszAmmo2 && *II.pszAmmo2 )
			{
				AddAmmoNameToAmmoRegistry( II.pszAmmo2 );
			}

			memset( &II, 0, sizeof II );
		}
	}

	REMOVE_ENTITY(pent);
}
Example #29
0
// find all the cinematic entities with my targetname and tell them to wait before starting
void CCineMonster::DelayStart(int state)
{
	edict_t *pentCine = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->targetname));

	while(!FNullEnt(pentCine))
	{
		if(FClassnameIs(pentCine, "scripted_sequence"))
		{
			CCineMonster *pTarget = GetClassPtr((CCineMonster *)VARS(pentCine));
			if(state)
			{
				pTarget->m_iDelay++;
			}
			else
			{
				pTarget->m_iDelay--;
				if(pTarget->m_iDelay <= 0)
					pTarget->m_startTime = gpGlobals->time + 0.05;
			}
		}
		pentCine = FIND_ENTITY_BY_TARGETNAME(pentCine, STRING(pev->targetname));
	}
}
Example #30
0
void CServer::CheckClients()
{
   // check if any clients (or bots) have joined the game or
   // disconnected, so that we can update the list we have...
   for (int i = 0; i < GetMaxClients(); i++) {
      edict_t *pPlayer = INDEXENT(i + 1);
      if (!FNullEnt(pPlayer) && !pPlayer->free && STRING(pPlayer->v.netname)[0]) {
         if (m_rgpClients[i] == NULL) {
            // a client has joined the game
            g_Debug.DebugLog(DEBUG_GENERAL, "client index #%d joined the game", i + 1);
            m_rgpClients[i] = new CClient; // add him/her to the list
            m_rgpClients[i]->pev = VARS(pPlayer);
         }
      } else {
         if (m_rgpClients[i] != NULL) {
            // a client (or bot) has disconnected from the game
            g_Debug.DebugLog(DEBUG_GENERAL, "client index #%d left the game", i + 1);
            delete m_rgpClients[i]; // delete him/her/it from the list
            m_rgpClients[i] = NULL;
         }
      }
   }
}