本文整理匯總了C++中EDICT_TO_PROG函數的典型用法代碼示例。如果您正苦於以下問題:C++ EDICT_TO_PROG函數的具體用法?C++ EDICT_TO_PROG怎麽用?C++ EDICT_TO_PROG使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了EDICT_TO_PROG函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: SV_TouchLinks
/*
====================
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;
}
}
示例2: SV_Physics
/*
================
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;
}
示例3: SV_PTrack_f
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);
}
示例4: Sentry_FindTarget_Angel
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;
}
示例5: Sentry_FindTarget
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;
}
示例6: T_Dispenser
//=========================================================================
// 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;
}
}
示例7: SV_RunThink
/*
=============
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;
}
示例8: SV_Physics_Pusher
/*
================
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;
}
}
示例9: LaunchLaser
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;
}
示例10: SV_RemoveBot
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);
}
示例11: set_move_trace
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);
}
示例12: Bot_Spawn_And_Begin
// 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;
}
示例13: SV_Impact
/*
==================
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;
}
示例14: SV_Impact
/*
==================
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;
}
示例15: Engineer_UseSentryGun
//=========================================================================
// 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;
}