Hall of Famer
11-28-2010, 06:53 AM
Well before we get this started, I am noticing you that this is based on Pokemon's HP system. You will have to modify the formula or even redefine the variables used in your formula to create a custom HP system of your own interest. Here I will begin:
Before getting started, we will need to set up the new structure of the 'adoptables' and 'owned_adoptables' tables. In my pokemon HP system, the following column is needed in 'adoptables' table and another three are required for 'owned_adoptables' table. You can do it pretty much easily in phpmyadmin:
in table 'adoptables', add:
'basehitpoints', INT( 11 )
in table 'owned_adoptables', add:
'individualvalue', INT( 11 )
'maxhp', INT( 11 ), DEFAULT '10'
'basehp', INT( 11 )
Alright, we are done with the database structure. The next thing to do is to add this definition of base hp to admincp.
In admin.php, find:
<hr>
<p><strong>Alternate Outcomes Settings:</strong></p>
<p>This section allows you to set if you want to enable alternate outcomes. This setting allows you to specify what the chances are of a user getting an alternate or special version of this adoptable. Check the checkbox below to enable this feature and then fill out the information below.. </p>
<p><strong>
<input name='alternates' type='checkbox' id='alternates' value='enabled'>
</strong>Enable Alternate Outcomes </p>
<p>Alternate Outcomes Selection Information:</p>
<p>Start using the alternate outcome at level number:
<input name='altoutlevel' type='text' id='altoutlevel' size='6' maxlength='6'>
<br>
(Use Level 0 to have the alternate outcome be used from birth. This will not affect the first / egg image.) </p>
<p>The alternate outcome has a chance of 1 in
<input name='altchance' type='text' id='altchance' size='6' maxlength='6'>
of being selected.<br>
(Here you can select the chance that the alternate images for this adoptable are used. So, for an equal chance of using say male or female images, put 2 in the box to have a 1 out of 2 or 50% chance of using the alternate image. If you want to have the alternate images be rare images, use a higher number, like 100 for a 1 out of 100 chance of using the alternates.)</p>
<p>
Add after:
<p><strong>Stats Settings</strong></p>
<p>The Base HP of this Adoptable is
<input name='basehitpoints' type='text' id='basehitpoints' size='6' maxlength='6'>
<p>
<p>
This step is technically not required, but it makes your life easier if you wish to add adoptables through admin control panel instead of phpmyadmin. The next thing to do is to update nadopt.php so you will be able to successfully created this adoptable.
In nadopt.php, find:
$alternates = $_POST["alternates"];
$alternates = secure($alternates);
$altoutlevel = $_POST["altoutlevel"];
$altoutlevel = secure($altoutlevel);
$altchance = $_POST["altchance"];
$altchance = secure($altchance);
Add after:
$basehitpoints = $_POST["basehitpoints"];
$basehitpoints = secure($basehitpoints);
Then find the sql query(assume you have yet to add other columns to this 'adoptables table'):
mysql_query("INSERT INTO ".$prefix."adoptables VALUES ('', '$name', '$description','$eggimage','$cba','$promocode', '$freqcond', '$number','$datecond','$date','$adoptscond','$maxn umcond','$morethannum','$usergroupcond','$usergrou ps','$alternates','$altoutlevel','$altchance')");
Replace with:
mysql_query("INSERT INTO ".$prefix."adoptables VALUES ('', '$name', '$description','$eggimage','$cba','$promocode', '$freqcond', '$number','$datecond','$date','$adoptscond','$maxn umcond','$morethannum','$usergroupcond','$usergrou ps','$alternates','$altoutlevel','$altchance','$ba sehitpoints')");
So basically what we are doing here is to enable admins to create adoptables successfully by matching the number of columns in table 'adoptables'. If you are using Kaeliah's multialternative mods, your sql query will look quite different and all you have to do is to add ,'$basehitpoints' to the end of your codes. We are done with the definition of base HP, and its still rather important to convert this base HP to an adoptable's actual HP. You may wonder where the variable 'individualvalue' come from, and I will illustrate this point to you next.
In doadopt.php, find:
$name = $_GET["name"];
$name = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $name);
$name = secure($name);
Add below:
$basehitpoints = $_GET["basehitpoints"];
$basehitpoints = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $basehitpoints);
$basehitpoints = secure($basehitpoints);
Next, find:
$aid=@mysql_result($result,$i,"id"); //The adoptable's ID
$type=@mysql_result($result,$i,"type");
$description=@mysql_result($result,$i,"description");
$eggimage=@mysql_result($result,$i,"eggimage");
Add below:
$basehitpoints=@mysql_result($result,$i,"basehitpoints");
By doing this, we successfully add the reference of basehitpoints to each individual adoptable. The value 'basehitpoints' will be passed onto the database table 'owned_adoptables', since it is a variable in our HP formula. Another variable that determines an adoptable's HP is this 'individualvalue', a random variable between 0 and 31. To do this, find the following codes:
if($name == ""){
$name = $type;
}
Add below:
//This is what we do to determine a pet's individual value(IV) and base HP, which is simple
$individualvalue = rand(0, 31);
$basehp = $basehitpoints;
Before closing out your script file, you will still need to edit the sql query codes. Assume you havent added any other columns to your owned_adoptable table yet, find the following codes below:
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','notfortrade','no')");
Replace with:
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','notfortrade','no','$individualvalue',' 10', '$basehp')");
We are done with doadopt.php now, isnt this easy? By doing this, an adoptable's hp will be determined to be 10 once it is added to your party. Note I define the column 'basehp' in 'owned_adoptables' table so that it wont mess up with the corresponding column 'basehitpoints' in 'adoptables' table. However, the key point of this HP system is that its value is not a constant and thus varies with the following three variables:
Base HP
Individual Values
Levels
Therefore, its rather important to make sure that the adoptable's HP does receive a new value after its level increases. To do this, you will need to modify another script file.
In levelup.php, find:
$aid=@mysql_result($result,$i,"aid");
$type=@mysql_result($result,$i,"type");
$name=@mysql_result($result,$i,"name");
$totalclicks=@mysql_result($result,$i,"totalclicks");
$currentlevel=@mysql_result($result,$i,"currentlevel");
$usealternates=@mysql_result($result,$i,"usealternates");
$isfrozen=@mysql_result($result,$i,"isfrozen");
$owner=@mysql_result($result,$i,"owner");
Replace with:
$aid=@mysql_result($result,$i,"aid");
$type=@mysql_result($result,$i,"type");
$name=@mysql_result($result,$i,"name");
$totalclicks=@mysql_result($result,$i,"totalclicks");
$currentlevel=@mysql_result($result,$i,"currentlevel");
$usealternates=@mysql_result($result,$i,"usealternates");
$isfrozen=@mysql_result($result,$i,"isfrozen");
$owner=@mysql_result($result,$i,"owner");
$individualvalue=@mysql_result($result,$i,"individualvalue");
$maxhp=@mysql_result($result,$i,"maxhp");
$basehp=@mysql_result($result,$i,"basehp");
Here comes the fun, you will need to find the codes below which updates a pet's level when its totalclicks matches requiredclicks:
// We need to level this adoptable up...
$query = "UPDATE ".$prefix."owned_adoptables SET currentlevel='".$nextlevel."' WHERE aid='".$id."'";
mysql_query($query);
Add after:
// We need to update this adoptable's maximum HP...
$newhp = (($individualvalue + 2*$basehp + 100)*$nextlevel)/100 + 10;
$query = "UPDATE ".$prefix."owned_adoptables SET maxhp='".$newhp."' WHERE aid='".$id."'";
mysql_query($query);
By doing this, we define the adoptable's new HP after its level increases by 1. Note the formula is used for pokemon HP system, you can modify it to wahtever you like for your own adoptable site. Make sure the variables you will need may not be the same with Pokemon system. We are almost done now, there's one last thing to do before heading to bed. You may want to display your pet's HP when looking at its stats.
If this is what you want, then go to myadopts.php and find the following lines:
$aid=@mysql_result($result,$i,"aid"); //The adoptable's ID
$currentlevel=@mysql_result($result,$i,"currentlevel");
$type=@mysql_result($result,$i,"type");
$name=@mysql_result($result,$i,"name");
$totalclicks=@mysql_result($result,$i,"totalclicks");
Add after:
$maxhp=@mysql_result($result,$i,"maxhp");
The very last thing to do is quite simple, find:
$article_title = $name."'s Statistics:";
$article_content = "<img src='".$image."'><br><br>
<b>Total Clicks: ".$totalclicks."<br>
Current Level: ".$currentlevel."<br>
Next Level: ".$nloutput."<br></b>";
Replace with:
$article_title = $name."'s Statistics:";
$article_content = "<img src='".$image."'><br><br>
<b>Total Clicks: ".$totalclicks."<br>
HP: ".$maxhp."<br>
Current Level: ".$currentlevel."<br>
Next Level: ".$nloutput."<br></b>";
You are all set now, cheers. If done correctly, you should get a similar stats page for your adoptables as the screenshot provided below. Keep in mind that I have Arianna's gender mod added to my script file, so it may not appear to be the same with yours:
http://oi51.tinypic.com/2z5uexw.jpg
This HP system may look quite useless at this point, unless a battle system is made. But anyway, this is the first step to create a complicated battle system. You can use my HP system directly if you run a Pokemon site, but if not, please do at least modify the formula so that it works out for your site. Note the variable 'individualvalue' is designed for Pokemon games only, and you may need a different set of variables in your HP formula. If you are using Kaeliah's status system, you may wish to create another column called 'currenthp' for your adoptables. The pet's current HP value may be set to be exactly the same as max HP but it may decreases if your pet's sick. If you have an itemshop system, you may even be able to create medicines/potions used to heal your pets. So yeah, this HP system can be easily integrated with other addons we currently have here.
For me, I will create other stats such as attack, defense for adoptables next, and maybe I should create a new table 'stats' to store each individual pet's stats if too many columns make the table 'owned_adoptables' look messy. My thanksgiving break will end soon so I wont be quite active since the end of the week, but I will continue to learn and write codes whenever I can. Thanks for support, everyone.
Before getting started, we will need to set up the new structure of the 'adoptables' and 'owned_adoptables' tables. In my pokemon HP system, the following column is needed in 'adoptables' table and another three are required for 'owned_adoptables' table. You can do it pretty much easily in phpmyadmin:
in table 'adoptables', add:
'basehitpoints', INT( 11 )
in table 'owned_adoptables', add:
'individualvalue', INT( 11 )
'maxhp', INT( 11 ), DEFAULT '10'
'basehp', INT( 11 )
Alright, we are done with the database structure. The next thing to do is to add this definition of base hp to admincp.
In admin.php, find:
<hr>
<p><strong>Alternate Outcomes Settings:</strong></p>
<p>This section allows you to set if you want to enable alternate outcomes. This setting allows you to specify what the chances are of a user getting an alternate or special version of this adoptable. Check the checkbox below to enable this feature and then fill out the information below.. </p>
<p><strong>
<input name='alternates' type='checkbox' id='alternates' value='enabled'>
</strong>Enable Alternate Outcomes </p>
<p>Alternate Outcomes Selection Information:</p>
<p>Start using the alternate outcome at level number:
<input name='altoutlevel' type='text' id='altoutlevel' size='6' maxlength='6'>
<br>
(Use Level 0 to have the alternate outcome be used from birth. This will not affect the first / egg image.) </p>
<p>The alternate outcome has a chance of 1 in
<input name='altchance' type='text' id='altchance' size='6' maxlength='6'>
of being selected.<br>
(Here you can select the chance that the alternate images for this adoptable are used. So, for an equal chance of using say male or female images, put 2 in the box to have a 1 out of 2 or 50% chance of using the alternate image. If you want to have the alternate images be rare images, use a higher number, like 100 for a 1 out of 100 chance of using the alternates.)</p>
<p>
Add after:
<p><strong>Stats Settings</strong></p>
<p>The Base HP of this Adoptable is
<input name='basehitpoints' type='text' id='basehitpoints' size='6' maxlength='6'>
<p>
<p>
This step is technically not required, but it makes your life easier if you wish to add adoptables through admin control panel instead of phpmyadmin. The next thing to do is to update nadopt.php so you will be able to successfully created this adoptable.
In nadopt.php, find:
$alternates = $_POST["alternates"];
$alternates = secure($alternates);
$altoutlevel = $_POST["altoutlevel"];
$altoutlevel = secure($altoutlevel);
$altchance = $_POST["altchance"];
$altchance = secure($altchance);
Add after:
$basehitpoints = $_POST["basehitpoints"];
$basehitpoints = secure($basehitpoints);
Then find the sql query(assume you have yet to add other columns to this 'adoptables table'):
mysql_query("INSERT INTO ".$prefix."adoptables VALUES ('', '$name', '$description','$eggimage','$cba','$promocode', '$freqcond', '$number','$datecond','$date','$adoptscond','$maxn umcond','$morethannum','$usergroupcond','$usergrou ps','$alternates','$altoutlevel','$altchance')");
Replace with:
mysql_query("INSERT INTO ".$prefix."adoptables VALUES ('', '$name', '$description','$eggimage','$cba','$promocode', '$freqcond', '$number','$datecond','$date','$adoptscond','$maxn umcond','$morethannum','$usergroupcond','$usergrou ps','$alternates','$altoutlevel','$altchance','$ba sehitpoints')");
So basically what we are doing here is to enable admins to create adoptables successfully by matching the number of columns in table 'adoptables'. If you are using Kaeliah's multialternative mods, your sql query will look quite different and all you have to do is to add ,'$basehitpoints' to the end of your codes. We are done with the definition of base HP, and its still rather important to convert this base HP to an adoptable's actual HP. You may wonder where the variable 'individualvalue' come from, and I will illustrate this point to you next.
In doadopt.php, find:
$name = $_GET["name"];
$name = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $name);
$name = secure($name);
Add below:
$basehitpoints = $_GET["basehitpoints"];
$basehitpoints = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $basehitpoints);
$basehitpoints = secure($basehitpoints);
Next, find:
$aid=@mysql_result($result,$i,"id"); //The adoptable's ID
$type=@mysql_result($result,$i,"type");
$description=@mysql_result($result,$i,"description");
$eggimage=@mysql_result($result,$i,"eggimage");
Add below:
$basehitpoints=@mysql_result($result,$i,"basehitpoints");
By doing this, we successfully add the reference of basehitpoints to each individual adoptable. The value 'basehitpoints' will be passed onto the database table 'owned_adoptables', since it is a variable in our HP formula. Another variable that determines an adoptable's HP is this 'individualvalue', a random variable between 0 and 31. To do this, find the following codes:
if($name == ""){
$name = $type;
}
Add below:
//This is what we do to determine a pet's individual value(IV) and base HP, which is simple
$individualvalue = rand(0, 31);
$basehp = $basehitpoints;
Before closing out your script file, you will still need to edit the sql query codes. Assume you havent added any other columns to your owned_adoptable table yet, find the following codes below:
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','notfortrade','no')");
Replace with:
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','notfortrade','no','$individualvalue',' 10', '$basehp')");
We are done with doadopt.php now, isnt this easy? By doing this, an adoptable's hp will be determined to be 10 once it is added to your party. Note I define the column 'basehp' in 'owned_adoptables' table so that it wont mess up with the corresponding column 'basehitpoints' in 'adoptables' table. However, the key point of this HP system is that its value is not a constant and thus varies with the following three variables:
Base HP
Individual Values
Levels
Therefore, its rather important to make sure that the adoptable's HP does receive a new value after its level increases. To do this, you will need to modify another script file.
In levelup.php, find:
$aid=@mysql_result($result,$i,"aid");
$type=@mysql_result($result,$i,"type");
$name=@mysql_result($result,$i,"name");
$totalclicks=@mysql_result($result,$i,"totalclicks");
$currentlevel=@mysql_result($result,$i,"currentlevel");
$usealternates=@mysql_result($result,$i,"usealternates");
$isfrozen=@mysql_result($result,$i,"isfrozen");
$owner=@mysql_result($result,$i,"owner");
Replace with:
$aid=@mysql_result($result,$i,"aid");
$type=@mysql_result($result,$i,"type");
$name=@mysql_result($result,$i,"name");
$totalclicks=@mysql_result($result,$i,"totalclicks");
$currentlevel=@mysql_result($result,$i,"currentlevel");
$usealternates=@mysql_result($result,$i,"usealternates");
$isfrozen=@mysql_result($result,$i,"isfrozen");
$owner=@mysql_result($result,$i,"owner");
$individualvalue=@mysql_result($result,$i,"individualvalue");
$maxhp=@mysql_result($result,$i,"maxhp");
$basehp=@mysql_result($result,$i,"basehp");
Here comes the fun, you will need to find the codes below which updates a pet's level when its totalclicks matches requiredclicks:
// We need to level this adoptable up...
$query = "UPDATE ".$prefix."owned_adoptables SET currentlevel='".$nextlevel."' WHERE aid='".$id."'";
mysql_query($query);
Add after:
// We need to update this adoptable's maximum HP...
$newhp = (($individualvalue + 2*$basehp + 100)*$nextlevel)/100 + 10;
$query = "UPDATE ".$prefix."owned_adoptables SET maxhp='".$newhp."' WHERE aid='".$id."'";
mysql_query($query);
By doing this, we define the adoptable's new HP after its level increases by 1. Note the formula is used for pokemon HP system, you can modify it to wahtever you like for your own adoptable site. Make sure the variables you will need may not be the same with Pokemon system. We are almost done now, there's one last thing to do before heading to bed. You may want to display your pet's HP when looking at its stats.
If this is what you want, then go to myadopts.php and find the following lines:
$aid=@mysql_result($result,$i,"aid"); //The adoptable's ID
$currentlevel=@mysql_result($result,$i,"currentlevel");
$type=@mysql_result($result,$i,"type");
$name=@mysql_result($result,$i,"name");
$totalclicks=@mysql_result($result,$i,"totalclicks");
Add after:
$maxhp=@mysql_result($result,$i,"maxhp");
The very last thing to do is quite simple, find:
$article_title = $name."'s Statistics:";
$article_content = "<img src='".$image."'><br><br>
<b>Total Clicks: ".$totalclicks."<br>
Current Level: ".$currentlevel."<br>
Next Level: ".$nloutput."<br></b>";
Replace with:
$article_title = $name."'s Statistics:";
$article_content = "<img src='".$image."'><br><br>
<b>Total Clicks: ".$totalclicks."<br>
HP: ".$maxhp."<br>
Current Level: ".$currentlevel."<br>
Next Level: ".$nloutput."<br></b>";
You are all set now, cheers. If done correctly, you should get a similar stats page for your adoptables as the screenshot provided below. Keep in mind that I have Arianna's gender mod added to my script file, so it may not appear to be the same with yours:
http://oi51.tinypic.com/2z5uexw.jpg
This HP system may look quite useless at this point, unless a battle system is made. But anyway, this is the first step to create a complicated battle system. You can use my HP system directly if you run a Pokemon site, but if not, please do at least modify the formula so that it works out for your site. Note the variable 'individualvalue' is designed for Pokemon games only, and you may need a different set of variables in your HP formula. If you are using Kaeliah's status system, you may wish to create another column called 'currenthp' for your adoptables. The pet's current HP value may be set to be exactly the same as max HP but it may decreases if your pet's sick. If you have an itemshop system, you may even be able to create medicines/potions used to heal your pets. So yeah, this HP system can be easily integrated with other addons we currently have here.
For me, I will create other stats such as attack, defense for adoptables next, and maybe I should create a new table 'stats' to store each individual pet's stats if too many columns make the table 'owned_adoptables' look messy. My thanksgiving break will end soon so I wont be quite active since the end of the week, but I will continue to learn and write codes whenever I can. Thanks for support, everyone.