Example #1
0
 /**
  * Creates an list a loot in `loots` for a player/party.
  * The chance is in calculated from 1 to 10000. So 1 = 0.01%, 100 = 1%, etc
  *
  * @todo if there is a party. Then the quest items have to drop for every character who has the quest.
  *
  * @param int $mob_id The ID of the killed mob
  * @param int $area_id The ID where the loot took place
  * @param int $character_id The ID of the character
  * @param int $party_id @todo the ID of the party group.
  * @return void
  */
 function createLootFromMob($mob_id = null, $area_id = 0, $character_id = 0, $party_id = 0)
 {
     if (!isset($mob_id) || empty($mob_id)) {
         return;
     }
     App::import('Model', 'Mob');
     $Mob = new Mob();
     $Mob->contain('Item');
     $someMob = $this->Mob->find('first', array('conditions' => array('Mob.id' => $mob_id)));
     if (empty($Mob)) {
         return;
     }
     $itemsLoot = array();
     foreach ($someMob['Item'] as $item) {
         // As the chance is higher then 100% (>10000) we have to decrease this number
         // by the factor of 10000 and will the factor number will be dropped. For example:
         // If a item has 250% (25000) chance to drop. You will have 50% chance for 2 of that item
         // and 50% of 3 of that item.
         if ($item['ItemsMob']['chance'] > 10000) {
             for ($i = $item['ItemsMob']['chance']; $i > 10000; $i -= 10000) {
                 $itemsLoot[] = array('party_id' => $party_id, 'character_id' => $character_id, 'item_id' => $item['id'], 'area_id' => $area_id, 'mob_id' => $mob_id);
             }
             $item['ItemsMob']['chance'] = $i;
         }
         // Let's roll if this item is dropped.
         // For example: $chance is 25% chance. so if($chance <= rand(1,10000)) { drop(); }
         if ($item['ItemsMob']['chance'] <= rand(1, 10000)) {
             $itemsLoot[] = array('party_id' => $party_id, 'character_id' => $character_id, 'item_id' => $item['id'], 'area_id' => $area_id, 'mob_id' => $mob_id);
         }
     }
     $this->saveAll($itemsLoot);
     return;
 }
Example #2
0
                         }
                         $mobs = Mob::Lister();
                         $_SESSION["sim_combat_aventuriers"] = serialize($aventuriers);
                         include "view/simulation_combat_mobs_selection.php";
                     } else {
                         if ($_GET["action"] == "creation_simulation_combat") {
                             $armes = Arme::Lister();
                             $equipements = Equipement::Lister();
                             $protections = Protection::Lister();
                             $compte = 0;
                             $mobs = array();
                             foreach ($_POST as $key => $value) {
                                 if (substr($key, 0, 3) == "mob") {
                                     for ($a = 0; $a < $value; $a++) {
                                         $id = substr($key, 3);
                                         $mob = new Mob($id);
                                         $mob->getLoot();
                                         $mobs[] = $mob;
                                     }
                                 }
                             }
                             $_SESSION["sim_combat_mobs"] = serialize($mobs);
                             $aventuriers = unserialize($_SESSION["sim_combat_aventuriers"]);
                             include "view/simulation_combat.php";
                         }
                     }
                 }
             }
         }
     }
 }
Example #3
0
<?php
if (!isset($_SESSION)) {
	session_start();
}
if (!isset($_SESSION["name"]) || !isset($_SESSION["pw"]) || !isset($_SESSION["level"])) {
	header("Location: index.php");
	exit;
}
include("lib.php");
$query = "select attack, defence, critical, avoid from game_status where name=\"".$_SESSION["name"]."\" and level=".$_SESSION["level"];
$level = (int)$_SESSION["level"];
$mob = new Mob($level);
echo("HP : ".$mob->get_hp()."<br />Defence : ".$mob->get_defen()."<br />Attack : ".$mob->get_attk());
// Battle code.
unset($mob);
?>