コード例 #1
0
function xenobetosecdef()
{
    include_once "destroy_fighters.php";
    include_once "explode_mines.php";
    include_once "cancel_bounty.php";
    // Xenobe to sector defense
    global $playerinfo, $targetlink, $xenobeisdead, $db, $l;
    // Check for sector defenses
    if ($targetlink > 0) {
        $resultf = $db->Execute("SELECT * FROM {$db->prefix}sector_defence WHERE sector_id=? and defence_type ='F' ORDER BY quantity DESC", array($targetlink));
        db_op_result($db, $resultf, __LINE__, __FILE__);
        $i = 0;
        $total_sector_fighters = 0;
        if ($resultf > 0) {
            while (!$resultf->EOF) {
                $defences[$i] = $resultf->fields;
                $total_sector_fighters += $defences[$i]['quantity'];
                $i++;
                $resultf->MoveNext();
            }
        }
        $resultm = $db->Execute("SELECT * FROM {$db->prefix}sector_defence WHERE sector_id=? and defence_type ='M'", array($targetlink));
        db_op_result($db, $resultm, __LINE__, __FILE__);
        $i = 0;
        $total_sector_mines = 0;
        if ($resultm > 0) {
            while (!$resultm->EOF) {
                $defences[$i] = $resultm->fields;
                $total_sector_mines += $defences[$i]['quantity'];
                $i++;
                $resultm->MoveNext();
            }
        }
        if ($total_sector_fighters > 0 || $total_sector_mines > 0 || $total_sector_fighters > 0 && $total_sector_mines > 0) {
            playerlog($db, $playerinfo['ship_id'], LOG_RAW, "ATTACKING SECTOR DEFENCES {$total_sector_fighters} fighters and {$total_sector_mines} mines.");
            $targetfighters = $total_sector_fighters;
            $playerbeams = NUM_BEAMS($playerinfo['beams']);
            if ($playerbeams > $playerinfo['ship_energy']) {
                $playerbeams = $playerinfo['ship_energy'];
            }
            $playerinfo['ship_energy'] = $playerinfo['ship_energy'] - $playerbeams;
            $playershields = NUM_SHIELDS($playerinfo['shields']);
            if ($playershields > $playerinfo['ship_energy']) {
                $playershields = $playerinfo['ship_energy'];
            }
            $playertorpnum = round(pow($level_factor, $playerinfo['torp_launchers'])) * 2;
            if ($playertorpnum > $playerinfo['torps']) {
                $playertorpnum = $playerinfo['torps'];
            }
            $playertorpdmg = $torp_dmg_rate * $playertorpnum;
            $playerarmor = $playerinfo['armor_pts'];
            $playerfighters = $playerinfo['ship_fighters'];
            $totalmines = $total_sector_mines;
            if ($totalmines > 1) {
                $roll = mt_rand(1, $totalmines);
            } else {
                $roll = 1;
            }
            $totalmines = $totalmines - $roll;
            $playerminedeflect = $playerinfo['ship_fighters'];
            // Xenobe keep as many deflectors as fighters
            // Combat - Beams v fighters
            if ($targetfighters > 0 && $playerbeams > 0) {
                if ($playerbeams > round($targetfighters / 2)) {
                    $temp = round($targetfighters / 2);
                    $targetfighters = $temp;
                    $playerbeams = $playerbeams - $temp;
                } else {
                    $targetfighters = $targetfighters - $playerbeams;
                    $playerbeams = 0;
                }
            }
            // Torpedoes v. fighters
            if ($targetfighters > 0 && $playertorpdmg > 0) {
                if ($playertorpdmg > round($targetfighters / 2)) {
                    $temp = round($targetfighters / 2);
                    $targetfighters = $temp;
                    $playertorpdmg = $playertorpdmg - $temp;
                } else {
                    $targetfighters = $targetfighters - $playertorpdmg;
                    $playertorpdmg = 0;
                }
            }
            // Fighters v. fighters
            if ($playerfighters > 0 && $targetfighters > 0) {
                if ($playerfighters > $targetfighters) {
                    echo $l->get('l_sf_destfightall');
                    $temptargfighters = 0;
                } else {
                    $temptargfighters = $targetfighters - $playerfighters;
                }
                if ($targetfighters > $playerfighters) {
                    $tempplayfighters = 0;
                } else {
                    $tempplayfighters = $playerfighters - $targetfighters;
                }
                $playerfighters = $tempplayfighters;
                $targetfighters = $temptargfighters;
            }
            // There are still fighters, so armor v. fighters
            if ($targetfighters > 0) {
                if ($targetfighters > $playerarmor) {
                    $playerarmor = 0;
                } else {
                    $playerarmor = $playerarmor - $targetfighters;
                }
            }
            // Get rid of the sector fighters that died
            $fighterslost = $total_sector_fighters - $targetfighters;
            destroy_fighters($db, $targetlink, $fighterslost);
            // Message the defence owner with what happened
            $l_sf_sendlog = str_replace("[player]", "Xenobe {$playerinfo['character_name']}", $l->get('l_sf_sendlog'));
            $l_sf_sendlog = str_replace("[lost]", $fighterslost, $l_sf_sendlog);
            $l_sf_sendlog = str_replace("[sector]", $targetlink, $l_sf_sendlog);
            message_defence_owner($db, $targetlink, $l_sf_sendlog);
            // Update Xenobe after comnbat
            $armor_lost = $playerinfo['armor_pts'] - $playerarmor;
            $fighters_lost = $playerinfo['ship_fighters'] - $playerfighters;
            $energy = $playerinfo['ship_energy'];
            $update1 = $db->Execute("UPDATE {$db->prefix}ships SET ship_energy=?, ship_fighters=ship_fighters-?, armor_pts=armor_pts-?,torps=torps-? WHERE ship_id=?", array($energy, $fighters_lost, $armor_lost, $playertorpnum, $playerinfo['ship_id']));
            db_op_result($db, $update1, __LINE__, __FILE__);
            // Check to see if Xenobe is dead
            if ($playerarmor < 1) {
                $l_sf_sendlog2 = str_replace("[player]", "Xenobe " . $playerinfo['character_name'], $l->get('l_sf_sendlog2'));
                $l_sf_sendlog2 = str_replace("[sector]", $targetlink, $l_sf_sendlog2);
                message_defence_owner($db, $targetlink, $l_sf_sendlog2);
                cancel_bounty($db, $playerinfo['ship_id']);
                db_kill_player($playerinfo['ship_id']);
                $xenobeisdead = 1;
                return;
            }
            // Xenobe is still alive, so he hits mines, and logs it
            $l_chm_hehitminesinsector = str_replace("[chm_playerinfo_character_name]", "Xenobe " . $playerinfo['character_name'], $l->get('l_chm_hehitminesinsector'));
            $l_chm_hehitminesinsector = str_replace("[chm_roll]", $roll, $l_chm_hehitminesinsector);
            $l_chm_hehitminesinsector = str_replace("[chm_sector]", $targetlink, $l_chm_hehitminesinsector);
            message_defence_owner($db, $targetlink, "{$l_chm_hehitminesinsector}");
            // Deflectors v. mines
            if ($playerminedeflect >= $roll) {
                // Took no mine damage due to virtual mine deflectors
            } else {
                $mines_left = $roll - $playerminedeflect;
                // Shields v. mines
                if ($playershields >= $mines_left) {
                    $update2 = $db->Execute("UPDATE {$db->prefix}ships SET ship_energy=ship_energy-? WHERE ship_id=?", array($mines_left, $playerinfo['ship_id']));
                    db_op_result($db, $update2, __LINE__, __FILE__);
                } else {
                    $mines_left = $mines_left - $playershields;
                    // Armor v. mines
                    if ($playerarmor >= $mines_left) {
                        $update2 = $db->Execute("UPDATE {$db->prefix}ships SET armor_pts=armor_pts-?, ship_energy=0 WHERE ship_id=?", array($mines_left, $playerinfo['ship_id']));
                        db_op_result($db, $update2, __LINE__, __FILE__);
                    } else {
                        // Xenobe dies, logs the fact that he died
                        $l_chm_hewasdestroyedbyyourmines = str_replace("[chm_playerinfo_character_name]", "Xenobe " . $playerinfo['character_name'], $l->get('l_chm_hewasdestroyedbyyourmines'));
                        $l_chm_hewasdestroyedbyyourmines = str_replace("[chm_sector]", $targetlink, $l_chm_hewasdestroyedbyyourmines);
                        message_defence_owner($db, $targetlink, "{$l_chm_hewasdestroyedbyyourmines}");
                        // Actually kill the Xenobe now
                        cancel_bounty($db, $playerinfo['ship_id']);
                        db_kill_player($playerinfo['ship_id']);
                        $xenobeisdead = 1;
                        // Lets get rid of the mines now and return out of this function
                        explode_mines($db, $targetlink, $roll);
                        return;
                    }
                }
            }
            explode_mines($db, $targetlink, $roll);
            // Dispose of the mines now
        } else {
            // This was called without any sector defences to attack
            return;
        }
    }
}
コード例 #2
0
    }
    $playerfighters = $tempplayfighters;
    $targetfighters = $temptargfighters;
}
if ($targetfighters > 0) {
    if ($targetfighters > $playerarmor) {
        $playerarmor = 0;
        echo $l_sf_armorbreach . "<br>";
    } else {
        $playerarmor = $playerarmor - $targetfighters;
        $l_sf_armorbreach2 = str_replace("[lost]", $targetfighters, $l_sf_armorbreach2);
        echo $l_sf_armorbreach2 . "<br>";
    }
}
$fighterslost = $total_sector_fighters - $targetfighters;
destroy_fighters($db, $sector, $fighterslost);
$l_sf_sendlog = str_replace("[player]", $playerinfo['character_name'], $l_sf_sendlog);
$l_sf_sendlog = str_replace("[lost]", $fighterslost, $l_sf_sendlog);
$l_sf_sendlog = str_replace("[sector]", $sector, $l_sf_sendlog);
message_defence_owner($db, $sector, $l_sf_sendlog);
playerlog($db, $playerinfo['ship_id'], LOG_DEFS_DESTROYED_F, "{$fighterslost}|{$sector}");
$armor_lost = $playerinfo['armor_pts'] - $playerarmor;
$fighters_lost = $playerinfo['ship_fighters'] - $playerfighters;
$energy = $playerinfo['ship_energy'];
$update4b = $db->Execute("UPDATE {$db->prefix}ships SET ship_energy={$energy},ship_fighters=ship_fighters-{$fighters_lost}, armor_pts=armor_pts-{$armor_lost}, torps=torps-{$playertorpnum} WHERE ship_id={$playerinfo['ship_id']}");
db_op_result($db, $update4b, __LINE__, __FILE__, $db_logging);
$l_sf_lreport = str_replace("[armor]", $armor_lost, $l_sf_lreport);
$l_sf_lreport = str_replace("[fighters]", $fighters_lost, $l_sf_lreport);
$l_sf_lreport = str_replace("[torps]", $playertorpnum, $l_sf_lreport);
echo $l_sf_lreport . "<br><br>";
if ($playerarmor < 1) {
コード例 #3
0
function furangeetosecdef()
{
  // **********************************
  // *** FURANGEE TO SECTOR DEFENCE ***
  // **********************************

  // *********************************
  // *** SETUP GENERAL VARIABLES  ****
  // *********************************
  global $playerinfo;
  global $shipinfo;
  global $targetlink;

  global $l_sf_sendlog;
  global $l_sf_sendlog2;
  global $l_chm_hehitminesinsector;
  global $l_chm_hewasdestroyedbyyourmines;

  global $furangeeisdead;
  global $db, $dbtables;

  // *********************************
  // *** CHECK FOR SECTOR DEFENCE ****
  // *********************************
  if ($targetlink>0)
  {
    $resultf = $db->Execute ("SELECT * FROM $dbtables[sector_defence] WHERE sector_id='$targetlink' and defence_type ='F' ORDER BY quantity DESC");
    $i = 0;
    $total_sector_fighters = 0;
    if($resultf > 0)
    {
      while(!$resultf->EOF)
      {
        $defences[$i] = $resultf->fields;
        $total_sector_fighters += $defences[$i]['quantity'];
        $i++;
        $resultf->MoveNext();
      }
    }
    $resultm = $db->Execute ("SELECT * FROM $dbtables[sector_defence] WHERE sector_id='$targetlink' and defence_type ='M'");
    $i = 0;
    $total_sector_mines = 0;
    if($resultm > 0)
    {
      while(!$resultm->EOF)
      {
        $defences[$i] = $resultm->fields;
        $total_sector_mines += $defences[$i]['quantity'];
        $i++;
        $resultm->MoveNext();
      }
    }
    if ($total_sector_fighters>0 || $total_sector_mines>0 || ($total_sector_fighters>0 && $total_sector_mines>0))
    //*** DEST LINK HAS DEFENCES SO LETS ATTACK THEM***
    {
      playerlog($playerinfo[player_id], LOG_RAW, "ATTACKING SECTOR DEFENCES $total_sector_fighters fighters and $total_sector_mines mines."); 
      // ************************************
      // *** LETS GATHER COMBAT VARIABLES ***
      // ************************************
      $targetfighters = $total_sector_fighters;
      $playerbeams = NUM_BEAMS($shipinfo[beams]);
      if($playerbeams>$shipinfo[ship_energy]) {
        $playerbeams=$shipinfo[ship_energy];
      }
      $shipinfo[ship_energy]=$shipinfo[ship_energy]-$playerbeams;
      $playershields = NUM_SHIELDS($shipinfo[shields]);
      if($playershields>$shipinfo[ship_energy]) {
        $playershields=$shipinfo[ship_energy];
      }
      $playertorpnum = round(mypw($level_factor,$shipinfo[torp_launchers]))*2;
      if($playertorpnum > $shipinfo[torps]) {
        $playertorpnum = $shipinfo[torps];
      }
      $playertorpdmg = $torp_dmg_rate*$playertorpnum;
      $playerarmour = $shipinfo[armour_pts];
      $playerfighters = $shipinfo[ship_fighters];
      $totalmines = $total_sector_mines;
      if ($totalmines>1) {
        $roll = rand(1,$totalmines);
      } else {
        $roll = 1;
      }
      $totalmines = $totalmines - $roll;
      $playerminedeflect = $shipinfo[ship_fighters]; // *** Furangee keep as many deflectors as fighters ***

      // *****************************
      // *** LETS DO SOME COMBAT ! ***
      // *****************************
      // *** BEAMS VS FIGHTERS ***
      if($targetfighters > 0 && $playerbeams > 0) {
        if($playerbeams > round($targetfighters / 2))
        {
          $temp = round($targetfighters/2);
          $targetfighters = $temp;
          $playerbeams = $playerbeams-$temp;
        } else {
          $targetfighters = $targetfighters-$playerbeams;
          $playerbeams = 0;
        }   
      }
      // *** TORPS VS FIGHTERS ***
      if($targetfighters > 0 && $playertorpdmg > 0) {
        if($playertorpdmg > round($targetfighters / 2)) {
          $temp=round($targetfighters/2);
          $targetfighters=$temp;
          $playertorpdmg=$playertorpdmg-$temp;
        } else {
          $targetfighters=$targetfighters-$playertorpdmg;
          $playertorpdmg=0;
        }
      }
      // *** FIGHTERS VS FIGHTERS ***
      if($playerfighters > 0 && $targetfighters > 0) {
       if($playerfighters > $targetfighters) {
         echo $l_sf_destfightall;
         $temptargfighters=0;
        } else {
          $temptargfighters=$targetfighters-$playerfighters;
        }
        if($targetfighters > $playerfighters) {
          $tempplayfighters=0;
        } else {
          $tempplayfighters=$playerfighters-$targetfighters;
        }     
        $playerfighters=$tempplayfighters;
        $targetfighters=$temptargfighters;
      }
      // *** OH NO THERE ARE STILL FIGHTERS **
      // *** ARMOUR VS FIGHTERS ***
      if($targetfighters > 0) {
        if($targetfighters > $playerarmour) {
          $playerarmour=0;
        } else {
          $playerarmour=$playerarmour-$targetfighters;
        } 
      }
      // *** GET RID OF THE SECTOR FIGHTERS THAT DIED ***
      $fighterslost = $total_sector_fighters - $targetfighters;
      destroy_fighters($targetlink,$fighterslost);

      // *** LETS LET DEFENCE OWNER KNOW WHAT HAPPENED *** 
      $l_sf_sendlog = str_replace("[player]", "Furangee $playerinfo[character_name]", $l_sf_sendlog);
      $l_sf_sendlog = str_replace("[lost]", $fighterslost, $l_sf_sendlog);
      $l_sf_sendlog = str_replace("[sector]", $targetlink, $l_sf_sendlog);
      message_defence_owner($targetlink,$l_sf_sendlog);

      // *** UPDATE FURANGEE AFTER COMBAT ***
      $armour_lost=$shipinfo[armour_pts]-$playerarmour;
      $fighters_lost=$shipinfo[ship_fighters]-$playerfighters;
      $energy=$shipinfo[ship_energy];
      $update1 = $db->Execute ("UPDATE $dbtables[ships] SET energy=$energy,fighters=fighters-$fighters_lost, armour_pts=armour_pts-$armour_lost, torps=torps-$playertorpnum WHERE player_id=$playerinfo[player_id] AND ship_id=$playerinfo[currentship]");

      // *** CHECK TO SEE IF FURANGEE IS DEAD ***
      if($playerarmour < 1) {
        $l_sf_sendlog2 = str_replace("[player]", "Furangee " . $playerinfo[character_name], $l_sf_sendlog2);
        $l_sf_sendlog2 = str_replace("[sector]", $targetlink, $l_sf_sendlog2);
        message_defence_owner($targetlink,$l_sf_sendlog2);
        cancel_bounty($playerinfo[player_id]);
        db_kill_player($playerinfo[player_id],$playerinfo[currentship]);
        $furangeeisdead = 1;
        return;
      }

      // *** OK FURANGEE MUST STILL BE ALIVE ***

      // *** NOW WE HIT THE MINES ***

      // *** LETS LOG THE FACT THAT WE HIT THE MINES ***
      $l_chm_hehitminesinsector = str_replace("[chm_playerinfo_character_name]", "Furangee " . $playerinfo[character_name], $l_chm_hehitminesinsector);
      $l_chm_hehitminesinsector = str_replace("[chm_roll]", $roll, $l_chm_hehitminesinsector);
      $l_chm_hehitminesinsector = str_replace("[chm_sector]", $targetlink, $l_chm_hehitminesinsector);
      message_defence_owner($targetlink,"$l_chm_hehitminesinsector");

      // *** DEFLECTORS VS MINES ***
      if($playerminedeflect >= $roll) {
        // Took no mine damage due to virtual mine deflectors
      } else {
        $mines_left = $roll - $playerminedeflect;

        // *** SHIELDS VS MINES ***
        if($playershields >= $mines_left) {
          $update2 = $db->Execute("UPDATE $dbtables[ships] set energy=energy-$mines_left WHERE player_id=$playerinfo[player_id] AND ship_id=$playerinfo[currentship]");
        } else {
          $mines_left = $mines_left - $playershields;

          // *** ARMOUR VS MINES ***
          if($playerarmour >= $mines_left)
          {
            $update2 = $db->Execute("UPDATE $dbtables[ships] SET armour_pts=armour_pts-$mines_left,energy=0 WHERE player_id=$playerinfo[player_id] AND ship_id=$playerinfo[currentship]");
          } else {
            // *** OH NO WE DIED ***
            // *** LETS LOG THE FACT THAT WE DIED *** 
            $l_chm_hewasdestroyedbyyourmines = str_replace("[chm_playerinfo_character_name]", "Furangee " . $playerinfo[character_name], $l_chm_hewasdestroyedbyyourmines);
            $l_chm_hewasdestroyedbyyourmines = str_replace("[chm_sector]", $targetlink, $l_chm_hewasdestroyedbyyourmines);
            message_defence_owner($targetlink,"$l_chm_hewasdestroyedbyyourmines");
            // *** LETS ACTUALLY KILL THE FURANGEE NOW ***
            cancel_bounty($playerinfo[player_id]);
            db_kill_player($playerinfo[player_id],$playerinfo[currentship],0);
            $furangeeisdead = 1;
            // *** LETS GET RID OF THE MINES NOW AND RETURN OUT OF THIS FUNCTION ***
            explode_mines($targetlink,$roll);
            return;
          }
        }
      }
      // *** LETS GET RID OF THE MINES NOW ***
      explode_mines($targetlink,$roll);
    } else {
      //*** FOR SOME REASON THIS WAS CALLED WITHOUT ANY SECTOR DEFENCES TO ATTACK ***
      return;
    }
  }
}