Ground Combat Sequence

From PlanetsWiki

Jump to: navigation, search

Contents

[edit] Overview

This page shows the ground combat code (Host 19?).

[edit] Check all Planets

z = loop variable
k = loop variable
i = loop variable
vID = Object ID
vCount = number of objects at location
vC = number of bases on planet
fg = flag (signals combat)

Loop through all objects (z loop, 20,000 iterations)
  IF object(z) is Planet
    Set base list for each player to 0
    vC = 0
    Mark all objects at location of planet z
    vCount = Number of objects at location
    IF vCount > 0
      For each object (k loop, 1 to vCount)
        vID = object k
        check for valid object (# from 1 to 20,000)
        IF object is Base
          IF Base is on Planet z  (eliminates bases on other planets at the same location)
            IF Base owned by valid player (# from 1 to 30)
              Base added to Player’s Baselist for this location
              vC increased by 1
    fg = 0
    IF vC > 1 (more than 1 Base on Planet z)
      For each player (k loop, 1 to 30)
        IF player’s baselist > 0 (max of 1?)
          For each player (I loop, 1 to 30)
            IF fg = 1 EXIT i loop
              IF player’s baselist > 0 (max of 1?)
                IF k <> i (k = i means same player)
                  IF players for Base k and Base i are at war
                    fg = 1
                    EXIT i loop
    IF fg = 1
      GROUNDCOMBATNOW z (initiate ground combat code at planet z)

Summary:

  • Loops through all 20,000 possible objects in the game.
  • Checks each Planet for Bases.
  • IF Bases of multiple Players present, check Attack settings.
  • IF any combination of Players is at War, then call GROUNDCOMBATNOW with the Planet ID.

[edit] BEGIN GROUND COMBAT

[edit] LOAD BASE DATA

For each Player (z loop, 1 to 30)
  IF player’s baselist > 0 (max of 1?)
    Player’s Base loaded into BaseA(z)
    Player’s Colonists loaded into colonistHome(z)
    Get all Mech and Fighter data from base
      Player’s mechs loaded into mechA(z, 1to3)
      Player’s fighers loaded into fighterA(z, 1to3)
    IF Base belongs to Cyborg
      Troops increased by colonistHome(z) * 0.2
      colonistHome = colonistsHome * 0.8
    IF Base belongs to Privateer
      vPrivHappy(z) = colonists/1000
      Minimum vPrivHappy(z) of 2
      Maximum vPrivHappy(z) of 200

[edit] ATTACK MODE MODIFIER

For each Player (z loop, 1 to 30)
  IF player’s baselist > 0 (max of 1?)
    Mech type 3 count loaded into vStartMech3(z)
    Check Base Attack Mode
      0 = Peaceful (everything in base)
      1 = Roaming Defense (25% Troops on patrol)
        troopAccount(z) = Troops / 4
      2 = Deep Ground Patrol (50% Troops, Fighters and Mechs on patrol)
        troopAccount(z) = Troops / 2
        fighterAccount(z, 1to3) = fighter(1to3) * 0.5
        mechAccount(z, 1to3) = mech(1to3) * 0.5
      3 = Attack and Run (90% Troops, 100% Fighters and Mechs on patrol)
        troopAccount(z) = Troops * 0.9
        fighterAccount(z, 1to3) = fighter(1to3) (All Mechs)
        mechAccount(z, 1to3) = mech(1to3) (All Mechs)
      4 = Crush KILL Destroy (95% Troops and Crew, 80% HG, 100% Fighters and Mechs on patrol)
        troopAccount(z) = Troops * 0.95
        crewAccount(z) = Crew * 0.95
        guardAccount(z) = HighGuard * 0.8
        fighterAccount(z, 1to3) = fighter(1to3) (All Mechs)
        mechAccount(z, 1to3) = mech(1to3) (All Mechs)
      5 = Capture
        Identical to Crush KILL Destroy

    Loop 3 times (i loop)
      Minimum 0 for fighter(1to3)
      Minimum 0 for each mech(1to3)

[edit] CENTAUR KILL MODIFIER

For each Player (z loop, 1 to 30)
  rAB(z) = 1
  IF Base belongs to Centaur
    rV = vStartMech3(z) * 0.2
    Maximum rV of 0.3
    rAB(z) increased by rV

[edit] ROAMING DEFENSE

countz = 0
countk = 0
z = 1 + (Rnd * 29) (Randomly pick 1 player to Attack)
For each Player (z loop, 30x)
  z incremented by 1
  countz incremented by 1 (makes sure each player is only checked once)
  IF z > 30, set z to 1
  IF player’s baselist > 0 (max of 1?)
    IF attackMode = 1 (Roaming Defense)
      k = 1 + (Rnd * 29) (Randomly pick 1 player to Defend)
      For each Player (k loop, 30x)
        k incremented by 1
        countk incremented by 1 (makes sure each player is only checked once)
        IF k > 30, set k to 1
        IF player’s baselist > 0 (max of 1?)
          fgLizZ = 0 (Lizard attacker flag)
          fgLizK = 0 (Lizard defender flag)
          IF attacker’s Base is owned by Lizard
            fgLizZ = 1
          IF defender’s Base is owned by Lizard
              fgLizK =1
          IF fgLizZ = 1 AND fgLizK = 1
            fgLizZ = 0
            fgLizK = 0
          IF (k <> z) AND (baseDefeatedBy(k) = 0) AND (baseDefeatedBy(z) = 0)
            IF owner’s of the bases are at War (Attack switch)
              d = guardAccount(k) * defender’s CombatHighGuard
              rHGFactorK = 1 - (d / 1000)
              Minimum rHGFactorK of 0.5
              d = guardAccount(z) * attacker’s CombatHighGuard
              rHGFactorZ = 1 – (d / 1000)
              Minimum rHGFactorZ of 0.5

[edit] Troops Attack

IF troopAccount(z) > 0

[edit] Troop vs Troop

IF troopAccount(k) > 0 AND troopAccount(z) > 0
  dKillz = troopAccount(z) * (attacker’s CombatTroop / 100) * rAB(z) + troopAccount(z) * attacker’s forceDark / 100
  IF fgLizZ = 1, dKillz multiplied by 30
  IF fgLizK = 1, dKillz reduced by half
  Minimum dKills of 0
  v = (dKillz * rHGFactorK * Rnd)
  Maximum v of troopAccount(k)
  troopAccount(k) reduced by v
  vRecoverK increased by v
  vDeadTroop(k) increased by v

COUNTERATTACK
IF troopAccount(k) > 0 AND troopAccount(z) > 0 
  d = troopAccount(k) * (defender’s CombatTroop / 150) * rAB(k) + troopAccount(k) * defender’s forceDark / 50
  IF fgLizZ = 1, dKillz multiplied by 30
  IF fgLizK = 1, dKillz reduced by half
  Minimum d of 0
  v = (d * rHGFactorZ * Rnd)
  Maximum v of troopAccount(z)
  troopAccount(z) reduced by v
  vRecoverZ increased by v
  vDeadTroop(z) increased by v

[edit] Troop vs Crew

[edit] Troop vs Colonist

[edit] Troop vs Mech

[edit] Troop vs Fighter

[edit] Cyborg Recovery

[edit] DEEP GROUND PATROL

[edit] ATTACK AND RUN

[edit] CRUSH KILL DESTROY

[edit] CAPTURE

Personal tools