Author Topic: SMFPets is Finally Here (0.1 out)  (Read 104218 times)

Offline Basil Beard

Re: SMFPets is Finally Here
« Reply #15 on: February 28, 2007, 09:58:59 pm »
Quote
Anyways here are some suggestions:

- Make the arrangement of the Pet Hatchery look like the arrangement of items.
- Fix spelling errors (Description)
- Add around 2 default pets instead of blank to show people how to add them
- Make a way to get rid of pets once you've bought one.
- A way to view other people's pets
- A way to trade pets
- PM the user when his/her pet levels up or can level up... etc
- Make a place that admins can adjust everything a lot more easily

And if you make this mod into a dueling mod, here are some other suggestions:

- Pet battles (They wouldn't be live, it would be like messaging back and forth of two members, members can use items and forfeit and stuff like that.)
- Pet stuff (Weapons, items, armor, so on....)
- Display stats of pets in a better fashion (Heath, Skills, Level, and if you decide to, Armor, Attack... etc.)
- Take and put them in their own section away from the shop, (It would make it less cluttered, easier to use, especially if  you can trade, duel, and stuff like that)

I personally do not see why the hatchery should look like the sotre items. I kinda wanted it to be different in its own way.
I plan on adding more default pets with default skills, but that wasn't needed for a package like this.]
Getting rid of pets and trading pets may be an option in the future, but not for a while.  :P
PMing user would be really really annoying, to the point where I don't think i'll ever code it.
Admin side of things will come eventually, but again wasn't needed for the first release.
Go to a user's profile(On the default theme) and scroll down if you do not think you can view other peoples pets.

Pet battles may be coded *eventually* be not for a while. Coding battles is way *way* more complex than coding pets itself =P.
Pet items(ones that like, reduce training cost or reduce training time) are one of my next goals to code.
What do you mean by "Better fashion"? Lemme know how you want it to look can I'll see what I can do.
Keeping in the shop saves a ton of busy work for me, and really, they are integrated into the shop system. This really is a SMFSop mod, not an SMF mod.

Quote
My second breed can not be bought. (first new breed was no problem) As soon as I buy it, the screen changes to where the "you bought this pet" should be, but theres no text there. The Pet also doenst get bought...

This may have something to do with a second bug I found.

In the Pet Hatchery I can see my animals icons, but as soon as i buy them and look them up in "Pet Central" the icons disapear.
Seems its searching for the image in the wrong place. My forum is in "http://www.silverrose.nl/forum/sources/shop/pet_images but in the hatchery its trying to find the image in http://www.silverrose.nl/sources/shop/pet_images

You do not get any errors when trying to buy the bread? What is the breed name?(Both breedname and filename. Actually, giving me the whole breed file might help) That is the only thing that could be causing it.

As for the image files being wrong, ill look into that as well. I might have use "sources/" instad of "$sourcedir" by accident once or twice in the code.


Anyways, please keep in mind that my main goal was to get the pet mod to this stage--and that while I will spend time debugging it, major features will not be my main coding goal now because i'll want to work on other little projects. So don't expect any of the major stuff I talked about any time soon. Sorry =P
Arrrrr!

Alexander

  • Guest
Re: SMFPets is Finally Here
« Reply #16 on: February 28, 2007, 10:34:44 pm »
Just a question, how would I be able to delete a pet manually? Also, maybe for getting rid of a pet you could make a item so users can't dispose of pets at their own liking and they have to pay.

One last question, I'm a bit confused about the skills, what is a good example of one, and could they work as items? Say you want a pet to use a skill could your pet get you a random item and give it to you/use it?

« Last Edit: February 28, 2007, 10:37:55 pm by Alexander »

Offline Basil Beard

Re: SMFPets is Finally Here
« Reply #17 on: February 28, 2007, 10:49:29 pm »
Here is one of my skills:

Code: [Select]
function use_skill_0() {
global $db_prefix, $ID_MEMBER;
$value = mt_rand(1,10);
$result = db_query("UPDATE {$db_prefix}members SET money = money + {$value} WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
return "{$this->name} climbs a near-by tree and drops down ".formatMoney($value)." for you to collect!";
}

with corresponding values:

Code: [Select]
$this->skill[0] = new skill;
$this->skill[0]->name = "Tree Climb";
$this->skill[0]->level_learn = 5;
$this->skill[0]->level_max = 10;
$this->skill[0]->cost = 1;

This skill takes 1 SP and gives the user between 1 and 10 credits.

SKills can also give items. One cool trick would be to give items that cannot normally be bought in stores. (This isn't possible with daniel's current build, IIRC, but if you make the changes it could be fun).

Skills can also simply do random stuff. Another of my skills is

Code: [Select]
$this->skill[3] = new skill;
$this->skill[3]->name = "Lucky Number Generation";
$this->skill[3]->level_learn = 1;
$this->skill[3]->level_max = 3;
$this->skill[3]->cost = 1;
...
...
...
function use_skill_3() {
$string = "{$this->name} thinks for a while and says: \"Your lucky numbers are: ";
for ($i = 0; $i < 6; $i++) {
$num = mt_rand(1,40);
$string .= $num." ";
}
$string .= "\"";
return $string;
}

That just gives you 6 lottery numbers =D.

Anyways, you can delete pets through the database--they are stored in shop_pets. Thats the only way you can do it currently. You could always make a DEATH skill for each pet that removes the pet from the database---but there is no way to like, make sure someone doesn't accidentally nuke there pet. XD.
Arrrrr!

Offline Aruta

Re: SMFPets is Finally Here
« Reply #18 on: February 28, 2007, 10:58:00 pm »
You do not get any errors when trying to buy the bread? What is the breed name?(Both breedname and filename. Actually, giving me the whole breed file might help) That is the only thing that could be causing it.

No errors when buying the breed. When I try to buy a breed now I get the same situation as i get when trying to buy the second breed. I just get a blank notification bar. I must admit that I uploaded the the first breed without buying it. I just edited the blank_pet.php, renamed it and copied it to the directory.  :-[
can that be the problem?

No worries about the extra options, Im really glad with the mod the way it is. And so are my users!  8)


Offline perplexed

Re: SMFPets is Finally Here
« Reply #19 on: February 28, 2007, 11:56:43 pm »
Here is one of my skills:

Code: [Select]
function use_skill_0() {
global $db_prefix, $ID_MEMBER;
$value = mt_rand(1,10);
$result = db_query("UPDATE {$db_prefix}members SET money = money + {$value} WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
return "{$this->name} climbs a near-by tree and drops down ".formatMoney($value)." for you to collect!";
}

with corresponding values:

Code: [Select]
$this->skill[0] = new skill;
$this->skill[0]->name = "Tree Climb";
$this->skill[0]->level_learn = 5;
$this->skill[0]->level_max = 10;
$this->skill[0]->cost = 1;

This skill takes 1 SP and gives the user between 1 and 10 credits.

SKills can also give items. One cool trick would be to give items that cannot normally be bought in stores. (This isn't possible with daniel's current build, IIRC, but if you make the changes it could be fun).

Skills can also simply do random stuff. Another of my skills is

Code: [Select]
$this->skill[3] = new skill;
$this->skill[3]->name = "Lucky Number Generation";
$this->skill[3]->level_learn = 1;
$this->skill[3]->level_max = 3;
$this->skill[3]->cost = 1;
...
...
...
function use_skill_3() {
$string = "{$this->name} thinks for a while and says: \"Your lucky numbers are: ";
for ($i = 0; $i < 6; $i++) {
$num = mt_rand(1,40);
$string .= $num." ";
}
$string .= "\"";
return $string;
}

That just gives you 6 lottery numbers =D.

Anyways, you can delete pets through the database--they are stored in shop_pets. Thats the only way you can do it currently. You could always make a DEATH skill for each pet that removes the pet from the database---but there is no way to like, make sure someone doesn't accidentally nuke there pet. XD.

I don't know what 'skills' are or what I should do with this code, but the lottery number generator sounds pretty cool.  How would I go about getting that in my shop?  What do I have to do?

~thanks

(have just downloaded pets to test it)
Estne volumen in toga, an solum tibi libet me videre?

Alexander

  • Guest
Re: SMFPets is Finally Here
« Reply #20 on: March 01, 2007, 12:03:03 am »
Thanks Basil Beard. :)

Also, about the Pet Central problems, this should fix it:

In Pet Engine Find:
Code: [Select]
<img border='0' width='120' height='120' src='".$boardurl."/Sources/shop/pet_images/".$this->breed_img."' alt='".$this->breed."' />Replace with:
Code: [Select]
<center><img border='0' src='".$boardurl."$boardurl."[b]/[your forum directory[/b]]/Sources/shop/pet_images/".$this->breed_img."' alt='".$this->breed."' /></center>I'm not 100% sure it'll fix it, but it will also make the image not resize and will be centered. Also do it for both codes you find.

If my fix doesn't work try:
$boardurl."/$sourcedir/shop/pet_images replacing with $boardurl."/[your forum directory]/Sources/shop/pet_images

Edit-
Also for the rest of the image resizing:

Find in Shop Pets:
Code: [Select]
<img border='0' ' src='".$boardurl."/Sources/shop/pet_images/".$pet->breed_img."' alt='".$pet->breed."' />Replace with:
Code: [Select]
<center><img border='0' ' src='".$boardurl."/Sources/shop/pet_images/".$pet->breed_img."' alt='".$pet->breed."' /></center>
« Last Edit: March 01, 2007, 10:23:57 am by Alexander »

Alexander

  • Guest
Re: SMFPets is Finally Here
« Reply #21 on: March 01, 2007, 12:54:23 am »
Sorry for the double post and all, but I didn't want my last post to be to cluttered.

Would this work for a pet, I know there's probably at least 2-3 errors?
Code: [Select]
<?php
if (!class_exists(pet_Forest_Minish)) { 
class 
pet_Forest_Minish extends petTemplate 
function load_breed() {
$this->breed 'Forest Minish'
$this->breed_desc 'A minish, straight from the woods!';
    
$this->price 250
    
$this->breed_img 'forestminish.gif';
    
$this->skills_cnt 2
        
$this->skill[0] = new skill;
$this->skill[0]->name "Minish Luck";
$this->skill[0]->level_learn 5;
$this->skill[0]->level_max 10;
$this->skill[0]->cost 1;
$this->skill[1] = new skill;
$this->skill[1]->name "Positive pet";
$this->skill[1]->level_learn 2;
$this->skill[1]->level_max 5;
$this->skill[1]->cost 1;
}


function use_skill_0() {
global $db_prefix$ID_MEMBER;
$value mt_rand(1,20);
$result db_query("UPDATE {$db_prefix}members SET money = money + {$value} WHERE ID_MEMBER = {$ID_MEMBER}"__FILE____LINE__);
return "{$this->name} searches a plant and finds ".formatMoney($value)." for you to collect!";
}
function use_skill_1() {
global $db_prefix$ID_MEMBER$item_info;

db_query("
UPDATE 
{$db_prefix}members
SET karmaGood = karmaGood + 
{$item_info[1]}
WHERE ID_MEMBER = 
{$ID_MEMBER}"__FILE____LINE__);
return 'Successfully increased your Karma by ' $item_info[1] . '!';
}
}
}
?>
/code]

Offline Basil Beard

Re: SMFPets is Finally Here
« Reply #22 on: March 01, 2007, 04:03:13 am »
It should work. I don't see why it wouldn't. Are you getting any errors?

Quote
I don't know what 'skills' are or what I should do with this code, but the lottery number generator sounds pretty cool.  How would I go about getting that in my shop?  What do I have to do?

~thanks

Skills are found in the pets files. See the blank_pet.php for more information.


Quote
No errors when buying the breed. When I try to buy a breed now I get the same situation as i get when trying to buy the second breed. I just get a blank notification bar. I must admit that I uploaded the the first breed without buying it. I just edited the blank_pet.php, renamed it and copied it to the directory.  Embarrassed
can that be the problem?

No worries about the extra options, Im really glad with the mod the way it is. And so are my users!  Cool

Sounds like the problem is a bad txt file. Are you sure that you should be able to buy the pet(That is, you have enough pet spaces and money)?
Arrrrr!

Offline xfollowthereaperx

Re: SMFPets is Finally Here
« Reply #23 on: March 01, 2007, 04:08:50 am »
Pet battles may be coded *eventually* be not for a while. Coding battles is way *way* more complex than coding pets itself =P.
:D OMG YAY

Alexander

  • Guest
Re: SMFPets is Finally Here
« Reply #24 on: March 01, 2007, 04:20:07 am »
I just tested it out, I'm getting:
Code: [Select]
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE ID_MEMBER = 1' at line 3
File: /home/zeldaevo/public_html/forums/Sources/shop/pets_breeds/Forest_Minish.php
Line: 36

Offline Basil Beard

Re: SMFPets is Finally Here
« Reply #25 on: March 01, 2007, 04:30:17 am »
Code: [Select]
SET karmaGood = karmaGood + {$item_info[1]}
$item_info[1] is not defined. try changing that to karmaGood = karmaGood + 1

=)

Quote
OMG YAY

What part about "may" "eventually" and "really really hard" didn't you understand  :P
« Last Edit: March 01, 2007, 04:33:01 am by Basil Beard »
Arrrrr!

Offline TechnoDragon

Re: SMFPets is Finally Here
« Reply #26 on: March 01, 2007, 05:28:33 am »
ok, here's an example of what i am describing....
This is the original code which is the function  view_pet_owner
Code: [Select]
return "
<table width='75%' cellpadding='5' cellspacing='0' border='1' align='center'>
<tr 'titlebg2'><th colspan='6'>".$this->name." the ".$this->breed."</th></tr>
<tr><td colspan='1' rowspan='3' width='10%'><img border='0' width='120' height='120' src='".$boardurl."/Sources/shop/pet_images/".$this->breed_img."' alt='".$this->breed."' />
    <th colspan='1' width='20%'>".$txt['pets_name']."</th>
    <td colspan='1'>".$this->name."</td>
    <th colspan='1' width='20%'>".$txt['pets_breed']."</th>
<td colspan='2'>".$this->breed."</td></tr>
<tr><th colspan='1' width='10%'>".$txt['pets_happy']."</th>
<td colspan='1'>".$this->happy."</td>
<th colspan='1'>".$txt['pets_hunger']."</th>
<td colspan='1'>".$this->hunger."</td></tr>
<tr><th colspan='1' width='20%'>".$txt['pets_level']."</th>
<td colspan='1'>".$this->level."</td>
<th colspan='1' width='20%'>".$txt['pets_age']."</th>
<td colspan='2'>".sprintf($txt['pets_days'], $this->age)."</td></tr>
<tr><th colspan='1'>".$txt['pets_description']."</th>
<td colspan='5'>".$this->desc."</td></tr>
<tr><th colspan='6'>".$txt['pets_do_stuff'].$this->curap."/".$this->maxap.")</th></tr>
<tr><th colspan='1' width='10%'>".$txt['pets_use_skill']."</th>
<td colspan='2'>".$this->skillsMenu()."</td>
<th colspan='1' width='10%'>".$txt['pets_train']."</th>
<td colspan='2'>".$this->trainMenu()."</td></tr>
<tr><th colspan='1' width='10%'>".$txt['pets_rename']."</th>
<td colspan='2'>".$this->renameMenu()."</td>
<th colspan='1' width='10%'>".$txt['pets_describe']."</th>
<td colspan='2'>".$this->describeMenu()."</td></tr></table><br />";

here's what i would like to do (at least in the early stages):
Code: [Select]
        echo' <table width="75%" cellpadding="5" cellspacing="0" border="1" align="center">
<tr "titlebg2"><th colspan="6">'.$this->name.' the '.$this->breed.'</th></tr>
<tr><td colspan="1" rowspan="3" width="10%"><img border="0" width="120" height="120" src="'.$boardurl.'/Sources/shop/pet_images/'.$this->breed_img.'" alt="'.$this->breed.'" />
    <th colspan="1" width="20%">'.$txt['pets_name'].'</th>
    <td colspan="1">'.$this->name.'</td>
    <th colspan="1" width="20%">'.$txt['pets_breed'].'</th>
<td colspan="2">'.$this->breed.'</td></tr>
<tr><th colspan="1" width="10%">'.$txt['pets_happy'].'</th>';
                if ($this->happy < 10 && $this->happy > 9){
                  echo'
<td colspan="1">Joyous</td>';
                }
                elseif($this->happy < 9 && $this->happy > 5){
                  echo'
<td colspan="1">Content</td>';
                }
                elseif($this->happy < 5 && $this->happy > 1){
                  echo'
<td colspan="1">Depressed</td>';
                }
                elseif($this->happy <= 1){
                  echo'
<td colspan="1">Angry</td>';
                }
                else{
                  echo'
<td colspan="1">Excstatic</td>';
                }
echo'
                <th colspan="1">'.$txt['pets_hunger'].'</th>
<td colspan="1">'.$this->hunger.'</td></tr>
<tr><th colspan="1" width="20%">'.$txt['pets_level'].'</th>
<td colspan="1">'.$this->level.'</td>
<th colspan="1" width="20%">'.$txt['pets_age'].'</th>
<td colspan="2">'.sprintf($txt['pets_days'], $this->age).'</td></tr>
<tr><th colspan="1">'.$txt['pets_description'].'</th>
<td colspan="5">'.$this->desc.'</td></tr>
<tr><th colspan="6">'.$txt['pets_do_stuff'].$this->curap.'/'.$this->maxap.')</th></tr>
<tr><th colspan="1" width="10%">'.$txt['pets_use_skill'].'</th>
<td colspan="2">'.$this->skillsMenu().'</td>
<th colspan="1" width="10%">'.$txt['pets_train'].'</th>
<td colspan="2">'.$this->trainMenu().'</td></tr>
<tr><th colspan="1" width="10%">'.$txt['pets_rename'].'</th>
<td colspan="2">'.$this->renameMenu().'</td>
<th colspan="1" width="10%">'.$txt['pets_describe'].'</th>
<td colspan="2">'.$this->describeMenu().'</td></tr></table><br />';

if i do that it makes the pet display at the top of the page before the forum is even rendered.
Don't tell me to get into shape...I have a shape...It is round!


Offline xfollowthereaperx

Re: SMFPets is Finally Here
« Reply #27 on: March 01, 2007, 06:15:45 am »
What part about "may" "eventually" and "really really hard" didn't you understand  :P
The part where you said it might happen

Very awesome code TechnoDragon  :smitten:

Offline Basil Beard

Re: SMFPets is Finally Here
« Reply #28 on: March 01, 2007, 06:32:50 am »
The number one rule of coding with SMF is: "If it is not a template file, DO NOT ECHO" =D.
Also, simply to have nicer code, I would suggest

Code: [Select]
switch ($this->happy) {
     case 0,1: $mood = "Angry"; break;
     case 2,3,4: $mood = "Depressed"; break;
     case 5,6,7,8,9: $mood = "Content"; break;
     case 10,11,12,13,14,15: $mood = "Joyous"; break;
     default: $mood = "Excstatic"; break;
}

        return' <table width="75%" cellpadding="5" cellspacing="0" border="1" align="center">
<tr "titlebg2"><th colspan="6">'.$this->name.' the '.$this->breed.'</th></tr>
<tr><td colspan="1" rowspan="3" width="10%"><img border="0" width="120" height="120" src="'.$boardurl.'/Sources/shop/pet_images/'.$this->breed_img.'" alt="'.$this->breed.'" />
    <th colspan="1" width="20%">'.$txt['pets_name'].'</th>
    <td colspan="1">'.$this->name.'</td>
    <th colspan="1" width="20%">'.$txt['pets_breed'].'</th>
<td colspan="2">'.$this->breed.'</td></tr>
<tr><th colspan="1" width="10%">'.$txt['pets_happy'].'</th>
<td colspan="1">'.$mood.'</td>
                <th colspan="1">'.$txt['pets_hunger'].'</th>
<td colspan="1">'.$this->hunger.'</td></tr>
<tr><th colspan="1" width="20%">'.$txt['pets_level'].'</th>
<td colspan="1">'.$this->level.'</td>
<th colspan="1" width="20%">'.$txt['pets_age'].'</th>
<td colspan="2">'.sprintf($txt['pets_days'], $this->age).'</td></tr>
<tr><th colspan="1">'.$txt['pets_description'].'</th>
<td colspan="5">'.$this->desc.'</td></tr>
<tr><th colspan="6">'.$txt['pets_do_stuff'].$this->curap.'/'.$this->maxap.')</th></tr>
<tr><th colspan="1" width="10%">'.$txt['pets_use_skill'].'</th>
<td colspan="2">'.$this->skillsMenu().'</td>
<th colspan="1" width="10%">'.$txt['pets_train'].'</th>
<td colspan="2">'.$this->trainMenu().'</td></tr>
<tr><th colspan="1" width="10%">'.$txt['pets_rename'].'</th>
<td colspan="2">'.$this->renameMenu().'</td>
<th colspan="1" width="10%">'.$txt['pets_describe'].'</th>
<td colspan="2">'.$this->describeMenu().'</td></tr></table><br />';

But yeah. Do not echo stuff. When you echo stuff stuff appears on the top and everyone is very, very sad. =P
Arrrrr!

Offline TechnoDragon

Re: SMFPets is Finally Here
« Reply #29 on: March 01, 2007, 07:14:50 am »
Ahhh, see that is a different method of coding than i am used to (most everything i have done is with source and template files)

i will give that a shot tonight and see what happens...have i told you this is an awesome mod yet?

other than the $context error it is working flawlessly...i have waited to code skills and pets until i "tweak" a few settings, but once i do i will make most of them available for everyone here!  if anyone has any ideas for additional items let me know and i will try to make them happen (trying to take some of the load off of you basilbeard)
Don't tell me to get into shape...I have a shape...It is round!