[spoiler]
Code: Select all
POSS M 1 A_DeathChunks("MatrixGlyphs")Code: Select all
void A_DeathChunks (AActor *actor)
{
	int i, numChunks;
	AActor * mo;
	int index=CheckIndex(1, NULL);
	if (index<0) return;
	const TypeInfo * chunk = TypeInfo::FindType((const char *)StateParameters[index]);
	actor->momx = actor->momy = actor->momz = 0;
	actor->height = actor->GetDefault()->height;
	// [RH] In Hexen, this creates a random number of shards (range [24,56])
	// with no relation to the size of the actor shattering. I think it should
	// base the number of shards on the size of the dead thing, so bigger
	// things break up into more shards than smaller things.
	// An actor with radius 20 and height 64 creates ~40 chunks.
	numChunks = MAX<int> (4, (actor->radius>>FRACBITS)*(actor->height>>FRACBITS)/32);
	i = (pr_freeze.Random2()) % (numChunks/4);
	for (i = MAX (24, numChunks + i); i >= 0; i--)
	{
		mo = Spawn(chunk,
			actor->x + (((pr_freeze()-128)*actor->radius)>>7), 
			actor->y + (((pr_freeze()-128)*actor->radius)>>7), 
			actor->z + (pr_freeze()*actor->height/255));
		//mo->SetState (mo->SpawnState + (pr_freeze()%3)); //Uncomment for a fatal error
		if (mo)
		{
			mo->momz = FixedDiv(mo->z-actor->z, actor->height)<<2;
			mo->momx = pr_freeze.Random2 () << (FRACBITS-7);
			mo->momy = pr_freeze.Random2 () << (FRACBITS-7);
			A_IceSetTics (mo); // set a random tic wait
			mo->RenderStyle = actor->RenderStyle;
			mo->alpha = actor->alpha;
		}
	}
	// [RH] Do some stuff to make this more useful outside Hexen
	if (actor->flags4 & MF4_BOSSDEATH)
	{
		A_BossDeath (actor);
	}
	A_NoBlocking (actor);
	actor->Destroy ();

