Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Addons and Modifications > Mys v1.3.x Mods

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 07-01-2016, 11:38 AM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 132,475
Abronsyth is on a distinguished road
Default Simple NPC Battle

Simple NPC Battle V.1.0

Hello!

This mod will cover several topics:
-assigning stats to adoptables (and making them inheritable through breeding)
-training adoptables to increase stats
-competing against randomly generated NPCs
-earning trophies from competing

This mod was specifically coded for and tested with Mysidia 1.3.4. While it may be adaptable to other versions of Mysidia it would take quite a bit of tweaking.

Note: the battleview.php code is based on Kyttias's explore code, I have permission from her to use and share it with you all :)

Demo:


P.1: Stats
The code I will provide uses four stats: Sense, Speed, Strength, and Stamina. In this section I will show you how to add these four, but with some tweaking you can honestly use/add any sort of stats you'd like.

The first step is adding these stats to the database. In phpMyAdmin go to the table prefix_owned_adoptables, then go to the structure tab and scroll down to add four columns, naming them sense, speed, strength, and stamina. Type should be varchar and you shouldn't need more than 5. I set the default value as 10. (screenshot)

Once that is done, it's time to make it so that when a user adopts a new pet that pet has random stats. Go into the file adopt.php and find this line:
PHP Code:
$mysidia->db->insert("owned_adoptables"... 
Right above that insert this chunk of code:
PHP Code:
$sense rand(10,100);     
$speed rand(10,100); 
$strength rand(10,100); 
$stamina rand(10,100); 
Now add this to the end of the insert string, make sure it is BEFORE the ending ));, and that there is a comma between the last thing in there and the new stuff. So right after "lastbred" => 0 add a comma, and then add this before the ));
PHP Code:
"sense" => $sense"speed" => $speed"strength" => $strength"stamina" => $stamina 
Now we need to do the same thing in the files class_promocode.php and class_stockadopt.php, just follow the above steps for these two files.

Now breeding is a little bit more tricky since we want bred adoptables to inherit their parent's stats. So go into class_breeding.php and find the insert statement ($mysidia->db->insert("owned_adoptables"...). Right above it add this lovely chunk of code:
PHP Code:
$mother_se =  $this->female->sense;
$father_se =  $this->male->sense;
$mother_sp =  $this->female->speed;
$father_sp =  $this->male->speed;
$mother_str =  $this->female->strength;
$father_str =  $this->male->strength;
$mother_st =  $this->female->stamina;
$father_st =  $this->male->stamina;

$parent_se $mother_se $father_se;
$parent_sp $mother_sp $father_sp;
$parent_str $mother_str $father_str;
$parent_st $mother_st $father_st;

$sense $parent_se 2;     
$speed $parent_sp 2
$strength $parent_str 2
$stamina $parent_st 2
What this does is retrieve all of the parent stats, add each stat together (mother's sense + father's sense, etc), and then finds the average between them. So if the mother has 32 sense and the father has 64, the babies will have 48.
After you add that, add this in just like we did for the other files:
PHP Code:
"sense" => $sense"speed" => $speed"strength" => $strength"stamina" => $stamina 
Cool, now that's it for stats! Our battle page will display the pet's stats anyways, but if you want to display it on the level up pages and such check these threads out:
Restyling the Manage Page
Public Pet Profiles

P.2: Training
This section will cover how to train pets in order to increase stats!

So, we are going to need two files. First create a file called train.php and paste this in it:
PHP Code:
<?php

class TrainController extends AppController{
    
    public function 
__construct(){
        
parent::__construct("member");
    }

    public function 
index(){
        
$mysidia Registry::get("mysidia");        
    }

}
?>
That goes in your root folder and it is good to go. Close it and make a new file, this one called trainview.php. Now copy and paste this code into it:
PHP Code:
<?php
class TrainView extends View{
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document
        
$document->setTitle("Stat Training");
                    
$document->add(new Comment("Welcome to the Gym. People from all across the land come here to train their pets and prep them for battle.<br>
                    <center><b>Each training session costs 30 CURRENCY.</b></center><br><br>
                    To train your pet it must be an adult, and it must be set as your assigned companion."
FALSE)); 
        
$profile $mysidia->user->getprofile();
        
$mysidia->user->getprofile(); 
        if ((int)
$profile->getFavpetID() == 0) { 
            
$document->addLangVar('<br><br>It seems you do not yet have not assigned a companion! Assign one and then come back.'); 
        return; 
        } 
        
$favpet = new OwnedAdoptable($profile->getFavpetID());    
        
        if (
$favpet->currentlevel 3){ 
            
$document->add(new Comment("<br><br>Woah, sorry there! Your pet isn't old enough to train, yet! Come back with an adult if you want to train!"FALSE)); 
      return; 
        } 
        if(
$favpet->currentlevel 3){
            
$document->add(new Comment("To train, select the stat that you would like to work on.<br><br>
                    <center><b>
{$favpet->name}'s Stats</b><br>
                    <u>Se | Sp | Str | Stm</u><br>
                    
{$favpet->sense} | {$favpet->speed} | {$favpet->strength} | {$favpet->stamina}<br>"FALSE));
            
$this->exploreButton("Train_Sense"FALSE"Train Sense");
            
$this->exploreButton("Train_Speed"FALSE"Train Speed");
            
$this->exploreButton("Train_Strength"FALSE"Train Strength");
            
$this->exploreButton("Train_Stamina"FALSE"Train Stamina");
        } 
# END no area selected

        /* If an area is selected: */
        
if($mysidia->input->post("area")){
            
            
$area $mysidia->input->post("area"); // This has apostrophes as *s instead, just like the exploreButtons above!
            
$str str_replace("_"" "$area);
            
$areaname str_replace("*""'"$str); // This one has apostrophes instead of asterisks.

            
$document->setTitle("{$areaname}");
                
$increase rand(1,5);
                
$sense $favpet->sense;
                
$newsense $sense $increase;
                
$speed $favpet->speed;
                
$newspeed $speed $increase;
                
$strength $favpet->strength;
                
$newstrength $strength $increase;
                
$stamina $favpet->stamina;
                
$newstamina $stamina $increase;
        
            switch (
$area){
                
# First one is the default response that will happen unless something specific is specified:
                
case $areaname$document->add(new Comment("<br><br>Oops, something has gone wrong."FALSE));
                break;

                
                case 
"Train_Sense"
                    
$currentcash $mysidia->user->money;
                    
$newmoney $currentcash 30;
                        
$document->add(new Comment("<br><b>The Session:</b><br> Write something here about the Sense training.<br><br>
                        
{$favpet->name} gained {$increase} Sense from this session!"FALSE));
                        
$mysidia->db->update("users", array("money" => $newmoney), "username='{$mysidia->user->username}'");
                        
$mysidia->db->update("owned_adoptables", array("sense" => $newsense), "aid='{$profile->getFavpetID()}'");
                break;
                case 
"Train_Speed"
                    
$currentcash $mysidia->user->money;
                    
$newmoney $currentcash 30;
                        
$document->add(new Comment("<br><b>The Session:</b><br> Write something here about the Speed training.<br><br>
                        
{$favpet->name} gained {$increase} Speed from this session!"FALSE));
                        
$mysidia->db->update("users", array("money" => $newmoney), "username='{$mysidia->user->username}'");
                        
$mysidia->db->update("owned_adoptables", array("speed" => $newspeed), "aid='{$profile->getFavpetID()}'");
                break;
                case 
"Train_Strength"
                    
$currentcash $mysidia->user->money;
                    
$newmoney $currentcash 30;
                        
$document->add(new Comment("<br><b>The Session:</b><br> Write something here about the Strength training.<br><br>
                        
{$favpet->name} gained {$increase} Strength from this session!"FALSE));
                        
$mysidia->db->update("users", array("money" => $newmoney), "username='{$mysidia->user->username}'");
                        
$mysidia->db->update("owned_adoptables", array("strength" => $newstrength), "aid='{$profile->getFavpetID()}'");
                break;
                case 
"Train_Stamina"
                    
$currentcash $mysidia->user->money;
                    
$newmoney $currentcash 30;
                        
$document->add(new Comment("<br><b>The Session:</b><br> Write something here about the training.<br><br>
                        
{$favpet->name} gained {$increase} Stamina from this session!"FALSE));
                        
$mysidia->db->update("users", array("money" => $newmoney), "username='{$mysidia->user->username}'");
                        
$mysidia->db->update("owned_adoptables", array("stamina" => $newstamina), "aid='{$profile->getFavpetID()}'");
                break;

            }

            return;
        }
    }

    public function 
exploreButton($areaname$image_link ""$customtext ""$customimg ""){
        
$document $this->document;
        
        if (
$image_link){ /* Image Links */
            
             
if (!$customimg){ /* Area Logo Image */
                 
$imgname str_replace("*""'"$areaname);
                
$document->add(new Comment("
                    <form id='exploreform' action='train' name='exploreform' method='post' role='form'>
                    <input id='area' name='area' type='hidden' value='
{$areaname}'>
                    <button id='
{$areaname}' class='btn-text btn-sm' value='train' name='{$areaname}' type='submit'>
                    <img src=\"./images/
{$imgname}_logo.png\"/>
                    </button>
                    </form>
                "
FALSE)); 
             }
             
             else { 
/* Custom Link Image */
                 
$imgname str_replace("*""'"$customimg);
                
$document->add(new Comment("
                    <form id='exploreform' action='train' name='exploreform' method='post' role='form'>
                    <input id='area' name='area' type='hidden' value='
{$areaname}'>
                    <button id='
{$areaname}' class='btn-text btn-sm' value='train' name='{$areaname}' type='submit'>
                    <img src=\"./images/
{$imgname}\"/>
                    </button>
                    </form>
                "
FALSE)); 
             }
        } 
        
        else { 
/* Text-Only Links */
            
            
if (!$customtext){ /* Area Name Button */
                
$str str_replace("_"" "$areaname); $btn_name str_replace("*""'"$str);
                
$document->add(new Comment("
                    <form id='exploreform' action='train' name='exploreform' method='post' role='form'>
                    <input id='area' name='area' type='hidden' value='
{$areaname}'>
                    <button id='
{$areaname}' class='btn-violet btn-sm' value='train' name='{$areaname}' type='submit'>
                    
{$btn_name}
                    </button>
                    </form>
                "
FALSE));
            } 
            
            else { 
/* Custom Link Text */
                
$customtext str_replace("*""'"$customtext);
                
$document->add(new Comment("
                    <form id='exploreform' action='train' name='exploreform' method='post' role='form'>
                    <input id='area' name='area' type='hidden' value='
{$areaname}'>
                    <button id='
{$areaname}' class='btn-violet btn-sm' style='display: inline;' value='train' name='{$areaname}' type='submit'>
                    
{$customtext}
                    </button>
                    </form>
                "
FALSE));
            }
        }
        return;
    }
}    
?>
First, customize the currency name around line 9 where it just says CURRENCY. Also change the price so that it reflects whatever you want to charge for each training session.

Then, to change the charge, scroll to where you see the line
PHP Code:
$newmoney $currentcash 30
and just change 30 to whatever the cost should be.

Each type of training has a section for you to write about the training session or add images, etc. Just fill it in to your pleasing!

P.3: Battle
This is the major focus of this mod! Creating a page that allows the user's fave pet to battle!

This requires two new files:
battle.php
This goes in the root folder where the files like adopt.php and account.php are.
PHP Code:
<?php

class BattleController extends AppController{
    
    public function 
__construct(){
        
parent::__construct("member");
    }

    public function 
index(){
        
$mysidia Registry::get("mysidia");        
    }

}
?>
battleview.php
This goes in the view folder.
PHP Code:
<?php
/* This is the Battle Mod view page. This page is created based on the explore script created by Kyttias, so credit for the base of that goes to her. The ability to select and use the favepet was from RestlessThoughts, as posted on this thread; http://mysidiaadoptables.com/forum/showthread.php?t=4827&page=3
*This mod is entirely a collection of what Abronsyth has learned from messing around with mods created by wonderful users such as the two mentioned above.
 */
class BattleView extends View{
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document
        
$document->setTitle("Battle");
                    
$document->add(new Comment("<br>"FALSE)); 
        
$profile $mysidia->user->getprofile();
        
$mysidia->user->getprofile(); 
        if ((int)
$profile->getFavpetID() == 0) { 
            
$document->addLangVar('<br><br>It seems you do not yet have not assigned a companion! Assign one and then come back.'); 
        return; 
        } 
        
$favpet = new OwnedAdoptable($profile->getFavpetID());    
        
        if (
$favpet->currentlevel 3){ 
            
$document->add(new Comment("<br><br>Woah, sorry there! Your companion isn't old enough to battle, yet! Come back with an adult companion if you want to compete!"FALSE)); 
      return; 
        } 
        if(
$favpet->currentlevel 3){
 
/*Random Opponent Stats*/
        
$opsense rand(1,100);
        
$opstamina rand(1,100);
        
$opstrength rand(1,100);
        
$opspeed rand(1,100);
    
/*Below determines how many trophies the pet earns by winning a batttle.*/
        
$trophies $favpet->trophies;
        
$newtrophy $trophies 1;
            
$document->add(new Comment("You enter the battle arena with {$favpet->name} at your side. Waiting at the opposite end of the arena is your opponent!<br>
            To engage in battle, select an attack from below. If you would not like to battle, you may simply leave this page.<br>"
FALSE));
            
$this->exploreButton("Use_Bite"FALSE"Bite");
            
$this->exploreButton("Use_Tackle"FALSE"Tackle");
            
$this->exploreButton("Use_Trick"FALSE"Trick");
        } 
        if(
$mysidia->input->post("area")){
            
            
$area $mysidia->input->post("area");

            
$document->setTitle("Battle");
        
            switch (
$area){
                case 
"Use_Bite"
                    
$opbite $opspeed $opstrength;
                    
$bite $favpet->speed $favpet->strength;
                    
$prize rand(25,50);
                    
$currentcash $mysidia->user->money;
                    
$newmoney $prize $currentcash;
                    if(
$bite $opbite){
                        
$document->add(new Comment("<br><br><table align='center' border='0px'>
                <tr>
                    <td width='40%' style='text-align:left;vertical-align:bottom;'>
                    <i>
{$favpet->name}</i><br>
                    <b>Sense:</b> 
{$favpet->sense}<br>
                    <b>Speed:</b> 
{$favpet->speed}<br>
                    <b>Strength:</b> 
{$favpet->strength}<br>
                    <b>Stamina:</b> 
{$favpet->stamina}<br>
                    </td>
                    <td width='20%'>
                    <center><b>VS</b></center>
                    </td>
                    <td width='40%' style='text-align:right;vertical-align:bottom'>
                    <i>Opponent</i><br>
                    <b>Sense:</b> 
{$opsense}<br>
                    <b>Speed:</b> 
{$opspeed}<br>
                    <b>Strength:</b> 
{$opstrength}<br>
                    <b>Stamina:</b> 
{$opstamina}<br>
                    </td>
                </tr>
            </table><br><center>Your pet dives in and attacks your opponent with a bite dealing 
{$bite} damage.
                        <br>The opponent counters the attack with 
{$opbite} damage, but it isn't enough!<br>
                        Your pet has won, and brought you 
{$prize} currency! Furthermore, {$favpet->name} has won a trophy!</center><br><br>"FALSE));
                        
$mysidia->db->update("users", array("money" => $newmoney), "username='{$mysidia->user->username}'");
                        
$mysidia->db->update("owned_adoptables", array("trophies" => $newtrophy), "aid='{$profile->getFavpetID()}'");
                    }
                    else{
                        
$document->add(new Comment("<br><br><table align='center' border='0px'>
                <tr>
                    <td width='40%' style='text-align:left;vertical-align:bottom;'>
                    <i>
{$favpet->name}</i><br>
                    <b>Sense:</b> 
{$favpet->sense}<br>
                    <b>Speed:</b> 
{$favpet->speed}<br>
                    <b>Strength:</b> 
{$favpet->strength}<br>
                    <b>Stamina:</b> 
{$favpet->stamina}<br>
                    </td>
                    <td width='20%'>
                    <center><b>VS</b></center>
                    </td>
                    <td width='40%' style='text-align:right;vertical-align:bottom'>
                    <i>Opponent</i><br>
                    <b>Sense:</b> 
{$opsense}<br>
                    <b>Speed:</b> 
{$opspeed}<br>
                    <b>Strength:</b> 
{$opstrength}<br>
                    <b>Stamina:</b> 
{$opstamina}<br>
                    </td>
                </tr>
            </table><br><center>Your pet dives in and attacks your opponent with a bite dealing 
{$bite} damage.
                        <br>The opponent counters the attack with 
{$opbite} damage, and manages to over power {$favpet->name}!<br>
                        Unfortunately your pet lost...better luck next time!</center><br><br>"
FALSE));
                    }
                break;
                case 
"Use_Tackle"
                    
$optackle $opstrength $opstamina;
                    
$tackle $favpet->strength $favpet->stamina;
                    
$prize rand(25,50);
                    
$currentcash $mysidia->user->money;
                    
$newmoney $prize $currentcash;
                    if(
$tackle $optackle){
                        
$document->add(new Comment("<br><br>
                        <table align='center' border='0px'>
                    <tr>
                    <td width='40%' style='text-align:left;vertical-align:bottom;'>
                    <i>
{$favpet->name}</i><br>
                    <b>Sense:</b> 
{$favpet->sense}<br>
                    <b>Speed:</b> 
{$favpet->speed}<br>
                    <b>Strength:</b> 
{$favpet->strength}<br>
                    <b>Stamina:</b> 
{$favpet->stamina}<br>
                    </td>
                    <td width='20%'>
                    <center><b>VS</b></center>
                    </td>
                    <td width='40%' style='text-align:right;vertical-align:bottom'>
                    <i>Opponent</i><br>
                    <b>Sense:</b> 
{$opsense}<br>
                    <b>Speed:</b> 
{$opspeed}<br>
                    <b>Strength:</b> 
{$opstrength}<br>
                    <b>Stamina:</b> 
{$opstamina}<br>
                    </td>
                </tr>
            </table><br><center>Your pet launches forward and slams into the opponent, dealing 
{$tackle} damage!
                        <br>The opponent counters the attack with 
{$optackle} damage, but it isn't enough!<br>
                        Your pet has won, and brought you 
{$prize} currency! Furthermore, {$favpet->name} has won a trophy!</center><br><br>"FALSE));
                        
$mysidia->db->update("users", array("money" => $newmoney), "username='{$mysidia->user->username}'");
                        
$mysidia->db->update("owned_adoptables", array("trophies" => $newtrophy), "aid='{$profile->getFavpetID()}'");
                    }
                    else{
                        
$document->add(new Comment("<br><br>
                        <table align='center' border='0px'>
                    <tr>
                    <td width='40%' style='text-align:left;vertical-align:bottom;'>
                    <i>
{$favpet->name}</i><br>
                    <b>Sense:</b> 
{$favpet->sense}<br>
                    <b>Speed:</b> 
{$favpet->speed}<br>
                    <b>Strength:</b> 
{$favpet->strength}<br>
                    <b>Stamina:</b> 
{$favpet->stamina}<br>
                    </td>
                    <td width='20%'>
                    <center><b>VS</b></center>
                    </td>
                    <td width='40%' style='text-align:right;vertical-align:bottom'>
                    <i>Opponent</i><br>
                    <b>Sense:</b> 
{$opsense}<br>
                    <b>Speed:</b> 
{$opspeed}<br>
                    <b>Strength:</b> 
{$opstrength}<br>
                    <b>Stamina:</b> 
{$opstamina}<br>
                    </td>
                </tr>
            </table><br><center>Your pet launches forward and slams into the opponent, dealing 
{$tackle} damage!
                        <br>The opponent counters the attack with 
{$opbite} damage, and manages to over power {$favpet->name}!<br>
                        Unfortunately your pet lost...better luck next time!</center><br><br>"
FALSE));
                    }
                break;
                case 
"Use_Trick"
                    
$optrick $opsense $opspeed;
                    
$trick $favpet->sense $favpet->speed;
                    
$prize rand(25,50);
                    
$currentcash $mysidia->user->money;
                    
$newmoney $prize $currentcash;
                    if(
$trick $optrick){
                        
$document->add(new Comment("<br><br>
                        <table align='center' border='0px'>
                    <tr>
                    <td width='40%' style='text-align:left;vertical-align:bottom;'>
                    <i>
{$favpet->name}</i><br>
                    <b>Sense:</b> 
{$favpet->sense}<br>
                    <b>Speed:</b> 
{$favpet->speed}<br>
                    <b>Strength:</b> 
{$favpet->strength}<br>
                    <b>Stamina:</b> 
{$favpet->stamina}<br>
                    </td>
                    <td width='20%'>
                    <center><b>VS</b></center>
                    </td>
                    <td width='40%' style='text-align:right;vertical-align:bottom'>
                    <i>Opponent</i><br>
                    <b>Sense:</b> 
{$opsense}<br>
                    <b>Speed:</b> 
{$opspeed}<br>
                    <b>Strength:</b> 
{$opstrength}<br>
                    <b>Stamina:</b> 
{$opstamina}<br>
                    </td>
                </tr>
            </table><br><center>Your pet taunts the opponent and dashes out of the way at the last minute, tricking the opponent into running at the wall, dealing 
{$trick} damage!
                        <br>The opponent counters the attack with 
{$optrick} damage, but it isn't enough!<br>
                        Your pet has won, and brought you 
{$prize} currency! Furthermore, {$favpet->name} has won a trophy!</center><br><br>"FALSE));
                        
$mysidia->db->update("users", array("money" => $newmoney), "username='{$mysidia->user->username}'");
                        
$mysidia->db->update("owned_adoptables", array("trophies" => $newtrophy), "aid='{$profile->getFavpetID()}'");
                    }
                    else{
                        
$document->add(new Comment("<br><br>
                        <table align='center' border='0px'>
                    <tr>
                    <td width='40%' style='text-align:left;vertical-align:bottom;'>
                    <i>
{$favpet->name}</i><br>
                    <b>Sense:</b> 
{$favpet->sense}<br>
                    <b>Speed:</b> 
{$favpet->speed}<br>
                    <b>Strength:</b> 
{$favpet->strength}<br>
                    <b>Stamina:</b> 
{$favpet->stamina}<br>
                    </td>
                    <td width='20%'>
                    <center><b>VS</b></center>
                    </td>
                    <td width='40%' style='text-align:right;vertical-align:bottom'>
                    <i>Opponent</i><br>
                    <b>Sense:</b> 
{$opsense}<br>
                    <b>Speed:</b> 
{$opspeed}<br>
                    <b>Strength:</b> 
{$opstrength}<br>
                    <b>Stamina:</b> 
{$opstamina}<br>
                    </td>
                </tr>
            </table><br><center>Your pet taunts the opponent and dashes out of the way at the last minute, tricking the opponent into running at the wall, dealing 
{$trick} damage!
                        <br>The opponent counters the attack with 
{$optrick} damage, and manages to over power {$favpet->name}!<br>
                        Unfortunately your pet lost...better luck next time!</center><br><br>"
FALSE));
                    }
                break;
            }

            return;
        }
    }

    public function 
exploreButton($areaname$image_link ""$customtext ""$customimg ""){
        
$document $this->document;
        
        if (
$image_link){ /* Image Links */
            
             
if (!$customimg){ /* Area Logo Image */
                 
$imgname str_replace("*""'"$areaname);
                
$document->add(new Comment("
                    <form id='exploreform' action='battle' name='exploreform' method='post' role='form'>
                    <input id='area' name='area' type='hidden' value='
{$areaname}'>
                    <button id='
{$areaname}' class='btn-text btn-sm' value='battle' name='{$areaname}' type='submit'>
                    <img src=\"./images/
{$imgname}_logo.png\"/>
                    </button>
                    </form>
                "
FALSE)); 
             }
             
             else { 
/* Custom Link Image */
                 
$imgname str_replace("*""'"$customimg);
                
$document->add(new Comment("
                    <form id='exploreform' action='battle' name='exploreform' method='post' role='form'>
                    <input id='area' name='area' type='hidden' value='
{$areaname}'>
                    <button id='
{$areaname}' class='btn-text btn-sm' value='battle' name='{$areaname}' type='submit'>
                    <img src=\"./images/
{$imgname}\"/>
                    </button>
                    </form>
                "
FALSE)); 
             }
        } 
        
        else { 
/* Text-Only Links */
            
            
if (!$customtext){ /* Area Name Button */
                
$str str_replace("_"" "$areaname); $btn_name str_replace("*""'"$str);
                
$document->add(new Comment("
                    <form id='exploreform' action='battle' name='exploreform' method='post' role='form'>
                    <input id='area' name='area' type='hidden' value='
{$areaname}'>
                    <button id='
{$areaname}' class='btn-violet btn-sm' value='battle' name='{$areaname}' type='submit'>
                    
{$btn_name}
                    </button>
                    </form>
                "
FALSE));
            } 
            
            else { 
/* Custom Link Text */
                
$customtext str_replace("*""'"$customtext);
                
$document->add(new Comment("
                    <form id='exploreform' action='battle' name='exploreform' method='post' role='form'>
                    <input id='area' name='area' type='hidden' value='
{$areaname}'>
                    <button id='
{$areaname}' class='btn-violet btn-sm' style='display: inline;' value='battle' name='{$areaname}' type='submit'>
                    
{$customtext}
                    </button>
                    </form>
                "
FALSE));
            }
        }
        return;
    }
}    
?>
Note lines 20 and 24:
PHP Code:
if ($favpet->currentlevel 3
PHP Code:
if($favpet->currentlevel 3
These make it so that if the user's assigned fave pet must be level 3 in order to battle. Change this number to whichever suits your needs (and remember the levels start at 0 for the egg).

Also note lines 49, 108, and 169:
PHP Code:
    $prize rand(25,50); 
This determines how much the user will be awarded each time their pet wins. The first number (25) is the minimum amount, and the second number (50) is the maximum amount.

There are many places in the code where you can alter and customize the text to your liking. For example, each attack uses two different stats, combines them to get a total, and uses that total against a similar total for the opponent.

Ask about it if you have questions!

Continue reading below for a guide on adding a simply trophy system!
__________________
My Mods Site (1.3.4, 2020 Mods)

Last edited by Abronsyth; 10-13-2016 at 02:15 PM.
Reply With Quote
  #2  
Old 07-01-2016, 11:39 AM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 132,475
Abronsyth is on a distinguished road
Default

P.4: Trophies
Alright, finally ready for this!
Trophies are just another little extra thing that gives users more reason to engage in the battle system. I add extra incentive by rearranging my stats page to display based on number of trophies instead of clicks.

The battle code up above is already set up to add trophies, so no need to worry about that. We do have to set up the database, though.

Database
Go into phpMyAdmin, prefix_ownedadoptables, and add one new row with the following data:
Name Type Collation Null Default
trophies varchar(10) latin1_swedish_ci No 0

Displaying
Good job! Now in a file where you want to display the number of trophies (such as on the myadopts page, etc), you just need to include this to call it:
PHP Code:
$trophies $mysidia->db->select("owned_adoptables", array("trophies"), "aid = '{$adopt->getAdoptID()}'")->fetchColumn(); 
and this to display it:
PHP Code:
{$trophies
Stats Page
If you want to use the stats page to show adopts based on trophies instead of clicks there is just a minor adjustment to make.

Go to stats.php and change the FIRST line starting with "$stmt = " and replace that line with this:
PHP Code:
$stmt $mysidia->db->select("owned_adoptables", array("aid"), "1 ORDER BY trophies DESC LIMIT 10"); 
Now go into view/statsview.php...we have some things here to change so it actually displays the trophies.

Where you see the line $table->buildHeaders...replace it with this:
PHP Code:
$table->buildHeaders("Image""Name""Owner""Total Clicks""Trophies"); 
Now, scroll down to find this line:
PHP Code:
$cells->add(new String($adopt->getTotalClicks())); 
And add this right under it:
PHP Code:
$cells->add(new TCell($adopt->getTrophies())); 
That's it! You might also want to change the lang_stats.php file so that it reflects the changes.

P.5: Extras
You can add extra depth to this by creating other stats, such as health, battle skill, etc! Check out Dinocanid's health and mood mod, which could pair with this very nicely!
http://mysidiaadoptables.com/forum/s...ead.php?t=5263
__________________
My Mods Site (1.3.4, 2020 Mods)

Last edited by Abronsyth; 11-26-2016 at 08:28 AM.
Reply With Quote
  #3  
Old 07-18-2016, 03:08 PM
Missy Master's Avatar
Missy Master Missy Master is offline
Pet-Sim.Online
 
Join Date: Jan 2010
Posts: 475
Gender: Unknown/Other
Credits: 63,840
Missy Master is an unknown quantity at this point
Default

Surprised no one commented to this!

Thank you for making this, I'm going to try it on one or more of my sites!! This looks pretty fantastic!!
Reply With Quote
  #4  
Old 07-29-2016, 03:28 PM
Missy Master's Avatar
Missy Master Missy Master is offline
Pet-Sim.Online
 
Join Date: Jan 2010
Posts: 475
Gender: Unknown/Other
Credits: 63,840
Missy Master is an unknown quantity at this point
Default

Before I had a favpet selected, it came up ok and asked me to go choose a Companion -- I manually input the number of one of my pets in the appropriate section in the database (for the life of me I cannot remember how to just go choose one!) -- and got a white page!

This seems to be my time to get white pages haha. Got one on this and for every try at a public pet profile page so far ...



edit: Did find where to choose him in my account page, but still white page now for battle

Last edited by Missy Master; 07-29-2016 at 03:36 PM.
Reply With Quote
  #5  
Old 07-30-2016, 10:54 PM
Missy Master's Avatar
Missy Master Missy Master is offline
Pet-Sim.Online
 
Join Date: Jan 2010
Posts: 475
Gender: Unknown/Other
Credits: 63,840
Missy Master is an unknown quantity at this point
Default

Is anyone else using this or getting a white page from it ?

I'm two days from launching and I am considering not trying to use this, though it looks so fun ...
Reply With Quote
  #6  
Old 08-01-2016, 02:29 AM
Hwona's Avatar
Hwona Hwona is offline
Member
 
Join Date: Mar 2013
Posts: 620
Gender: Female
Credits: 57,599
Hwona is on a distinguished road
Default

This looks amazing! :D
__________________
Reply With Quote
  #7  
Old 08-01-2016, 08:03 PM
NobodysHero's Avatar
NobodysHero NobodysHero is offline
Co-Owner of MystFell
 
Join Date: Nov 2013
Posts: 144
Gender: Female
Credits: 21,675
NobodysHero is on a distinguished road
Default

I'm stoked for this! Can't wait to use it! Thanks, Abronsyth!
Reply With Quote
  #8  
Old 08-03-2016, 12:14 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 132,475
Abronsyth is on a distinguished road
Default

Missy Master, try doing it through the user CP instead? Go to /account/profile, and then select your pet from the drop down there. Then get back to me and let me know if it persists!
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #9  
Old 08-03-2016, 09:10 PM
Missy Master's Avatar
Missy Master Missy Master is offline
Pet-Sim.Online
 
Join Date: Jan 2010
Posts: 475
Gender: Unknown/Other
Credits: 63,840
Missy Master is an unknown quantity at this point
Default

Still not working :(

If I remove the fav pet from the database, the page loads .. but once that id is in there, nope!



'It seems you do not yet have not assigned a companion! Assign one and then come back. ' With no fav pet assigned. With one, white page!
Reply With Quote
  #10  
Old 09-01-2016, 10:26 PM
NobodysHero's Avatar
NobodysHero NobodysHero is offline
Co-Owner of MystFell
 
Join Date: Nov 2013
Posts: 144
Gender: Female
Credits: 21,675
NobodysHero is on a distinguished road
Default

Thought I would add in something here, maybe shed a little more light on the issue.

I'm seeing the same problem Missy did.

My error log is showing:
PHP Code:
[01-Sep-2016 22:15:11 America/ChicagoPHP Fatal error:  Uncaught exception 'Exception' with message 'Fatal Error: Class Owned_Adoptable either does not exist, or has its include path misconfigured!' in /home/mystfell/public_html/classes/class_loader.php:83
Stack trace
:
#0 [internal function]: Loader->load('Owned_Adoptable')
#1 /home/mystfell/public_html/view/battleview.php(18): spl_autoload_call('Owned_Adoptable')
#2 /home/mystfell/public_html/classes/class_frontcontroller.php(100): battleView->index()
#3 /home/mystfell/public_html/index.php(74): FrontController->render()
#4 /home/mystfell/public_html/index.php(78): IndexController::main()
#5 {main}
  
thrown in /home/mystfell/public_html/classes/class_loader.php on line 83
[01-Sep-2016 22:16:22 America/ChicagoPHP Notice:  Undefined variablecontroller in /home/mystfell/public_html/classes/class_language.php on line 111
[01-Sep-2016 22:16:22 America/ChicagoPHP Fatal error:  Cannot access protected property OwnedAdoptable::$currentlevel in /home/mystfell/public_html/view/battleview.php on line 20 
Reply With Quote
Reply


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 02:00 AM.

Currently Active Users: 856 (0 members and 856 guests)
Threads: 4,081, Posts: 32,029, 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