Author Topic: Firepower Calculation  (Read 934 times)

Offline resonence

  • Newbie Mark III
  • *
  • Posts: 27
Firepower Calculation
« on: April 20, 2012, 08:51:05 pm »
Is there a place that shows the firepower value of each ship? For example, an artillery golem that spawns as part of an exo-galactic wave has 2500 firepower. I'm kinda curious what other ships are worth.

Offline TechSY730

  • Core Member Mark V
  • *****
  • Posts: 4,570
Re: Firepower Calculation
« Reply #1 on: April 20, 2012, 11:09:35 pm »
Kieth posted a good chunk of the firepower calculation code a while back.
I could try running each of the ships through that function and get you a table of all firepowers in the game, if you like.

EDIT:
For reference:
Code: [Select]
private void InitializeFirePower( bool SetFull )
    {
        long firepower = 0;
        if ( this.BaseAttackPower == 0 || this.BaseAttackRechargeSeconds == 0 )
            firepower = 0;
        else
        {
            firepower = this.BaseAttackPower;
            if ( firepower > 400000 && !SetFull )
                firepower = 400000;

            if ( !this.ExplosionsEqualsDeath ) //make sure not to overvalue autobombs, etc
            {
                firepower *= 20; // firepower <= BaseAttackPower before this line, and BaseAttackPower is an Int32, so no danger of overflowing an Int64
                firepower /= this.BaseAttackRechargeSeconds;
            }

            firepower = firepower * ( 1 + this.NumberSecondaryShots );

            if ( this.IsSelfDamaging ) //make sure not to overvalue cutlasses, etc
            {
                if ( firepower > this.BaseMaxHealth )
                    firepower = this.BaseMaxHealth;
            }
        }

        switch ( this.ShipType )
        {
            case ShipType.Launched_Missile:
            case ShipType.Mine:
                firepower = 0;
                break;
            case ShipType.SpireCityFacility:
                if ( !SetFull )
                    firepower /= 2; //account for the general high difficulty of the spire campaign overall
                break;
        }

        firepower /= 50;

        if ( SetFull )
        {
            if ( this.BaseAttackPower > 0 && firepower <= 0 )
                firepower = 1;
            if ( firepower > Int32.MaxValue )
                firepower = Int32.MaxValue;
            this.FullFirePower = (int)firepower;

            firepower = firepower + firepower + firepower;
            if ( firepower > Int32.MaxValue )
                firepower = Int32.MaxValue;
            this.TripleFullFirePower = (int)firepower;
        }
        else
        {
            if ( this.BaseMoveSpeed <= 0 && !this.ShotIsSniper )
                firepower /= 10;
            if ( this.IsUnableToHitFleetShips )
                firepower /= 10;

            if ( this.BaseAttackPower > 0 && firepower <= 0 )
                firepower = 1;
            if ( firepower > Int32.MaxValue )
                firepower = Int32.MaxValue;
            this.AICheckFirePower = (int)firepower;
        }
    }

Note that it doesn't account for other forms of "multiple shots per salvo" and thus drastically underestimates heavy beam cannons (but not spire photon lances), most aoe (particularly lightning), etc.  Also pays no attention to vs-hull-type bonuses or the wacko bonuses like the polarizer, IRE, and vulture.  May fix that one of these days :)

The AICheckFirePower is used for:
- the reinforcements "am I outnumbered" calculation in evaluating enemy firepower
- for part of the threat-ball "should we keep waiting here?"
-- basically it takes "total FullFirePower of allies on current planet - AICheckFirepower of enemies on current planet" + "the FullFirepower of the threat-ball itself" and if that is > "the FullFirePower of allies on target planet - AICheckFirepower of enemies on target planet" then it goes for it
- for the "should we retreat?" logic in evaluating enemy firepower
- for the hybrids' "ready to execute attack mission?" logic in evaluating enemy firepower; that was added in the past couple months or so (it used to just wait until 7/8ths of everyone who was coming was there)

FullFirePower is used for everything else, including:
- computing NearbyMilitaryUnitPower on the AI thread.  I don't know much about what it does with that, but I think it's used for stuff like "can I take down that Fact-IV on my planet".

Munitions boosts are sometimes considered, and sometimes not (threat-ball power doesn't use it since they'd be moving).
« Last Edit: April 20, 2012, 11:25:50 pm by techsy730 »

Offline resonence

  • Newbie Mark III
  • *
  • Posts: 27
Re: Firepower Calculation
« Reply #2 on: April 21, 2012, 12:21:28 pm »
Nah, I can run the code myself. But thanks for the info. It was just something I was curious about.