Exemplo n.º 1
0
//=============================================================
//Body::Body
//=============================================================
Body::Body()
{
	Event *newEvent;
	
	takedamage         = DamageYes;
	edict->s.eType     = ET_MODELANIM;
	health             = 10;
	edict->clipmask    = MASK_DEADSOLID;
	edict->svflags    |= SVF_DEADMONSTER;
	
	setSolidType( SOLID_NOT );
	//setSolidType( SOLID_BBOX );
	//setContents( CONTENTS_CORPSE );
	setMoveType( MOVETYPE_NONE );
	
	//PostEvent( EV_FadeOut, 6.0f );
	
	newEvent = new Event( EV_DisplayEffect );
	newEvent->AddString( "TransportOut" );
	newEvent->AddString( "Multiplayer" );
	PostEvent( newEvent, 0.0f );
	
	PostEvent( EV_Remove, 5.0f );
	
	//Event *transport_event = new Event( EV_DisplayEffect );
	//transport_event->AddString( "transport_out" );
	//ProcessEvent( transport_event );
	
	animate = new Animate( this );
}
Exemplo n.º 2
0
Object::Object()
{
	animate = new Animate( this );
	
	if ( LoadingSavegame )
	{
		// Archive function will setup all necessary data
		return;
	}
	//
	// all objects default to not solid
	//
	setSolidType( SOLID_NOT );
	
	health = 0;
	
	takedamage = ( spawnflags & 2 ) ? DamageNo : DamageYes;
	
	//
	// we want the bounds of this model auto-rotated
	//
	flags |= FlagRotatedbounds;
	
	if ( !com_blood->integer )
	{
		flags &= ~FlagBlood;
		flags &= ~FlagDieGibs;
	}
	
	PostEvent( EV_Object_Setup, EV_POSTSPAWN );
}
Exemplo n.º 3
0
void Item::Respawn( Event * )
{
	if ( _missingSkin )
	{
		ChangeSkin( _missingSkin, false );
	}
	else
	{
		showModel();
	}
	
	// allow it to be touched again
	setSolidType( SOLID_TRIGGER );
	
	// play respawn sound
	if ( playrespawn )
	{
		Sound( "snd_itemspawn" );
	}
	
	setOrigin();
	
	if ( animate->HasAnim( "respawn" ) )
		animate->RandomAnimate( "respawn", EV_Item_RespawnDone );
	
	look_at_me = true;
	has_been_looked_at = false;
}
Exemplo n.º 4
0
Gib::Gib
	(
	str name,
	qboolean blood_trail,
	str bloodtrailname,
	str bloodspurtname,
	str bloodsplatname,
	float bloodsplatsize,
	float pitch
	)

   {
   setSize( Vector( "0 0 0" ), Vector( "0 0 0" ) );

	if ( name.length() )
		setModel( name.c_str() );

	setMoveType( MOVETYPE_GIB );
	setSolidType( SOLID_BBOX );
	takedamage = DAMAGE_YES;
   sprayed     = false;
   fadesplat   = true;
   scale       = 2.0f;

	next_bleed_time = 0;

	final_pitch	= pitch;

	if ( blood_trail )
		{
		// Make a blood emitter and bind it to the head
		blood = new Mover;
   
		if ( bloodtrailname.length() )
			blood->setModel( bloodtrailname.c_str() );

		blood->setMoveType( MOVETYPE_BOUNCE );
		blood->setSolidType( SOLID_NOT );
		blood->bind( this );

		// Save the blood spurt name

		if ( bloodspurtname.length() )
			blood_spurt_name = bloodspurtname;

		// Save the blood splat name

		if ( bloodsplatname.length() )
			blood_splat_name = bloodsplatname;

		blood_splat_size = bloodsplatsize;
		}
	else
		{
		blood = NULL;
		}

   Sound( "snd_decap", CHAN_BODY, 1, 300 );
   }
Exemplo n.º 5
0
/*
============
PlaceItem

Puts an item back in the world
============
*/
void Item::PlaceItem( void )
{
	GameplayManager *gpm = GameplayManager::getTheGameplayManager();
	if ( gpm->hasProperty(getArchetype(), "noautopickup") )
	{
		setContents( CONTENTS_USABLE );
		setSolidType( SOLID_BBOX );
	}
	else
	{
		setSolidType( SOLID_TRIGGER );
	}
	
	setMoveType( MOVETYPE_TOSS );
	showModel();
	
	groundentity = NULL;
}
Exemplo n.º 6
0
void PowerupBase::init( const str &modelName, Sentient *owner )
{
	_modelName = modelName;
	_owner = owner;

	setModel( modelName );

	CancelEventsOfType( EV_ProcessInitCommands );
	ProcessInitCommands( gi.modelindex( modelName.c_str() ) );

	CancelEventsOfType( EV_Item_DropToFloor );

	setSolidType( SOLID_NOT );
	hideModel();
}
Exemplo n.º 7
0
Gib::Gib()
   {
   if ( LoadingSavegame )
      {
      return;
      }

   setSize( Vector( "0 0 0" ), Vector( "0 0 0" ) );
   setModel("gib1.def");
	setMoveType( MOVETYPE_GIB );
	setSolidType( SOLID_BBOX );
   sprayed           = 0;
   fadesplat         = true;
   scale             = 2.0f;
   }
Exemplo n.º 8
0
void ThrowObject::Throw( const Entity *owner, float speed, const Sentient *targetent, float gravity, float throw_damage )
{
	float    traveltime;
	float    vertical_speed;
	Vector   target;
	Vector   dir;
	Vector   xydir;
	Event    *e;
	
	
	e = new Event( EV_Detach );
	ProcessEvent( e );
	
	this->owner = owner->entnum;
	edict->ownerNum = owner->entnum;
	
	damage = throw_damage;
	target = targetent->origin;
	target.z += targetent->viewheight;
	
	setMoveType( MOVETYPE_BOUNCE );
	setSolidType( SOLID_BBOX );
	edict->clipmask = MASK_PROJECTILE;
	
	dir = target - origin;
	xydir = dir;
	xydir.z = 0;
	traveltime = xydir.length() / speed;
	vertical_speed = ( dir.z / traveltime ) + ( 0.5f * gravity * sv_currentGravity->value * traveltime );
	xydir.normalize();
	
	// setup ambient flying sound
	if ( throw_sound.length() )
	{
		LoopSound( throw_sound.c_str() );
	}
	
	velocity = speed * xydir;
	velocity.z = vertical_speed;
	
	angles = velocity.toAngles();
	setAngles( angles );
	
	avelocity.x = crandom() * 200.0f;
	avelocity.y = crandom() * 200.0f;
	takedamage = DamageYes;
}
Exemplo n.º 9
0
void Item::SetOwner( Sentient *ent )
{
	assert( ent );
	if ( !ent )
	{
		// return to avoid any buggy behaviour
		return;
	}
	
	owner = ent;
	edict->s.parent = ent->entnum;
	setRespawn( false );
	
	setSolidType( SOLID_NOT );
	hideModel();
	CancelEventsOfType( EV_Touch );
	CancelEventsOfType( EV_Item_DropToFloor );
	CancelEventsOfType( EV_Remove );
	//	ItemPickup( ent );
}
Exemplo n.º 10
0
//
// Name:        _pickupArmor()
// Class:       Armor
//
// Description: Takes care of "Picking Up" the armor, by playing the
//              appropriate sounds, removing the model...
//
// Parameters:  None
// 
// Returns:     None
//
void Armor::_pickupArmor( Sentient *sentient)
{
	str      realname;
	
	// Play pickup sound
	realname = GetRandomAlias( "snd_pickup" );
	if ( realname.length() > 1 )
		sentient->Sound( realname, CHAN_ITEM );
	
	// Cancel some events
	CancelEventsOfType( EV_Item_DropToFloor );
	CancelEventsOfType( EV_Item_Respawn );
	CancelEventsOfType( EV_FadeOut );
	
	// Hide the model
	setSolidType( SOLID_NOT );

	if ( _missingSkin )
	{
		ChangeSkin( _missingSkin, true );
	}
	else
	{
		hideModel();
	}
	
	// Respawn?
	if ( !Respawnable() )
		PostEvent( EV_Remove, FRAMETIME );
	else
		PostEvent( EV_Item_Respawn, RespawnTime() );
	
	// fire off any pickup_thread's
	if ( pickup_thread.length() )
		ExecuteThread( pickup_thread );	
}
Exemplo n.º 11
0
Item *PowerupBase::ItemPickup( Entity *other, qboolean add_to_inventory, qboolean )
{
	Player *player;
	str      realname;

	Q_UNUSED(add_to_inventory);

	if ( !other->isSubclassOf( Player ) )
		return NULL;

	if ( !Pickupable( other ) )
		return NULL;

	if ( multiplayerManager.inMultiplayer() )
	{
		if ( !multiplayerManager.canPickup( (Player *)other, getMultiplayerItemType(), item_name ) )
			return NULL;
	}

	player = ( Player * )other;

	// Play pickup sound
	realname = GetRandomAlias( "snd_pickup" );
	if ( realname.length() > 1 )
		player->Sound( realname, CHAN_ITEM );

	// Cancel some events
	CancelEventsOfType( EV_Item_DropToFloor );
	CancelEventsOfType( EV_Item_Respawn );
	CancelEventsOfType( EV_FadeOut );

	// Hide the model
	setSolidType( SOLID_NOT );

	if ( _missingSkin )
	{
		ChangeSkin( _missingSkin, true );
	}
	else
	{
		hideModel();
	}

	// Respawn?
	if ( !Respawnable() )
		PostEvent( EV_Remove, FRAMETIME );
	else
		PostEvent( EV_Item_Respawn, RespawnTime() );

	// fire off any pickup_thread's
	if ( pickup_thread.length() )
      {
      ExecuteThread( pickup_thread );
      }

	givePlayerItem( player );

	if ( multiplayerManager.inMultiplayer() )
	{
		multiplayerManager.pickedupItem( (Player *)other, MP_ITEM_TYPE_POWERUP, item_name );
	}

	return NULL; // This doesn't create any items
}
Exemplo n.º 12
0
Item * Item::ItemPickup( Entity *other, qboolean add_to_inventory, qboolean checkautopickup )
{
	Sentient * sent;
	Item * item = NULL;
	str realname;
	
	// Query the gameplay manager and see if we should not auto-pickup this item
	if ( checkautopickup )
	{
		GameplayManager *gpm = GameplayManager::getTheGameplayManager();
		if ( gpm->hasProperty(getArchetype(), "noautopickup") )
			return NULL;
	}
	
	if ( !Pickupable( other ) )
	{
		return NULL;
	}
	
	sent = ( Sentient * )other;
	
	if ( add_to_inventory )
	{
		item = sent->giveItem( model, getAmount(), true );
		
		
		if ( !item )
			return NULL;
	}
	else
	{
		item = this;
	}
	
	//
	// make sure to copy over the coolness factor :)
	//
	item->coolitem = coolitem;
	item->cool_dialog = cool_dialog;
	item->cool_anim = cool_anim;
	item->coolitemforced = coolitemforced;
	
	//
	// let our sent know they received it
	// we put this here so we can transfer information from the original item we picked up
	//

	if ( !isSubclassOf( Weapon ) || add_to_inventory )
		sent->ReceivedItem( item );
	
	realname = GetRandomAlias( "snd_pickup" );
	if ( realname.length() > 1 )
		sent->Sound( realname, CHAN_ITEM );
	
	if ( !Removable() )
	{
		// leave the item for others to pickup
		return item;
	}
	
	look_at_me = false;
	
	CancelEventsOfType( EV_Item_DropToFloor );
	CancelEventsOfType( EV_Item_Respawn );
	CancelEventsOfType( EV_FadeOut );
	
	setSolidType( SOLID_NOT );
	
	if ( animate && animate->HasAnim( "pickup" ) )
		animate->RandomAnimate( "pickup", EV_Item_PickupDone );
	else
	{
		if ( !no_remove )
		{
			if ( _missingSkin )
			{
				ChangeSkin( _missingSkin, true );
			}
			else
			{
				hideModel();
			}
			
			if ( !Respawnable() )
				PostEvent( EV_Remove, FRAMETIME );
		}
	}
	
	if ( Respawnable() )
		PostEvent( EV_Item_Respawn, RespawnTime() );
	
	// fire off any pickup_thread's
	if ( pickup_thread.length() )
	{
		ExecuteThread( pickup_thread );
	}
	
	
	if ( item && multiplayerManager.checkFlag( MP_FLAG_INSTANT_ITEMS ) )
	{
		Event *ev;
		
		ev = new Event( EV_InventoryItem_Use );
		ev->AddEntity( other );
		
		item->ProcessEvent( ev );
	}
	
	return item;
}
Exemplo n.º 13
0
//--------------------------------------------------------------
// Name:		Item()
// Class:		Item
//
// Description:	Constructor
//
// Parameters:	None
//
// Returns:		None
//--------------------------------------------------------------
Item::Item()
{
	str fullname;
	animate = new Animate( this );

	if ( LoadingSavegame )
		return;

	setSolidType( SOLID_NOT );

	// Set default respawn behavior
	// Derived classes should use setRespawn
	// if they want to override the default behavior
	setRespawn( false );
	setRespawnTime( 20 );

	if ( multiplayerManager.inMultiplayer() )
	{
		setRespawn( true );
		edict->s.renderfx |= RF_FULLBRIGHT;
	}

	//
	// we want the bounds of this model auto-rotated
	//
	flags |= FlagRotatedbounds;

	//
	// set a minimum mins and maxs for the model
	//
	if ( size.length() < 10.0f )
	{
		mins = Vector(-10, -10, 0);
		maxs = Vector(10, 10, 20);
	}

	//
	// reset the mins and maxs to pickup the FlagRotatedbounds flag
	//
	setSize( mins, maxs );

	if ( !LoadingSavegame )
	{
		// Items can't be immediately dropped to floor, because they might
		// be on an entity that hasn't spawned yet.
		PostEvent( EV_Item_DropToFloor, EV_POSTSPAWN );
	}

	respondto = TRIGGER_PLAYERS;

	// items should collide with everything that the player does
	edict->clipmask	 = MASK_PLAYERSOLID;

	bot_inventory_index = 0; // INVENTORY_NONE
	item_index = 0;
	maximum_amount = 1.0f;
	playrespawn = false;

	// this is an item entity

	if ( g_gametype->integer == GT_SINGLE_PLAYER )
		edict->s.eType = ET_MODELANIM;
	else
		edict->s.eType = ET_ITEM;

	// Set our default skill level 
	_skillLevel = 1.0f;
	amount = 1.0f;
	no_remove = false;
	setName( "Unknown Item" );

	look_at_me = true;
	coolitem = false;
	coolitemforced = false;

	has_been_looked_at = false;

	_nextPickupTime = 0.0f;

	_mpItemType = MP_ITEM_TYPE_NORMAL;

	_iconIndex = -1;

	_missingSkin = 0;

	if ( !LoadingSavegame )
	{
		PostEvent( EV_Item_PostSpawn, EV_POSTSPAWN );
	}
}
Exemplo n.º 14
0
World::World()
{
	const char  *text;
	str         mapname;
	int		   i;

	assert( this->entnum == ENTITYNUM_WORLD );

	world = this;
	world_dying = false;

	setMoveType( MOVETYPE_NONE );
	setSolidType( SOLID_BSP );

	// world model is always index 1
	edict->s.modelindex = 1;
	model = "*1";

	turnThinkOn();

	UpdateConfigStrings();

	groupcoordinator = NULL;

	// Anything that modifies configstrings, or spawns things is ignored when loading savegames
	if ( LoadingSavegame )
	{
		return;
	}

	// clear out the soundtrack from the last level
	ChangeSoundtrack( "" );

	// set the default farplane parameters
	farplane_distance = 0;
	farplane_color = Vector(0, 0, 0);
	farplane_cull = true;
	farplane_fog = true;
	UpdateFog();

	terrain_global = false;
	terrain_global_min = MIN_WORLD_COORD;
	UpdateTerrain();

	entity_fade_dist = DEFAULT_ENTITY_FADE_DIST;
	UpdateEntityFadeDist();

	UpdateDynamicLights();

	UpdateWeather();

	time_scale = 1.0f;
	sky_alpha = 1.0f;
	sky_portal = true;
	UpdateSky();

	//
	// see if this is a cinematic level
	//
	level.cinematic = ( spawnflags & CINEMATIC ) ? true : false;

	if ( level.cinematic )
		gi.cvar_set( "sv_cinematic", "1" );
	else
		gi.cvar_set( "sv_cinematic", "0" );

	level.nextmap = "";
	level.level_name = level.mapname;

	// Set up the mapname as the default script
	mapname = "maps/";
	mapname += level.mapname;
	for( i = mapname.length() - 1; i >= 0; i-- )
	{
		if ( mapname[ i ] == '.' )
		{
			mapname[ i ] = 0;
			break;
		}
	}

	mapname += ".scr";
	text = &mapname[ 5 ];

	// If there isn't a script with the same name as the map, then don't try to load script
	if ( gi.FS_ReadFile( mapname.c_str(), NULL, true ) != -1 )
	{
		gi.DPrintf( "Adding script: '%s'\n", text );

		// just set the script, we will start it in G_Spawn
		level.SetGameScript( mapname.c_str() );
	}
	else
	{
		level.SetGameScript( "" );
	}

	level.consoleThread = Director.CreateThread();

	SoundMan.Init();
	SoundMan.Load();

	// Set the color for the blends.
	level.water_color       = Vector( 0.0f, 0.0f, 0.5f );
	level.water_alpha       = 0.4f;

	level.slime_color       = Vector( 0.2f, 0.4f, 0.2f );
	level.slime_alpha       = 0.6f;

	level.lava_color        = Vector( 0.5f, 0.15f, 0.0f );
	level.lava_alpha        = 0.6f;

	//
	// set the targetname of the world
	//
	SetTargetName( "world" );

	groupcoordinator = new GroupCoordinator;

	// Initialize movement info

	for ( i = 0 ; i < WORLD_PHYSICS_TOTAL_NUMBER ; i++ )
	{
		_physicsInfo[ i ] = -1.0f;
	}

	_canShakeCamera = false;
}
Exemplo n.º 15
0
void Object::Killed(Event *ev)
{
	Entity * ent;
	Entity * attacker;
	Vector dir;
	Event * event;
	const char * name;
	
	takedamage = DamageNo;
	setSolidType( SOLID_NOT );
	hideModel();
	
	attacker	= ev->GetEntity( 1 );
	
	if (flags & FlagDieExplode)
	{
		CreateExplosion( origin, 50.0f, this, this, this );
	}
	
	if (flags & FlagDieGibs)
	{
		setSolidType( SOLID_NOT );
		hideModel();
		
		CreateGibs( this, -150.0f, edict->s.scale, 3 );
	}
	
	//
	// kill the killtargets
	//
	name = KillTarget();
	if ( name && strcmp( name, "" ) )
	{
		ent = NULL;
		do
		{
			ent = G_FindTarget( ent, name );
			if ( !ent )
			{
				break;
			}
			ent->PostEvent( EV_Remove, 0.0f );
		}
		while ( 1 );
	}
	
	//
	// fire targets
	//
	name = Target();
	if ( name && strcmp( name, "" ) )
	{
		ent = NULL;
		do
		{
			ent = G_FindTarget( ent, name );
			if ( !ent )
			{
				break;
			}
			event = new Event( EV_Activate );
			event->AddEntity( attacker );
			ent->ProcessEvent( event );
		}
		while ( 1 );
	}
	
	PostEvent( EV_Remove, 0.0f );
}