Exemple #1
0
//-----------------------------------------------------------------------------
// Purpose: Setup the item's respawn in the time set
//-----------------------------------------------------------------------------
void CItem::Respawn( float flTime )
{
	pev->effects |= EF_NODRAW;
	SetTouch( NULL );

	if (!m_flMoneyRandomRespawn)
	{
		UTIL_SetOrigin( pev, pev->origin );
	}
		else
	{
		CBaseEntity *pSpot = NULL;
		for ( int i = RANDOM_LONG(1,5); i > 0; i-- )

		pSpot = UTIL_FindEntityByClassname( pSpot, "info_money_start" );

	if (pSpot)
	{
		Vector tmp = pSpot->pev->origin;
		UTIL_SetOrigin( pev, tmp );
		DROP_TO_FLOOR ( ENT(pev) );
	}
}

	// Come back in time
	SetThink ( Materialize );
	pev->nextthink = gpGlobals->time + flTime;
}
Exemple #2
0
//=========================================================
// Respawn- this item is already in the world, but it is
// invisible and intangible. Make it visible and tangible.
//=========================================================
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 );

	if ( pNewWeapon )
	{
		pNewWeapon->pev->effects |= EF_NODRAW;// invisible for now
		pNewWeapon->SetTouch( NULL );// no touch
		pNewWeapon->SetThink( AttemptToMaterialize );

		DROP_TO_FLOOR ( ENT(pev) );

		// not a typo! We want to know when the weapon the player just picked up should respawn! This new entity we created is the replacement,
		// but when it should respawn is based on conditions belonging to the weapon that was taken.
		pNewWeapon->pev->nextthink = g_pGameRules->FlWeaponRespawnTime( this );
	}
	else
	{
		ALERT ( at_console, "Respawn failed to create %s!\n", STRING( pev->classname ) );
	}

	return pNewWeapon;
}
Exemple #3
0
/* <2469b9> ../cstrike/dlls/wpn_shared/wpn_c4.cpp:50 */
void CC4::__MAKE_VHOOK(Spawn)(void)
{
	SET_MODEL(edict(), "models/w_backpack.mdl");

	pev->frame = 0;
	pev->body = 3;
	pev->sequence = 0;
	pev->framerate = 0;

	m_iId = WEAPON_C4;
	m_iDefaultAmmo = C4_DEFAULT_GIVE;
	m_bStartedArming = false;
	m_fArmedTime = 0;

	if (!FStringNull(pev->targetname))
	{
		pev->effects |= EF_NODRAW;
		DROP_TO_FLOOR(edict());

		return;
	}

	FallInit();
	SetThink(&CBasePlayerItem::FallThink);
	pev->nextthink = UTIL_WeaponTimeBase() + 0.1;
}
Exemple #4
0
void CHostage::RePosition(void)
{
	pev->health = pev->max_health;
	pev->movetype = MOVETYPE_STEP;
	pev->solid = SOLID_SLIDEBOX;
	pev->takedamage = DAMAGE_YES;
	pev->deadflag = DEAD_NO;
	pev->velocity = Vector(0, 0, 0);
	pev->angles = m_vStartAngles;
	pev->effects &= ~EF_NODRAW;

	m_hTargetEnt = NULL;
	m_hStoppedTargetEnt = NULL;
	m_bTouched = FALSE;
	m_bRescueMe = FALSE;
	m_vOldPos = Vector(9999, 9999, 9999);
	m_flNextRadarTime = 0;

	UTIL_SetOrigin(pev, m_vStart);
	UTIL_SetSize(pev, VEC_HOSTAGE_HULL_MIN, VEC_HOSTAGE_HULL_MAX);
	DROP_TO_FLOOR(ENT(pev));
	SetActivity(ACT_IDLE);

	SetThink(&CHostage::IdleThink);
	pev->nextthink = gpGlobals->time + RANDOM_FLOAT(0.1, 0.2);

	m_fHasPath = FALSE;
	nTargetNode = -1;
	m_flLastPathCheck = -1;
	m_flPathAcquired = -1;
	m_flPathCheckInterval = 0.1;
	m_flNextFullThink = gpGlobals->time + RANDOM_FLOAT(0.1, 0.2);
}
Exemple #5
0
void CFuncMachinegun::Spawn()
{
	Precache();
	pev->movetype	= MOVETYPE_FLY;
	pev->solid	= SOLID_BBOX;
	pev->takedamage = DAMAGE_AIM;
	pev->angles.x	= 0;
	pev->renderfx 	= 51; // хак для рендерера, чтобы он не интерполировал контроллеры
	pev->health 	= pev->max_health;
	pev->armorvalue = pev->armortype;
	pev->weapons 	= m_iAmmo;//for respawn
	pev->origin.z  += 1;
	DROP_TO_FLOOR ( ENT(pev) );
	pev->oldorigin 	= pev->origin;

	if (pev->model)
		SET_MODEL( ENT(pev), STRING(pev->model) );
	else
		SET_MODEL(ENT(pev), "models/error.mdl");

	UTIL_SetSize( pev, Vector(-25,-25,0), Vector(25,25,35));

	ResetSequenceInfo();
	m_fSequenceLoops = TRUE;
	InitBoneControllers();
}
Exemple #6
0
//from jghg, who says it doesn't work
// it works, it's just a picky engine call -sawce
static cell AMX_NATIVE_CALL drop_to_floor(AMX *amx, cell *params)
{
	int iEnt = params[1];

	CHECK_ENTITY(iEnt);

	edict_t *e = INDEXENT2(iEnt);

	return DROP_TO_FLOOR(e);
}
Exemple #7
0
void NPC::MoveAction(void)
{
	if ((g_waypoint->g_waypointPointFlag[m_currentWaypointIndex] & WAYPOINT_LADDER &&
		GetDistance2D(pev->origin, g_waypoint->g_waypointPointOrigin[m_currentWaypointIndex]) <= 10.0f) ||
		(m_oldNavIndex != -1 && g_waypoint->g_waypointPointFlag[m_oldNavIndex] & WAYPOINT_LADDER &&
			GetDistance2D(pev->origin, g_waypoint->g_waypointPointOrigin[m_oldNavIndex]) <= 10.0f))
		pev->movetype = MOVETYPE_FLY;
	else
		pev->movetype = MOVETYPE_PUSHSTEP;

	float oldSpeed = pev->speed;
	pev->speed = m_moveSpeed;
	if (m_moveSpeed == 0.0f || !IsAlive (GetEntity ()))
	{
		if (!IsOnLadder(GetEntity()) && pev->solid != SOLID_NOT)
			DROP_TO_FLOOR(GetEntity());
		return;
	}

	if (IsOnLadder(GetEntity()) || pev->solid == SOLID_NOT)
	{
		pev->velocity = GetSpeedVector(pev->origin, m_destOrigin, pev->speed);

		if (pev->solid == SOLID_NOT)
			goto lastly;
	}
	else
	{
		Vector vecMove = m_destOrigin - pev->origin;
		Vector vecFwd, vecAng;
		VEC_TO_ANGLES(vecMove, vecAng);
		vecAng = Vector(0.0f, vecAng.y, 0.0f);
		UTIL_MakeVectorsPrivate(vecAng, vecFwd, null, null);

		pev->velocity.x = vecFwd.x * pev->speed;
		pev->velocity.y = vecFwd.y * pev->speed;
	}

	if (m_jumpAction)
	{
		pev->velocity.z = (270.0f * pev->gravity) + 32.0f; // client gravity 1 = 270.0f , and jump+duck + 32.0f
		m_jumpAction = false;
	}

	CheckStuck(oldSpeed);

	lastly:
	float speed = GetDistance2D(pev->velocity);
	if (speed > 10.0f || speed < -10.0f)
		g_npcAS |= ASC_MOVE;

	MakeVectors(pev->angles);
}
Exemple #8
0
void CItem::Spawn(void)
{
	pev->movetype = MOVETYPE_TOSS;
	pev->solid = SOLID_TRIGGER;
	UTIL_SetOrigin(pev, pev->origin);
	UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16));
	SetTouch(&CItem::ItemTouch);

	if (DROP_TO_FLOOR(ENT(pev)) == 0)
	{
		UTIL_Remove(this);
		return;
	}
}
Exemple #9
0
void CItem::Spawn( void )
{
	pev->movetype = MOVETYPE_TOSS;
	pev->solid = SOLID_TRIGGER;
	UTIL_SetOrigin( pev, pev->origin );
	UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16));
	SetTouch(&CItem::ItemTouch);

	if (DROP_TO_FLOOR(ENT(pev)) == 0)
	{
		ALERT(at_error, "Item %s fell out of level at %f,%f,%f", STRING( pev->classname ), pev->origin.x, pev->origin.y, pev->origin.z);
		UTIL_Remove( this );
		return;
	}
}
Exemple #10
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;

}
Exemple #11
0
//
// ********** Scientist SPAWN **********
//
void CSittingScientist :: Spawn( )
{
	if (pev->model)
		PRECACHE_MODEL((char*)STRING(pev->model)); //LRC
	else
		PRECACHE_MODEL("models/scientist.mdl");
	if (pev->model)
		SET_MODEL(ENT(pev), STRING(pev->model)); //LRC
	else
		SET_MODEL(ENT(pev), "models/scientist.mdl");
	Precache();
	InitBoneControllers();

	UTIL_SetSize(pev, Vector(-14, -14, 0), Vector(14, 14, 36));

	pev->solid			= SOLID_SLIDEBOX;
	pev->movetype		= MOVETYPE_STEP;
	pev->effects		= 0;
	pev->health			= 50;
	
	m_bloodColor = BLOOD_COLOR_RED;
	m_flFieldOfView		= VIEW_FIELD_WIDE; // indicates the width of this monster's forward view cone ( as a dotproduct result )

	m_afCapability		= bits_CAP_HEAR | bits_CAP_TURN_HEAD;

	if (!FBitSet(pev->spawnflags, SF_SITTINGSCI_POSTDISASTER)) //LRC- allow a sitter to be postdisaster.
		SetBits(pev->spawnflags, SF_MONSTER_PREDISASTER); // predisaster only!

	if ( pev->body == -1 )
	{// -1 chooses a random head
		pev->body = RANDOM_LONG(0, NUM_SCIENTIST_HEADS-1);// pick a head, any head
	}
	// Luther is black, make his hands black
	if ( pev->body == HEAD_LUTHER )
		pev->skin = 1;
	
	m_baseSequence = LookupSequence( "sitlookleft" );
	pev->sequence = m_baseSequence + RANDOM_LONG(0,4);
	ResetSequenceInfo( );
	
	SetThink(&CSittingScientist ::SittingThink);
	SetNextThink( 0.1 );

	DROP_TO_FLOOR ( ENT(pev) );
}
Exemple #12
0
void CQuakeItem::Spawn()
{ 
	pev->movetype = MOVETYPE_TOSS;
	pev->solid = SOLID_TRIGGER;
	
	SetTouch(&CQuakeItem::ItemTouch);

	if (DROP_TO_FLOOR(ENT(pev)) == 0)
	{
		ALERT(at_error, "Item %s fell out of level at %f,%f,%f", STRING( pev->classname ), pev->origin.x, pev->origin.y, pev->origin.z);
		UTIL_Remove( this );
		return;
	}

	//UTIL_SetOrigin( pev, pev->origin + Vector(0,0,16) );

	if (!m_flRespawnTime)
		m_flRespawnTime = 20;
}
Exemple #13
0
void CCycler :: Spawn( )
{
	InitBoneControllers();
	pev->solid			= SOLID_SLIDEBOX;
	
	pev->movetype		= MOVETYPE_NONE;

	pev->takedamage		= DAMAGE_YES;
	pev->effects		= 0;
	pev->health			= 80000;// no cycler should die
	pev->yaw_speed		= 5;
	pev->ideal_yaw		= pev->angles.y;
	ChangeYaw( 360 );
	
	m_flFrameRate		= 75;
	m_flGroundSpeed		= 0;

	pev->nextthink		+= 1.0;

	ResetSequenceInfo( );

	if (pev->sequence != 0 || pev->frame != 0)
	{
		m_animate = 0;
		pev->framerate = 0;
	}
	else
	{
		m_animate = 1;
	}

	if ( FClassnameIs ( pev, "cine_entity" ) )
	{
		m_bloodColor = DONT_BLEED;

		pev->origin.z += 1;
		DROP_TO_FLOOR ( ENT(pev) );
	}
}
Exemple #14
0
void NPC::Spawn(Vector origin)
{
	pev->solid = SOLID_BBOX;
	pev->takedamage = DAMAGE_AIM;
	pev->deadflag = DEAD_NO;
	pev->health = pev->max_health;
	pev->fixangle = true;

	SET_SIZE(GetEntity(), g_npcSize[0], g_npcSize[1]);
	SET_ORIGIN(GetEntity(), origin);

	m_pmodel = null;

	DROP_TO_FLOOR(GetEntity());

	pev->animtime = gpGlobals->time;
	pev->nextthink = m_nextThinkTime = gpGlobals->time + 0.2f;
	m_frameInterval = gpGlobals->time;

	m_iDamage = false;
	SetEntityAction(GetIndex(), m_npcTeam, 1);

	m_workNPC = true;
}
Exemple #15
0
BOOL CBaseMonster::CineCleanup()
{
	CCineMonster *pOldCine = m_pCine;

	// am I linked to a cinematic?
	if(m_pCine)
	{
		// okay, reset me to what it thought I was before
		m_pCine->m_hTargetEnt = NULL;
		pev->movetype         = m_pCine->m_saved_movetype;
		pev->solid            = m_pCine->m_saved_solid;
		pev->effects          = m_pCine->m_saved_effects;
	}
	else
	{
		// arg, punt
		pev->movetype = MOVETYPE_STEP; // this is evil
		pev->solid    = SOLID_SLIDEBOX;
	}
	m_pCine      = NULL;
	m_hTargetEnt = NULL;
	m_pGoalEnt   = NULL;
	if(pev->deadflag == DEAD_DYING)
	{
		// last frame of death animation?
		pev->health    = 0;
		pev->framerate = 0.0;
		pev->solid     = SOLID_NOT;
		SetState(MONSTERSTATE_DEAD);
		pev->deadflag = DEAD_DEAD;
		UTIL_SetSize(pev, pev->mins, Vector(pev->maxs.x, pev->maxs.y, pev->mins.z + 2));

		if(pOldCine && FBitSet(pOldCine->pev->spawnflags, SF_SCRIPT_LEAVECORPSE))
		{
			SetUse(NULL);   // BUGBUG -- This doesn't call Killed()
			SetThink(NULL); // This will probably break some stuff
			SetTouch(NULL);
		}
		else
			SUB_StartFadeOut(); // SetThink( SUB_DoNothing );
		// This turns off animation & physics in case their origin ends up stuck in the world or something
		StopAnimation();
		pev->movetype = MOVETYPE_NONE;
		pev->effects |= EF_NOINTERP; // Don't interpolate either, assume the corpse is positioned in its final resting place
		return FALSE;
	}

	// If we actually played a sequence
	if(pOldCine && pOldCine->m_iszPlay)
	{
		if(!(pOldCine->pev->spawnflags & SF_SCRIPT_NOSCRIPTMOVEMENT))
		{
			// reset position
			Vector new_origin, new_angle;
			GetBonePosition(0, new_origin, new_angle);

			// Figure out how far they have moved
			// We can't really solve this problem because we can't query the movement of the origin relative
			// to the sequence.  We can get the root bone's position as we do here, but there are
			// cases where the root bone is in a different relative position to the entity's origin
			// before/after the sequence plays.  So we are stuck doing this:

			// !!!HACKHACK: Float the origin up and drop to floor because some sequences have
			// irregular motion that can't be properly accounted for.

			// UNDONE: THIS SHOULD ONLY HAPPEN IF WE ACTUALLY PLAYED THE SEQUENCE.
			Vector oldOrigin = pev->origin;

			// UNDONE: ugly hack.  Don't move monster if they don't "seem" to move
			// this really needs to be done with the AX,AY,etc. flags, but that aren't consistantly
			// being set, so animations that really do move won't be caught.
			if((oldOrigin - new_origin).Length2D() < 8.0)
				new_origin = oldOrigin;

			pev->origin.x = new_origin.x;
			pev->origin.y = new_origin.y;
			pev->origin.z += 1;

			pev->flags |= FL_ONGROUND;
			int drop = DROP_TO_FLOOR(ENT(pev));

			// Origin in solid?  Set to org at the end of the sequence
			if(drop < 0)
				pev->origin = oldOrigin;
			else if(drop == 0) // Hanging in air?
			{
				pev->origin.z = new_origin.z;
				pev->flags &= ~FL_ONGROUND;
			}
			// else entity hit floor, leave there

			// pEntity->pev->origin.z = new_origin.z + 5.0; // damn, got to fix this

			UTIL_SetOrigin(pev, pev->origin);
			pev->effects |= EF_NOINTERP;
		}

		// We should have some animation to put these guys in, but for now it's idle.
		// Due to NOINTERP above, there won't be any blending between this anim & the sequence
		m_Activity = ACT_RESET;
	}
	// set them back into a normal state
	pev->enemy = NULL;
	if(pev->health > 0)
		m_IdealMonsterState = MONSTERSTATE_IDLE; // m_previousState;
	else
	{
		// Dropping out because he got killed
		// Can't call killed() no attacker and weirdness (late gibbing) may result
		m_IdealMonsterState = MONSTERSTATE_DEAD;
		SetConditions(bits_COND_LIGHT_DAMAGE);
		pev->deadflag = DEAD_DYING;
		FCheckAITrigger();
		pev->deadflag = DEAD_NO;
	}

	//	SetAnimation( m_MonsterState );
	ClearBits(pev->spawnflags, SF_MONSTER_WAIT_FOR_SCRIPT);

	return TRUE;
}
Exemple #16
0
void CHostage::Spawn(void)
{
	Precache();

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

	pev->classname = MAKE_STRING("hostage_entity");
	AddEntityHashValue(pev, STRING(pev->classname), CLASSNAME);

	pev->movetype = MOVETYPE_STEP;
	pev->solid = SOLID_SLIDEBOX;
	pev->takedamage = DAMAGE_YES;
	pev->flags |= FL_MONSTER;
	pev->deadflag = DEAD_NO;
	pev->max_health = 100;
	pev->health = pev->max_health;
	pev->gravity = 1;
	pev->view_ofs = VEC_HOSTAGE_VIEW;
	pev->velocity = Vector(0, 0, 0);

	if (pev->spawnflags & SF_MONSTER_HITMONSTERCLIP)
		pev->flags |= FL_MONSTERCLIP;

	if (pev->skin < 0)
		pev->skin = 0;

	SET_MODEL(ENT(pev), STRING(pev->model));
	SetActivity(ACT_IDLE);

	m_flNextChange = 0;
	m_State = STAND;
	m_hTargetEnt = NULL;
	m_hStoppedTargetEnt = NULL;
	m_vPathToFollow[0] = Vector(0, 0, 0);
	m_flFlinchTime = 0;
	m_bRescueMe = 0;

	UTIL_SetSize(pev, VEC_HOSTAGE_HULL_MIN, VEC_HOSTAGE_HULL_MAX);
	UTIL_MakeVectors(pev->v_angle);

	SetBoneController(0, UTIL_VecToYaw(gpGlobals->v_forward));
	SetBoneController(1, 0);
	SetBoneController(2, 0);
	SetBoneController(3, 0);
	SetBoneController(4, 0);

	DROP_TO_FLOOR(ENT(pev));

	SetThink(&CHostage::IdleThink);
	pev->nextthink = gpGlobals->time + RANDOM_FLOAT(0.1, 0.2);

	m_flNextFullThink = gpGlobals->time + RANDOM_FLOAT(0.1, 0.2);
	m_vStart = pev->origin;
	m_vStartAngles = pev->angles;
	m_vOldPos = Vector(9999, 9999, 9999);
	m_iHostageIndex = ++g_iHostageNumber;
	nTargetNode = -1;
	m_fHasPath = FALSE;
	m_flLastPathCheck = -1;
	m_flPathAcquired = -1;
	m_flPathCheckInterval = 0.1;
	m_flNextRadarTime = gpGlobals->time + RANDOM_FLOAT(0, 1);
	m_LocalNav = new CLocalNav(this);
	m_bStuck = FALSE;
	m_flStuckTime = 0;
	m_improv = NULL;
}