Item function to turn an adopt into another species?

Forum
Last Post
Threads / Messages

tahbikat

Member
Member
Joined
Feb 11, 2014
Messages
408
Points
16
Age
30
Location
Louisiana
Mysidian Dollar
32,360
Just wondering if anyone's done this yet? I'm going to be looking into it in the coming days.

Essentially, you'd use a consumable item that would change one species into a completely different species that you've set for that item. This item can only work for species you've enabled it to work on. It would only be changing the adopt's "type" column.
 
Shouldn't be too difficult, to be honest. I'd imagine something like this in functions_items.php...just replace where I have "speciesA" and "speciesAname".

PHP:
function items_speciesA($item, $adopt){
  $mysidia = Registry::get("mysidia");
  $mysidia->db->update("owned_adoptables", array("type" => 'speciesAname'), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
  $note = "The item has been successfully used on your adoptable, it is now a {$adopt->type}!<br>";
  //Update item quantity...
  $delitem = $item->remove(); 
  return $note;
}

Then going off of what Kyttias did for the gender mod, just go into your items_functions table, copy level1 function, change ID to latest ID, change the item name to be the exact of where I put "speciesA". Then inside of class/class_privateitem.php;
PHP:
case "Species A":
            $message = items_speciesA($this, $owned_adoptable);
            break;
 
Last edited:
Thanks for this!!! Works brilliantly! Is there any chance this could be made into a random opportunity to make it into any pet? Like, random pet change? >.>
 
You could do some things to manually add pets, use a rand function to assign each pet as a number. You'll just have to manually add in all of the pet types that you want to be possible from it. I haven't tested it, but I think it'd be something like this. Then just change "speciesA" (etc) to a specific pet type (make sure it is word for word, case and all). Should work, I think, but as I said I haven't tested it, so use at your own risk.
PHP:
function items_albino($item, $adopt){
  $mysidia = Registry::get("mysidia");
  $random = rand(1,9); 
					if($random >= 1 && $random <= 3){
					$newtype = ('speciesA');
					}
					elseif($random >= 4 && $random <= 6){
					$newtype = ('speciesB');
					}
					elseif($random >= 7 && $random <= 9){
					$newtype = ('speciesC');
					}
  $mysidia->db->update("owned_adoptables", array("type" => '{$newtype}'), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
  $note = "The {$item->itemname} has been successfully used on your pet, it is now an {$adopt->type}!<br>";
  //Update item quantity...
  $delitem = $item->remove(); 
  return $note;
}

You could make this challenging for your users by making more common pets have greater probability and less common pets have a lower probability :)
 
Last edited:
THANK YOU THANK YOU THANK YOU!!!!

I did have to tweak it a little bit and I'm really surprised I got it working. x.x I'm horrible with PHP (Inexperienced and dyslexic), but for those who want this for their site, this is the code that worked for me. Don't forget to replace my pet types with your own!

PHP:
function items_random($item, $adopt){
  $mysidia = Registry::get("mysidia");
  $random = rand(1,9); 
                    if($random >= 1 && $random <= 3){
                    $newtype = ('Chestnut Unicorn');
                    }
                    elseif($random >= 4 && $random <= 6){
                    $newtype = ('Sienna Kirin');
                    }
                    elseif($random >= 7 && $random <= 9){
                    $newtype = ('Piebald Kirin');
                    }
  $mysidia->db->update("owned_adoptables", array("type" => $newtype), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
  $note = "The {$item->itemname} has been successfully used on your pet, it is now an {$newtype}!<br>";
  //Update item quantity...
  $delitem = $item->remove(); 
  return $note;
}
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

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

Latest Threads

Latest Posts

Top