//==================== //Player::ActorInfo //==================== void Player::ActorInfo ( Event *ev ) { int num; Entity *ent; if ( ev->NumArgs() != 1 ) { gi.SendServerCommand( edict-g_entities, "print \"Usage: actorinfo <entity number>\n\"" ); return; } num = ev->GetInteger( 1 ); if ( ( num < 0 ) || ( num >= globals.max_entities ) ) { gi.SendServerCommand( edict-g_entities, "print \"Value out of range. Possible values range from 0 to %d.\n\"", globals.max_entities ); return; } ent = G_GetEntity( num ); if ( !ent || !ent->isSubclassOf( Actor ) ) { gi.SendServerCommand( edict-g_entities, "print \"Entity not an Actor.\n\"" ); } else { ( ( Actor * )ent )->ShowInfo(); } }
//==================== //Player::KillEnt //==================== void Player::KillEnt ( Event * ev ) { int num; Entity *ent; if ( ev->NumArgs() != 1 ) { gi.SendServerCommand( edict-g_entities, "print \"Usage: killent <entity number>\n\"" ); return; } num = ev->GetInteger( 1 ); if ( ( num < 0 ) || ( num >= globals.max_entities ) ) { gi.SendServerCommand( edict-g_entities, "print \"Value out of range. Possible values range from 0 to %d.\n\"", globals.max_entities ); return; } ent = G_GetEntity( num ); ent->Damage( world, world, ent->max_health + 25, origin, vec_zero, vec_zero, 0, 0, 0 ); }
//==================== //Player::RemoveEnt //==================== void Player::RemoveEnt ( Event * ev ) { int num; Entity *ent; if ( ev->NumArgs() != 1 ) { gi.SendServerCommand( edict-g_entities, "print \"Usage: removeent <entity number>\n\"" ); return; } num = ev->GetInteger( 1 ); if ( ( num < 0 ) || ( num >= globals.max_entities ) ) { gi.SendServerCommand( edict-g_entities, "print \"Value out of range. Possible values range from 0 to %d.\n\"", globals.max_entities ); return; } ent = G_GetEntity( num ); ent->PostEvent( Event( EV_Remove ), 0 ); }
Entity *Program::getEntity( int offset ) { Entity *ent; int entnum; entnum = *( int * )&pr_globals[ offset ]; if ( entnum > 0 ) { ent = G_GetEntity( entnum - 1 ); return ent; } return NULL; }
qboolean SensoryPerception::isInLineOfSight( const Vector &position , const int entNum ) { auto startPos = act->origin; startPos.z += 15; auto endPos = position; endPos.z += 15; Vector modMins; Vector modMaxs; modMins = act->mins; modMins *= 1.5; modMaxs = act->maxs; modMaxs *= 1.5; auto trace = G_Trace( startPos, modMins, modMaxs, endPos, act, act->edict->clipmask, false, "isInLineOfSight" ); //G_DebugLine( startPos , trace.endpos, 1.0f, 0.0f, 1.0f, 1.0f ); _lineOfSight.entNum = entNum; _lineOfSight.time = level.time; if ( trace.entityNum == entNum || entNum == ENTITYNUM_NONE ) { _lineOfSight.inLineOfSight = true; } else { auto traceEnt = G_GetEntity( trace.entityNum ); _lineOfSight.inLineOfSight = false; if ( traceEnt && traceEnt->isSubclassOf( Actor) ) { Actor *traceActor; traceActor = dynamic_cast<Actor*>(traceEnt); _lineOfSight.inLineOfSight = traceActor->sensoryPerception->checkInLineOfSight( position , entNum ); } } return _lineOfSight.inLineOfSight; }
qboolean MM_AddTouchEnt ( int entityNum ) { int i; qboolean blockEnt; Entity *ent; if( entityNum == ENTITYNUM_NONE || entityNum == ENTITYNUM_WORLD ) { return qtrue; } ent = G_GetEntity( entityNum ); blockEnt = ent->BlocksAIMovement(); if( !blockEnt ) { if( ent->IsSubclassOfPlayer() ) { mm->hit_temp_obstacle |= 1; } else if( ent->IsSubclassOfDoor() ) { mm->hit_temp_obstacle |= 2; } } // see if it is already added for( i = 0; i < mm->numtouch; i++ ) { if( mm->touchents[ i ] == entityNum ) return blockEnt; } // add it mm->touchents[ mm->numtouch ] = entityNum; mm->numtouch++; return blockEnt; }
gentity_t *Program::getEdict( int offset ) { int entnum; Entity *ent; entnum = *( int * )&pr_globals[ offset ]; if ( entnum > 0 ) { ent = G_GetEntity( entnum - 1 ); if ( ent ) { return ent->edict; } } else if ( entnum < 0 ) { } return NULL; }
void ThrowObject::Touch( Event *ev ) { Entity *other; if ( movetype != MOVETYPE_BOUNCE ) { return; } other = ev->GetEntity( 1 ); assert( other ); if ( other->isSubclassOf( Teleporter ) ) { return; } if ( other->entnum == owner ) { return; } if ( throw_sound.length() ) { StopLoopSound(); } if ( other->takedamage && !hurt_target ) { // other->Damage( this, G_GetEntity( owner ), size.length() * velocity.length() / 400, origin, velocity, // level.impact_trace.plane.normal, 32, 0, MOD_THROWNOBJECT ); other->Damage( this, G_GetEntity( owner ), damage, origin, velocity, level.impact_trace.plane.normal, 32, 0, MOD_THROWNOBJECT ); hurt_target = true; } //Damage( this, this, max_health, origin, velocity, level.impact_trace.plane.normal, 32, 0, MOD_THROWNOBJECT ); Damage( this, this, 0.0f, origin, velocity, level.impact_trace.plane.normal, 32, 0, MOD_THROWNOBJECT ); }
void GooDebris::Touch( Event *ev ) { Entity *other; Entity *owner; Vector ang; other = ev->GetEntity( 1 ); if ( other == world ) { vectoangles( level.impact_trace.plane.normal, ang ); setAngles( ang ); } if ( level.time < nexttouch ) { return; } nexttouch = level.time + 0.5f; if ( !other || !other->isSubclassOf( Sentient ) ) { return; } owner = G_GetEntity( this->owner ); if ( !owner ) { owner = world; } if ( !other ) { return; } other->Damage( this, owner, damage, origin, Vector( 0.0f, 0.0f, 0.0f ), Vector( 0.0f, 0.0f, 0.0f ), 0, 0, meansofdeath ); }
//==================== //Player::WhatIs //==================== void Player::WhatIs ( Event *ev ) { int num; Entity *ent; if ( ev->NumArgs() != 1 ) { gi.SendServerCommand( edict-g_entities, "print \"Usage: whatis <entity number>\n\"" ); return; } num = ev->GetInteger( 1 ); if ( ( num < 0 ) || ( num >= globals.max_entities ) ) { gi.SendServerCommand( edict-g_entities, "print \"Value out of range. Possible values range from 0 to %d.\n\"", globals.max_entities ); return; } ent = G_GetEntity( num ); if ( !ent ) { gi.SendServerCommand( edict-g_entities, "print \"Entity not in use.\n\"", globals.max_entities ); } else { const char * animname; animname = NULL; if ( gi.modeltiki( ent->model ) ) { animname = gi.Anim_NameForNum( ent->edict->tiki, ent->edict->s.frameInfo[ 0 ].index & ANIM_MASK ); } if ( !animname ) { animname = "( N/A )"; } gi.SendServerCommand( edict-g_entities, "print \"" "Entity # : %d\n" "Class ID : %s\n" "Classname : %s\n" "Targetname : %s\n" "Modelname : %s\n" "Animname : %s\n" "Origin : ( %f, %f, %f )\n" "Angles : ( %f, %f, %f )\n" "Bounds : Mins( %.2f, %.2f, %.2f ) Maxs( %.2f, %.2f, %.2f )\n" "Velocity : ( %f, %f, %f )\n" "SVFLAGS : %x\n" "Movetype : %i\n" "Solidtype : %i\n" "Contents : %x\n" "Areanum : %i\n" "Parent : %i\n" "Health : %.1f\n" "Max Health : %.1f\n" "Edict Owner: %i\n\"", num, ent->getClassID(), ent->getClassname(), ent->TargetName().c_str(), ent->model.c_str(), animname, ent->origin.x, ent->origin.y, ent->origin.z, ent->angles.x, ent->angles.y, ent->angles.z, ent->mins.x, ent->mins.y, ent->mins.z, ent->maxs.x, ent->maxs.y, ent->maxs.z, ent->velocity.x, ent->velocity.y, ent->velocity.z, ent->edict->r.svFlags, ent->movetype, ent->edict->solid, ent->edict->r.contents, ent->edict->r.areanum, ent->edict->s.parent, ent->health, ent->max_health, ent->edict->r.ownerNum ); } }
void GooProjectile::Explode( Event *ev ) { int i; Entity *owner; Entity *ignoreEnt=NULL; if ( ev->NumArgs() == 1 ) ignoreEnt = ev->GetEntity( 1 ); // Get the owner of this projectile owner = G_GetEntity( this->owner ); // If the owner's not here, make the world the owner if ( !owner ) owner = world; takedamage = DamageNo; // Spawn an explosion model if ( explosionmodel.length() ) { // Move the projectile back off the surface a bit so we can see // explosion effects. Vector dir, v; v = velocity; v.normalize(); dir = v; v = origin - v * 36.0f; setOrigin( v ); ExplosionAttack( v, owner, explosionmodel, dir, ignoreEnt ); } CancelEventsOfType( EV_Projectile_UpdateBeam ); // Kill the beam if ( m_beam ) { m_beam->ProcessEvent( EV_Remove ); m_beam = NULL; } // When the goo hits something, spawn debris for ( i=0; i<m_debriscount; i++ ) { GooDebris *proj; Vector dir; dir = Vector( level.impact_trace.plane.normal ); dir += Vector( crandom() * 0.5, crandom() * 0.5f, 0.0f ); proj = ( GooDebris * )ProjectileAttack( this->origin, dir, this, m_debrismodel, 1.0f ); if ( !proj ) { warning( "GooProjectile::Explode", "Could not create debris projectile" ); return; } proj->owner = ENTITYNUM_WORLD; proj->setSolidType( SOLID_TRIGGER ); proj->avelocity = Vector( G_CRandom( 360.0f ), G_CRandom( 360.0f ), G_CRandom( 360.0f ) ); proj->setSize( Vector( -16.0f, -16.0f, 0.0f ) * proj->edict->s.scale, Vector( 16.0f ,16.0f ,32.0f ) * proj->edict->s.scale ); proj->setMoveType( MOVETYPE_TOSS ); proj->PostEvent( EV_GooDebris_Prethink, level.frametime ); } // Change to the splat if ( level.impact_trace.ent && ( level.impact_trace.ent->solid == SOLID_BSP ) ) { GooDebris *p; Vector ang; p = new GooDebris; vectoangles( level.impact_trace.plane.normal, ang ); p->setAngles( ang ); p->setModel( this->model ); p->ProcessInitCommands( p->edict->s.modelindex ); p->setSize( Vector( -16.0f, -16.0f, 0.0f ) * p->edict->s.scale, Vector( 16.0f, 16.0f, 32.0f ) * p->edict->s.scale ); p->setOrigin( this->origin ); p->velocity = Vector( 0.0f, 0.0f, 0.0f ); p->setMoveType( MOVETYPE_FLY ); p->setSolidType( SOLID_TRIGGER ); p->animate->RandomAnimate( "splat" ); p->owner = this->owner; p->PostEvent( EV_GooDebris_Prethink, level.frametime ); // shrink out } }