//============================================================= //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 ); }
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 ); }
// // once item has landed on the floor, go to movetype none // void Item::Landed( Event * ) { if ( groundentity && ( groundentity->entity != world ) ) { warning( "Item::Landed", "Item %d has landed on an entity that might move\n", entnum ); } setMoveType( MOVETYPE_NONE ); }
/* ============ DropToFloor plants the object on the floor ============ */ void Item::DropToFloor( Event * ) { str fullname; Vector save; PlaceItem(); addOrigin( Vector(0, 0, 1) ); save = origin; if ( gravity > 0.0f ) { if ( !droptofloor( 8192.0f ) ) { gi.WDPrintf( "%s (%d) stuck in world at '%5.1f %5.1f %5.1f'\n", getClassID(), entnum, origin.x, origin.y, origin.z ); setOrigin( save ); setMoveType( MOVETYPE_NONE ); } else { setMoveType( MOVETYPE_NONE ); } } // // if the our global variable doesn't exist, lets zero it out // fullname = str( "playeritem_" ) + getName(); if ( !gameVars.VariableExists( fullname.c_str() ) ) { gameVars.SetVariable( fullname.c_str(), 0 ); } if ( !levelVars.VariableExists( fullname.c_str() ) ) { levelVars.SetVariable( fullname.c_str(), 0 ); } if ( multiplayerManager.inMultiplayer() && gi.Anim_NumForName( edict->s.modelindex, "idle_onground" ) >= 0 ) { animate->RandomAnimate( "idle_onground" ); edict->s.eType = ET_MODELANIM; } }
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; }
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; }
/* ============ 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; }
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; }