Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 03-05-2016, 04:02 PM
Ittermat's Avatar
Ittermat Ittermat is offline
The awesomesauce
 
Join Date: Feb 2016
Location: in front of my laptop
Posts: 272
Gender: Female
Credits: 32,798
Ittermat is on a distinguished road
Default Active pet widget?

EDIT: heres the post with the working code-


How would I make a thing to display on my side bar that shows your active/spotlight pet? And maybe make them say random things?

So for a picture example- and we'll say this pets name is...Marian?

-----------------------------


Marian says: "Lets go exploring!"
_____________________________

But that there would be a list of different things you can make them say? So it would choose from a random assortment of Phrases Or sometimes nothing at all? Possibly depending on the pet species if possible?

So one species would have a different List of things they could say.
But if thats too hard its fine XD Same list is okay.

I was just wondering if this was possible. and if so how it would be done.

Last edited by Ittermat; 03-21-2016 at 02:05 PM.
Reply With Quote
  #2  
Old 03-05-2016, 05:18 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 86,935
Kyttias is on a distinguished road
Default

To make a favpet display inthe sidebar, first in the AdminCP you'll create a module (surprisingly not a widget):


Then in classes/class_sidebar.php you'll need to add these functions:
PHP Code:
public function getFavPetSB(){
        return 
$this->FavPetSB;
    }

protected function 
setFavPetSB(){
        
$mysidia Registry::get("mysidia");

        
$userfavpet $mysidia->db->select("users_profile", array("favpet"), "username = '{$mysidia->user->username}'")->fetchColumn(); 
        if (
$this->userfavpet == "0"){
            
$this->FavPetSB = new Paragraph
            
$this->FavPetSB->add(new Comment("<b>No Favorite Pet Set</b>"));
        }
        else{
            
$adopt = new OwnedAdoptable($userfavpet);
            
$this->FavPetSB = new Paragraph
            
$this->FavPetSB->add(new Comment("<b>Favorite Pet!</b> <br/>
                <a href='/myadopts/manage/
{$userfavpet}'><img src='{$adopt->getImage()}'></a>
                "
));
        }

        
$this->setDivision($this->FavPetSB);
    } 
Using "$adopt = new OwnedAdoptable($userfavpet);" you can also pull up data like {$adopt->getName()} and {$adopt->getCurrentLevel()} - these are functions found in classes/class_ownedadoptable.php, but you should also be able to use {$adopt->type} (which is not a function) to pull raw data from the database from the 'type' column - this holds the species.

But I'll get back to that. Let me know if you can at least get the pet into the sidebar and then I'll be back later help you set up a switch statement to display random phrases for pets to say.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote
  #3  
Old 03-05-2016, 05:31 PM
Ittermat's Avatar
Ittermat Ittermat is offline
The awesomesauce
 
Join Date: Feb 2016
Location: in front of my laptop
Posts: 272
Gender: Female
Credits: 32,798
Ittermat is on a distinguished road
Default

thank you! I'll mess with it and get back to you after I eat dinner!! ^^
Reply With Quote
  #4  
Old 03-05-2016, 05:53 PM
Ittermat's Avatar
Ittermat Ittermat is offline
The awesomesauce
 
Join Date: Feb 2016
Location: in front of my laptop
Posts: 272
Gender: Female
Credits: 32,798
Ittermat is on a distinguished road
Default

Yup Got him in the sidebar! Whats next? ^___^

Last edited by Ittermat; 03-07-2016 at 05:38 PM.
Reply With Quote
  #5  
Old 03-06-2016, 11:23 AM
Corsair's Avatar
Corsair Corsair is offline
Member
 
Join Date: Jan 2012
Posts: 128
Gender: Female
Credits: 11,223
Corsair is on a distinguished road
Default

Ittermat do you mind if I use this too? I was going to screw around with the code to try to make a active pet too.
Reply With Quote
  #6  
Old 03-06-2016, 11:47 AM
Ittermat's Avatar
Ittermat Ittermat is offline
The awesomesauce
 
Join Date: Feb 2016
Location: in front of my laptop
Posts: 272
Gender: Female
Credits: 32,798
Ittermat is on a distinguished road
Default

Of course not! Lol ^^
Reply With Quote
  #7  
Old 03-07-2016, 05:38 PM
Ittermat's Avatar
Ittermat Ittermat is offline
The awesomesauce
 
Join Date: Feb 2016
Location: in front of my laptop
Posts: 272
Gender: Female
Credits: 32,798
Ittermat is on a distinguished road
Default

Also another question- what if I wanted that pet to randomly find items or money- or have "fake" Status effects happen to it?
Reply With Quote
  #8  
Old 03-07-2016, 06:49 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 86,935
Kyttias is on a distinguished road
Default

That can be done, too. Sounds quite fun, really! (I had work today so I'm super tired. I should be be able to get to this tomorrow, though.)
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote
  #9  
Old 03-07-2016, 07:33 PM
Ittermat's Avatar
Ittermat Ittermat is offline
The awesomesauce
 
Join Date: Feb 2016
Location: in front of my laptop
Posts: 272
Gender: Female
Credits: 32,798
Ittermat is on a distinguished road
Default

no its fine! get some rest! Help me when you can ^^ thank you!! <3
Reply With Quote
  #10  
Old 03-08-2016, 11:19 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 86,935
Kyttias is on a distinguished road
Default

We're going to set it up like this: 1% of the time the pet may get a status effect. Of the 99% of the time that the pet does not come away with a status effect, 75% of the remaining time - nothing will happen at all. Of the other 25% of the time, 5% of the time it will either be because it found some money or an item (about 50% toward either). The remaining 20% of the time it will say a random phrase based on its species. Below is commented but empty code just to get the odds of each event happening right:
PHP Code:
$status_chance mt_rand(1100);  
if (
$status_chance <= 1){ # One percent chance the pet will obtain a status effect.
    /* We would apply a status effect here...*/
} else { # Ninety-nine percent chance the pet will not get a status effect. Will something else happen?
    
$something_chance mt_rand(1100); 
    if (
$something_chance <= 25){ # Twenty-five percent chance something will happen.
        
$gift_chance mt_rand(1100); 
        if (
$gift_chance <= 5){ # Five percent chance the user will receive a gift from their pet.
            
$item_chance mt_rand(1100);
            if (
$item_chance <= 50){ # Fifty percent chance the gift from their pet will be an item.
                /* The pet has found an item for you! */ 
            
} else { # Fifty percent chance the gift from their pet will be money.
                /* The pet has found some money for you! */
            
}
        } else { 
# Twenty percent chance the pet will talk but have no gift.
            /* No gift will be given but a neat species-specific phrase can still be said! */
        
}
    } else { 
# Seventy-five percent chance nothing will happen whatsoever.
        /* Nothing will happen with the pet at all. */
    
}

Basically, just a tower of if-else statements so far, using PHP's built in mt_rand() function - we're feeding it the numbers 1 and 100 so it'll choose a random number between the two, just like rolling (if possible) a 100-sided dice. It's the easiest way to fudge in percents.

More soon! I've got to go look up some of the code I've used to give items and such again.

1) Is it alright if items and money are automatically collected, even without the user clicking or doing anything? It becomes much more complicated otherwise.

2) Inevitably if you wanted to, say, make it so your active pet can find an abandoned egg 1/500th of the time (about 0.2% chance of happening) but require that the user also be paying attention and clicking that message, remind me - I should be able to think this one through, given enough time. Let me know if this is something you want.

3) These percents should all be easy to modify. Let me know if you have questions and I can help tweak the code. If you change an mt_rand(1,100) to mt_rand(1,200) you will literally make something twice as hard to get and this will be relevant as soon as you want things to happen less than 1% of the time. One percent of that (1,200) would be 0.5% instead of (1,100)'s obvious 1%.

4) The fake status... placeholders for potentially real ones later? Is there a list of random events (nice ones are better than mean ones) you'd be interested in? Such as the pet suddenly gaining experience (as if clicked) or an entire level (if it's not frozen)? More complicated things (that existing item functions can't do) I might be interested in helping out with later, once everything else is done. For now, status effects will be the last on the list of things I'll do, and we'll fill it in with a message of "a status effect would have happened here" so long as we're testing. There are also some ideas I have that would be optional status effects that would require the user to click to accept and have it explained that the changes are somewhat permanent but entirely optional - such as the pet's gender or species changing, or the species' alternate appearance activated. Most of the time the user would be enthusiastically agreeing to this change but what if they really like their pet exactly how it is? We wouldn't want to force something, no matter how cool we think it is.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.

Last edited by Kyttias; 03-08-2016 at 12:32 PM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 04:51 AM.

Currently Active Users: 444 (0 members and 444 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636