spawnradius
Jump to navigation
Jump to search
This function acts as an extension to Spawn, used to spawn things in circular patterns. It uses a MapSpot (or any other thing) as a base, and will spawn the object at the appropriate angle and radius relative to the MapSpot as the center. The radius and angle passed should be in fixed point format. The function returns a non-zero value if the spawn was successful, 0 if not.
function int SpawnRadius(str type, int spotid, int radius, int angle, int newtid, bool fog) { int x = GetActorX(spotid) + FixedMul(cos(angle), radius); int y = GetActorY(spotid) + FixedMul(sin(angle), radius); int test = Spawn(type, x, y, GetActorZ(spotid), newtid, angle >> 8); if (test && fog) Spawn("TeleportFog", x, y, GetActorZ(spotid), 0, 0); if (test) return TRUE; return FALSE; }
Spawn 5 Imps around the player.
script 1 ENTER { for (int i=0; i<5; i++) { int angle = 1.0 / 5 * i; SpawnRadius("DoomImp", 0, 128.0, angle, 0, TRUE); } }