Mys 1.3.4 Gender Ratio Mod for Mys v1.3.4

Forum
Last Post
Threads / Messages

Hall of Famer

Administrator
Staff member
Administrator
Joined
Dec 15, 2008
Messages
4,564
Points
48
Location
United States
Mysidian Dollar
214,223
Well since I've had some new users requesting this plugin, I decide that its necessary to make a Mys v1.3.4 compatible version of the Gender Ratio Mod. I've included an rar file at the end of this post for you to download the files, make sure to enter the directory /install and execute the file /install/genderratio.php so that the column genderratio will be inserted successfully into the database.

Incase you cannot use the default files I have provided for some reason, I am writing a simple guide for manual installation of this Mod. It is quite easy, and requires less script edits than the older version.


Anyway, to begin with, insert the column genderratio into your table prefix.adoptables. Its type is INT, default value should be 50:

PHP:
'genderratio', INT( 11 ), default 50
After this is done, go to your script file /admincp/view/adoptview.php, and find the following code:

PHP:
        $adoptForm->add($basicInfo);
        $adoptForm->add($shopSettings);
        $adoptForm->add($conditions);
        $adoptForm->add($miscellaneous);
        $adoptForm->add(new Button("Create this Adoptable", "submit", "submit"));
        $document->add($adoptForm);
Add above:(it actually does not matter if you mistakenly inserted these lines below instead, thats the beauty of OOP and GUI!)
PHP:
        $miscellaneous->add(new Comment("The Gender Ratio of your adoptable is ", FALSE));
        $miscellaneous->add(new TextField("genderratio", 50));
Before closing this file, find the sql insertion query for prefix.adoptables at:
PHP:
            $mysidia->db->insert("adoptables", array("id" =>  NULL, "type" => $mysidia->input->post("type"), "class" =>  $mysidia->input->post("class"), "description" =>  $mysidia->input->post("description"), "eggimage" => $eggimage,  "whenisavail" => $mysidia->input->post("cba"),
                                                     "alternates" =>  $mysidia->input->post("alternates"), "altoutlevel" =>  $mysidia->input->post("altoutlevel"), "altchance" =>  $mysidia->input->post("altchance"), "shop" =>  $mysidia->input->post("shop"), "cost" =>  $mysidia->input->post("cost")));
Okay now go to admincp/adopt.php, and replace this chunk of code with:
PHP:
            $mysidia->db->insert("adoptables", array("id" =>  NULL, "type" => $mysidia->input->post("type"), "class" =>  $mysidia->input->post("class"), "description" =>  $mysidia->input->post("description"), "eggimage" => $eggimage,  "whenisavail" => $mysidia->input->post("cba"),
                                                     "alternates" =>  $mysidia->input->post("alternates"), "altoutlevel" =>  $mysidia->input->post("altoutlevel"), "altchance" =>  $mysidia->input->post("altchance"), "shop" =>  $mysidia->input->post("shop"), "cost" =>  $mysidia->input->post("cost"), "genderratio" =>  $mysidia->input->post("genderratio")));
You may now close this /admincp/adopt.php file. The very next thing to do is to open a file located at /classes/class_adoptable.php. First of all, find a list of properties for this class at:
PHP:
    protected $id;
    protected $type;
    protected $class;
    protected $description;
    protected $eggimage;
    protected $whenisavail;
    protected $alternates;
    protected $altoutlevel;
    protected $altchance;
    protected $shop;
    protected $cost;  
    protected $conditions;
    protected $levels;
Replace by:
PHP:
    protected $id;
    protected $type;
    protected $class;
    protected $description;
    protected $eggimage;
    protected $whenisavail;
    protected $alternates;
    protected $altoutlevel;
    protected $altchance;
    protected $shop;
    protected $cost;  
    protected $genderratio;
    protected $conditions;
    protected $levels;
Perfect, we only have one last thing to do before this is all completed. Find the gender determination code at:
PHP:
    public function getGender(){
        $genders = array('f', 'm');
        $rand = rand(0,1);
        return $genders[$rand];
    }
Replace by:
PHP:
    public function getGenderRatio(){
        return $this->genderratio;
    }
    
    public function getGender(){        
        $genderNumber = rand(0, 99);
        if($genderNumber < $this->genderratio) $gender = "f";
        else $gender = "m";
        return $gender;        
    }
The only difference between the Mys v1.3.3 and v1.3.4 version is that the adopt.php file in ACP is now split into two separate files. For this reason, you need to edit two files, not just one. Some users may have figured it out on their own, its a good thing.

This is a reusable method, which means that both adopt.php and breeding.php can make use of it without writing the same block of code twice. Another reason why OOP pwns.


So this marks the end of manual installation process, its a lot simpler than last time isnt it? Anyway I hope you enjoy the Mods I am making for the script, I've decided to work on a few more new plugins for the script in the next few days. Lemme know if you have any suggestions to make, please do lemme know.
 

Attachments

  • gender ratio mod v1.3.4.rar
    6.3 KB · Views: 25
I have a few questions :3

1) So does this allow for there to be, approximately, a 50% chance of a male or female to be produced? (I am not clear on it, I searched for previous ones of this Mod and finally found it in the 1.1.x section XD And i just wanna clarify)

2) (This is a general question) For the alternate images, is the first image generally a male one and, if you enable an alternate image, is the alternate generally a female one? Because on my site the males and females have different images and I don't want a male with a female image and vice versa XD

3) Will this addon use the alternate image system? (As stated above, by detecting if the image is supposed to be male or female, I dunno if I explained that right...) And then it, like, makes a female have the female image and male have the male image?

Thank you ^_^
 
@ Parayna:

1. Just enter the value 50 in gender ratio field whenever you are filling adoptable creation form, and you will get half-half chance for male and female.

2. Nope, the alternate images have nothing to do with this mod nor the gender system at this stage. In Mys v1.4.0 alternate images can be configured to be gender-specific, but for the current version it's not possible.

3. I think I sorta already answered this question above.
 
I installed this on my site. It works perfectly. The test pet was meant to be 100% female and it certainly happens as intended.

It requires the number to be set as 100. I assume a number lower than 50 means it has a higher chance of being male.
Seems to me that the number actually means "chances of being female"
 
Yup, the gender ratio number is chance of being female. So 100 = all female, 0 = all male, and 50 = half/half.
 
Apparently it doesn't work like that. I set 0 for an all male species and it comes out random gender still.

*Edit*
Apparently setting it to 100 isn't 100% for females either.

It used to work, at least for female only species.
Maybe something in the code is having trouble?
 
Last edited:
for those that have this mod running, this mod don't affect the adopts in the adopts shop so if you want to have it working on the adoptshops too, you must find in the /classes/class_stockadopt.php this:
PHP:
$genders = array('f', 'm');
	  $rand = rand(0,1);

and replace it with this:
PHP:
$genderNumber = rand(0, 99);
if($genderNumber < $this->genderratio) $gender = "f";
else $gender = "m";
in the $mysidia->db->insert change this:
PHP:
"gender" => $genders[$rand],
for this:
PHP:
"gender" =>  $gender,

Dont know if this is the correct way of doing it, but i have test it in my site and is working.

just in case... probably wont make to much of a change but add
PHP:
 Protected $genderratio;

down of
PHP:
public $owner;
in the same class_stockadopt.php
 
Need a little help... I tried adding the option of genderless like the code for 2.x.x, but i can't figure out... And i really need it for my site pokeponies(upgraded the site to the new version)...i think i have the idea... But cant make it work...
 
Hmm, could you get a link to the genderless code from that version? How genderless are we talking? Like... actually still a gender but not shown, or 'other' from birthday and entirely unable to breed? I'm not positive just how many errors (or not) such a thing might cause. x'D I've made my breeding entirely genderless and, for a while, had all pet genders hidden from view entirely, though still technically stored.
 
Last edited:
@ Parayna:

2. Nope, the alternate images have nothing to do with this mod nor the gender system at this stage. In Mys v1.4.0 alternate images can be configured to be gender-specific, but for the current version it's not possible.

Could you tell us how to do this?
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,119
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top