예제 #1
0
파일: npc_ai.cpp 프로젝트: CCNHsK-Dev/SyPB
NPC::NPC(const char *className, const char *modelName, float maxHealth, float maxSpeed, int team)
{
	pev = null;
	NewNPCSetting();

	edict_t *pent;
	pent = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));

	if (FNullEnt(pent))
		return;

	pev = VARS(pent);
	pev->classname = ALLOC_STRING(className);
	pev->model = MAKE_STRING(modelName);

	pev->flags |= (FL_MONSTER | FL_MONSTERCLIP);

	pev->movetype = MOVETYPE_STEP;
	pev->solid = SOLID_BBOX;
	pev->takedamage = DAMAGE_NO;
	pev->deadflag = DEAD_DEAD;
	pev->max_health = maxHealth;
	pev->gravity = 1.0f;
	pev->maxspeed = maxSpeed;

	SET_MODEL(GetEntity(), (char *)STRING(pev->model));
	pev->framerate = 1.0;
	pev->frame = 0;
	g_npcSize[0] = Vector(-16.0f, -16.0f, -32.0f);
	g_npcSize[1] = Vector(16.0f, 16.0f, 32.0f);

	m_npcTeam = team;
}
예제 #2
0
파일: player.cpp 프로젝트: reuben/amxmodx
// ns_giveiteM(id,"item");
static cell AMX_NATIVE_CALL ns_giveitem(AMX *amx, cell *params)
{
	CreatePlayerPointer(amx,params[1]);

	char *classname = MF_GetAmxString(amx,params[2],0,NULL);

	if (!player->IsConnected())
	{
		return 0;
	}
	if (player->GetPev()->deadflag > 0)
	{
		return 0;
	}

	edict_t *object=CREATE_NAMED_ENTITY(ALLOC_STRING2(classname));

	if (!object)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Error creating entity \"%s\"", classname);
		return 0;
	}

	SET_ORIGIN(object,player->GetPev()->origin);						// move to player
	gpGamedllFuncs->dllapi_table->pfnSpawn(object);						// emulate spawn
	object->v.flags |= FL_ONGROUND;										// make it think it's touched the ground
	gpGamedllFuncs->dllapi_table->pfnThink(object);						// 
	gpGamedllFuncs->dllapi_table->pfnTouch(object,player->GetEdict());	// give it to the player

	return 1;
}
예제 #3
0
CBaseEntity *GiveNamedItemInternal(AMX *amx, CBasePlayer *pPlayer, const char *pszItemName, const size_t uid)
{
	edict_t *pEdict = CREATE_NAMED_ENTITY(ALLOC_STRING(pszItemName));
	if (FNullEnt(pEdict))
	{
		AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: Item \"%s\" failed to create!\n", __FUNCTION__, pszItemName);
		return nullptr;
	}

	pEdict->v.origin = pPlayer->pev->origin;
	pEdict->v.spawnflags |= SF_NORESPAWN;

	// In some cases, we must to sets unique id
	// for the entity before it will triggered a spawn.
	pEdict->v.impulse = uid;

	MDLL_Spawn(pEdict);
	MDLL_Touch(pEdict, ENT(pPlayer->pev));

	CBaseEntity *pEntity = getPrivate<CBaseEntity>(pEdict);

	// not allow the item to fall to the ground.
	if (FNullEnt(pEntity->pev->owner) || pEntity->pev->owner != pPlayer->edict())
	{
		pEntity->pev->targetname = iStringNull;
		pEntity->pev->flags |= FL_KILLME;

		return nullptr;
	}

	return pEntity;
}
예제 #4
0
파일: world.cpp 프로젝트: ET-NiK/amxxgroup
static void InitBodyQue(void)
{
	string_t	istrClassname = MAKE_STRING("bodyque");

	g_pBodyQueueHead = CREATE_NAMED_ENTITY( istrClassname );
	entvars_t *pev = VARS(g_pBodyQueueHead);
	
	// Reserve 3 more slots for dead bodies
	for ( int i = 0; i < 3; i++ )
	{
		pev->owner = CREATE_NAMED_ENTITY( istrClassname );
		pev = VARS(pev->owner);
	}
	
	pev->owner = g_pBodyQueueHead;
}
예제 #5
0
//shamelessly pulled from fun
static cell AMX_NATIVE_CALL csdm_give_item(AMX *amx, cell *params) // native give_item(index, const item[]); = 2 params
{
	// Check index.
	if (params[1] < 1 || params[1] > gpGlobals->maxClients)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", params[1]);
		return 0;
	} else if (!MF_IsPlayerIngame(params[1])) {
		MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not in game", params[1]);
		return 0;
	}

	// Get player pointer.
	edict_t *pPlayer = MF_GetPlayerEdict(params[1]);

	// Create item entity pointer
	edict_t	*pItemEntity;

	// Make an "intstring" out of 2nd parameter
	int length;
	const char *szItem = MF_GetAmxString(amx, params[2], 1, &length);

	//check for valid item
	if (strncmp(szItem, "weapon_", 7) && 
		strncmp(szItem, "ammo_", 5) && 
		strncmp(szItem, "item_", 5) &&
		strncmp(szItem, "tf_weapon_", 10)
	) {
		return 0;
	}

	string_t item = ALLOC_STRING(szItem); // Using MAKE_STRING makes "item" contents get lost when we leave this scope! ALLOC_STRING seems to allocate properly...
	pItemEntity = CREATE_NAMED_ENTITY(item);

	if (FNullEnt(pItemEntity)) {
		MF_LogError(amx, AMX_ERR_NATIVE, "Item \"%s\" failed to create", szItem);
		return 0;
	}

	pItemEntity->v.origin = pPlayer->v.origin;
	pItemEntity->v.spawnflags |= (1 << 30);	//SF_NORESPAWN;

	MDLL_Spawn(pItemEntity);

	int save = pItemEntity->v.solid;

	MDLL_Touch(pItemEntity, ENT(pPlayer));

	if (pItemEntity->v.solid == save)
	{
		REMOVE_ENTITY(pItemEntity);
		//the function did not fail - we're just deleting the item
		return -1;
	}

	return ENTINDEX(pItemEntity);
}
예제 #6
0
/*
create new model entity
*/
void editorBrush::newModel() {
    model = CREATE_NAMED_ENTITY(ALLOC_STRING(BRUSH_CLASSNAME));
    SET_MODEL(model,BRUSH_MODELNAME);
    model->v.origin = mins;
    Vector size = (maxs-mins)/4;
    for(int i = 0; i < 3; i++) {
        model->v.controller[i] = size[i];
    }
    model->v.skin = g_textures->getSkin(faces[0].texture);	//faces[0]->texture should do the trick
    MDLL_Spawn(model);
}
예제 #7
0
파일: entity.cpp 프로젝트: Chuvi-w/amxmodx
static cell AMX_NATIVE_CALL create_entity(AMX *amx, cell *params)
{
	int len;
	int iszClass = AmxStringToEngine(amx, params[1], len);

	edict_t *pEnt = CREATE_NAMED_ENTITY(iszClass);

	if (FNullEnt(pEnt))
		return 0;

	return ENTINDEX(pEnt);
}
예제 #8
0
파일: avpara.cpp 프로젝트: Landokane/avc
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;

}
예제 #9
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);
}
예제 #10
0
// NOTE: szName must be a pointer to constant memory, e.g. "monster_class" because the entity
// will keep a pointer to it after this call.
CBaseEntity *CBaseEntity::Create(char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner)
{
	edict_t *    pent;
	CBaseEntity *pEntity;

	pent = CREATE_NAMED_ENTITY(MAKE_STRING(szName));
	if(FNullEnt(pent))
	{
		ALERT(at_console, "NULL Ent in Create!\n");
		return NULL;
	}
	pEntity              = Instance(pent);
	pEntity->pev->owner  = pentOwner;
	pEntity->pev->origin = vecOrigin;
	pEntity->pev->angles = vecAngles;
	DispatchSpawn(pEntity->edict());
	return pEntity;
}
예제 #11
0
파일: fun.cpp 프로젝트: 9iky6/amxmodx
// SidLuke
static cell AMX_NATIVE_CALL strip_user_weapons(AMX *amx, cell *params) // index
{
	CHECK_PLAYER(params[1]);

	edict_t* pPlayer = MF_GetPlayerEdict(params[1]);

	string_t item = MAKE_STRING("player_weaponstrip");
	edict_t *pent = CREATE_NAMED_ENTITY(item);
	
	if (FNullEnt(pent)) 
	{
		return 0;
	}

	MDLL_Spawn(pent);
	MDLL_Use(pent, pPlayer);
	REMOVE_ENTITY(pent);

	*reinterpret_cast<int *>(MF_PlayerPropAddr(params[1], Player_CurrentWeapon)) = 0;

	return 1;
}
예제 #12
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);
}
예제 #13
0
파일: cmbase.cpp 프로젝트: ET-NiK/amxxgroup
edict_t *CMBaseEntity::CreateEntity(char *classname)
{
    int istr = MAKE_STRING(classname);

    edict_t *pent = CREATE_NAMED_ENTITY(istr);

    if ( FNullEnt( pent ) )
        return NULL;

    pev = VARS(pent);

    pev->movetype = MOVETYPE_NONE;
    pev->solid = SOLID_NOT;
    pev->flags = 0;

    m_pfnThink = NULL;
    m_pfnTouch = NULL;
    m_pfnUse = NULL;
    m_pfnBlocked = NULL;

    pev->euser4 = (edict_t *)this;

    return pent;
}
//=========================================================
// MakeMonster-  this is the code that drops the monster
//=========================================================
CBaseMonster* CMonsterMaker::MakeMonster( void )
{
	edict_t	*pent;
	entvars_t		*pevCreate;

//	ALERT(at_console,"Making Monster NOW\n");

	pent = CREATE_NAMED_ENTITY( m_iszMonsterClassname );

	if ( FNullEnt( pent ) )
	{
		ALERT ( at_debug, "NULL Ent in MonsterMaker!\n" );
		return NULL;
	}

	pevCreate = VARS( pent );
	
	pevCreate->origin = pev->vuser1;	//AJH dynamic (*locus) position
	pevCreate->angles = pev->vuser2;
	pevCreate->velocity = pev->vuser3;

	SetBits( pevCreate->spawnflags, SF_MONSTER_FALL_TO_GROUND );

	if (pev->spawnflags & SF_MONSTERMAKER_NO_WPN_DROP)
		SetBits( pevCreate->spawnflags, SF_MONSTER_NO_WPN_DROP);

	// Children hit monsterclip brushes
	if ( pev->spawnflags & SF_MONSTERMAKER_MONSTERCLIP )
		SetBits( pevCreate->spawnflags, SF_MONSTER_HITMONSTERCLIP );

	DispatchSpawn( ENT( pevCreate ) );
	pevCreate->owner = edict();

	//LRC - custom monster behaviour
	CBaseEntity *pEntity = CBaseEntity::Instance( pevCreate );
	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	

	}

	if ( !FStringNull( pev->netname ) )
	{
		// if I have a netname (overloaded), give the child monster that name as a targetname
		pevCreate->targetname = pev->netname;
	}

	m_cLiveChildren++;// count this monster
	m_cNumMonsters--;

	if ( m_cNumMonsters == 0 )
	{
		// Disable this forever.  Don't kill it because it still gets death notices
		SetThink( NULL );
		SetUse( NULL );
	}
	else if (m_fActive)
	{
		SetNextThink( m_flDelay );
		SetThink(&CMonsterMaker:: MakerThink );
	}

	return pMonst;
}
예제 #15
0
//=========================================================
// MakeMonster-  this is the code that drops the monster
//=========================================================
void CMonsterMaker::MakeMonster( void )
{
	edict_t	*pent;
	entvars_t		*pevCreate;

	if ( m_iMaxLiveChildren > 0 && m_cLiveChildren >= m_iMaxLiveChildren )
	{// not allowed to make a new one yet. Too many live ones out right now.
		return;
	}

	if ( !m_flGround )
	{
		// set altitude. Now that I'm activated, any breakables, etc should be out from under me. 
		TraceResult tr;

		UTIL_TraceLine ( pev->origin, pev->origin - Vector ( 0, 0, 2048 ), ignore_monsters, ENT(pev), &tr );
		m_flGround = tr.vecEndPos.z;
	}

	Vector mins = pev->origin - Vector( 34, 34, 0 );
	Vector maxs = pev->origin + Vector( 34, 34, 0 );
	maxs.z = pev->origin.z;
	mins.z = m_flGround;

	CBaseEntity *pList[2];
	int count = UTIL_EntitiesInBox( pList, 2, mins, maxs, FL_CLIENT|FL_MONSTER );
	if ( count )
	{
		// don't build a stack of monsters!
		return;
	}

	pent = CREATE_NAMED_ENTITY( m_iszMonsterClassname );

	if ( FNullEnt( pent ) )
	{
		ALERT ( at_console, "NULL Ent in MonsterMaker!\n" );
		return;
	}
	
	// If I have a target, fire!
	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 );
	}

	pevCreate = VARS( pent );
	pevCreate->origin = pev->origin;
	pevCreate->angles = pev->angles;
	SetBits( pevCreate->spawnflags, SF_MONSTER_FALL_TO_GROUND );

	// Children hit monsterclip brushes
	if ( pev->spawnflags & SF_MONSTERMAKER_MONSTERCLIP )
		SetBits( pevCreate->spawnflags, SF_MONSTER_HITMONSTERCLIP );

	DispatchSpawn( ENT( pevCreate ) );
	pevCreate->owner = edict();

	if ( !FStringNull( pev->netname ) )
	{
		// if I have a netname (overloaded), give the child monster that name as a targetname
		pevCreate->targetname = pev->netname;
	}

	m_cLiveChildren++;// count this monster
	m_cNumMonsters--;

	if ( m_cNumMonsters == 0 )
	{
		// Disable this forever.  Don't kill it because it still gets death notices
		SetThink( NULL );
		SetUse( NULL );
	}
}
예제 #16
0
파일: fun.cpp 프로젝트: 9iky6/amxmodx
static cell AMX_NATIVE_CALL give_item(AMX *amx, cell *params) // native give_item(index, const item[]); = 2 params
{
	/* Gives item to player, name of item can start
	* with weapon_, ammo_ and item_. This event
	* is announced with proper message to all players. */
	// params[1] = index
	// params[2] = item...

	// Check index.
	CHECK_PLAYER(params[1]);

	// Get player pointer.
	edict_t *pPlayer = MF_GetPlayerEdict(params[1]);

	// Create item entity pointer
	edict_t	*pItemEntity;

	// Make an "intstring" out of 2nd parameter
	int length;
	const char *szItem = MF_GetAmxString(amx, params[2], 1, &length);

	//check for valid item
	if (strncmp(szItem, "weapon_", 7) && 
		strncmp(szItem, "ammo_", 5) && 
		strncmp(szItem, "item_", 5) &&
		strncmp(szItem, "tf_weapon_", 10)
	) {
		return 0;
	}

	//string_t item = MAKE_STRING(szItem);
	string_t item = ALLOC_STRING(szItem); // Using MAKE_STRING makes "item" contents get lost when we leave this scope! ALLOC_STRING seems to allocate properly...
	// Create the entity, returns to pointer
	pItemEntity = CREATE_NAMED_ENTITY(item);

	if (FNullEnt(pItemEntity)) {
		MF_LogError(amx, AMX_ERR_NATIVE, "Item \"%s\" failed to create", szItem);
		return 0;
	}

	//VARS(pItemEntity)->origin = VARS(pPlayer)->origin; // nice to do VARS(ent)->origin instead of ent->v.origin? :-I
	//I'm not sure, normally I use macros too =P
	pItemEntity->v.origin = pPlayer->v.origin;
	pItemEntity->v.spawnflags |= SF_NORESPAWN;	//SF_NORESPAWN;

	MDLL_Spawn(pItemEntity);

	int save = pItemEntity->v.solid;

	MDLL_Touch(pItemEntity, ENT(pPlayer));

	//The problem with the original give_item was the
	// item was not removed.  I had tried this but it
	// did not work.  OLO's implementation is better.
	/*
	int iEnt = ENTINDEX(pItemEntity->v.owner);
	if (iEnt > 32 || iEnt <1 ) {
		MDLL_Think(pItemEntity);
	}*/

	if (pItemEntity->v.solid == save) {
		REMOVE_ENTITY(pItemEntity);
		//the function did not fail - we're just deleting the item
		return -1;
	}

	return ENTINDEX(pItemEntity);
}
예제 #17
0
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 );
}
예제 #18
0
파일: avdance.cpp 프로젝트: Landokane/avc
bool DanceCreateMachine( Vector cent, edict_t *pEntity, const char *dancename)
{


	entvars_t *pPev = VARS( pEntity );


	KeyValueData	kvd;
			
	edict_t *tEntity;
	tEntity = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
		
	entvars_t *pev;
	pev =  VARS(tEntity);
			
	// Set the KEYVALUES here!
	kvd.fHandled = FALSE;
	kvd.szClassName = NULL;
	kvd.szKeyName = "classname";
	kvd.szValue = "building_dancemachine";

	DispatchKeyValue( tEntity, &kvd );

	// place this in front
	
	pev->origin = cent;
	pev->solid = SOLID_BBOX;
	
	SET_ORIGIN( tEntity , cent );
	//pev->angles = angles;
	pev->solid = SOLID_BBOX;

	SET_MODEL( ENT( pev ) , "models/sphere.mdl");

	UTIL_SetSize( pev, Vector( -16, -16 , -16), Vector(16, 16, 16) );

	pev->takedamage = DAMAGE_NO;
	pev->max_health = 40 + 10000;
	pev->health = 40 + 10000;
	pev->euser4 = pEntity;
	pev->movetype = MOVETYPE_FLY;

	// play deploy sound
	EMIT_SOUND_DYN2( tEntity, CHAN_VOICE, "weapons/mine_deploy.wav", 1.0, ATTN_NORM , 0, 100);
	pev->nextthink = gpGlobals->time + 1;
			
	pev->avelocity.y = 50;
	
	sprintf( EntData[ENTINDEX(tEntity)].digitgroup, "%s", dancename);

	if (FStrEq(Cmd_Argv(2), "rot"))
	{
		// rotates. get the distance, angular speed, and initial angle

		pev->iuser1 = atoi(Cmd_Argv(3));
		pev->fuser1 = atof(Cmd_Argv(4));
		pev->iuser3 = atoi(Cmd_Argv(5));

		// mark original origin
		pev->vuser1 = pEntity->v.origin;
		pev->avelocity.y = 0;
	}
			
	return 0;

}
예제 #19
0
파일: avradio.cpp 프로젝트: Landokane/avc
bool RadioCreate( edict_t *pEntity )
{
	// Create the radio and stick to the wall

	entvars_t *pPev = VARS( pEntity );

	if (pPev->iuser1 > 0) return 0;


	// make sure we dont already have a radio

	int radiocount = 0;
	int i = 1;
	char *pClassname;
	edict_t *frontEnt;

	for (i; i < 1025; i++) {

		frontEnt = INDEXENT ( i );
		if (frontEnt) {
			pClassname =  (char *)STRING(frontEnt->v.classname); 
			if (FStrEq("building_radio", pClassname)) {

				if (frontEnt->v.euser4 == pEntity) 
				{
					radiocount++;
				}
			}
		}
	}

	
	if (AdminLoggedIn[ENTINDEX(pEntity)] == 0)
	{
		if (radiocount >= 2) {
			ClientPrint( pPev, HUD_PRINTTALK, "* Cant have more than 2 radios!\n");
			return 0;
		}
	}

	UTIL_MakeVectors( pPev->v_angle + pPev->punchangle );
	Vector vecSrc	 = GetGunPosition( pEntity );
	Vector vecAiming = gpGlobals->v_forward;

	TraceResult tr;

	UTIL_TraceLine( vecSrc, vecSrc + vecAiming * 128, dont_ignore_monsters, pEntity , &tr );

	if (tr.flFraction < 1.0 || AdminLoggedIn[ENTINDEX(pEntity)])
	{

		
		if (tr.pHit && !(tr.pHit->v.flags & FL_CONVEYOR) && (FStrEq((char *)STRING(tr.pHit->v.classname), "worldspawn") || FStrEq((char *)STRING(tr.pHit->v.classname), "func_wall") || AdminLoggedIn[ENTINDEX(pEntity)] || FStrEq((char *)STRING(tr.pHit->v.classname), "building_dancemachine")))	// Make sure it isnt a conveyor!
		{
			Vector angles = UTIL_VecToAngles( tr.vecPlaneNormal );

			if ((angles.x > 30 || angles.x < -30) && AdminLoggedIn[ENTINDEX(pEntity)] == 0)
			{
				ClientPrint( pPev, HUD_PRINTTALK, "* Can't place radios on floors or cielings!\n");
				return 0;
			}
			// Create the camera here!
			Vector vecOri = tr.vecEndPos + tr.vecPlaneNormal * 14;
			//Vector vecOri = tr.vecEndPos + tr.vecPlaneNormal * 15;

			int maxdist = (int)CVAR_GET_FLOAT("sa_radiospread");

			// make sure we arent placing it within 400 units of another radio
			for (i=1; i < 1025; i++) {

				frontEnt = INDEXENT ( i );
				if (frontEnt) {
					pClassname =  (char *)STRING(frontEnt->v.classname); 
					if (FStrEq("building_radio", pClassname)) {
						
						if ((frontEnt->v.origin - vecOri).Length() < maxdist && AdminLoggedIn[ENTINDEX(pEntity)] == 0)
						{
							ClientPrint( pPev, HUD_PRINTTALK, "* Can't place a radio so close to another radio!\n");
							return 0;
						}
					}
				}
			}

			KeyValueData	kvd;
			
			//edict_t *pent = CREATE_ENTITY();
			//edict_t *pent = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));

			edict_t *tEntity;
			tEntity = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
		
			entvars_t *pRunOnPev;
			pRunOnPev =  VARS(tEntity);
			
			char buf[80];
			sprintf( buf, "%s", "building_radio");

			// Set the KEYVALUES here!
			kvd.fHandled = FALSE;
			kvd.szClassName = NULL;
			kvd.szKeyName = "classname";
			kvd.szValue = buf;

			DispatchKeyValue( tEntity, &kvd );

			// place this in front

			pRunOnPev->origin = vecOri;
			SET_ORIGIN( tEntity , vecOri );
			pRunOnPev->angles = angles;

			//DispatchSpawn( ENT( pRunOnPev ) );

			pRunOnPev->solid = SOLID_BBOX;

			SET_MODEL( ENT( pRunOnPev ) , "avatar-x/avadd16.avfil");
			UTIL_SetSize( pRunOnPev, Vector( -2, -2 ,-2) - (tr.vecPlaneNormal * 15), Vector(2, 2, 16) - (tr.vecPlaneNormal * 15));
			
			pRunOnPev->takedamage = DAMAGE_YES;
			pRunOnPev->max_health = 40 + 10000;
			pRunOnPev->health = 40 + 10000;
			pRunOnPev->euser4 = pEntity;
			
			/*
			edict_t *pent;
			pent = CREATE_NAMED_ENTITY(MAKE_STRING("xen_tree"));
			entvars_t *pv = VARS( pent );
			
			pv->origin = vecOri;
			SET_ORIGIN(pent, vecOri);

			kvd.fHandled = FALSE;
			kvd.szClassName = NULL;
			kvd.szKeyName = "classname";
			kvd.szValue = "xen_tree";
			DispatchKeyValue( pent, &kvd );

			DispatchSpawn(pent);
			//pev->angles = angles;
			
			
			*/

			//pev->iuser1 = angles.y;
			//pv->vuser3 = angles;

			// for now don't take damage
			//pev->takedamage = DAMAGE_YES;
			//pev->max_health = 40 + 10000;
			//pev->health = 40 + 10000;

			/*
			// Call the SPAWN routine to set more stuff
			kvd.fHandled = FALSE;
			kvd.szClassName = NULL;
			kvd.szKeyName = "classname";
			kvd.szValue = "building_radio";
			//DispatchKeyValue( pent, &kvd );
			kvd.fHandled = FALSE;

			

			
			*/

			RadioSpawn( tEntity );
	
			return 1;
		}
		else
		{
			ClientPrint( pPev, HUD_PRINTTALK, "* Couldn't place radio here!\n");
			return 0;
		}
		
	}
	else
	{
		ClientPrint( pPev, HUD_PRINTTALK, "* Couldn't place radio here!\n");
		
	}
	return 0;
}
예제 #20
0
void startHudTimer()
{
	g_hudTimer = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
	g_hudTimer->v.classname = MAKE_STRING("hudTimer");
	g_hudTimer->v.nextthink = gpGlobals->time + 1.0;
}
예제 #21
0
// ns_create_partsys(const name[], pGenShape, const pGenShapeParams[], pGenRate, const pSprite[], 
// pSpriteFrames, pNumParticles, Float:pSize, const pVelParams[], pVelShape, 
// Float:pSystemLifetime, Float:pParticleLifetime, pRenderMode, const pPSToGen[], pAnimationSpeed, pSpawnFlags)
static cell AMX_NATIVE_CALL ns_create_partsys(AMX *amx, cell *params)
{
	return (cell)CREATE_NAMED_ENTITY(MAKE_STRING("env_particles_custom"));
};
예제 #22
0
파일: avdance.cpp 프로젝트: Landokane/avc
bool DanceCreate( edict_t *pEntity )
{
	// Create the dance machine

	entvars_t *pPev = VARS( pEntity );


	if (AdminLoggedIn[ENTINDEX(pEntity)] == 0)
	{
		ClientPrint( pPev, HUD_PRINTTALK, "* Admin only feature\n");
		return 0;
	}

	UTIL_MakeVectors( pPev->v_angle + pPev->punchangle );
	Vector vecSrc	 = GetGunPosition( pEntity );
	Vector vecAiming = gpGlobals->v_forward;

	TraceResult tr;

	UTIL_TraceLine( vecSrc, vecSrc + vecAiming * 128, dont_ignore_monsters, pEntity , &tr );

	//if (tr.flFraction < 1.0)
	//{
	
			Vector angles = UTIL_VecToAngles( tr.vecPlaneNormal );

			// Create the paper here!
			KeyValueData	kvd;
			
			edict_t *tEntity;
			tEntity = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
		
			entvars_t *pRunOnPev;
			pRunOnPev =  VARS(tEntity);
			
			// Set the KEYVALUES here!
			kvd.fHandled = FALSE;
			kvd.szClassName = NULL;
			kvd.szKeyName = "classname";
			kvd.szValue = "building_dancemachine";

			DispatchKeyValue( tEntity, &kvd );

			// place this in front
			Vector vecOri = tr.vecEndPos;
			pRunOnPev->origin = vecOri;
			pRunOnPev->solid = SOLID_BBOX;

			SET_ORIGIN( tEntity , vecOri );
			pRunOnPev->angles = angles;
			pRunOnPev->solid = SOLID_BBOX;

			SET_MODEL( ENT( pRunOnPev ) , "models/sphere.mdl");

			UTIL_SetSize( pRunOnPev, Vector( -16, -16 , -16), Vector(16, 16, 16) );

			pRunOnPev->takedamage = DAMAGE_NO;
			pRunOnPev->max_health = 40 + 10000;
			pRunOnPev->health = 40 + 10000;
			pRunOnPev->euser4 = pEntity;
			pRunOnPev->movetype = MOVETYPE_FLY;

			//DROP_TO_FLOOR( tEntity );


			// play deploy sound
			EMIT_SOUND_DYN2( tEntity, CHAN_VOICE, "weapons/mine_deploy.wav", 1.0, ATTN_NORM , 0, 100);
			//unOnPev->iuser2 = pRunOnPev->euser4->v.team; // Set the team this radio belongs to
			pRunOnPev->nextthink = gpGlobals->time + 1;
			
			pRunOnPev->avelocity.y = 50;
	
			sprintf( EntData[ENTINDEX(tEntity)].digitgroup, "%s", Cmd_Argv(1));

			if (FStrEq(Cmd_Argv(2), "rot"))
			{
				// rotates. get the distance, angular speed, and initial angle

				pRunOnPev->iuser1 = atoi(Cmd_Argv(3));
				pRunOnPev->fuser1 = atof(Cmd_Argv(4));
				pRunOnPev->iuser3 = atoi(Cmd_Argv(5));
	
				// mark original origin
				pRunOnPev->vuser1 = pEntity->v.origin;
				pRunOnPev->avelocity.y = 0;
	
			}


			
	return 0;
}
예제 #23
0
파일: engine.cpp 프로젝트: 9iky6/amxmodx
// SetView, this sets the view of a player. This is done by
// Creating a camera entity, which follows the player.
//(vexd)
static cell AMX_NATIVE_CALL set_view(AMX *amx, cell *params) { 
	int iIndex = params[1];
	int iCameraType = params[2];

	if (iIndex > gpGlobals->maxClients || !MF_IsPlayerIngame(iIndex)) {
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", iIndex);
		return 0;
	}

	edict_t *pPlayer = INDEXENT2(iIndex);
	edict_t *pNewCamera;

	switch(iCameraType)
	{
		case CAMERA_NONE:
			SET_VIEW(pPlayer, pPlayer);
			if(plinfo[ENTINDEX(pPlayer)].pViewEnt) {
				REMOVE_ENTITY(plinfo[ENTINDEX(pPlayer)].pViewEnt);
			}
			if (plinfo[ENTINDEX(pPlayer)].iViewType != CAMERA_NONE) // Verify that they were originally in a modified view
			{
				g_CameraCount--;
				if (g_CameraCount < 0)
					g_CameraCount=0;
				if (g_CameraCount==0) // Reset the AddToFullPack pointer if there's no more cameras in use...
					g_pFunctionTable->pfnAddToFullPack=NULL;
			}

			plinfo[ENTINDEX(pPlayer)].iViewType = CAMERA_NONE;
			plinfo[ENTINDEX(pPlayer)].pViewEnt = NULL;
			return 1;
			break;
		case CAMERA_3RDPERSON:
			if(plinfo[ENTINDEX(pPlayer)].iViewType != CAMERA_NONE) {
				plinfo[ENTINDEX(pPlayer)].iViewType = CAMERA_3RDPERSON;
				return 1;
			}
			g_CameraCount++;
			g_pFunctionTable_Post->pfnAddToFullPack=AddToFullPack_Post;
			g_pFunctionTable_Post->pfnPlayerPostThink=PlayerPostThink_Post;

			plinfo[ENTINDEX(pPlayer)].iViewType = CAMERA_3RDPERSON;
			pNewCamera = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
			pNewCamera->v.classname = MAKE_STRING("VexdCam");

			SET_MODEL(pNewCamera, "models/rpgrocket.mdl");
			SET_SIZE(pNewCamera, Vector(0, 0, 0), Vector(0, 0, 0));

			pNewCamera->v.movetype = MOVETYPE_NOCLIP;
			pNewCamera->v.solid = SOLID_NOT;
			pNewCamera->v.takedamage = DAMAGE_NO;
			pNewCamera->v.gravity = 0;
			pNewCamera->v.owner = pPlayer;
			pNewCamera->v.rendermode = kRenderTransColor;
			pNewCamera->v.renderamt = 0;
			pNewCamera->v.renderfx = kRenderFxNone;

			SET_VIEW(pPlayer, pNewCamera);

			plinfo[ENTINDEX(pPlayer)].pViewEnt = pNewCamera;
			break;
		case CAMERA_UPLEFT:
			if(plinfo[ENTINDEX(pPlayer)].iViewType != CAMERA_NONE) {
				plinfo[ENTINDEX(pPlayer)].iViewType = CAMERA_UPLEFT;
				return 1;
			}

			g_CameraCount++;
			g_pFunctionTable_Post->pfnAddToFullPack=AddToFullPack_Post;
			g_pFunctionTable_Post->pfnPlayerPostThink=PlayerPostThink_Post;

			plinfo[ENTINDEX(pPlayer)].iViewType = CAMERA_UPLEFT;
			pNewCamera = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
			pNewCamera->v.classname = MAKE_STRING("VexdCam");

			SET_MODEL(pNewCamera, "models/rpgrocket.mdl");
			SET_SIZE(pNewCamera, Vector(0, 0, 0), Vector(0, 0, 0));

			pNewCamera->v.movetype = MOVETYPE_NOCLIP;
			pNewCamera->v.solid = SOLID_NOT;
			pNewCamera->v.takedamage = DAMAGE_NO;
			pNewCamera->v.gravity = 0;
			pNewCamera->v.owner = pPlayer;
			pNewCamera->v.rendermode = kRenderTransColor;
			pNewCamera->v.renderamt = 0;
			pNewCamera->v.renderfx = kRenderFxNone;

			SET_VIEW(pPlayer, pNewCamera);

			plinfo[ENTINDEX(pPlayer)].pViewEnt = pNewCamera;
			break;
		case CAMERA_TOPDOWN:
			if(plinfo[ENTINDEX(pPlayer)].iViewType != CAMERA_NONE) {
				plinfo[ENTINDEX(pPlayer)].iViewType = CAMERA_TOPDOWN;
				return 1;
			}

			g_CameraCount++;
			g_pFunctionTable_Post->pfnAddToFullPack=AddToFullPack_Post;
			g_pFunctionTable_Post->pfnPlayerPostThink=PlayerPostThink_Post;

			plinfo[ENTINDEX(pPlayer)].iViewType = CAMERA_TOPDOWN;
			pNewCamera = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
			pNewCamera->v.classname = MAKE_STRING("VexdCam");

			SET_MODEL(pNewCamera, "models/rpgrocket.mdl");
			SET_SIZE(pNewCamera, Vector(0, 0, 0), Vector(0, 0, 0));

			pNewCamera->v.movetype = MOVETYPE_NOCLIP;
			pNewCamera->v.solid = SOLID_NOT;
			pNewCamera->v.takedamage = DAMAGE_NO;
			pNewCamera->v.gravity = 0;
			pNewCamera->v.owner = pPlayer;
			pNewCamera->v.rendermode = kRenderTransColor;
			pNewCamera->v.renderamt = 0;
			pNewCamera->v.renderfx = kRenderFxNone;

			SET_VIEW(pPlayer, pNewCamera);

			plinfo[ENTINDEX(pPlayer)].pViewEnt = pNewCamera;
			break;
		default:
			break;
	}

	return 1;
}