void CLocusVariable::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { Vector vecPos = g_vecZero; Vector vecDir = g_vecZero; float fRatio = 0; if (m_iszPosition) vecPos = CalcLocus_Position(this, pActivator, STRING(m_iszPosition)); if (m_iszVelocity) vecDir = CalcLocus_Velocity(this, pActivator, STRING(m_iszVelocity)); if (m_iszRatio) fRatio = CalcLocus_Ratio(pActivator, STRING(m_iszRatio)); if (m_iszTargetName) { CMark *pMark = GetClassPtr( (CMark*)NULL ); pMark->pev->classname = MAKE_STRING("mark"); pMark->pev->origin = vecPos; pMark->pev->movedir = vecDir; pMark->pev->frags = fRatio; pMark->pev->targetname = m_iszTargetName; pMark->SetNextThink(m_fDuration); FireTargets(STRING(m_iszFireOnSpawn), pMark, this, USE_TOGGLE, 0); } else { pev->origin = vecPos; pev->movedir = vecDir; pev->frags = fRatio; FireTargets(STRING(m_iszFireOnSpawn), this, this, USE_TOGGLE, 0); } }
Vector CCalcVelocityPath::CalcVelocity( CBaseEntity *pLocus ) { Vector vecStart = CalcLocus_Position( this, pLocus, STRING(pev->target) ); // ALERT(at_console, "vecStart %f %f %f\n", vecStart.x, vecStart.y, vecStart.z); Vector vecOffs; float fFactor = CalcLocus_Ratio( pLocus, STRING(pev->noise) ); switch ((int)pev->armorvalue) { case 0: vecOffs = CalcLocus_Position( this, pLocus, STRING(pev->netname) ) - vecStart; break; case 1: vecOffs = CalcLocus_Velocity( this, pLocus, STRING(pev->netname) ); break; } // ALERT(at_console, "vecOffs %f %f %f\n", vecOffs.x, vecOffs.y, vecOffs.z); if (pev->health) { float len = vecOffs.Length(); switch ((int)pev->health) { case 1: vecOffs = vecOffs/len; break; case 2: vecOffs = vecOffs/(len*len); break; case 3: vecOffs = vecOffs/(len*len*len); break; case 4: vecOffs = vecOffs*len; break; } } vecOffs = vecOffs * fFactor; if (pev->frags) { TraceResult tr; IGNORE_GLASS iIgnoreGlass = ignore_glass; IGNORE_MONSTERS iIgnoreMonsters = ignore_monsters; switch ((int)pev->frags) { case 2: iIgnoreGlass = dont_ignore_glass; break; case 4: iIgnoreGlass = dont_ignore_glass; // fall through case 3: iIgnoreMonsters = dont_ignore_monsters; break; } UTIL_TraceLine( vecStart, vecStart+vecOffs, iIgnoreMonsters, iIgnoreGlass, NULL, &tr ); vecOffs = tr.vecEndPos - vecStart; } // ALERT(at_console, "path: %f %f %f\n", vecOffs.x, vecOffs.y, vecOffs.z); return vecOffs; }
void CEnvExplosion::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { TraceResult tr; pev->model = iStringNull;//invisible pev->solid = SOLID_NOT;// intangible Vector vecSpot;// trace starts here! //LRC if (FStringNull(pev->target)) { vecSpot = pev->origin; } else { vecSpot = CalcLocus_Position(this, pActivator, STRING(pev->target)); } UTIL_TraceLine ( vecSpot + Vector( 0, 0, 8 ), vecSpot + Vector ( 0, 0, -32 ), ignore_monsters, ENT(pev), & tr); // Pull out of the wall a bit if ( tr.flFraction != 1.0 ) { pev->origin = tr.vecEndPos + (tr.vecPlaneNormal * (m_iMagnitude - 24) * 0.6); } else { pev->origin = vecSpot; //LRC } // draw decal if (! ( pev->spawnflags & SF_ENVEXPLOSION_NODECAL)) { if ( RANDOM_FLOAT( 0 , 1 ) < 0.5 ) { UTIL_DecalTrace( &tr, DECAL_SCORCH1 ); } else { UTIL_DecalTrace( &tr, DECAL_SCORCH2 ); } } // draw fireball if ( !( pev->spawnflags & SF_ENVEXPLOSION_NOFIREBALL ) ) { Vector vecOrigin(pev->origin.x, pev->origin.y, pev->origin.z); MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); WRITE_BYTE( TE_EXPLOSION); WRITE_COORD(vecOrigin.x); WRITE_COORD(vecOrigin.y); WRITE_COORD(vecOrigin.z); WRITE_SHORT( g_sModelIndexFireball ); WRITE_BYTE( (BYTE)m_spriteScale ); // scale * 10 WRITE_BYTE( 15 ); // framerate WRITE_BYTE(TE_EXPLFLAG_NOSOUND); MESSAGE_END(); UTIL_EmitAmbientSound(ENT(pev), vecOrigin, "weapons/explode3.wav", VOL_NORM, 0.6, 0, 100); } else { Vector vecOrigin(pev->origin.x, pev->origin.y, pev->origin.z); MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); WRITE_BYTE( TE_EXPLOSION); WRITE_COORD(vecOrigin.x); WRITE_COORD(vecOrigin.y); WRITE_COORD(vecOrigin.z); WRITE_SHORT( g_sModelIndexFireball ); WRITE_BYTE( 0 ); // no sprite WRITE_BYTE( 15 ); // framerate WRITE_BYTE(TE_EXPLFLAG_NOSOUND); MESSAGE_END(); UTIL_EmitAmbientSound(ENT(pev), vecOrigin, "weapons/explode3.wav", VOL_NORM, 0.6, 0, 100); } // do damage if ( !( pev->spawnflags & SF_ENVEXPLOSION_NODAMAGE ) ) { RadiusDamage ( pev, pev, m_iMagnitude, CLASS_NONE, DMG_BLAST ); } SetThink(&CEnvExplosion:: Smoke ); SetNextThink( 0.3 ); // draw sparks if ( !( pev->spawnflags & SF_ENVEXPLOSION_NOSPARKS ) ) { int sparkCount = RANDOM_LONG(0,3); for ( int i = 0; i < sparkCount; i++ ) { Create( "spark_shower", pev->origin, tr.vecPlaneNormal, NULL ); } } }
void CLocusBeam::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { CBaseEntity *pStartEnt; CBaseEntity *pEndEnt; Vector vecStartPos; Vector vecEndPos; CBeam *pBeam; switch(pev->impulse) { case 0: // ents pStartEnt = UTIL_FindEntityByTargetname(NULL, STRING(m_iszStart), pActivator); pEndEnt = UTIL_FindEntityByTargetname(NULL, STRING(m_iszEnd), pActivator); if (pStartEnt == NULL || pEndEnt == NULL) return; pBeam = CBeam::BeamCreate( STRING(m_iszSprite), m_iWidth ); pBeam->EntsInit( pStartEnt->entindex(), pEndEnt->entindex() ); break; case 1: // pointent vecStartPos = CalcLocus_Position( this, pActivator, STRING(m_iszStart) ); pEndEnt = UTIL_FindEntityByTargetname(NULL, STRING(m_iszEnd), pActivator); if (pEndEnt == NULL) return; pBeam = CBeam::BeamCreate( STRING(m_iszSprite), m_iWidth ); pBeam->PointEntInit( vecStartPos, pEndEnt->entindex() ); break; case 2: // points vecStartPos = CalcLocus_Position( this, pActivator, STRING(m_iszStart) ); vecEndPos = CalcLocus_Position( this, pActivator, STRING(m_iszEnd) ); pBeam = CBeam::BeamCreate( STRING(m_iszSprite), m_iWidth ); pBeam->PointsInit( vecStartPos, vecEndPos ); break; case 3: // point & offset vecStartPos = CalcLocus_Position( this, pActivator, STRING(m_iszStart) ); vecEndPos = CalcLocus_Velocity( this, pActivator, STRING(m_iszEnd) ); pBeam = CBeam::BeamCreate( STRING(m_iszSprite), m_iWidth ); pBeam->PointsInit( vecStartPos, vecStartPos + vecEndPos ); break; } pBeam->SetColor( pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z ); pBeam->SetBrightness( pev->renderamt ); pBeam->SetNoise( m_iDistortion ); pBeam->SetFrame( m_fFrame ); pBeam->SetScrollRate( m_iScrollRate ); pBeam->SetFlags( m_iFlags ); pBeam->pev->dmg = m_fDamage; pBeam->pev->frags = m_iDamageType; pBeam->pev->spawnflags |= pev->spawnflags & (SF_BEAM_RING | SF_BEAM_SPARKSTART | SF_BEAM_SPARKEND | SF_BEAM_DECALS); if (m_fDuration) { pBeam->SetThink(&CBeam:: SUB_Remove ); pBeam->SetNextThink( m_fDuration ); } pBeam->pev->targetname = m_iszTargetName; if (pev->target) { FireTargets( STRING(pev->target), pBeam, this, USE_TOGGLE, 0 ); } }
//========================================================= // TryMakeMonster- check that it's ok to drop a monster. //========================================================= void CMonsterMaker::TryMakeMonster( void ) { if ( m_iMaxLiveChildren > 0 && m_cLiveChildren >= m_iMaxLiveChildren ) {// not allowed to make a new one yet. Too many live ones out right now. return; } CBaseEntity* pTemp; if (pev->noise){ // AJH dynamic origin for monstermakers pTemp = UTIL_FindEntityByTargetname(NULL,STRING(pev->noise),this); if (pTemp) { pev->vuser1 = pTemp->pev->origin; // ALERT(at_debug,"DEBUG: Monstermaker setting dynamic position %f %f %f \n", pWhere->pev->origin.x,pWhere->pev->origin.y,pWhere->pev->origin.z); } }else{ pev->vuser1=pev->origin; } if (pev->noise1) { //AJH dynamic offset for monstermaker Vector vTemp =CalcLocus_Position(this, NULL, STRING(pev->noise1)); pev->vuser1 = pev->vuser1 + vTemp; // ALERT(at_debug,"DEBUG: Monstermaker dynamic offset is %f %f %f\n",vTemp.x,vTemp.y,vTemp.z); // ALERT(at_debug,"DEBUG: Monstermaker position now %f %f %f \n", pWhere->pev->origin.x,pWhere->pev->origin.y,pWhere->pev->origin.z); } if (pev->noise2){ // AJH dynamic angles for monstermakers pTemp = UTIL_FindEntityByTargetname(NULL,STRING(pev->noise2),this); if (pTemp) pev->vuser2=pTemp->pev->angles; // ALERT(at_debug,"DEBUG: Monstermaker setting angles to %f %f %f\n",pWhere->pev->angles.x,pWhere->pev->angles.y,pWhere->pev->angles.z); }else{ pev->vuser2=pev->angles; } if (pev->noise3){ // AJH dynamic velocity for monstermakers pTemp = UTIL_FindEntityByTargetname(NULL,STRING(pev->noise3),this); if (pTemp) pev->vuser3 = pTemp->pev->velocity; // ALERT(at_debug,"DEBUG: Monstermaker setting velocity to %f %f %f\n",pWhere->pev->velocity.x,pWhere->pev->velocity.y,pWhere->pev->velocity.z); } // ALERT(at_debug,"DEBUG: Montermaker spawnpoint set to %f, %f, %f\n", pWhere->pev->origin.x,pWhere->pev->origin.y,pWhere->pev->origin.z); if ( !m_flGround ) { // set altitude. Now that I'm activated, any breakables, etc should be out from under me. TraceResult tr; UTIL_TraceLine ( pev->vuser1, pev->vuser1 - Vector ( 0, 0, 2048 ), ignore_monsters, ENT(pev), &tr ); m_flGround = tr.vecEndPos.z; } Vector mins = pev->vuser1 - Vector( 34, 34, 0 ); Vector maxs = pev->vuser1 + Vector( 34, 34, 0 ); maxs.z = pev->vuser1.z; mins.z = m_flGround; CBaseEntity *pList[2]; int count = UTIL_EntitiesInBox( pList, 2, mins, maxs, FL_CLIENT|FL_MONSTER ); if ( !SF_MONSTERMAKER_FORCESPAWN&&count ) { // don't build a stack of monsters! return; } if (m_fSpawnDelay) { // If I have a target, fire. (no locus) if ( !FStringNull ( pev->target ) ) { // delay already overloaded for this entity, so can't call SUB_UseTargets() FireTargets( STRING(pev->target), this, this, USE_TOGGLE, 0 ); } // ALERT(at_console,"Making Monster in %f seconds\n",m_fSpawnDelay); SetThink(&CMonsterMaker:: MakeMonsterThink ); SetNextThink( m_fSpawnDelay ); } else { // ALERT(at_console,"No delay. Making monster.\n",m_fSpawnDelay); CBaseMonster* pMonst = MakeMonster(); // If I have a target, fire! (the new monster is the locus) if ( !FStringNull ( pev->target ) ) { ALERT(at_debug,"DEBUG: Monstermaker fires target %s locus is child\n",STRING(pev->target)); FireTargets( STRING(pev->target), pMonst, this, USE_TOGGLE, 0 ); } } }