Nuclear Missle Damage + map deformation

Ok, so here is what I am looking as so far.

In the src/explosions.cpp line 822-852 explosion_handler::nuke & src/computer.cpp line 624-693 computer::activate_function.

In these two files are the handles for the nuke. The explosions file handles the submaps, so the 12x12 section and the computer handles the overmap locations of the explosion.

For the computer.cpp it seems that the whole nuke explosion should be moved to the explosion_handler.cpp file.

From there I purpose the following.

Add

void nuke( const tripoint &p , const float megatons)
{
    const float blastPower = 4184000000000000;
    float realBlastPower = blastPower * megatons;
    tripoint dest( 0, 0, p.z );
    float powerloss ( const float power, const int x, const int y, const in z ) {
        // get the distance from the destination point and then modify the power by
        //  the inverse square to simulate power loss over distance
        float v = sqrt(pow(dest.x - x, 2), pow(dest.y - y, 2), pow(dest.z - z, 2));
        return power * 1 / sqrt(v);
    }

The megatons pass in is the real damage the nuke would bring to the equation. If it is over a certain threshold it will annihilate the tile else it will damage everything in the tiles appropriately.

Also, following my previous post about the contents causing fallout there could be a parameter that causes the nuke to be dirty randomly or something else.

Also as a note the power is in joules.

In addition I would also add in Z-level deformation with this while moving all deformation code to the explosion.cpp from the computer.cpp.

The radius of the blast would be directly linked with the power of the nuke. I have to ask though how distance should be handled though as the effects of the nuke should be HUGE.

I was thinking about something like the following,

int c_x = 0, c_y = 0, c_z = 0;
float c_power = realBlastPower;
while ( (c_power = powerloss(realBlastPower, c_x, c_y, c_z)) > 0) {
    // code to deform map
    deform(c_power, dest.xy(), c_x, c_y, c_z);
    // code to increment c_x, c_y, c_z
}

If anyone has an opinion on this let me know. I am going to flesh it out over the next few days.

The above will rapidly lose power as it leaves the epicenter of the explosion just like IRL. On top of that it would make the nuke adjustable and very dangerous.

Seeing overmap locations decimated in a radius of 4+ should be easy enough with much larger ones only a slight change to the megatons.

2 Likes