Author Topic: Questions about fxDTSbrick  (Read 750 times)

Hey guys, I have 2 quick questions. First, when you parent onPlant you get the variable '%brick' How do you then, with %brick, make the brick explode with tank shell explosion, and then delete itself? Like, say that I want an event that when you place a brick, it automatically explodes it and delete. How would I do that? Secondly, how do you automatically detect when a brick is hit when any projectile?


Secondly, how do you automatically detect when a brick is hit when any projectile?
Code: [Select]
package onBrickHit
{
function projectile::onCollision(%this, %obj, %col, %fade, %pos, %normal)
{
parent::onCollision(%this, %obj, %col, %fade, %pos, %normal);


if(%col.getClassName() $= "fxDtsBrick" && (%col.getDatablock().uiName $= "myBrickName"))
{
messageClient(%obj.client,'',"Oi! You hit my brick!");
}
}
}
activatePackage(onBrickHit);
Not sure if that's exactly the right function.

If that does not work try function projectileData::onCollision.
« Last Edit: February 25, 2012, 08:37:08 PM by jes00 »

Not too good with bricks, but I imagine you could simply do this:

%brick.spawnExplosion(TankShellProjectile, 1, %client);

where %client is the gameConnection of the person who deals the damage, if that makes sense.

then

%brick.killBrick();


In this case, unless you want otherwise, you could do %brick.client, which would get your own client. Unless you had self damage on, the planting of the brick would only hurt other people.

%brick.delete(); should work too.
I recall that errors can occur when fake kill bricks attempt to respawn even though the brick is gone resulting in a crash so you want to be careful to not let the explosion fake kill the brick

%brick.delete(); should work too.

I would avoid %brick.delete() because that may cause some severe issues because you have removed the object, and if %brick is used at all later in the script or in another package, you will get console spam saying that blah blah object doesnt exist and cannot find specific class functions because you deleted the object that defined the class.  use killbrick()

Using %brick.delete() is perfectly fine and does the same thing as %brick.killBrick(), just without the killed brick effect.