Author Topic: make a whiteout for a large radius when a projectile explodes  (Read 2853 times)

i need to make it so when a custom projectile hits the ground, all people within a large radius of the explosion get the whiteout.

Do a radius container search originating from the position where the projectile impacted (ProjectileName::onCollision).

errr... im not sure how to do that


^ is a fantastic tutorial. I was going to post some code that would be fairly plug-and-play, but I feel like that would be a disservice to Dylan's hard work.

so how exactly should I put that into my projectile script
im not really much into scripting so I dont really know what to do

Code: [Select]
package myWhiteout
{
    function MyProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal)
    {
        initContainerRadiusSearch(%obj.getPosition(), %this.explosion.damageRadius, $TypeMasks::PlayerObjectType);
        while(%player = containerSearchNext())
            %player.setWhiteOut((%this.explosion.damageRadius/2)/vectorLen(vectorSub(%player.getPosition(), %obj.getPosition())));
        parent::onCollision(%this, %obj, %col, %fade, %pos, %normal);
    }
};
activatePackage(myWhiteout);
« Last Edit: September 29, 2013, 11:18:51 AM by $trinick »

it works, but in a small radius. how do I make the radius larger?

it works, but in a small radius. how do I make the radius larger?
Increase the explosion's damageRadius variable.

Increase the explosion's damageRadius variable.
its already an enormous amount, at least 4 times the mini-nuke, yet the whiteout occurs only in a small radius in the middle
what i tried is changing this

%player.setWhiteOut((%this.explosion.damageRadius/4)/vectorLen(vectorSub(%player.getPosition(), %obj.getPosition())));

to this

%player.setWhiteOut((%this.explosion.damageRadius*30)/vectorLen(vectorSub(%player.getPosition(), %obj.getPosition())));

yet the only difference is that the whiteout is way brighter, but still in that very small radius

its already an enormous amount, at least 4 times the mini-nuke, yet the whiteout occurs only in a small radius in the middle
what i tried is changing this

%player.setWhiteOut((%this.explosion.damageRadius/4)/vectorLen(vectorSub(%player.getPosition(), %obj.getPosition())));

to this

%player.setWhiteOut((%this.explosion.damageRadius*30)/vectorLen(vectorSub(%player.getPosition(), %obj.getPosition())));

yet the only difference is that the whiteout is way brighter, but still in that very small radius
That part is just how bright the white out is.

initContainerRadiusSearch(%obj.getPosition(), %this.explosion.damageRadius, $TypeMasks::PlayerObjectType);
The second variable in this is the radius.

That part is just how bright the white out is.

initContainerRadiusSearch(%obj.getPosition(), %this.explosion.damageRadius, $TypeMasks::PlayerObjectType);
The second variable in this is the radius.
Thanks! it works perfectly now

Thanks! it works perfectly now
Rather than multiply the radius in the search, to create a better visual effect you should edit the explosion datablock's damageRadius variable. The line you tried editing is just an equation to make the whiteout less bright the further you are from it, and it will get all messed up if you change the size of the explosion but not the equation to calculate the brightness.