|
QuakeZone MOD Coding Tutorials
|
|
|
Introduction Pre-requisites Code Notes Exercises |
|
| Introduction |
|
|
This tutorial describe show to generate a table of random spawn points, useful when spawning pick-up items, such as Tech pick-ups (cf). These spawn points are not strictly random as they are merely the spawn points
of already existing items. In the case of this tutorial, they are those items that
are not allowed to spawn (in Team Rocket, no weapons or ammo items are spawned, so their
spawn points are used to build our table).
|
| Pre-requisites |
|
|
| Code |
|
|
g_local.h At the end of structure level_locals_t, add the following 2 lines: vec3_t spawn_points[50]; // random spawn points int num_spawn_points; // number of spawn points g_spawn.c In procedure InitGame, add the following line at the indicated position:
skill = gi.cvar ("skill", "1", CVAR_LATCH);
maxentities = gi.cvar ("maxentities", "1024", CVAR_LATCH);
level.num_spawn_points = 0; // PJT - spawn points
g_items.c In procedure SpawnItem, add the following lines at the start of the procedure:
// PJT - spawn points
// create spawn points for disallowed items
// only spawn armour and health (but may still get disallowed by dm flags)
if (!(item->pickup == Pickup_Health || item->pickup == Pickup_Adrenaline ||
item->pickup == Pickup_AncientHead || item->pickup == Pickup_Armor ||
item->pickup == Pickup_PowerArmor))
{
// PJT - spawn rockets
if (level.num_spawn_points < 51)
{
level.num_spawn_points++;
VectorCopy(ent->s.origin, level.spawn_points[level.num_spawn_points - 1]);
}
// PJT
G_FreeEdict (ent);
return;
}
// PJT
|
| Notes |
|
|
g_local.h
g_spawn.c
g_items.c
|
| Exercises |
|
|
Nope, can't think of any. If I come up with a method for truly random spawn points that don't end up in lava I will post it on this site. |