A_DeathChunks/A_Replace

Bugs that have been resolved.

Moderator: Graf Zahl

Locked
User avatar
justin023
Posts: 165
Joined: Wed Sep 21, 2005 10:51
Location: Illinois
Contact:

A_DeathChunks/A_Replace

Post by justin023 »

Here is a function I modified which allows an actor to be broken into pieces like A_FreezeDeathChunks. But it allows any chunks to be used instead of just IceChunk. It works like a combination of A_IceGuyDie and A_FreezeDeathChunks (the actor is immediately broken when this is called). I remember a feature request for this by cutmanmike, but I didn't know as much then. This would probably work good as a generic death for some ultimate weapon.
[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 ();
[/spoiler]
Last edited by justin023 on Wed Nov 16, 2005 22:50, edited 3 times in total.
User avatar
Soultaker
Posts: 219
Joined: Fri Sep 02, 2005 8:26
Location: Capping some zombies Gangsta Style.
Contact:

Post by Soultaker »

Uh custom deaths are coming soon. This is overstepping Randy's and Graf's ability to implement custom deaths since what your are asking for can be classified as a custom death sequence.

(Maybe Graf can better explain... I think I failed at explaining...)
User avatar
TheDarkArchon
Posts: 1000
Joined: Wed Jul 06, 2005 11:58
Location: What's that fucking smell
Contact:

Post by TheDarkArchon »

The title is a bit deceptive: He's essentially parametized A_FreezeDeathChunks.
User avatar
justin023
Posts: 165
Joined: Wed Sep 21, 2005 10:51
Location: Illinois
Contact:

Post by justin023 »

I have changed it. This doesn't involve custom state labels, because custom labels or not, this isn't otherwise possible without some overcomplicated ACS.
User avatar
justin023
Posts: 165
Joined: Wed Sep 21, 2005 10:51
Location: Illinois
Contact:

Post by justin023 »

**double post

I have updated A_DeathChunks so that it allows an exact number of chunks to be created. I also created A_Replace, which simply replaces thing A with thing B. There is also A_Chunks, but that is an internal function only.

Code: Select all

A_DeathChunks("Water", 5) //Creates 6 water chunks
A_Replace("Zombie2") //Removes whatever called it and replaces it with Zombie2
Using these two functions, I was able to create an IceGuy that bursts into smaller IceGuys (NOTE: The smaller iceguys still have the same attack so use god mode). This is the entire decorate to make that happen:

[spoiler]

Code: Select all

ACTOR IceGuy2 : IceGuy
{
	renderstyle translucent
	alpha 0.8
	states
	{
	death:
		ICEY A 1 A_DeathChunks("SpawnChunk", 8)
		Stop
	}
}

ACTOR SpawnChunk
{
	Scale 0.25
	radius 5
	height 18
	PROJECTILE
	- NOGRAVITY
	+LOWGRAVITY
	States
	{
	Spawn:
		ICEY A -1
		Stop
	Death:
		ICEY A 1 A_Replace("MiniIceGuy")
		Stop
	}
}

ACTOR MiniIceGuy : IceGuy
{
	radius 5
	height 18
	scale 0.25
	renderstyle translucent
	alpha 0.8
	states
	{
	death:
		ICEY A 1 A_DeathChunks("MiniChunk", 20)
		Stop
	}
}

ACTOR MiniChunk : IceChunk
{
	scale 0.25
	height 1
	radius 1	
}
[/spoiler]

A_Replace is nessecary because using A_DeathChunks to create a monster, makes the monster invincible!? These are the files containing these new things:
Locked

Return to “Closed Bugs”