Author Topic: How to "enable" onExplode when brick damage is turned off [SOLVED]  (Read 1449 times)

original title: Turning off brick damage in minigames prevents bricks from triggering onExplode

Title explains it all. I need it to run because the area damage calculations that killable prop bricks use is contained within fxDTSBrick::canExplode. If there is any other function I can package that gets called when a brick is affected by area impulse, that would also work as a solution.

This is the current code for this damage calculation. I know that i'm not using radius damage - this decision is half intentional, half because i was unable to find any easy-to-implement way to do it with radius damage.


function fxDTSbrick::canExplode(%brick,%mv,%mfv)
   {
      if(%brick.getGroup() ==  BrickGroup_888999.getID())
      {
         %db = %brick.getDatablock();
         %dam = %db.brickSizeY*%db.brickSizeX*%db.brickSizeZ;
         %dam = %dam/3;
         if (%mv > 29)
            %dam = mPow((%mv - %dam), 0.6)*18;
         if (%dam < 0)
            echo("cannot damage a prop brick for negative hp");
         //echo("explosion damage " @ %dam);
         %brick.damage(%dam);

         return 0;
      }
      return parent::canExplode(%brick,%mv,%mfv);
   }
« Last Edit: February 24, 2016, 06:18:31 PM by Conan »

just create an radius search whenever an explosion goes off
something like this
Code: [Select]
package swol_thing
{
function projectileData::onExplode(%db,%proj,%pos)
{
%explosion = %db.explosion;
%radius = %explosion.damageRadius;
if(%radius > 0)
{
%mask = $TypeMasks::FxBrickObjectType;
initContainerRadiusSearch(%pos,%radius,%mask);
while(isObject(%hit = containerSearchNext()))
{
%hit.doStuff();
}
}
parent::onExplode(%db,%proj,%pos);
}
};
activatePackage(swol_thing);

Edit 2/24/2016 17:08 PST: Added a parent and fixed while loop
« Last Edit: February 24, 2016, 07:09:29 PM by Swollow »

i forgot to explain that i figured out how to fix it - by doing what you just posted (minus the coding errors)
chrono/nulily/shift kitty pointed me to your admin orb rockets mod, swollow, and that helped me figure out how to do radius searches.

also you made the same mistake of using an if statement instead of a while, just like in the admin orb rockets :P
and you forgot to parent the function

Code: [Select]
package swol_thing_fixed
{
function projectileData::onExplode(%db,%proj,%pos)
{
%explosion = %db.explosion;
%radius = %explosion.damageRadius; //%explosion.brickDamageRadius is an alternative (which i used)
if(%radius > 0)
{
%mask = $TypeMasks::FxBrickObjectType;
initContainerRadiusSearch(%pos,%radius,%mask);
while (isObject(%hit = containerSearchNext())) //use while if you're looking to affect every brick in the radius
{
%hit.doStuff();
}
}
parent::onExplode(%db, %proj, %pos); //dont forget to parent your functions!!!
}
};
activatePackage(swol_thing_fixed);

as a general note, since I didn't know this till shift kitty told me, $TypeMasks::FxBrickObjectType only includes raycasted bricks, while $TypeMasks::FxBrickAlwaysObjectType includes deraycasted bricks as well.

keywords: typemask for bricks, typemask differences, container radius search, how to do check explosions radius
« Last Edit: February 24, 2016, 06:17:04 PM by Conan »

i wrote the container search without testing it and dumbly made the while loop error, so thank you for pointing that out

also I decided fxBrickObjectType should be used in this case since I didn't see a reason to blow up bricks without raycasting

i wrote the container search without testing it and dumbly made the while loop error, so thank you for pointing that out

also I decided fxBrickObjectType should be used in this case since I didn't see a reason to blow up bricks without raycasting
some prop builds may have invisible bricks and need to be damaged by radius damage in order to get destroyed since bullets or normal raycasts wont hit them.

Enabling it

User was banned for this post
« Last Edit: February 29, 2016, 06:51:28 PM by Badspot »

Enabling it
Please stop stuffposting. You've already been banned once - do you want to get banned again?

Please stop stuffposting. You've already been banned once - do you want to get banned again?

Just lock this topic -_-
« Last Edit: February 29, 2016, 06:07:55 PM by FelipeO_O »

Ban me, you can't even hold you breath to a simple answer. Where did i stuffposted? Just lock this thread -_-
Don't answer questions to which you have no idea of what is being asked about.
I am leaving this thread open in case anyone has something to say that's useful/not covered in the thread contents, eg if there's something I didn't consider when solving this problem or that most people dont know.

Me not locking the thread doesn't mean you should come in and post a blatantly useless and pointless answer, for a problem that was already clearly solved. Think twice before posting.

i suggested you "enabling it". It's not useful for you?
« Last Edit: February 29, 2016, 06:20:11 PM by FelipeO_O »

Let's stop this. Yes i was wrong with my ignorant answer.