Exemplo n.º 1
0
/*
================
LaunchItem

Spawns an item and tosses it forward
================
*/
GameEntity *LaunchItem( gitem_t *item, vec3_t origin, vec3_t velocity ) 
{
	GameEntity	*dropped;

	dropped = theLevel.spawnEntity();

	dropped->s.eType = ET_ITEM;
	dropped->s.modelindex = item - bg_itemlist;	// store item number in modelindex
	dropped->s.modelindex2 = 1; // This is non-zero is it's a dropped item

	dropped->classname_ = item->classname;
	dropped->item_ = item;
	VectorSet( dropped->r.mins, -ITEM_RADIUS, -ITEM_RADIUS, -ITEM_RADIUS );
	VectorSet( dropped->r.maxs, ITEM_RADIUS, ITEM_RADIUS, ITEM_RADIUS );
	dropped->r.contents = CONTENTS_TRIGGER;

	dropped->setTouch(new Touch_ItemTouch);

	G_SetOrigin( dropped, origin );
	dropped->s.pos.trType = TR_GRAVITY;
	dropped->s.pos.trTime = theLevel.time_;
	VectorCopy( velocity, dropped->s.pos.trDelta );

	dropped->s.eFlags |= EF_BOUNCE_HALF;

	if( g_gametype.integer == GT_CTF && item->giType == IT_TEAM) 
	{ 
		// Special case for CTF flags
		dropped->setThink(new Think_Team_DroppedFlagThink);
		dropped->nextthink_ = theLevel.time_ + 180000;
		Team_CheckDroppedItem( dropped );
	} 
	else
	{
		// auto-remove after 30 seconds
		dropped->setThink(new GameEntity::EntityFunc_Free);
		dropped->nextthink_ = theLevel.time_ + 30000;
	}

	dropped->flags_ = FL_DROPPED_ITEM;

	SV_LinkEntity( dropped );

	return dropped;
}
/*
================
LaunchItem

Spawns an item and tosses it forward
================
*/
gentity_t *LaunchItem( gitem_t *item, vec3_t origin, vec3_t velocity ) {
	gentity_t	*dropped;

	dropped = G_Spawn();

	dropped->s.eType = ET_ITEM;
	dropped->s.modelindex = item - bg_itemlist;	// store item number in modelindex
	dropped->s.modelindex2 = 1; // This is non-zero is it's a dropped item

	dropped->classname = item->classname;
	dropped->item = item;
	VectorSet (dropped->r.mins, -ITEM_RADIUS, -ITEM_RADIUS, -ITEM_RADIUS);
	VectorSet (dropped->r.maxs, ITEM_RADIUS, ITEM_RADIUS, ITEM_RADIUS);
	dropped->r.contents = CONTENTS_TRIGGER;

	dropped->touch = Touch_Item;

	G_SetOrigin( dropped, origin );
	dropped->s.pos.trType = TR_GRAVITY;
	dropped->s.pos.trTime = level.time;
	VectorCopy( velocity, dropped->s.pos.trDelta );

	dropped->s.eFlags |= EF_BOUNCE_HALF;
	// Special case for CTF flags
	if ( ( g_gametype.integer == GT_CTF ) && ( item->giType == IT_TEAM ) ) {
		dropped->think = Team_DroppedFlagThink;
		dropped->nextthink = ( level.time + RESPAWN_DROPPED_FLAG * 1000 );
		Team_CheckDroppedItem( dropped );
	}
	// auto-remove after timeout
	else {
		dropped->think = G_FreeEntity;
		dropped->nextthink = ( level.time + RESPAWN_DROPPED_ITEM * 1000 );
	}

	dropped->flags = FL_DROPPED_ITEM;

	trap_LinkEntity (dropped);

	return dropped;
}
Exemplo n.º 3
0
Arquivo: g_items.c Projeto: Razish/QtZ
// Spawns an item and tosses it forward
gentity_t *LaunchItem( const gitem_t *item, vector3 *origin, vector3 *velocity ) {
	gentity_t	*dropped;
	vector3 mins=ITEM_MINS, maxs=ITEM_MAXS;

	dropped = G_Spawn();

	dropped->s.eType = ET_ITEM;
	dropped->s.modelindex = ARRAY_INDEX( bg_itemlist, item ); // store item number in modelindex
	dropped->s.modelindex2 = 1; // This is non-zero is it's a dropped item

	dropped->classname = item->classname;
	dropped->item = item;
	VectorCopy( &mins, &dropped->r.mins );
	VectorCopy( &maxs, &dropped->r.maxs );
	dropped->r.contents = CONTENTS_TRIGGER;

	dropped->touch = Touch_Item;

	G_SetOrigin( dropped, origin );
	dropped->s.pos.trType = TR_GRAVITY;
	dropped->s.pos.trTime = level.time;
	VectorCopy( velocity, &dropped->s.pos.trDelta );

	dropped->flags |= FL_BOUNCE_HALF;
	if ((level.gametype == GT_FLAGS || level.gametype == GT_TROJAN) && item->giType == IT_TEAM) { // Special case for CTF flags
		dropped->think = Team_DroppedFlagThink;
		dropped->nextthink = level.time + 30000;
		Team_CheckDroppedItem( dropped );
	} else { // auto-remove after 30 seconds
		dropped->think = G_FreeEntity;
		dropped->nextthink = level.time + 30000;
	}

	dropped->flags = FL_DROPPED_ITEM;

	trap->SV_LinkEntity ((sharedEntity_t *)dropped);

	return dropped;
}
Exemplo n.º 4
0
/*
================
LaunchItem

Spawns an item and tosses it forward
================
*/
gentity_t *LaunchItem( gitem_t *item, vec3_t origin, vec3_t velocity ) {
	gentity_t	*dropped;

	dropped = G_Spawn();

	dropped->s.eType = ET_ITEM;
	dropped->s.modelindex = item - bg_itemlist;	// store item number in modelindex
	dropped->s.modelindex2 = 1; // This is non-zero is it's a dropped item

	dropped->classname = item->classname;
	dropped->item = item;
	VectorSet (dropped->r.mins, -ITEM_RADIUS, -ITEM_RADIUS, -ITEM_RADIUS);
	VectorSet (dropped->r.maxs, ITEM_RADIUS, ITEM_RADIUS, ITEM_RADIUS);
	dropped->r.contents = CONTENTS_TRIGGER;

	dropped->touch = Touch_Item;

	G_SetOrigin( dropped, origin );
	dropped->s.pos.trType = TR_GRAVITY;
	dropped->s.pos.trTime = level.time;
	VectorCopy( velocity, dropped->s.pos.trDelta );

	dropped->s.eFlags |= EF_BOUNCE_HALF;
#ifdef MISSIONPACK
	if ((g_gametype.integer == GT_CTF || g_gametype.integer == GT_1FCTF)			&& item->giType == IT_TEAM) { // Special case for CTF flags
#else
	if (g_gametype.integer == GT_CTF && item->giType == IT_TEAM) { // Special case for CTF flags
#endif
		dropped->think = Team_DroppedFlagThink;
		dropped->nextthink = level.time + 30000;
		Team_CheckDroppedItem( dropped );
	} else { // auto-remove after 30 seconds
		dropped->think = G_FreeEntity;
		dropped->nextthink = level.time + 30000;
	}

	dropped->flags = FL_DROPPED_ITEM;

	trap_LinkEntity (dropped);

	return dropped;
}

/*
================
Drop_Item

Spawns an item and tosses it forward
================
*/
gentity_t *Drop_Item( gentity_t *ent, gitem_t *item, float angle ) {
	vec3_t	velocity;
	vec3_t	angles;

	VectorCopy( ent->s.apos.trBase, angles );
	angles[YAW] += angle;
	angles[PITCH] = 0;	// always forward

	AngleVectors( angles, velocity, NULL, NULL );
	VectorScale( velocity, 150, velocity );
	velocity[2] += 200 + crandom() * 50;

	return LaunchItem( item, ent->s.pos.trBase, velocity );
}
Exemplo n.º 5
0
/*
================
LaunchItem

Spawns an item and tosses it forward
================
*/
gentity_t *LaunchItem(gitem_t * item, vec3_t origin, vec3_t velocity, int xr_flags)
{
	gentity_t *dropped;

	dropped = G_Spawn();

	dropped->s.eType = ET_ITEM;
	dropped->s.modelindex = item - bg_itemlist;	// store item number in modelindex
	dropped->s.modelindex2 = 1;	// This is non-zero if it's a dropped item

	dropped->classname = item->classname;
	dropped->item = item;
	VectorSet(dropped->r.mins, -ITEM_RADIUS, -ITEM_RADIUS, -ITEM_RADIUS);
	VectorSet(dropped->r.maxs, ITEM_RADIUS, ITEM_RADIUS, ITEM_RADIUS);
	dropped->r.contents = CONTENTS_TRIGGER;

	dropped->touch = Touch_Item;
	//Makro - added for TP
	dropped->reset = G_ResetItem;

	//Elder: suspend thrown knives so they don't jitter
	//G_Printf("xr_flags: %d, condition: %d\n", xr_flags, (xr_flags & FL_THROWN_KNIFE) == FL_THROWN_KNIFE);
	if (item->giTag == WP_KNIFE && ((xr_flags & FL_THROWN_KNIFE) == FL_THROWN_KNIFE)) {
		G_SetOrigin(dropped, origin);

		//reset back the dropped item case
		//dropped->flags = FL_DROPPED_ITEM;
		//dropped->s.eFlags |= EF_BOUNCE_HALF;
	} else {
		G_SetOrigin(dropped, origin);
		dropped->s.pos.trType = TR_GRAVITY;
		dropped->s.pos.trTime = level.time;
		VectorCopy(velocity, dropped->s.pos.trDelta);

		//Elder: moved from outside else statement
		dropped->s.eFlags |= EF_BOUNCE_HALF;
	}

	if (g_gametype.integer == GT_CTF && item->giType == IT_TEAM) {	// Special case for CTF flags
		dropped->think = Team_DroppedFlagThink;
		dropped->nextthink = level.time + 45000;
		Team_CheckDroppedItem(dropped);
	}
	//Elder: Reaction Unique Weapons in deathmatch - respawn in ~60 seconds
	//Don't forget to condition it when we get teamplay in
	// JBravo: not forgotten and that if should not have the knife and pistol.
/*	else if (item->giType == IT_WEAPON &&
		 item->giTag != WP_GRENADE && item->giTag != WP_PISTOL &&
		 item->giTag != WP_AKIMBO && item->giTag != WP_KNIFE) { */
	else if (item->giType == IT_WEAPON &&
		item->giTag != WP_GRENADE && item->giTag != WP_AKIMBO) {
		if (g_gametype.integer == GT_TEAMPLAY)
			dropped->think = 0;
		else
			dropped->think = RQ3_DroppedWeaponThink;
// JBravo: weapons and items go away faster in CTF
		if (g_gametype.integer == GT_CTF || (g_gametype.integer == GT_TEAM && !g_RQ3_tdmMode.integer))
			dropped->nextthink = level.time + RQ3_CTF_RESPAWNTIME_DEFAULT;
		else if (g_gametype.integer == GT_TEAMPLAY)
			dropped->nextthink = 0;
		else
			dropped->nextthink = level.time + RQ3_RESPAWNTIME_DEFAULT;
	}
	//Elder: for unique items in deathmatch ... remember to condition for teamplay
	//JBravo: not forgotten either ;)
	else if (item->giType == IT_HOLDABLE) {
	       	if (g_gametype.integer == GT_TEAMPLAY)
			dropped->think = 0;
		else
			dropped->think = RQ3_DroppedItemThink;
// JBravo: weapons and items go away faster in CTF
		if (g_gametype.integer == GT_CTF || (g_gametype.integer == GT_TEAM && !g_RQ3_tdmMode.integer))
			dropped->nextthink = level.time + RQ3_CTF_RESPAWNTIME_DEFAULT;
		else if (g_gametype.integer == GT_TEAMPLAY)
			dropped->nextthink = 0;
		else
			dropped->nextthink = level.time + RQ3_RESPAWNTIME_DEFAULT;
	} else {
		// auto-remove after 30 seconds
		dropped->think = G_FreeEntity;
		dropped->nextthink = level.time + 30000;
	}

	dropped->flags = xr_flags;	//FL_DROPPED_ITEM;
	if (xr_flags & FL_THROWN_ITEM) {
		//Elder: we don't want it to clip against players
		dropped->clipmask = MASK_SOLID;	//MASK_SHOT
		dropped->s.pos.trTime = level.time;	// +50; no pre-step if it doesn't clip players
		VectorScale(velocity, 40, dropped->s.pos.trDelta);	// 700 500 400
		SnapVector(dropped->s.pos.trDelta);	// save net bandwidth
		dropped->physicsBounce = 0.1f;
	}

	trap_LinkEntity(dropped);

	return dropped;
}
Exemplo n.º 6
0
/*
================
LaunchItem

Spawns an item and tosses it forward
================
*/
gentity_t *LaunchItem( gitem_t *item, gentity_t *who, vec3_t origin, vec3_t velocity, int flags, char *txt) // RPG-X: Marcin: for ThrowWeapon 03/12/2008
{                                                                                                           // and for PADD stuff too         06/12/2008, 08/12/2008
	gentity_t	*dropped;

	dropped = G_Spawn();

	dropped->s.eType = ET_ITEM;
	dropped->s.modelindex = item - bg_itemlist;	// store item number in modelindex
	dropped->s.modelindex2 = 1; // This is non-zero is it's a dropped item

	dropped->classname = item->classname;
	dropped->item = item;
	VectorSet (dropped->r.mins, -ITEM_RADIUS, -ITEM_RADIUS, -ITEM_RADIUS);
	VectorSet (dropped->r.maxs, ITEM_RADIUS, ITEM_RADIUS, ITEM_RADIUS);
	dropped->r.contents = CONTENTS_TRIGGER;

	dropped->touch = Touch_Item;

	G_SetOrigin( dropped, origin );
	dropped->s.pos.trType = TR_GRAVITY;
	dropped->s.pos.trTime = level.time;
	VectorCopy( velocity, dropped->s.pos.trDelta );

	dropped->s.eFlags |= EF_BOUNCE_HALF;
	dropped->s.eFlags |= EF_DEAD;	// Yes, this is totally lame, but we use it bg_misc to check
									// if the item has been droped, and if so, make it pick-up-able
									// cdr

    if ( item->giTag == WP_3 ) {
        //Q_strncpyz(item->paddMsg, txt, sizeof(item->paddMsg));
        Padd_Add(dropped, who, txt);
    }

	if (item->giType == IT_TEAM) { // Special case for CTF flags
		gentity_t	*te;

		VectorSet (dropped->r.mins, -23, -23, -15);
		VectorSet (dropped->r.maxs, 23, 23, 31);
		dropped->think = Team_DroppedFlagThink;
		dropped->nextthink = level.time + 30000;
		Team_CheckDroppedItem( dropped );

		// make the sound call for a dropped flag
		te = G_TempEntity( dropped->s.pos.trBase, EV_TEAM_SOUND );
		te->s.eventParm = DROPPED_FLAG_SOUND;
		/*if (dropped->item->giTag == PW_REDFLAG)
		{
			te->s.otherEntityNum = TEAM_RED;
		}
		else
		{
			te->s.otherEntityNum = TEAM_BLUE;
		}*/

		te->r.svFlags |= SVF_BROADCAST;

	} else { // auto-remove after 30 seconds
		dropped->think = G_FreeEntity;
		dropped->nextthink = level.time + 6000000; //30000; // RPG-X: Marcin: increased - 03/12/2008
	}

	dropped->flags = flags; // FL_DROPPED_ITEM; // RPG-X: Marcin: for ThrowWeapon - 03/12/2008

    if( flags & FL_THROWN_ITEM) {
        dropped->clipmask = MASK_SHOT;
        dropped->s.pos.trTime = level.time - 50;
        VectorScale( velocity, 300, dropped->s.pos.trDelta );
        SnapVector( dropped->s.pos.trDelta );
        dropped->physicsBounce = 0.2;
    }


	trap_LinkEntity (dropped);

	return dropped;
}