?? g_misc.c
字號:
extern void func_train_find (edict_t *self);
void misc_strogg_ship_use (edict_t *self, edict_t *other, edict_t *activator)
{
self->svflags &= ~SVF_NOCLIENT;
self->use = train_use;
train_use (self, other, activator);
}
void SP_misc_strogg_ship (edict_t *ent)
{
if (!ent->target)
{
gi.dprintf ("%s without a target at %s\n", ent->classname, vtos(ent->absmin));
G_FreeEdict (ent);
return;
}
if (!ent->speed)
ent->speed = 300;
ent->movetype = MOVETYPE_PUSH;
ent->solid = SOLID_NOT;
ent->s.modelindex = gi.modelindex ("models/ships/strogg1/tris.md2");
VectorSet (ent->mins, -16, -16, 0);
VectorSet (ent->maxs, 16, 16, 32);
ent->think = func_train_find;
ent->nextthink = level.time + FRAMETIME;
ent->use = misc_strogg_ship_use;
ent->svflags |= SVF_NOCLIENT;
ent->moveinfo.accel = ent->moveinfo.decel = ent->moveinfo.speed = ent->speed;
gi.linkentity (ent);
}
/*QUAKED misc_satellite_dish (1 .5 0) (-64 -64 0) (64 64 128)
*/
void misc_satellite_dish_think (edict_t *self)
{
self->s.frame++;
if (self->s.frame < 38)
self->nextthink = level.time + FRAMETIME;
}
void misc_satellite_dish_use (edict_t *self, edict_t *other, edict_t *activator)
{
self->s.frame = 0;
self->think = misc_satellite_dish_think;
self->nextthink = level.time + FRAMETIME;
}
void SP_misc_satellite_dish (edict_t *ent)
{
ent->movetype = MOVETYPE_NONE;
ent->solid = SOLID_BBOX;
VectorSet (ent->mins, -64, -64, 0);
VectorSet (ent->maxs, 64, 64, 128);
ent->s.modelindex = gi.modelindex ("models/objects/satellite/tris.md2");
ent->use = misc_satellite_dish_use;
gi.linkentity (ent);
}
/*QUAKED light_mine1 (0 1 0) (-2 -2 -12) (2 2 12)
*/
void SP_light_mine1 (edict_t *ent)
{
ent->movetype = MOVETYPE_NONE;
ent->solid = SOLID_BBOX;
ent->s.modelindex = gi.modelindex ("models/objects/minelite/light1/tris.md2");
gi.linkentity (ent);
}
/*QUAKED light_mine2 (0 1 0) (-2 -2 -12) (2 2 12)
*/
void SP_light_mine2 (edict_t *ent)
{
ent->movetype = MOVETYPE_NONE;
ent->solid = SOLID_BBOX;
ent->s.modelindex = gi.modelindex ("models/objects/minelite/light2/tris.md2");
gi.linkentity (ent);
}
/*QUAKED misc_gib_arm (1 0 0) (-8 -8 -8) (8 8 8)
Intended for use with the target_spawner
*/
void SP_misc_gib_arm (edict_t *ent)
{
gi.setmodel (ent, "models/objects/gibs/arm/tris.md2");
ent->solid = SOLID_NOT;
ent->s.effects |= EF_GIB;
ent->takedamage = DAMAGE_YES;
ent->die = gib_die;
ent->movetype = MOVETYPE_TOSS;
ent->svflags |= SVF_MONSTER;
ent->deadflag = DEAD_DEAD;
ent->avelocity[0] = random()*200;
ent->avelocity[1] = random()*200;
ent->avelocity[2] = random()*200;
ent->think = G_FreeEdict;
ent->nextthink = level.time + 30;
gi.linkentity (ent);
}
/*QUAKED misc_gib_leg (1 0 0) (-8 -8 -8) (8 8 8)
Intended for use with the target_spawner
*/
void SP_misc_gib_leg (edict_t *ent)
{
gi.setmodel (ent, "models/objects/gibs/leg/tris.md2");
ent->solid = SOLID_NOT;
ent->s.effects |= EF_GIB;
ent->takedamage = DAMAGE_YES;
ent->die = gib_die;
ent->movetype = MOVETYPE_TOSS;
ent->svflags |= SVF_MONSTER;
ent->deadflag = DEAD_DEAD;
ent->avelocity[0] = random()*200;
ent->avelocity[1] = random()*200;
ent->avelocity[2] = random()*200;
ent->think = G_FreeEdict;
ent->nextthink = level.time + 30;
gi.linkentity (ent);
}
/*QUAKED misc_gib_head (1 0 0) (-8 -8 -8) (8 8 8)
Intended for use with the target_spawner
*/
void SP_misc_gib_head (edict_t *ent)
{
gi.setmodel (ent, "models/objects/gibs/head/tris.md2");
ent->solid = SOLID_NOT;
ent->s.effects |= EF_GIB;
ent->takedamage = DAMAGE_YES;
ent->die = gib_die;
ent->movetype = MOVETYPE_TOSS;
ent->svflags |= SVF_MONSTER;
ent->deadflag = DEAD_DEAD;
ent->avelocity[0] = random()*200;
ent->avelocity[1] = random()*200;
ent->avelocity[2] = random()*200;
ent->think = G_FreeEdict;
ent->nextthink = level.time + 30;
gi.linkentity (ent);
}
//=====================================================
/*QUAKED target_character (0 0 1) ?
used with target_string (must be on same "team")
"count" is position in the string (starts at 1)
*/
void SP_target_character (edict_t *self)
{
self->movetype = MOVETYPE_PUSH;
gi.setmodel (self, self->model);
self->solid = SOLID_BSP;
self->s.frame = 12;
gi.linkentity (self);
return;
}
/*QUAKED target_string (0 0 1) (-8 -8 -8) (8 8 8)
*/
void target_string_use (edict_t *self, edict_t *other, edict_t *activator)
{
edict_t *e;
int n, l;
char c;
l = strlen(self->message);
for (e = self->teammaster; e; e = e->teamchain)
{
if (!e->count)
continue;
n = e->count - 1;
if (n > l)
{
e->s.frame = 12;
continue;
}
c = self->message[n];
if (c >= '0' && c <= '9')
e->s.frame = c - '0';
else if (c == '-')
e->s.frame = 10;
else if (c == ':')
e->s.frame = 11;
else
e->s.frame = 12;
}
}
void SP_target_string (edict_t *self)
{
if (!self->message)
self->message = "";
self->use = target_string_use;
}
/*QUAKED func_clock (0 0 1) (-8 -8 -8) (8 8 8) TIMER_UP TIMER_DOWN START_OFF MULTI_USE
target a target_string with this
The default is to be a time of day clock
TIMER_UP and TIMER_DOWN run for "count" seconds and the fire "pathtarget"
If START_OFF, this entity must be used before it starts
"style" 0 "xx"
1 "xx:xx"
2 "xx:xx:xx"
*/
#define CLOCK_MESSAGE_SIZE 16
// don't let field width of any clock messages change, or it
// could cause an overwrite after a game load
static void func_clock_reset (edict_t *self)
{
self->activator = NULL;
if (self->spawnflags & 1)
{
self->health = 0;
self->wait = self->count;
}
else if (self->spawnflags & 2)
{
self->health = self->count;
self->wait = 0;
}
}
static void func_clock_format_countdown (edict_t *self)
{
if (self->style == 0)
{
Com_sprintf (self->message, CLOCK_MESSAGE_SIZE, "%2i", self->health);
return;
}
if (self->style == 1)
{
Com_sprintf(self->message, CLOCK_MESSAGE_SIZE, "%2i:%2i", self->health / 60, self->health % 60);
if (self->message[3] == ' ')
self->message[3] = '0';
return;
}
if (self->style == 2)
{
Com_sprintf(self->message, CLOCK_MESSAGE_SIZE, "%2i:%2i:%2i", self->health / 3600, (self->health - (self->health / 3600) * 3600) / 60, self->health % 60);
if (self->message[3] == ' ')
self->message[3] = '0';
if (self->message[6] == ' ')
self->message[6] = '0';
return;
}
}
void func_clock_think (edict_t *self)
{
if (!self->enemy)
{
self->enemy = G_Find (NULL, FOFS(targetname), self->target);
if (!self->enemy)
return;
}
if (self->spawnflags & 1)
{
func_clock_format_countdown (self);
self->health++;
}
else if (self->spawnflags & 2)
{
func_clock_format_countdown (self);
self->health--;
}
else
{
struct tm *ltime;
time_t gmtime;
time(&gmtime);
ltime = localtime(&gmtime);
Com_sprintf (self->message, CLOCK_MESSAGE_SIZE, "%2i:%2i:%2i", ltime->tm_hour, ltime->tm_min, ltime->tm_sec);
if (self->message[3] == ' ')
self->message[3] = '0';
if (self->message[6] == ' ')
self->message[6] = '0';
}
self->enemy->message = self->message;
self->enemy->use (self->enemy, self, self);
if (((self->spawnflags & 1) && (self->health > self->wait)) ||
((self->spawnflags & 2) && (self->health < self->wait)))
{
if (self->pathtarget)
{
char *savetarget;
char *savemessage;
savetarget = self->target;
savemessage = self->message;
self->target = self->pathtarget;
self->message = NULL;
G_UseTargets (self, self->activator);
self->target = savetarget;
self->message = savemessage;
}
if (!(self->spawnflags & 8))
return;
func_clock_reset (self);
if (self->spawnflags & 4)
return;
}
self->nextthink = level.time + 1;
}
void func_clock_use (edict_t *self, edict_t *other, edict_t *activator)
{
if (!(self->spawnflags & 8))
self->use = NULL;
if (self->activator)
return;
self->activator = activator;
self->think (self);
}
void SP_func_clock (edict_t *self)
{
if (!self->target)
{
gi.dprintf("%s with no target at %s\n", self->classname, vtos(self->s.origin));
G_FreeEdict (self);
return;
}
if ((self->spawnflags & 2) && (!self->count))
{
gi.dprintf("%s with no count at %s\n", self->classname, vtos(self->s.origin));
G_FreeEdict (self);
return;
}
if ((self->spawnflags & 1) && (!self->count))
self->count = 60*60;;
func_clock_reset (self);
self->message = gi.TagMalloc (CLOCK_MESSAGE_SIZE, TAG_LEVEL);
self->think = func_clock_think;
if (self->spawnflags & 4)
self->use = func_clock_use;
else
self->nextthink = level.time + 1;
}
//=================================================================================
void teleporter_touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
{
edict_t *dest;
int i;
if (!other->client)
return;
dest = G_Find (NULL, FOFS(targetname), self->target);
if (!dest)
{
gi.dprintf ("Couldn't find destination\n");
return;
}
//ZOID
CTFPlayerResetGrapple(other);
//ZOID
// unlink to make sure it can't possibly interfere with KillBox
gi.unlinkentity (other);
VectorCopy (dest->s.origin, other->s.origin);
VectorCopy (dest->s.origin, other->s.old_origin);
other->s.origin[2] += 10;
// clear the velocity and hold them in place briefly
VectorClear (other->velocity);
other->client->ps.pmove.pm_time = 160>>3; // hold time
other->client->ps.pmove.pm_flags |= PMF_TIME_TELEPORT;
// draw the teleport splash at source and on the player
self->owner->s.event = EV_PLAYER_TELEPORT;
other->s.event = EV_PLAYER_TELEPORT;
// set angles
for (i=0 ; i<3 ; i++)
other->client->ps.pmove.delta_angles[i] = ANGLE2SHORT(dest->s.angles[i] - other->client->resp.cmd_angles[i]);
VectorClear (other->s.angles);
VectorClear (other->client->ps.viewangles);
VectorClear (other->client->v_angle);
// kill anything at the destination
KillBox (other);
gi.linkentity (other);
}
/*QUAKED misc_teleporter (1 0 0) (-32 -32 -24) (32 32 -16)
Stepping onto this disc will teleport players to the targeted misc_teleporter_dest object.
*/
void SP_misc_teleporter (edict_t *ent)
{
edict_t *trig;
if (!ent->target)
{
gi.dprintf ("teleporter without a target.\n");
G_FreeEdict (ent);
return;
}
gi.setmodel (ent, "models/objects/dmspot/tris.md2");
ent->s.skinnum = 1;
ent->s.effects = EF_TELEPORTER;
ent->s.sound = gi.soundindex ("world/amb10.wav");
ent->solid = SOLID_BBOX;
VectorSet (ent->mins, -32, -32, -24);
VectorSet (ent->maxs, 32, 32, -16);
gi.linkentity (ent);
trig = G_Spawn ();
trig->touch = teleporter_touch;
trig->solid = SOLID_TRIGGER;
trig->target = ent->target;
trig->owner = ent;
VectorCopy (ent->s.origin, trig->s.origin);
VectorSet (trig->mins, -8, -8, 8);
VectorSet (trig->maxs, 8, 8, 24);
gi.linkentity (trig);
}
/*QUAKED misc_teleporter_dest (1 0 0) (-32 -32 -24) (32 32 -16)
Point teleporters at these.
*/
void SP_misc_teleporter_dest (edict_t *ent)
{
gi.setmodel (ent, "models/objects/dmspot/tris.md2");
ent->s.skinnum = 0;
ent->solid = SOLID_BBOX;
// ent->s.effects |= EF_FLIES;
VectorSet (ent->mins, -32, -32, -24);
VectorSet (ent->maxs, 32, 32, -16);
gi.linkentity (ent);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -