Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Mys v1.3.x Mods (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=42)
-   -   Mys v1.3.4 Gender Ratio Mod for Mys v1.3.4 (http://www.mysidiaadoptables.com/forum/showthread.php?t=4361)

Hall of Famer 01-25-2014 10:07 AM

Gender Ratio Mod for Mys v1.3.4
 
1 Attachment(s)
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 Code:

'genderratio'INT11 ), default 50 

After this is done, go to your script file /admincp/view/adoptview.php, and find the following code:

PHP Code:

        $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 Code:

        $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 Code:

            $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 Code:

            $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 Code:

    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 Code:

    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 Code:

    public function getGender(){
        
$genders = array('f''m');
        
$rand rand(0,1);
        return 
$genders[$rand];
    } 

Replace by:
PHP Code:

    public function getGenderRatio(){
        return 
$this->genderratio;
    }
    
    public function 
getGender(){        
        
$genderNumber rand(099);
        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.

parayna 10-04-2014 03:29 PM

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 ^_^

Hall of Famer 10-05-2014 10:29 AM

@ 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.

parayna 10-05-2014 01:44 PM

Oh, OK! Thank you! ^_^ I might use this then :3

AndromedaKerova 11-20-2014 05:06 AM

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"

Hall of Famer 11-22-2014 01:09 AM

Yup, the gender ratio number is chance of being female. So 100 = all female, 0 = all male, and 50 = half/half.

AndromedaKerova 12-04-2014 12:23 PM

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?

kristhasirah 04-22-2015 12:17 PM

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 Code:

$genders = array('f''m');
      
$rand rand(0,1); 

and replace it with this:
PHP Code:

$genderNumber rand(099);
if(
$genderNumber $this->genderratio$gender "f";
else 
$gender "m"

in the $mysidia->db->insert change this:
PHP Code:

"gender" => $genders[$rand], 

for this:
PHP Code:

"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 Code:

 Protected $genderratio

down of
PHP Code:

public $owner

in the same class_stockadopt.php

kristhasirah 05-01-2015 10:57 PM

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...

Kyttias 05-01-2015 11:45 PM

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.


All times are GMT -5. The time now is 12:59 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.