Beispiel #1
0
/*
====================
SV_TouchLinks
====================
*/
void SV_TouchLinks ( edict_t *ent, areanode_t *node )
{
	int			i, numtouch;
	edict_t		*touchlist[MAX_EDICTS], *touch;
	int			old_self, old_other;

	numtouch = SV_AreaEdicts (ent->v.absmin, ent->v.absmax, touchlist, MAX_EDICTS, AREA_TRIGGERS);

// touch linked edicts
	for (i = 0; i < numtouch; i++)
	{
		touch = touchlist[i];
		if (touch == ent)
			continue;
		if (!touch->v.touch || touch->v.solid != SOLID_TRIGGER)
			continue;

		old_self = pr_global_struct->self;
		old_other = pr_global_struct->other;

		pr_global_struct->self = EDICT_TO_PROG(touch);
		pr_global_struct->other = EDICT_TO_PROG(ent);
		pr_global_struct->time = sv.time;
		PR_ExecuteProgram (touch->v.touch);

		pr_global_struct->self = old_self;
		pr_global_struct->other = old_other;
	}
}
Beispiel #2
0
/*
================
SV_Physics

================
*/
void SV_Physics (void)
{
	int		i;
	edict_t	*ent;

// let the progs know that a new frame has started
	pr_global_struct->self = ((int)EDICT_TO_PROG(sv.edicts));
	pr_global_struct->other = ((int)EDICT_TO_PROG(sv.edicts));
	pr_global_struct->time = sv.time;
	PR_ExecuteProgram (pr_global_struct->StartFrame);

//SV_CheckAllEnts ();

//
// treat each object in turn
//
	ent = sv.edicts;
	for (i=0 ; i<sv.num_edicts ; i++, ent = NEXT_EDICT(ent))
	{
		if (ent->free)
			continue;

		if (pr_global_struct->force_retouch)
		{
			SV_LinkEdict (ent, true);	// force retouch even for stationary
		}

		if (i > 0 && i <= svs.maxclients)
			SV_Physics_Client (ent, i);
		else if (ent->v.movetype == MOVETYPE_PUSH)
			SV_Physics_Pusher (ent);
		else if (ent->v.movetype == MOVETYPE_FAKEPUSH)
			SV_Physics_FakePusher (ent);
		else if (ent->v.movetype == MOVETYPE_NONE)
			SV_Physics_None (ent);
#ifdef QUAKE2
		else if (ent->v.movetype == MOVETYPE_FOLLOW)
			SV_Physics_Follow (ent);
#endif
		else if (ent->v.movetype == MOVETYPE_NOCLIP)
			SV_Physics_Noclip (ent);
		else if (ent->v.movetype == MOVETYPE_STEP)
			SV_Physics_Step (ent);
		else if (ent->v.movetype == MOVETYPE_TOSS 
		|| ent->v.movetype == MOVETYPE_BOUNCE
#ifdef QUAKE2
		|| ent->v.movetype == MOVETYPE_BOUNCEMISSILE
#endif
		|| ent->v.movetype == MOVETYPE_FLY
		|| ent->v.movetype == MOVETYPE_FLYMISSILE)
			SV_Physics_Toss (ent);
		else
			Sys_Error ("SV_Physics: bad movetype %i", (int)ent->v.movetype);			
	}
	
	if (pr_global_struct->force_retouch)
		pr_global_struct->force_retouch--;	

	sv.time += host_frametime;
}
Beispiel #3
0
void SV_PTrack_f (void)
{
	int		i;
	edict_t *ent, *tent;
	
	if (!host_client->spectator)
		return;

	if (Cmd_Argc() != 2)
	{
		// turn off tracking
		host_client->spec_track = 0;
		ent = EDICT_NUM(host_client - svs.clients + 1);
		tent = EDICT_NUM(0);
		ent->v.goalentity = EDICT_TO_PROG(tent);
		return;
	}
	
	i = atoi(Cmd_Argv(1));
	if (i < 0 || i >= MAX_CLIENTS || svs.clients[i].state != cs_spawned ||
		svs.clients[i].spectator) {
		SV_ClientPrintf (host_client, PRINT_HIGH, "Invalid client to track\n");
		host_client->spec_track = 0;
		ent = EDICT_NUM(host_client - svs.clients + 1);
		tent = EDICT_NUM(0);
		ent->v.goalentity = EDICT_TO_PROG(tent);
		return;
	}
	host_client->spec_track = i + 1; // now tracking

	ent = EDICT_NUM(host_client - svs.clients + 1);
	tent = EDICT_NUM(i + 1);
	ent->v.goalentity = EDICT_TO_PROG(tent);
}
Beispiel #4
0
int Sentry_FindTarget_Angel(  )
{
    gedict_t *client;
    gedict_t *enemy = PROG_TO_EDICT( self->s.v.enemy );

    if ( enemy != world )
    {
        if ( CheckTarget( enemy ) )
        {
            if ( g_globalvars.time > self->height )
            {
                Sentry_FoundTarget(  );
                return 1;
            } else
                return 0;
        }
    }
    for ( client = world; (client = trap_find( client, FOFS( s.v.classname ), "player" )); )
    {
        if ( CheckTarget( client ) )
        {
            self->s.v.enemy = EDICT_TO_PROG( client );
            self->height = g_globalvars.time + 0.1 * ( int ) ( g_random(  ) * tfset_sgppl );
            //     self.height = g_globalvars.time + 0.1 * Q_rint(sgppl);
            if ( self->height == g_globalvars.time )
            {
                Sentry_FoundTarget(  );
                return 1;
            }
            return 0;
        }
    }
    self->s.v.enemy = EDICT_TO_PROG( world );
    return 0;
}
Beispiel #5
0
int Sentry_FindTarget(  )
{
    gedict_t *client;
    float   r;
    float   gotone;
    float   loopc;

    r = 0;
    loopc = 0;
    gotone = 0;
    while ( loopc < 6 && !gotone )
    {
        client = checkclient(  );
        gotone = CheckTarget( client );
        loopc = loopc + 1;
    }
    if ( !gotone )
        return 0;
    self->s.v.enemy = EDICT_TO_PROG( client );
    if ( strneq( PROG_TO_EDICT( self->s.v.enemy )->s.v.classname, "player" ) )
    {
        self->s.v.enemy = PROG_TO_EDICT( self->s.v.enemy )->s.v.enemy;
        if ( strneq( PROG_TO_EDICT( self->s.v.enemy )->s.v.classname, "player" ) )
        {
            self->s.v.enemy = EDICT_TO_PROG( world );
            return 0;
        }
    }
    Sentry_FoundTarget(  );
    return 1;
}
Beispiel #6
0
//=========================================================================
// Dispenser Touch function. Allows players to get stuff from the Dispenser.
void T_Dispenser(  )
{
    gedict_t *dist_checker;

    if ( strneq( other->s.v.classname, "player" ) )
	return;

    if ( other->team_no && !TeamFortress_isTeamsAllied (other->team_no , self->team_no) )
	CenterPrint( self->real_owner, "Enemies are using your dispenser!\n" );

    // Ignore any engineer working on this dispenser	
    if ( ( !other->building || other->building == world ) && other->building_wait < g_globalvars.time )
    {
        // Pop up the menu
	other->current_menu = MENU_DISPENSER;
	other->menu_count = MENU_REFRESH_RATE;

	other->building = self;

        // Start a Distance checker, which removes the menu if the player
	// gets too far away from the Dispenser.
	dist_checker = spawn(  );
	dist_checker->s.v.classname = "timer";
	dist_checker->s.v.owner = EDICT_TO_PROG( other );
	dist_checker->s.v.enemy = EDICT_TO_PROG( self );
	dist_checker->s.v.think = ( func_t ) CheckDistance;
	dist_checker->s.v.nextthink = g_globalvars.time + 0.3;
    }
}
Beispiel #7
0
/*
=============
SV_RunThink

Runs thinking code if time.  There is some play in the exact time the think
function will be called, because it is called before any movement is done
in a frame.  Not used for pushmove objects, because they must be exact.
Returns false if the entity removed itself.
=============
*/
qboolean SV_RunThink (edict_t *ent)
{
	float	thinktime;

	do
	{
		thinktime = ent->v.nextthink;
		if (thinktime <= 0)
			return true;
		if (thinktime > sv.time + host_frametime)
			return true;
		
		if (thinktime < sv.time)
			thinktime = sv.time;	// don't let things stay in the past.
									// it is possible to start that way
									// by a trigger with a local time.
		ent->v.nextthink = 0;
		pr_global_struct->time = thinktime;
		pr_global_struct->self = EDICT_TO_PROG(ent);
		pr_global_struct->other = EDICT_TO_PROG(sv.edicts);
		PR_ExecuteProgram (ent->v.think);

		if (ent->free)
			return false;
	} while (1);

	return true;
}
Beispiel #8
0
/*
================
SV_Physics_Pusher

================
*/
void SV_Physics_Pusher (edict_t *ent)
{
	float	thinktime;
	float	oldltime;
	float	movetime;

	oldltime = ent->v.ltime;
	
	thinktime = ent->v.nextthink;
	if (thinktime < ent->v.ltime + host_frametime)
	{
		movetime = thinktime - ent->v.ltime;
		if (movetime < 0)
			movetime = 0;
	}
	else
		movetime = host_frametime;

	if (movetime)
	{
		SV_PushMove (ent, movetime);	// advances ent->v.ltime if not blocked
	}
		
	if (thinktime > oldltime && thinktime <= ent->v.ltime)
	{
		ent->v.nextthink = 0;
		pr_global_struct->time = sv.time;
		pr_global_struct->self = EDICT_TO_PROG(ent);
		pr_global_struct->other = EDICT_TO_PROG(sv.edicts);
		PR_ExecuteProgram (ent->v.think);
		if (ent->free)
			return;
	}

}
Beispiel #9
0
void LaunchLaser( vec3_t org, vec3_t vec )
{

	if ( !strcmp( self->s.v.classname, "monster_enforcer" ) )
		sound( self, CHAN_WEAPON, "enforcer/enfire.wav", 1, ATTN_NORM );

	normalize( vec, vec );

	newmis = spawn(  );
	g_globalvars.newmis = EDICT_TO_PROG( newmis );
	newmis->s.v.owner = EDICT_TO_PROG( self );
	newmis->s.v.movetype = MOVETYPE_FLY;
	newmis->s.v.solid = SOLID_BBOX;
	newmis->s.v.effects = EF_DIMLIGHT;

	setmodel( newmis, "progs/laser.mdl" );
	setsize( newmis, 0, 0, 0, 0, 0, 0 );

	setorigin( newmis, PASSVEC3( org ) );

	//newmis->s.v.velocity = vec * 600;
	VectorScale( vec, 600, newmis->s.v.velocity );

	vectoangles( newmis->s.v.velocity, newmis->s.v.angles );

	newmis->s.v.nextthink = g_globalvars.time + 5;
	newmis->s.v.think = ( func_t ) SUB_Remove;
	newmis->s.v.touch = ( func_t ) Laser_Touch;
}
Beispiel #10
0
void SV_RemoveBot (client_t *cl)
{
	if (cl->state == cs_spawned)
	{
		if (!cl->spectator)
		{
			// call the prog function for removing a client
			// this will set the body to a dead frame, among other things
			pr_global_struct->self = EDICT_TO_PROG(cl->edict);
			PR_ExecuteProgram (PR_GLOBAL(ClientDisconnect));
		}
		else if (SpectatorDisconnect)
		{
			// call the prog function for removing a client
			// this will set the body to a dead frame, among other things
			pr_global_struct->self = EDICT_TO_PROG(cl->edict);
			PR_ExecuteProgram (SpectatorDisconnect);
		}
	}

	Com_DPrintf ("Bot %s removed\n", cl->name.c_str());

	cl->state = cs_free;		// we don't have zombie bots :)
	cl->bot = false;
	cl->old_frags = 0;
	cl->name = "";
//	cl->edict->inuse = false;
	cl->edict->v.frags = 0;
	cl->userinfo.clear();

	SV_FreeDelayedPackets (cl);

// send notification to all remaining clients
	SV_FullClientUpdate (cl, &sv.reliable_datagram);
}
Beispiel #11
0
void set_move_trace(trace_t *trace)
{
	if (is_progdefs111)
	{
		pr_global_struct_v111->trace_allsolid = trace->allsolid;
		pr_global_struct_v111->trace_startsolid = trace->startsolid;
		pr_global_struct_v111->trace_fraction = trace->fraction;
		pr_global_struct_v111->trace_inwater = trace->inwater;
		pr_global_struct_v111->trace_inopen = trace->inopen;
		VectorCopy (trace->endpos, pr_global_struct_v111->trace_endpos);
		VectorCopy (trace->plane.normal, pr_global_struct_v111->trace_plane_normal);
		pr_global_struct_v111->trace_plane_dist =  trace->plane.dist;
		if (trace->ent)
			pr_global_struct_v111->trace_ent = EDICT_TO_PROG(trace->ent);
		else
			pr_global_struct_v111->trace_ent = EDICT_TO_PROG(sv.edicts);

		return;
	}

	pr_global_struct->trace_allsolid = trace->allsolid;
	pr_global_struct->trace_startsolid = trace->startsolid;
	pr_global_struct->trace_fraction = trace->fraction;
	pr_global_struct->trace_inwater = trace->inwater;
	pr_global_struct->trace_inopen = trace->inopen;
	VectorCopy (trace->endpos, pr_global_struct->trace_endpos);
	VectorCopy (trace->plane.normal, pr_global_struct->trace_plane_normal);
	pr_global_struct->trace_plane_dist =  trace->plane.dist;	
	if (trace->ent)
		pr_global_struct->trace_ent = EDICT_TO_PROG(trace->ent);
	else
		pr_global_struct->trace_ent = EDICT_TO_PROG(sv.edicts);
}
Beispiel #12
0
// called every time when adding a bot or bringing the bot from previous map
void Bot_Spawn_And_Begin (client_t *cl)
{
	int i;
	edict_t	*ent = cl->edict;

	// set colormap, name, entgravity and maxspeed
	SetUpClientEdict (cl, ent);

	cl->state = cs_spawned;

	// copy spawn parms out of the client_t
	for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
		(&PR_GLOBAL(parm1))[i] = cl->spawn_parms[i];

	// call the spawn function
	pr_global_struct->time = sv.time;
	pr_global_struct->self = EDICT_TO_PROG(ent);
	PR_ExecuteProgram (PR_GLOBAL(ClientConnect));

	// actually spawn the player
	pr_global_struct->time = sv.time;
	pr_global_struct->self = EDICT_TO_PROG(ent);
	PR_ExecuteProgram (PR_GLOBAL(PutClientInServer));

	cl->sendinfo = true;
}
Beispiel #13
0
/*
==================
SV_Impact

Two entities have touched, so run their touch functions
==================
*/
void SV_Impact (edict_t *e1, edict_t *e2)
{
	int		old_self, old_other;
	
	old_self = pr_global_struct->self;
	old_other = pr_global_struct->other;
	
	pr_global_struct->time = sv.time;
	if (e1->v.touch && e1->v.solid != SOLID_NOT)
	{
		pr_global_struct->self = ((int)EDICT_TO_PROG(e1));
		pr_global_struct->other = ((int)EDICT_TO_PROG(e2));
		PR_ExecuteProgram (e1->v.touch);
	}
	
	if (e2->v.touch && e2->v.solid != SOLID_NOT)
	{
		pr_global_struct->self = ((int)EDICT_TO_PROG(e2));
		pr_global_struct->other = ((int)EDICT_TO_PROG(e1));
		PR_ExecuteProgram (e2->v.touch);
	}

	pr_global_struct->self = old_self;
	pr_global_struct->other = old_other;
}
Beispiel #14
0
/*
==================
SV_Impact

Two entities have touched, so run their touch functions
==================
*/
void SV_Impact (edict_t *e1, edict_t *e2)
{
	int	old_self, old_other;
	
	old_self = PR_GLOBAL(self);
	old_other = PR_GLOBAL(other);
	
	PR_GLOBAL(time) = sv.time;
	if (e1->v.touch && e1->v.solid != SOLID_NOT)
	{
		PR_GLOBAL(self) = EDICT_TO_PROG(e1);
		PR_GLOBAL(other) = EDICT_TO_PROG(e2);
		PR_ExecuteProgram (e1->v.touch);
	}
	
	if (e2->v.touch && e2->v.solid != SOLID_NOT)
	{
		PR_GLOBAL(self) = EDICT_TO_PROG(e2);
		PR_GLOBAL(other) = EDICT_TO_PROG(e1);
		PR_ExecuteProgram (e2->v.touch);
	}

	PR_GLOBAL(self) = old_self;
	PR_GLOBAL(other) = old_other;
}
Beispiel #15
0
//=========================================================================
// Engineer has used a Spanner on the SentryGun
void Engineer_UseSentryGun( gedict_t * gun )
{
    gedict_t *dist_checker;

    G_sprint( self, 2, "Level %.0f Sentry Gun has %.0f health, %.0f shells",
	      gun->s.v.weapon, gun->s.v.health, gun->s.v.ammo_shells );
    if ( gun->s.v.weapon == 3 )
    {
	G_sprint( self, 2, ", %.0f rockets", gun->s.v.ammo_rockets );
    }

    if ( gun->has_sentry &&  tg_data.tg_enabled )
	G_sprint( self, 2, ", static" );

    G_sprint( self, 2, "\n" );
    self->current_menu = MENU_ENGINEER_FIX_SENTRYGUN;
    self->menu_count = MENU_REFRESH_RATE;
    self->building = gun;
    dist_checker = spawn(  );
    dist_checker->s.v.classname = "timer";
    dist_checker->s.v.owner = EDICT_TO_PROG( self );
    dist_checker->s.v.enemy = EDICT_TO_PROG( gun );
    dist_checker->s.v.think = ( func_t ) CheckDistance;
    dist_checker->s.v.nextthink = g_globalvars.time + 0.3;
}
Beispiel #16
0
void SV_ProgStartFrame (void)
{
// let the progs know that a new frame has started
	pr_global_struct->self = EDICT_TO_PROG(sv.edicts);
	pr_global_struct->other = EDICT_TO_PROG(sv.edicts);
	pr_global_struct->time = sv.time;
	PR_ExecuteProgram (pr_global_struct->StartFrame);
}
Beispiel #17
0
//
// BuildChain - Builds the chain (linked list)
//
void BuildChain()
{
    self->s.v.goalentity = EDICT_TO_PROG( MakeLink() );
    PROG_TO_EDICT( self->s.v.goalentity )->s.v.think = (func_t) UpdateChain;
    PROG_TO_EDICT( self->s.v.goalentity )->s.v.nextthink = g_globalvars.time + 0.1;
    PROG_TO_EDICT( self->s.v.goalentity )->s.v.owner = self->s.v.owner;
    PROG_TO_EDICT( self->s.v.goalentity )->s.v.goalentity = EDICT_TO_PROG( MakeLink() );
    PROG_TO_EDICT( PROG_TO_EDICT( self->s.v.goalentity )->s.v.goalentity)->s.v.goalentity = EDICT_TO_PROG( MakeLink() );
}
/*
=====================
SV_DropClient

Called when the player is totally leaving the server, either willingly
or unwillingly.  This is NOT called if the entire server is quiting
or crashing.
=====================
*/
void SV_DropClient (client_t *drop)
{
	// add the disconnect
	MSG_WriteByte (&drop->netchan.message, svc_disconnect);

	if (drop->state == cs_spawned)
	{
		if (!drop->spectator)
		{
			// call the prog function for removing a client
			// this will set the body to a dead frame, among other things
			pr_global_struct->self = EDICT_TO_PROG(drop->edict);
			PR_ExecuteProgram (pr_global_struct->ClientDisconnect);
		}
		else if (SpectatorDisconnect)
		{
			// call the prog function for removing a client
			// this will set the body to a dead frame, among other things
			pr_global_struct->self = EDICT_TO_PROG(drop->edict);
			PR_ExecuteProgram (SpectatorDisconnect);
		}
	}
	else if (dmMode.integer == DM_SIEGE)
	{
		if (PR_GetString(drop->edict->v.puzzle_inv1)[0] != '\0')
		{
			// this guy has a puzzle piece, call this function anyway
			// to make sure he leaves it behind
			Con_Printf("Client in unspawned state had puzzle piece, forcing drop\n");
			pr_global_struct->self = EDICT_TO_PROG(drop->edict);
			PR_ExecuteProgram (pr_global_struct->ClientDisconnect);
		}
	}

	if (drop->spectator)
		Con_Printf ("Spectator %s removed\n",drop->name);
	else
		Con_Printf ("Client %s removed\n",drop->name);

	if (drop->download)
	{
		fclose (drop->download);
		drop->download = NULL;
	}

	drop->state = cs_zombie;		// become free in a few seconds
	drop->connection_started = realtime;	// for zombie timeout

	drop->old_frags = 0;
	drop->edict->v.frags = 0;
	drop->name[0] = 0;
	memset (drop->userinfo, 0, sizeof(drop->userinfo));

	// send notification to all remaining clients
	SV_FullClientUpdate (drop, &sv.reliable_datagram);
}
/*	Player character actions
*/
void SV_Physics_Client (edict_t	*ent, int num)
{
	if(!svs.clients[num-1].active)
		return;		// unconnected slot

	// call standard client pre-think
	pr_global_struct.self = EDICT_TO_PROG(ent);

	Game->Game_Init(SERVER_PLAYERPRETHINK,ent,sv.time);

	Game->Physics_CheckVelocity(ent);

	// decide which move function to call
	switch(ent->v.movetype)
	{
	case MOVETYPE_NONE:
		if (!Server_RunThink(ent))
			return;
		break;
	case MOVETYPE_WALK:
		if(!Server_RunThink(ent))
			return;

		if(!Physics_CheckWater(ent) && !(ent->v.flags & FL_WATERJUMP))
			Game->Physics_SetGravity(ent);

		SV_CheckStuck (ent);
		SV_WalkMove (ent);
		break;
	case MOVETYPE_TOSS:
	case MOVETYPE_BOUNCE:
	case MOVETYPE_FLYBOUNCE:
		Physics_Toss(ent);
		break;
	case MOVETYPE_FLY:
		if(!Server_RunThink(ent))
			return;

		SV_FlyMove(ent,host_frametime,NULL);
		break;
	case MOVETYPE_NOCLIP:
		if(!Server_RunThink(ent))
			return;
		Math_VectorMA (ent->v.origin, host_frametime, ent->v.velocity, ent->v.origin);
		break;
	default:
		Sys_Error ("SV_Physics_client: bad movetype %i", (int)ent->v.movetype);
	}

	// Call standard player post-think
	SV_LinkEdict(ent,true);

	pr_global_struct.self = EDICT_TO_PROG(ent);

	Game->Game_Init(SERVER_CLIENTPOSTTHINK,ent,sv.time);
}
Beispiel #20
0
/*
================
SV_Physics_Pusher

================
*/
void SV_Physics_Pusher (edict_t *ent)
{
    float	thinktime;
    float	oldltime;
    float	movetime;
    vec3_t oldorg, move;
    float	l;

    oldltime = ent->v.ltime;

    thinktime = ent->v.nextthink;
    if (thinktime < ent->v.ltime + sv_frametime)
    {
        movetime = thinktime - ent->v.ltime;
        if (movetime < 0)
            movetime = 0;
    }
    else
        movetime = sv_frametime;

    if (movetime)
    {
        if (ent->v.avelocity[0] || ent->v.avelocity[1] || ent->v.avelocity[2])
            SV_PushRotate (ent, sv_frametime);
        else
            SV_PushMove (ent, movetime);	// advances ent->v.ltime if not blocked
    }

    if (thinktime > oldltime && thinktime <= ent->v.ltime)
    {
        VectorCopy (ent->v.origin, oldorg);
        ent->v.nextthink = 0;
        pr_global_struct->time = sv.time;
        pr_global_struct->self = EDICT_TO_PROG(ent);
        pr_global_struct->other = EDICT_TO_PROG(sv.edicts);
        PR_ExecuteProgram (ent->v.think);
        if (!ent->inuse)
            return;

        VectorSubtract (ent->v.origin, oldorg, move);

        l = VectorLength(move);
        if (l > 1.0/64)
        {
            //	Com_Printf ("**** snap: %f\n", Length (l));
            VectorCopy (oldorg, ent->v.origin);
            SV_Push (ent, move);
        }
    }
}
Beispiel #21
0
/*
=============
SV_RunThink

Runs thinking code if time.  There is some play in the exact time the think
function will be called, because it is called before any movement is done
in a frame.  Not used for pushmove objects, because they must be exact.
Returns false if the entity removed itself.
=============
*/
qboolean SV_RunThink (edict_t *ent)
{
	float	thinktime;
	int		oldcount;

	thinktime = ent->v.nextthink;
	if (thinktime <= 0 || thinktime > sv.time + host_frametime)
		return true;
		
	if (thinktime < sv.time)
		thinktime = sv.time;	// don't let things stay in the past.
								// it is possible to start that way
								// by a trigger with a local time.
	ent->v.nextthink = 0;

	PR_GLOBAL(time) = thinktime;
	PR_GLOBAL(self) = EDICT_TO_PROG(ent);
	PR_GLOBAL(other) = EDICT_TO_PROG(sv.edicts);

// JDH: the extra 1 added to total_monsters by monster_fish happens 
//      in swimmonster_start_go, during the first frame (sv.time = 1). 
//      But fix it only if total_monsters was increased when fish were 
//      spawned (ie. if sv.fish_counted is true)

	if ((sv.time == 1.0) && sv_fishfix.value && sv.fish_counted && 
		!strcmp(pr_strings + ent->v.classname, "monster_fish") &&
		!strcmp(pr_functions[ent->v.think].s_name, "swimmonster_start_go"))
	{
		oldcount = PR_GLOBAL(total_monsters);		
	}
	else oldcount = -1;
	
	PR_ExecuteProgram (ent->v.think);
	
	if (oldcount != -1)
	{
		if ((int)PR_GLOBAL(total_monsters) - oldcount == 1)
		{
			PR_GLOBAL(total_monsters) -= 1;
			if (sv.fish_counted == 1)
			{
				Con_Print ("Detected fish-count bug in progs.dat; monster count has been adjusted\n");
				sv.fish_counted++;
			}
		}
	}

	return !ent->free;
}
Beispiel #22
0
static void set_move_trace(trace_t *trace)
{
	*sv_globals.trace_allsolid = trace->allsolid;
	*sv_globals.trace_startsolid = trace->startsolid;
	*sv_globals.trace_fraction = trace->fraction;
	*sv_globals.trace_inwater = trace->inwater;
	*sv_globals.trace_inopen = trace->inopen;
	VectorCopy (trace->endpos, *sv_globals.trace_endpos);
	VectorCopy (trace->plane.normal, *sv_globals.trace_plane_normal);
	*sv_globals.trace_plane_dist =  trace->plane.dist;
	if (trace->ent)
		*sv_globals.trace_ent = EDICT_TO_PROG(trace->ent);
	else
		*sv_globals.trace_ent = EDICT_TO_PROG(sv.edicts);
}
Beispiel #23
0
void RegenFlag( gedict_t *flag )
{
	flag->s.v.movetype = MOVETYPE_TOSS;
	flag->s.v.solid = SOLID_TRIGGER;
	setmodel( flag, flag->mdl );
	VectorCopy( flag->mangle, flag->s.v.angles );
	flag->cnt = FLAG_RETURNED;
	flag->cnt2 = 0.0;
	flag->s.v.owner = EDICT_TO_PROG( world );
	SetVector( flag->s.v.velocity, 0, 0, 0 );
	sound( flag, CHAN_VOICE, "items/itembk2.wav", 1, ATTN_NORM);
	flag->s.v.nextthink = g_globalvars.time + 0.2;
	flag->s.v.groundentity = EDICT_TO_PROG( world );
	flag->s.v.touch = (func_t) FlagTouch;
}
Beispiel #24
0
void SV_PostRunCmd(void)
{
	// run post-think

	if (!host_client->spectator) {
		pr_global_struct->time = sv.time;
		pr_global_struct->self = EDICT_TO_PROG(sv_player);
		PR_ExecuteProgram (pr_global_struct->PlayerPostThink);
		SV_RunNewmis ();
	} else if (SpectatorThink) {
		pr_global_struct->time = sv.time;
		pr_global_struct->self = EDICT_TO_PROG(sv_player);
		PR_ExecuteProgram (SpectatorThink);
	}
}
Beispiel #25
0
/*
================
SV_Physics_Pusher

================
*/
void SV_Physics_Pusher (edict_t *ent)
{
	float	thinktime;
	float	oldltime;
	float	movetime;

	oldltime = ent->v.ltime;
	
#ifdef _DEBUG
	if (!ent->v.classname && ent->v.think)
		movetime = 0;
#endif
	
	thinktime = ent->v.nextthink;
	if (thinktime < ent->v.ltime + host_frametime)
	{
		movetime = thinktime - ent->v.ltime;
		if (movetime < 0)
			movetime = 0;
	}
	else
		movetime = host_frametime;

	if (movetime)
	{
	#ifdef HEXEN2_SUPPORT
		if (hexen2 && (ent->v.avelocity[0] || ent->v.avelocity[1] || ent->v.avelocity[2]))
		{
			SV_PushRotate (ent, movetime);
		}
		else
	#endif
		SV_PushMove (ent, movetime);	// advances ent->v.ltime if not blocked
	}
		
	if (thinktime > oldltime && thinktime <= ent->v.ltime)
	{
		ent->v.nextthink = 0;

		PR_GLOBAL(time) = sv.time;
		PR_GLOBAL(self) = EDICT_TO_PROG(ent);
		PR_GLOBAL(other) = EDICT_TO_PROG(sv.edicts);

		PR_ExecuteProgram (ent->v.think);
		if (ent->free)
			return;
	}
}
Beispiel #26
0
static int
cpqw_user_cmd (void)
{
	int         argc, i;
	progs_t    *pr = &sv_pr_state;

	if (cpqw_funcs.ClientCommand) {
		argc = Cmd_Argc ();
		if (argc > 7)
			argc = 7;

		*sv_globals.time = sv.time;
		*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, sv_player);

		PR_PushFrame (pr);
		P_FLOAT (pr, 0) = argc;
		for (i = 0; i < argc; i++)
			P_STRING (pr, i + 1) = PR_SetTempString (pr, Cmd_Argv (i));
		for (; i < 7; i++)
			P_STRING (pr, i + 1) = 0;
		PR_ExecuteProgram (pr, cpqw_funcs.ClientCommand);
		PR_PopFrame (pr);
		return (int) R_FLOAT (pr);
	}
	return 0;
}
Beispiel #27
0
/*
** SV_RunNQNewmis
**
** sv_player will be valid
*/
void SV_RunNQNewmis (void)
{
    edict_t	*ent;
    double save_frametime;
    int i, pl;

    pl = EDICT_TO_PROG(sv_player);
    ent = NEXT_EDICT(sv.edicts);
    for (i=1 ; i<sv.num_edicts ; i++, ent = NEXT_EDICT(ent))
    {
        if (!ent->inuse)
            continue;
        if (ent->lastruntime || ent->v.owner != pl)
            continue;
        if (ent->v.movetype != MOVETYPE_FLY &&
                ent->v.movetype != MOVETYPE_FLYMISSILE &&
                ent->v.movetype != MOVETYPE_BOUNCE)
            continue;
        if (ent->v.solid != SOLID_BBOX && ent->v.solid != SOLID_TRIGGER)
            continue;

        save_frametime = sv_frametime;
        sv_frametime = 0.05;
        SV_RunEntity (ent);
        sv_frametime = save_frametime;
        return;
    }
}
Beispiel #28
0
void fire_fly(  )
{
	gedict_t *fireball;

	fireball = spawn(  );
	newmis = fireball;
	g_globalvars.newmis = EDICT_TO_PROG( newmis );
	fireball->s.v.solid = SOLID_TRIGGER;
	fireball->s.v.movetype = MOVETYPE_TOSS;
	SetVector( fireball->s.v.velocity,
		   ( g_random(  ) * 100 ) - 50, ( g_random(  ) * 100 ) - 50, self->speed + ( g_random(  ) * 200 ) );

	fireball->s.v.classname = "fireball";

	setmodel( fireball, "progs/lavaball.mdl" );
	setsize( fireball, 0, 0, 0, 0, 0, 0 );
	setorigin( fireball, PASSVEC3( self->s.v.origin ) );

	fireball->s.v.nextthink = g_globalvars.time + 5;
	fireball->s.v.think = ( func_t ) SUB_Remove;
	fireball->s.v.touch = ( func_t ) fire_touch;

	self->s.v.nextthink = g_globalvars.time + ( g_random(  ) * 5 ) + 3;
	self->s.v.think = ( func_t ) fire_fly;
}
Beispiel #29
0
void Vote_ChangeMap_Init()
{
	int f1;
	gedict_t* voteguard;

	f1 = CountPlayers();
	if(f1 == 1) {
		G_bprint(2, "%s changes map\n",self->s.v.netname);
		current_vote = -1;
		NextLevel();
		return;	// in case we get back here
	}

	
	G_bprint(2, "%s votes for mapchange\n",self->s.v.netname);

	if(f1/2 !=1)
		G_bprint(2, "%d‘ total votes needed\nType ",f1/2);
	else
		G_bprint(2, "%d‘ total vote needed\nType ",f1/2);

	G_bprint(3, "γνδ φοτε ωεσ");
	G_bprint(2, " in console to approve\n");

	k_vote = 1;
	self->k_voted = 1;
	voteguard = spawn(); // Check the 1 minute timeout for voting
	voteguard->s.v.owner = EDICT_TO_PROG(world);
	voteguard->s.v.classname  = "voteguard";
	voteguard->s.v.think = (func_t) VoteThink;
	voteguard->s.v.nextthink = g_globalvars.time + votes[current_vote].timeout;
}
Beispiel #30
0
//===========================================================================
// GameConsoleCommand
//===========================================================================
void PR2_GameConsoleCommand(void)
{
	int     old_other, old_self;
	client_t	*cl;
	int			i;

	if( sv_vm )
	{
		old_self = pr_global_struct->self;
		old_other = pr_global_struct->other;
		pr_global_struct->other = 0; //sv_cmd = SV_CMD_CONSOLE;
		pr_global_struct->self = 0;

		for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++)
		{
			if (!cl->state)
				continue;
			if ( cl->isBot )
				continue;

			if (NET_CompareAdr(cl->netchan.remote_address, net_from))
			{
				pr_global_struct->self = EDICT_TO_PROG(cl->edict);
				break;
			}
		}
		VM_Call(sv_vm, GAME_CONSOLE_COMMAND, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
		pr_global_struct->self = old_self;
		pr_global_struct->other = old_other;
	}
}