View Single Post
  #5  
Old 04-24-2012, 07:48 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 397,572
Hall of Famer is on a distinguished road
Default

I think this question was asked before when breeding first became available for Mys v1.2.0. The trick is here from breeding.php:

PHP Code:
        else {
            
// we choose the type!
            
$types = array($female->type$male->type);
            
$typerand rand(0,1);        
            
            
// we choose the gender
            
$genders = array('f''m');
            
$genderrand rand(0,1);                
            
$code codegen(100);

            
// MESSY - I'm blanking out on how to find the actual alt status stuff right now, any help would be lovely.
            
$alts getaltstatus($female_species->id00);

            
$time time();
            
$adopts->insert("owned_adoptables", array("aid" => NULL"type" => $types[$typerand], "name" => $types[$typerand], "owner" => $loggedinname"currentlevel" => 0"totalclicks" => 0"code" => $code
                            
"imageurl" => NULL"usealternates" => $alts"tradestatus" => 'fortrade'"isfrozen" => 'no'"gender" => $genders[$genderrand], "lastbred" => 0));
                        
            
$article_content "Congratulations! Breeding is successful, you have acquired a baby {$types[$typerand]} from breeding center.
            <br><a href='myadopts.php'>Manage your new 
{$types[$typerand]} now!</a></p>";

            
$adopts->update("owned_adoptables", array("lastbred" => $time), "aid = '{$femaleid}'");
            
$adopts->update("owned_adoptables", array("lastbred" => $time), "aid = '{$maleid}'");
        
        } 
// we end the place where it goes on if the levels are ok 
Assume the number of babies is a random variable ranging from 1 to 5, you can do the following:

PHP Code:
      else {
        
$num mt_rand(15);
        for(
$i 0;$i<$num;$i++){
            
// we choose the type!
            
$types = array($female->type$male->type);
            
$typerand rand(0,1);        
            
            
// we choose the gender
            
$genders = array('f''m');
            
$genderrand rand(0,1);                
            
$code codegen(100);

            
// MESSY - I'm blanking out on how to find the actual alt status stuff right now, any help would be lovely.
            
$alts getaltstatus($female_species->id00);

            
$time time();
            
$adopts->insert("owned_adoptables", array("aid" =>  NULL"type" => $types[$typerand], "name" => $types[$typerand],  "owner" => $loggedinname"currentlevel" => 0"totalclicks" =>  0"code" => $code
                            
"imageurl" => NULL"usealternates" =>  $alts"tradestatus" => 'fortrade'"isfrozen" => 'no'"gender"  => $genders[$genderrand], "lastbred" => 0));
                        
        } 
// the end of for loop
            
$article_content "Congratulations! Breeding is successful,  your pets have produced {$num} babies from breeding!";
            
$adopts->update("owned_adoptables", array("lastbred" => $time), "aid = '{$femaleid}'");
            
$adopts->update("owned_adoptables", array("lastbred" => $time), "aid = '{$maleid}'");
      } 
// we end the place where it goes on if the levels are ok 
This way the script will randomly produce 1-5 babies depending on what you get from the random number generator. You can easily make it to whatever number it can go up to. You can also do database integration by creating a new field in table prefix.adoptables that stores the number of babies a specific species can produce. It can get quite tricky for interspecies breeding though, so I do not recommend it at this moment.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote