Ejemplo n.º 1
0
 public function process_xenobes()
 {
     global $db_prefix;
     $sql_manager = new manage_table();
     $ship_manager = new manage_ship();
     $chance_xenobe_does_somthing = 20;
     $count_xenobes = 0;
     $count_xenobes_sentinal = 0;
     $count_xenobes_sentinal_attacking = 0;
     $count_xenobes_roam = 0;
     $count_xenobes_roam_attacking = 0;
     $count_xenobes_roamandtrade = 0;
     $count_xenobes_roamandtrade_attacking = 0;
     $count_xenobes_roamandhunt = 0;
     $count_xenobes_roamandhunt_attacking = 0;
     $count_xenobes_roamandhunt_hunting = 0;
     /*First we want to lock the tables*/
     $tables_to_lock_array = array('xenobe', 'ships', 'sector_defence', 'player_logs', 'security_logs');
     $tables_to_read_array = array('zones', 'universe', 'links');
     if ($sql_manager->lock_table($tables_to_lock_array, $tables_to_read_array)) {
         /*Now the table is locked, we can have some fun with the xenobes*/
         echo "<b>SCHEDULE - XENOBE<b><br/>";
         /*Cycle through all the xenobes and do somthing with them*/
         $join_query = "SELECT * FROM " . $db_prefix . "ships JOIN " . $db_prefix . "xenobe WHERE email=xenobe_id and active='Y' and ship_destroyed='N' ORDER BY ship_id;";
         $xenobe_pilots = $sql_manager->process_query($join_query);
         if ($xenobe_pilots) {
             foreach ($xenobe_pilots as $row) {
                 /*Xenobe is alive at the beginning of this function*/
                 $xenobeisdead = 'N';
                 /*Refresh the Xenobe, but make it pay for its own upgrades out of the credits it has onboard!*/
                 $this->regenerate_xenobe($row['ship_id'], $xenobeisdead);
                 /*Do somthing with each Xenobe Pilot*/
                 $count_xenobes++;
                 if (mt_rand(1, 100) > $chance_xenobe_does_somthing) {
                     #############################################################################################
                     # ORDERS = 0 = SENTINAL																		#
                     #############################################################################################
                     if ($row['orders'] == 0) {
                         echo "<b>Sentinal<b><br/>";
                         $count_xenobes_sentinal++;
                         $target_found = $this->check_for_target($row['ship_id'], $row['sector'], $row['email']);
                         if ($target_found) {
                             /*Load target Data*/
                             $target_data = $sql_manager->playerinfo($target_found, "");
                             if ($row['aggression'] == 0) {
                                 /*Do nothing*/
                             } else {
                                 if ($row['aggression'] == 1) {
                                     if ($row['ship_fighters'] > $target_data['ship_fighters']) {
                                         /*Xenobe has more fighters then the target ship... launch an attack*/
                                         $count_xenobes_sentinal_attacking++;
                                         # 	LAUNCH ATTACK 	#
                                         echo $ship_manager->attack_target_ship($target_found, $row['ship_id']);
                                         $xenobeisdead = $sql_manager->check_player_alive($row['ship_id']);
                                         if ($xenobeisdead == 'Y') {
                                             /*Xenobe dead, skip to the next xenobe*/
                                             continue;
                                         }
                                     }
                                 } else {
                                     if ($row['aggression'] == 2) {
                                         /*Xenobe has decided the target shouldnt be alive, attacks without any care for its own ship*/
                                         $count_xenobes_sentinal_attacking++;
                                         # 	LAUNCH ATTACK 	#
                                         echo $ship_manager->attack_target_ship($target_found, $row['ship_id']);
                                         $xenobeisdead = $sql_manager->check_player_alive($row['ship_id']);
                                         if ($xenobeisdead == 'Y') {
                                             /*Xenobe dead, skip to the next xenobe*/
                                             continue;
                                         }
                                     }
                                 }
                             }
                         }
                     } else {
                         if ($row['orders'] == 1) {
                             echo "<b>Roam<b><br/>";
                             $this->move_xenobe($row['ship_id'], $row['aggression'], $row['turns']);
                             $count_xenobes_roam++;
                         } else {
                             if ($row['orders'] == 2) {
                                 echo "<b>Roam And Trade<b><br/>";
                                 $count_xenobes_roamandtrade++;
                             } else {
                                 if ($row['orders'] == 3) {
                                     echo "<b>Roam And Hunt<b><br/>";
                                     $count_xenobes_roamandhunt++;
                                 }
                             }
                         }
                     }
                     #############################################################################################
                     # END ORDERS																				#
                     #############################################################################################
                 }
             }
         } else {
             /*No Xenobes Found, they're either all dead or somthing has gone wrong!*/
         }
     } else {
         /*Somthing went wrong*/
         echo "boo boo";
     }
     /*Now unlock the tables*/
     $sql_manager = new manage_table();
     if ($sql_manager->unlock_table()) {
         /*Now we have finished, unlock the tables.*/
         echo "<b>Unlocked</b><br/>";
     } else {
         /*Somthing went wrong*/
         echo "bo bo version 2";
     }
 }
Ejemplo n.º 2
0
if (checklogin()) {
    die;
}
$sql_manager = new manage_table();
$ship_manager = new manage_ship();
$player_manager = new manage_player();
$title = $l_att_title;
include "header.php";
?>
<div class="tablecell content both-border">
	<div class="pad">
<?php 
bigtitle();
// Kami Multi Browser Window Attack Fix
if (array_key_exists('ship_selected', $_SESSION) == false || $_SESSION['ship_selected'] != $ship_id) {
    echo "You need to Click on the ship first.<BR><BR>";
    TEXT_GOTOMAIN();
    ?>
    </div></div>
    <?php 
    include "footer.php";
    die;
}
unset($_SESSION['ship_selected']);
//$target_data = $sql_manager->playerinfo($victim_id,"");
echo $ship_manager->attack_target_ship($ship_id, $user_ship_id);
TEXT_GOTOMAIN();
?>
</div></div>
<?php 
include "footer.php";