void CBaseHumanRepel::Precache( void )
{
	UTIL_PrecacheOther( EntityName() );
	m_iSpriteTexture = PRECACHE_MODEL( "sprites/rope.spr" );
}
void CBaseHumanRepel::RepelUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
	TraceResult tr;
	UTIL_TraceLine( pev->origin, pev->origin + Vector( 0, 0, -4096.0), dont_ignore_monsters, ENT(pev), &tr);
	/*
	if ( tr.pHit && Instance( tr.pHit )->pev->solid != SOLID_BSP) 
		return NULL;
	*/

	edict_t	*pent;
	CBaseEntity *pEntity;

	pent = CREATE_NAMED_ENTITY( MAKE_STRING( EntityName() ));
	if ( FNullEnt( pent ) )
	{
		ALERT ( at_console, "NULL Ent in HumanRepel Create!\n" );
		return;
	}




	
	pEntity = Instance( pent );
	pEntity->pev->owner = NULL;

	//
	pEntity->pev->origin = pev->origin;
	pEntity->pev->angles = pev->angles;
	pEntity->pev->spawnflags = pev->spawnflags;
	pEntity->pev->weapons = pev->weapons;
	pEntity->pev->scale = pev->scale;
	pEntity->pev->health = pev->health;
	pEntity->pev->skin = pev->skin;
	pEntity->pev->frags = pev->frags;//HL2 model compatibility (not used anymore)
	pEntity->pev->dmg = pev->dmg;//for monster breakpoint
	pEntity->pev->message = pev->message;//when a surrender terrorist fires a trigger
	pEntity->pev->target = pev->noise;

	//LRC - custom monster behaviour
//	CBaseEntity *pEntity = CBaseEntity::Instance( pEntity );
	CBaseMonster *pMonst = NULL;
	if (pEntity && (pMonst = pEntity->MyMonsterPointer()) != NULL)
	{
		pMonst->m_iClass = this->m_iClass;
		pMonst->m_iPlayerReact = this->m_iPlayerReact;
		pMonst->m_iTriggerCondition = this->m_iTriggerCondition;	//AJH
		pMonst->m_iszTriggerTarget = this->m_iszTriggerTarget;		//AJH	
	}
	//

	/*
	pEntity->pev->origin = pev->origin;
	pEntity->pev->angles = pev->angles;
	pEntity->pev->spawnflags = pev->spawnflags;
	pEntity->pev->body = pev->body;
	pEntity->pev->weapons = pev->weapons;
	pEntity->pev->netname = pev->netname;
	*/




	DispatchSpawn( pEntity->edict() );

	pEntity->pev->movetype = MOVETYPE_FLY;
	pEntity->pev->velocity = Vector( 0, 0, RANDOM_FLOAT( -196, -128 ) );

	CBaseMonster *pHuman = pEntity->MyMonsterPointer( );
	pHuman->SetActivity( ACT_GLIDE );
	pHuman->m_vecLastPosition = tr.vecEndPos;

	CBeam *pBeam = CBeam::BeamCreate( "sprites/rope.spr", 10 );
	pBeam->PointEntInit( pev->origin/* + Vector(0,0,112)*/, pEntity->entindex() );
	pBeam->SetFlags( BEAM_FSOLID );
	pBeam->SetColor( 255, 255, 255 );
	pBeam->SetThink( SUB_Remove );
	pBeam->pev->nextthink = gpGlobals->time + -4096.0 * tr.flFraction / pEntity->pev->velocity.z + 0.5;

	UTIL_Remove( this );
}
Example #3
0
/**
	Convert entity to xml dom document
   	\param preferAttrib - if true (default) generate attributes, else elements
	... <attr name="atrname" val="atrVal"/> ... vs <atrname>atrVal<atrname/>
	\param skipEmpty	- if true (default) skip empty values
	\param upperCase	- if true - uppercase all tags (default is false)
	\return Dom document reference
*/
QDomDocument& RecordBase::GetDom
(
	bool preferAttrib,
	bool skipEmpty,
	bool upperCase
)
{
	QString idTag(kTagID);
	QString attrTag(kTagAttr);
	QString nameTag(kTagName);
	QString valTag(kTagValue);
	QString entName(EntityName());

	if (upperCase) 
	{
		entName = entName.toUpper();
		idTag   = idTag.toUpper();
		attrTag = attrTag.toUpper();
		nameTag = nameTag.toUpper();
		valTag  = valTag.toUpper();
	}

	if (_xmlDoc)
		delete _xmlDoc;

	QDomElement root;

	_xmlDoc = new QDomDocument;
	
	root = _xmlDoc->createElement(entName);
    _xmlDoc->appendChild(root);
	// append id attrib to root

	root.setAttribute(idTag, Key());
	// enumerate fields
	for (quint32 i(1); i < Count(); i++) 
	{
		QString name = Field(i);
		QString v = Value(i).toString().trimmed();
		
		if (v.length() > 0 || (v.length() == 0 && !skipEmpty)) 
		{
			if (upperCase) 
				name = name.toUpper();

			if (preferAttrib) 
			{
				QDomElement elem = _xmlDoc->createElement(attrTag);
				elem.setAttribute(nameTag, name);
				elem.setAttribute(valTag , v);
				root.appendChild (elem);
			}
			else // use elements
			{
				
				QDomElement elem = _xmlDoc->createElement(name);
				QDomText txt  = _xmlDoc->createTextNode(v);
				elem.appendChild(txt);
				root.appendChild(elem);
			}
		}
	}

	return *_xmlDoc;
}