Hall of Famer
09-10-2011, 01:00 AM
Well its been a long time since the old evolution script for Mys v1.1 was designed. I eventually decided to make a new one, which has its codes completely rewritten compared to the old program. I've included an installer in order to make you guys/gals lives easier, it is also more flexible for admins to manage evolution lines through ACP.
So what are the differences between Evolution Mod v1.2 and the old script released for Mys v1.1:
1. The entire script is redesigned, with much more advanced PHP codes that I'd hardly recommend to absolute beginners. Of course, it optimizes site performance to a certain extent. Installation becomes much easier for Evolution system, as it was indeed a pain back in the old days.
2. The new script introduces a concept called Evolution Line, it can be rather useful for long series evolution line and multi-evolution outcome branches in future. Also adoptables can have a certain percentage of chance to evolve or not even when their evolution conditions are all met. Apparently the admins decide the difficulty for evolution to occur.
3. The old script inserts many columns into table prefix.adoptables and prefix.owned_adoptables, which causes fatal errors while upgrading Mys and incompatibility issues with other scripts. Evolution Mod v1.2, on the other hand, creates a new table and does not interfere with any existing tables. Incompatibility with other Mods should not be a problem this time.
4. The new script introduces different approaches of evolution system, compared to merely level-based evolution. The trade-based evolution will be made available soon, and item-based evolution will also become possible once Mys v1.3.0 is released to public. There is even possibility for Trade - Item evolution integration, and time-based evolution if you dont mind using Cronjobs.
5. Powerful Admin Control Panel for Evolution system. Admins can create, edit and delete an evolution line at will, the product itself can be turned off and on(simply enable/disable the plugin through ACP or PHPmyadmin). I've also provided a section called FAQs for users to read as manual, they should pretty much explain what you can do with Evolution Mod V1.2.
Alright, let us begin. First of all you need to add the following three functions to your inc/functions.php file. They can be placed anywhere, and Id recommend the very end of your script file:
function pluginenabled($plug) {
$query = "SELECT * FROM {$GLOBALS['prefix']}acp_hooks WHERE pluginname='{$plug}'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
switch($row['pluginstatus']){
case "1":
$plugin = "enabled";
break;
default:
$plugin = "disabled";
}
return $plugin;
}
function checkevolution($adopt, $level, $item, $trade, $gender){
$query = "SELECT * FROM {$GLOBALS['prefix']}adoptables_evolution WHERE preevoform='{$adopt}'";
$result = runquery($query);
$row = mysql_fetch_array($result);
$randnum = mt_rand(0,99);
switch($row['evotype']){
case "level":
$canevolve = ($level >= $row['requiredlevel'] and $row['evochance'] > $randnum)?yes:no;
break;
case "item":
$canevolve = ($item == $row['requireditem'] and $row['evochance'] > $randnum)?yes:no;
break;
case "trade":
$canevolve = ($trade == "true" and $row['evochance'] > $randnum)?yes:no;
break;
default:
$canevolve = "no";
}
// Check the gender restriction setting
if($row['requiredgender'] != "no" and $row['requiredgender'] != $gender){
$canevolve = "no";
}
return $canevolve;
}
function execevolution($id, $adopt){
$result = runquery("SELECT * FROM {$GLOBALS['prefix']}adoptables_evolution WHERE preevoform='{$adopt}'");
$row = mysql_fetch_array($result);
$result2 = runquery("SELECT * FROM {$GLOBALS['prefix']}owned_adoptables WHERE aid='{$id}'");
$row2 = mysql_fetch_array($result2);
// Update adoptables type to the evolution form
if($row2['type'] == $row2['name']){
runquery("UPDATE {$GLOBALS['prefix']}owned_adoptables SET name='{$row['postevoform']}' WHERE aid = '{$id}'");
}
runquery("UPDATE {$GLOBALS['prefix']}owned_adoptables SET type='{$row['postevoform']}' WHERE aid = '{$id}'");
$message = "Congratulations! Your {$adopt} has successfully evolved into {$row['postevoform']}.";
return $message;
}
?>
The next thing to do is to modify the level increment engine a little bit. Find the following line in your levelup.php:
runquery("UPDATE {$prefix}owned_adoptables SET currentlevel='{$nextlevel}' WHERE aid='{$id}'");
Add below:
if(pluginenabled("Evolution Mod v1.2 by Hall of Famer") == "enabled"){
$item = "";
$trade = "false";
switch(checkevolution($owned_adoptable['type'], $nextlevel, $item, $trade ,$owned_adoptable['gender'])){
case "yes":
// Evolution Checkpoint passed, the process shall begin!
$message = execevolution($owned_adoptable['aid'],$owned_adoptable['type']);
$evolution = "true";
break;
default:
$message = "evolution does not occur...";
$evolution = "false";
}
}
This should pretty much do the job already. If you want to notice your users of their adoptables evolution, you may add this line to levelup.php too. Place it somewhere around line 150-160:
if($evolution == "true"){
$article_content = $article_content . "<div align='center'><br />Congratulations! Your adoptable {$owned_adoptable['name']} has evolved.</div>";
}
For those of you interested in Trade based Evolution system, simply copy/paste the following codes below to your redeem.php at around line 225:
// Trade Evolution Script Here:
if(pluginenabled("Evolution Mod v1.2 by Hall of Famer") == "enabled"){
$item = "";
$trade = "true";
$result5 = runquery("SELECT * FROM {$prefix}owned_adoptables WHERE aid = '{$row['adoptabledesired']}'");
$adoptdesired = mysql_fetch_array($result5);
switch(checkevolution($adoptdesired['type'], $adoptdesired['currentlevel'], $item, $trade , $adoptdesired['gender'])){
case "yes":
// Evolution Checkpoint passed, the process shall begin!
$message = execevolution($adoptdesired['aid'],$adoptdesired['type']);
$evolution = "true";
break;
default:
$message = "evolution does not occur...";
$evolution = "false";
}
}
Similarly, the user can be notified of his/her adoptables evolution by adding the following lines to near the bottom of redeem.php:
if($evolution == "true"){
$article_content = $article_content . "<div align='center'><br />Congratulations! Your adoptable {$adoptdesired['name']} has evolved.</div>";
}
So we are done with script modification already, isnt it easy this time? Well you will still need to download the following two script files I've uploaded, and make sure to run install_evolution.php script so the new table prefix.adoptables_evolution will be added into your database. Now have fun everyone, I am a bit tired already since its 2AM...
Hall of Famer
So what are the differences between Evolution Mod v1.2 and the old script released for Mys v1.1:
1. The entire script is redesigned, with much more advanced PHP codes that I'd hardly recommend to absolute beginners. Of course, it optimizes site performance to a certain extent. Installation becomes much easier for Evolution system, as it was indeed a pain back in the old days.
2. The new script introduces a concept called Evolution Line, it can be rather useful for long series evolution line and multi-evolution outcome branches in future. Also adoptables can have a certain percentage of chance to evolve or not even when their evolution conditions are all met. Apparently the admins decide the difficulty for evolution to occur.
3. The old script inserts many columns into table prefix.adoptables and prefix.owned_adoptables, which causes fatal errors while upgrading Mys and incompatibility issues with other scripts. Evolution Mod v1.2, on the other hand, creates a new table and does not interfere with any existing tables. Incompatibility with other Mods should not be a problem this time.
4. The new script introduces different approaches of evolution system, compared to merely level-based evolution. The trade-based evolution will be made available soon, and item-based evolution will also become possible once Mys v1.3.0 is released to public. There is even possibility for Trade - Item evolution integration, and time-based evolution if you dont mind using Cronjobs.
5. Powerful Admin Control Panel for Evolution system. Admins can create, edit and delete an evolution line at will, the product itself can be turned off and on(simply enable/disable the plugin through ACP or PHPmyadmin). I've also provided a section called FAQs for users to read as manual, they should pretty much explain what you can do with Evolution Mod V1.2.
Alright, let us begin. First of all you need to add the following three functions to your inc/functions.php file. They can be placed anywhere, and Id recommend the very end of your script file:
function pluginenabled($plug) {
$query = "SELECT * FROM {$GLOBALS['prefix']}acp_hooks WHERE pluginname='{$plug}'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
switch($row['pluginstatus']){
case "1":
$plugin = "enabled";
break;
default:
$plugin = "disabled";
}
return $plugin;
}
function checkevolution($adopt, $level, $item, $trade, $gender){
$query = "SELECT * FROM {$GLOBALS['prefix']}adoptables_evolution WHERE preevoform='{$adopt}'";
$result = runquery($query);
$row = mysql_fetch_array($result);
$randnum = mt_rand(0,99);
switch($row['evotype']){
case "level":
$canevolve = ($level >= $row['requiredlevel'] and $row['evochance'] > $randnum)?yes:no;
break;
case "item":
$canevolve = ($item == $row['requireditem'] and $row['evochance'] > $randnum)?yes:no;
break;
case "trade":
$canevolve = ($trade == "true" and $row['evochance'] > $randnum)?yes:no;
break;
default:
$canevolve = "no";
}
// Check the gender restriction setting
if($row['requiredgender'] != "no" and $row['requiredgender'] != $gender){
$canevolve = "no";
}
return $canevolve;
}
function execevolution($id, $adopt){
$result = runquery("SELECT * FROM {$GLOBALS['prefix']}adoptables_evolution WHERE preevoform='{$adopt}'");
$row = mysql_fetch_array($result);
$result2 = runquery("SELECT * FROM {$GLOBALS['prefix']}owned_adoptables WHERE aid='{$id}'");
$row2 = mysql_fetch_array($result2);
// Update adoptables type to the evolution form
if($row2['type'] == $row2['name']){
runquery("UPDATE {$GLOBALS['prefix']}owned_adoptables SET name='{$row['postevoform']}' WHERE aid = '{$id}'");
}
runquery("UPDATE {$GLOBALS['prefix']}owned_adoptables SET type='{$row['postevoform']}' WHERE aid = '{$id}'");
$message = "Congratulations! Your {$adopt} has successfully evolved into {$row['postevoform']}.";
return $message;
}
?>
The next thing to do is to modify the level increment engine a little bit. Find the following line in your levelup.php:
runquery("UPDATE {$prefix}owned_adoptables SET currentlevel='{$nextlevel}' WHERE aid='{$id}'");
Add below:
if(pluginenabled("Evolution Mod v1.2 by Hall of Famer") == "enabled"){
$item = "";
$trade = "false";
switch(checkevolution($owned_adoptable['type'], $nextlevel, $item, $trade ,$owned_adoptable['gender'])){
case "yes":
// Evolution Checkpoint passed, the process shall begin!
$message = execevolution($owned_adoptable['aid'],$owned_adoptable['type']);
$evolution = "true";
break;
default:
$message = "evolution does not occur...";
$evolution = "false";
}
}
This should pretty much do the job already. If you want to notice your users of their adoptables evolution, you may add this line to levelup.php too. Place it somewhere around line 150-160:
if($evolution == "true"){
$article_content = $article_content . "<div align='center'><br />Congratulations! Your adoptable {$owned_adoptable['name']} has evolved.</div>";
}
For those of you interested in Trade based Evolution system, simply copy/paste the following codes below to your redeem.php at around line 225:
// Trade Evolution Script Here:
if(pluginenabled("Evolution Mod v1.2 by Hall of Famer") == "enabled"){
$item = "";
$trade = "true";
$result5 = runquery("SELECT * FROM {$prefix}owned_adoptables WHERE aid = '{$row['adoptabledesired']}'");
$adoptdesired = mysql_fetch_array($result5);
switch(checkevolution($adoptdesired['type'], $adoptdesired['currentlevel'], $item, $trade , $adoptdesired['gender'])){
case "yes":
// Evolution Checkpoint passed, the process shall begin!
$message = execevolution($adoptdesired['aid'],$adoptdesired['type']);
$evolution = "true";
break;
default:
$message = "evolution does not occur...";
$evolution = "false";
}
}
Similarly, the user can be notified of his/her adoptables evolution by adding the following lines to near the bottom of redeem.php:
if($evolution == "true"){
$article_content = $article_content . "<div align='center'><br />Congratulations! Your adoptable {$adoptdesired['name']} has evolved.</div>";
}
So we are done with script modification already, isnt it easy this time? Well you will still need to download the following two script files I've uploaded, and make sure to run install_evolution.php script so the new table prefix.adoptables_evolution will be added into your database. Now have fun everyone, I am a bit tired already since its 2AM...
Hall of Famer