PDA

View Full Version : Adoptable Pet Status Mod by Kaeliah


Kaeliah
10-14-2010, 08:36 PM
Adoptable Pet Status Mod
Mod by Kaeliah


Description
Adds another dimension into the Adoptables Script by letting adoptables get sick! You can choose the chance each adoptable type has of getting sick every time it's clicked. If an adoptable gets sick, it can be cured by its owner by clicking on it. Of course you can edit this if you have an item/cash mod or anything along those lines. You can also feel free to add other status issues other than just Happy and Sick and this mod would be a perfect start for those popular Pokemon games. There is a lot you can do with this mod! My only request is you share what you've done with the mod!!

Possible Future Features:

Edit chance of getting sick from Admin panel



Directions For Installation


-MySQL Databases

In table 'adoptables' add another field:


Field | Type | Null | Default |
========================================|
sickchance | int(11) | Yes | NULL |
========================================|


In table 'owned_adoptables add another field:

Field | Type | Collation | Null | Default |
================================================== ============|
status | varchar(20) | utf8_general_ci | No | Happy |
================================================== ============|





-Code Editing


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");
$usealternates2=@mysql_result($result,$i,"usealternates2");
$isfrozen=@mysql_result($result,$i,"isfrozen");
$owner=@mysql_result($result,$i,"owner");

Add After:

$petstatus=@mysql_result($result,$i,"status");


Find:
if($isfrozen == "yes"){

$article_title = $lang_isfrozen_title;
$article_content = $lang_isfrozen_explain;

}

Add After:
else if($petstatus != "Happy" and $loggedinname != $owner){

$article_title = "Cannot Level Up";
$article_content = "This pet is not happy, only happy pets can be leveled up!";

}

Find:
// Now we need to update our vote_voters table with the user's vote...

mysql_query("INSERT INTO ".$prefix."vote_voters VALUES ('$date', '$loggedinname', '$ip','$id')");

Add After:
// By leveling up this adoptable, there's a chance that it will get sick!

if($loggedinname == $owner and $petstatus != "Happy") {
$petstatus = "Happy";
$query2 = "UPDATE ".$prefix."owned_adoptables SET status='".$petstatus."' WHERE aid='".$id."'";
mysql_query($query2);
}

$query2 = "SELECT * FROM ".$prefix."adoptables WHERE type='$type'";
$result2 = mysql_query($query2);
$num2 = mysql_numrows($result2);

//Loop out code
$i=0;
while ($i < 1) {

$sickchance=@mysql_result($result2,$i,"sickchance");

$i++;
}

if($sickchance != 0) {
$randnum = rand(1, $sickchance);

if($randnum == 1){

$petstatus = "Sick";
$query2 = "UPDATE ".$prefix."owned_adoptables SET status='".$petstatus."' WHERE aid='".$id."'";
mysql_query($query2);

}
}


In admin.php

Find:
<p>
<input type='submit' name='Submit' value='Create This Adoptable'>
</p>
<p>&nbsp; </p>
</form>";


} //End the create a new adoptable form

Add BEFORE:
<hr>

<p><strong>Status Settings</strong></p>
<p>
<input name='sickchance' type='text' id='sickchance' size='6' maxlength='6'><br>

This type of pet has a 1 in _____ chance of getting sick everytime it is clicked.<br>
This number should probably be higher as only the owner of the pet will be able to cure it.<br>
Leave blank or input 0 to have no chance of getting sick.<br>

</p>


In nadopt.php

Find:
$altchance = $_POST["altchance"];
$altchance = secure($altchance);

Add After:
$sickchance = $_POST["sickchance"];
$sickchance = secure($sickchance);

Find:
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:
if($sickchance == ""){
$sickchance = 0; }

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','$si ckchance')");



In doadopt.php
(Thank you HOF for pointing this out. ^.^)

FIND
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','Happy')");



Optional
It's probably a good idea to show the status of the pet somewhere. This will add the pet's status to the main manage panel. (Click on my adoptables then click on the adoptable and you'll be able to see the status)

In myadopts.php

Find:
$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");

Add after:

$petstatus=@mysql_result($result,$i,"status");

Find:

<b><a href='levelup.php?id=".$id."'><img src='templates/icons/add.gif' border=0> Level Up ".$name."</a><br>

Add BEFORE:
<b><u>Status:</b></u> ".$petstatus."<br>


That's everything for now.

Hall of Famer
10-14-2010, 10:49 PM
This looks absolutely amazing Miss Kaeliah, should be perfect for a pokemon system which contains about 6-7 different status. Thank you so much for this, I will see what I can do with it. Sure items integrated with status system is a neat idea too. ^^

Oh btw, you never reply to IM? Sorry if this is a harsh question. XD

Kaeliah
10-14-2010, 11:02 PM
I reply! It says your never online though. =( Maybe it's just my meebo... I should prolly go download msn for real...

Yes I thought it would work well for a Pokemon system which is half of my incentive for sharing it. You don't even really have to change that much, as you only need one status slot. idk how you'd want the status things to happen(like how something would get frozen or paralyzed) but you could set the item to simply change it's status back to normal or whatever.

In all honesty this was originally just a way of keeping my system cleaner. I am annoyed by inactive users who simply adopted 10 then left. So it's supposed to be set up that if a user doesn't cure his pets, they will die after a month or two and my system will have more room for those who are actually active. XD It's quite sly. I just haven't gotten the last part, where they die after a certain number of days... >.> Although I plan to have a medicine you have to buy to cure your pets but until I've got that shop script running smoothly I set it like this. (That script is working great by the way! I've been able to do a lot with it so far, I just haven't integrated it to the site yet)

redheadturkey
10-14-2010, 11:05 PM
ah, so much LOVE!!


I'll be installing this, and wowsers do I love the multiples mod so far :D :D :D

Hall of Famer
10-14-2010, 11:43 PM
Oh I am invisible, you can reply to my messages even if I do appear to be offline. But anyway, I will set my status to be online tomorrow and at weekends then. Its good to know that the shop and inventory system work well on your site, glad I can be of any help. ^^

And btw, is this script already integrated with your Multiple Alternative images system? I noticed this part of your codes, and seems that it is actually quite customizable if you have a different structure of ownedadoptable table:

mysql_query("INSERT INTO ".$prefix."adoptables VALUES ('', '$name', '$description','$eggimage','$cba','$promocode', '$freqcond','$number','$datecond','$date','$adopts cond','$maxnumcond','$morethannum','$usergroupcond ','$usergroups','$alternates','$altoutlevel','$alt chance','$sickchance')");

Kaeliah
10-15-2010, 01:13 AM
It is on my site... but otherwise no...

It is not already integrated. At least not on purpose. You would have to edit the tables to fit your own uses if you have other mods, but I'm just posting the script for the basics. So if you don't have other mods or you're not familiar with PHP you can just copy/paste.

@redheadturkey: I'm really glad you like it!! What's your site? We can affiliate once mine is released NEXT WEEK! Woot!

Hall of Famer
10-15-2010, 02:59 AM
Oh I see, dont worry this should be a piece of cake for me to figure out what to do with a highly customized adoptable site. ^^

Well I am indeed considering whether to add new types of items called healing items to the site, which consists of Potions and status healing items. There's actually a pokecenter on my site. It does nothing right now, but can be vital in future for healing purposes(Unlike in pokemon video games, pokecenter on my site will charge you about $500 Mysidian dollars for healing). It would be good if HP system is introduced somehow, since you can simply modify the script so that adoptables' HP drops gradually when they are sick or poisoned/injured, and they eventually become fainted if HP drops to 0 as they become 'frozen'. If an adoptable's not healed in time once its HP drops to 0, it will die. The issue here is that the adoptable's HP may or may not depend on its levels, so you will have to take this into consideration too.

And btw, can we affiliate too? We can exchange links of our site in not-so-distant future. ^^

Kaeliah
10-15-2010, 08:47 AM
Oh you could easily make HP depend on it's level. I'm assuming 1 level is 1 click. Simply use the required clicks and put a formula to it to create a new number for HP. For example if it's level is 99. A good HP might be 300 something? Maybe multiple the level by 3.5? So at level ten their HP is 35, or at least their max level is. Then(and this is where I'm a little fuzzy when it comes to codes) when a Pokemon get's poisoned. It can still do stuff or be interacted with, but each interaction and/or each day goes by drops it's currentHP level down a certain percentage of HP. Then it faints. Although when a Pokemon faints, it doesn't really die... maybe if it remains fainted for too long? But anyway yeah there is a lot that could be done with this mod.

Yes we can affiliate! Although my site has no Pokemon on it. >.> I'll give you a link once my site is released on October 21st!!

redheadturkey
10-16-2010, 09:16 PM
Would really love to affiliate <3 :) :)

the new KK and Pantheras is almoooooooooost ready, I am just having a terrible time getting a shop to work ---- that's really the last thing we need, but it's not working well.

Everything else is a go, as far as I can tell, so will keep all posted on this--- if anyone knows of a good WORKING shop mod, please, please :D

Hall of Famer
10-17-2010, 04:43 AM
Again this one works just great. ^^ I've found a small error though, which can be resolved by editing this line in doadopt.php:


mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','$alts2','$alts3','$alts4','fortrade',' no','$gender','$thetime')");


To:

mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','$alts2','$alts3','$alts4','Happy','for trade','no','$gender','$thetime','','','')");

If your default pet status is not Happy, then change this one to whatever you have as default. Also please do not just copy/paste my code since my sql tables are heavily modified and may not look exactly the same as yours. For instance, I have 4 alternative images and a gender system, so you need to delete these from your mysql_query script if yours does not have such things.

Kaeliah
10-17-2010, 08:55 AM
@Redheadturkey - My site is opening this weekend. Just send me a button(88x31) when your site is open. If you want I can make a button to represent your site but that's up to you. ^.^ Once my site opens I'll send you a button as well.

@HOF - Thanks for pointing that out. I did have that edited on my own site I just forgot to put it in the directions. *note to self* Write directions as you code!!! *end note to self*

^.^;