- used static constant arrays to shorten some code.

This commit is contained in:
Christoph Oelckers 2016-11-20 18:34:27 +01:00
parent 5951a9449c
commit 159f09105e
2 changed files with 8 additions and 22 deletions

View file

@ -282,21 +282,11 @@ class Actor : Thinker native
void SpawnDirt (double radius) void SpawnDirt (double radius)
{ {
class<Actor> dtype; static const class<Actor> chunks[] = { "Dirt1", "Dirt2", "Dirt3", "Dirt4", "Dirt5", "Dirt6" };
switch (random[Dirt](0, 5))
{
case 0: dtype = "Dirt1"; break;
case 1: dtype = "Dirt2"; break;
case 2: dtype = "Dirt3"; break;
case 3: dtype = "Dirt4"; break;
case 4: dtype = "Dirt5"; break;
default: dtype = "Dirt6"; break;
}
double zo = random[Dirt]() / 128. + 1; double zo = random[Dirt]() / 128. + 1;
Vector3 pos = Vec3Angle(radius, random[Dirt]() * (360./256), zo); Vector3 pos = Vec3Angle(radius, random[Dirt]() * (360./256), zo);
Actor mo = Spawn (dtype, pos, ALLOW_REPLACE); Actor mo = Spawn (chunks[random[Dirt](0, 5)], pos, ALLOW_REPLACE);
if (mo) if (mo)
{ {
mo.Vel.Z = random[Dirt]() / 64.; mo.Vel.Z = random[Dirt]() / 64.;

View file

@ -58,11 +58,9 @@ class Demon1 : Actor
DEMN H 6; DEMN H 6;
DEMN I 6 DEMN I 6
{ {
A_SpawnItemEx("Demon1Chunk1", 0,0,45, frandom[DemonChunks](1,4.984375)*cos(Angle+90), frandom[DemonChunks](1,4.984375)*sin(Angle+90), 8, 90, ChunkFlags); static const class<Actor> chunks[] = { "Demon1Chunk1", "Demon1Chunk2", "Demon1Chunk3", "Demon1Chunk4", "Demon1Chunk5" };
A_SpawnItemEx("Demon1Chunk2", 0,0,45, frandom[DemonChunks](1,4.984375)*cos(Angle-90), frandom[DemonChunks](1,4.984375)*sin(Angle-90), 8, 270, ChunkFlags); for(int i = 0; i < 5; i++)
A_SpawnItemEx("Demon1Chunk3", 0,0,45, frandom[DemonChunks](1,4.984375)*cos(Angle-90), frandom[DemonChunks](1,4.984375)*sin(Angle-90), 8, 270, ChunkFlags); A_SpawnItemEx(chunks[i], 0,0,45, frandom[DemonChunks](1,4.984375)*cos(Angle+90), frandom[DemonChunks](1,4.984375)*sin(Angle+90), 8, 90, ChunkFlags);
A_SpawnItemEx("Demon1Chunk4", 0,0,45, frandom[DemonChunks](1,4.984375)*cos(Angle-90), frandom[DemonChunks](1,4.984375)*sin(Angle-90), 8, 270, ChunkFlags);
A_SpawnItemEx("Demon1Chunk5", 0,0,45, frandom[DemonChunks](1,4.984375)*cos(Angle-90), frandom[DemonChunks](1,4.984375)*sin(Angle-90), 8, 270, ChunkFlags);
} }
Goto Death+2; Goto Death+2;
Ice: Ice:
@ -266,11 +264,9 @@ class Demon2 : Demon1
DEM2 H 6; DEM2 H 6;
DEM2 I 6 DEM2 I 6
{ {
A_SpawnItemEx("Demon2Chunk1", 0,0,45, frandom[DemonChunks](1,4.984375)*cos(Angle+90), frandom[DemonChunks](1,4.984375)*sin(Angle+90), 8, 90, ChunkFlags); static const class<Actor> chunks[] = { "Demon2Chunk1", "Demon2Chunk2", "Demon2Chunk3", "Demon2Chunk4", "Demon2Chunk5" };
A_SpawnItemEx("Demon2Chunk2", 0,0,45, frandom[DemonChunks](1,4.984375)*cos(Angle-90), frandom[DemonChunks](1,4.984375)*sin(Angle-90), 8, 270, ChunkFlags); for(int i = 0; i < 5; i++)
A_SpawnItemEx("Demon2Chunk3", 0,0,45, frandom[DemonChunks](1,4.984375)*cos(Angle-90), frandom[DemonChunks](1,4.984375)*sin(Angle-90), 8, 270, ChunkFlags); A_SpawnItemEx(chunks[i], 0,0,45, frandom[DemonChunks](1,4.984375)*cos(Angle+90), frandom[DemonChunks](1,4.984375)*sin(Angle+90), 8, 90, ChunkFlags);
A_SpawnItemEx("Demon2Chunk4", 0,0,45, frandom[DemonChunks](1,4.984375)*cos(Angle-90), frandom[DemonChunks](1,4.984375)*sin(Angle-90), 8, 270, ChunkFlags);
A_SpawnItemEx("Demon2Chunk5", 0,0,45, frandom[DemonChunks](1,4.984375)*cos(Angle-90), frandom[DemonChunks](1,4.984375)*sin(Angle-90), 8, 270, ChunkFlags);
} }
Goto Death+2; Goto Death+2;
} }