Game Development Reference
In-Depth Information
6. That was fun! Let's do it again with another Wolfenstein example:
/*
============
G_SpawnItem
Sets the clipping size and plants the object on the floor.
Items can't be immediately dropped to floor, because they might
be on an entity that hasn't spawned yet.
============
*/
(0) void G_SpawnItem (gentity_t *ent, gitem_t *item) {
(1) char *noise;
(2) G_SpawnFloat( “random�?, “0�?, &ent->random );
(3) G_SpawnFloat( “wait�?, “0�?, &ent->wait );
(4) ent->item = item;
(5) // some movers spawn on the second frame, so delay item
(6) // spawns until the third frame so they can ride trains
(7) ent->nextthink = level.time + FRAMETIME * 2;
(8) ent->think = FinishSpawningItem;
(9) if(G_SpawnString(“noise�?, 0, &noise))
(10) ent->noise_index = G_SoundIndex(noise);
(11) ent->physicsBounce = 0.50; // items are bouncy
(12) if(ent->model) {
(13) ent->s.modelindex2 = G_ModelIndex(ent->model);
(14) }
(15) if ( item->giType == IT_TEAM ) {
(16) G_SpawnInt( “count�?, “1�?, &ent->s.density );
(17) G_SpawnInt( “speedscale�?, “100�?, &ent->splashDamage );
(18) if( !ent->splashDamage ) {
(19) ent->splashDamage = 100;
(20) }
(21) }
}
Search WWH ::




Custom Search