Mys 1.3.4 Alchemy Mod

Forum
Last Post
Threads / Messages

Hall of Famer

Administrator
Staff member
Administrator
Joined
Dec 15, 2008
Messages
4,564
Points
48
Location
United States
Mysidian Dollar
214,223
Well I've had the idea of working on an alchemy system since the initial Mys v1.3.0 release, but did not carry out for numerous reasons. Now I finally decided to give it a try and it took me only about 4-5 hours.

The idea of Alchemy is to mix two old items(called ingredients) to create a new item, which is normally rarer and more valuable(otherwise it does not justify the economics lol). The Alchemy Mod allows you to achieve just that, you can create some items that are rare or even impossible to obtain without performing alchemy. This will make your site considerably more interesting to a good number of your users, it also offers incentives for the act of item collection.

Below is a screenshot of the basic alchemy page, which allows you to choose two items to produce a new one. Note at this time being only two items can be used to produce a new item, there is no way to mix more than two:
2lxckkg.jpg


This mod also comes with ACP integration, in which the admins can create alchemy practices that allow users to create new items from the old ones. Admins can also manipulate the settings for Alchemy System on their sites. The entire system can be turned on/off at will, while admins can specify whether alchemy success chance is 100% always or less. Other settings such as cost of action, recipe/license requirement for performing alchemy are also configurable.

To install the mod, simply run the installer script located at yoursite.com/install/alchemy.php. If your site is in a subdirectory, just change the example url accordingly. I assume you all know what I mean by this so I wont explain further.

If you have a brand new site or have never ever modified any part of the script, you may simply download the .rar file I provided and uploading them to your server through ftp. If the only changes you made are the mods I've offered lately(gender ratio and item drop), you may give a try just uploading the files as well as good chance my mods are compatible with each other.

However, for advanced users who have heavily modified sites, you will need to make some changes manually. I will post a brief description on how to do that in the next post.

At last, I hope you enjoy the new mod I've made for Mys v1.3.4, unlike the old ones like gender ratio which were simply revised to be compatible with the new version. You can edit the alchemy system to as you wish, maybe altering its user interface or adding more functionality(such as multiple item mix rather than just two), its all up to you.

Hall of Famer
 

Attachments

  • Alchemy Mod v1.3.4.rar
    16.2 KB · Views: 99
For advanced users who have heavily modified sites, you may follow the procedure below to install this mod on your site. Ignore this post if your site works fine with simply uploading/overwriting files.

First of all, upload and run the installer script at yoursite.com/install/alchemy.php. This step is identical for all users, unless you wish to create tables/insert rows into database manually, but will be a pain with this mod.

Second, upload the following new files to your server. Most of these files do not exist in the base script so you wont run into file overwriting problems. The new files are:
/admincp/alchemy.php
/admincp/view/alchemyview.php
/classes/class_alchemy.php
/classes/class_alchemysetting.php
/classes/class_alchemyvalidator.php
/lang/admincp/lang_alchemy.php

You may do the same for the lang file: lang_inventory.php since I assume nobody has ever modified it. If the answer is opposite however, you may wish to search through the differences of the two lang files to see how to append new lang vars to your site. It shouldnt be difficult.

Alright then, in the next step you will need to modify some old script files. I hope you are ready. Now go to file /classes/class_adminsidebar.php and find these line:

PHP:
        $components->add(new Division(new Comment("Inventory", FALSE)));
        $inventory = new Division;
        $inventory->add(new Link("admincp/inventory/add", "Give Item to User"));
        $inventory->add(new Link("admincp/inventory/edit", "Edit User Inventory"));
        $inventory->add(new Link("admincp/inventory/delete", "Delete Users items"));
        $components->add($inventory);
Add below:

PHP:
        $components->add(new Division(new Comment("Alchemy", FALSE)));
        $alchemy = new Division;
        $alchemy->add(new Link("admincp/alchemy/add", "Create new Alchemy Practice"));
        $alchemy->add(new Link("admincp/alchemy/edit", "Edit Alchemy Practices"));
        $alchemy->add(new Link("admincp/alchemy/delete", "Remove Alchemy Practices"));
        $alchemy->add(new Link("admincp/alchemy/settings", "Change Alchemy Settings"));        
        $components->add($alchemy);
Next, go to file /classes/class_itemtablehelper.php and find the constructor:
PHP:
    public function __construct(){
        parent::__construct();      
    }
insert these two methods right below the constructor definition:
PHP:
    /**
     * The getItem method, fetches the item type.
     * @param int  $item
     * @access public
     * @return String
     */    
    public function getItem($item){
        if(empty($item)) return "N/A";
        else return $item;        
    }
    
    /**
     * The getItemImage method, fetches the item image.
     * @param id  $item
     * @access public
     * @return Image
     */
    public function getItemImage($item){    
        $item = new Item($item);
        $image = new Image($item->imageurl, $item->itemname);
        return $image;            
    }
Then go to script file /inventory.php and find the method toss() at:

PHP:
    public function toss(){
        $mysidia = Registry::get("mysidia");
        $item = new PrivateItem($mysidia->input->post("itemname"), $mysidia->user->username);  
        if($item->iid == 0) throw new ItemException("toss_none");
        
        if($mysidia->input->get("confirm")){
            $item->toss();
            return;
        }        
    }
Add a new method alchemy() right below it:

PHP:
    public function alchemy(){
        $mysidia = Registry::get("mysidia");
        $settings = new AlchemySetting($mysidia->db);
        if($settings->system == "disabled") throw new ItemException("alchemy_disabled");
        
        if($mysidia->input->post("iid") and $mysidia->input->post("iid2")){
            $alchemy = new Alchemy($mysidia->input->post("iid"), $mysidia->input->post("iid2"), $settings);
            $alchemy->mix();
            $this->setField("alchemy", $alchemy);
            return;
        }
        
        $stmt = $mysidia->db->select("inventory", array("iid", "itemname"), "owner = '{$mysidia->user->username}'");
        $map = $mysidia->db->fetchMap($stmt);
        $this->setField("itemMap", $map);
        $this->setField("settings", $settings);
    }
Now open the file /view/inventoryview.php and find these lines:

PHP:
        $mysidia = Registry::get("mysidia");
        $document = $this->document;
        $document->setTitle($mysidia->lang->inventory);
Add the three new lines below:

PHP:
        $document->addLangvar("You may manage these items as you like, or go to the alchemy page to make your own items: <br>");    
        $document->add(new Link("inventory/alchemy", "Use the Alchemy Service Now!"));    
        $document->add(new Comment("<br><br>"));
Next, find the toss() method at:
PHP:
    public function toss(){
        $mysidia = Registry::get("mysidia");
        $document = $this->document;
        if($mysidia->input->get("confirm")){
            $document->setTitle($this->lang->global_action_complete);
            $document->addLangvar("{$this->lang->toss}{$mysidia->input->post("itemname")}{$this->lang->toss2}");
            return;
        }
    
        $document->setTitle($this->lang->toss_confirm);
        $document->addLangvar($this->lang->toss_warning);    

        $confirmForm = new FormBuilder("confirmform", "toss/confirm", "post");
        $confirmForm->buildPasswordField("hidden", "action", "toss")
                    ->buildPasswordField("hidden", "itemname", $mysidia->input->post("itemname"))
                    ->buildButton("Please Toss", "confirm", "confirm");
        $document->add($confirmForm);            
    }
Append the alchemy() method right below it:

PHP:
    public function alchemy(){
        $mysidia = Registry::get("mysidia");
        $document = $this->document;
        
        if($mysidia->input->post("iid") and $mysidia->input->post("iid2")){
            $alchemy = $this->getField("alchemy");
            $newitem = $alchemy->getNewItem()->itemname;
            $document->setTitle($this->lang->alchemy_success);
            $document->addLangvar($this->lang->alchemy_newitem.$newitem.$this->lang->alchemy_newitem2);    
            return;        
        }

        $document->setTitle($this->lang->alchemy_title);
        $document->addLangvar($this->lang->alchemy);
        $itemMap = $this->getField("itemMap");
        $settings = $this->getField("settings");
        $alchemyFrom = new Form("alchemyform", "alchemy", "post");
        $alchemyFrom->add(new Comment("<b>Cost of performing Alchemy: {$settings->cost} {$mysidia->settings->cost}</b><br>"));
        
        $alchemyFrom->add(new Comment($mysidia->lang->alchemy_choose));        
        $items = new DropdownList("iid");
        $items->add(new Option("None Selected", "none"));
        if($itemMap->size() > 0){
            $iterator = $itemMap->iterator();
            while($iterator->hasNext()){
                $item = $iterator->nextEntry();
                $items->add(new Option($item->getValue(), $item->getKey()));
            }
        }        
        $alchemyFrom->add($items);

        $alchemyFrom->add(new Comment($mysidia->lang->alchemy_choose2));        
        $items2 = new DropdownList("iid2");
        $items2->add(new Option("None Selected", "none"));
        if($itemMap->size() > 0){
            $iterator = $itemMap->iterator();
            while($iterator->hasNext()){
                $item2 = $iterator->nextEntry();
                $items2->add(new Option($item2->getValue(), $item2->getKey()));
            }
        }        
        $alchemyFrom->add($items2);        
        $alchemyFrom->add(new Button("Let's mix the items now!", "submit", "submit"));
        $document->add($alchemyFrom);        
    }

At last, open the file /functions/functions_items.php and add a new function to the bottom of the script(right above the php closing tag). It does not really do anything other than preventing some kind of bugs/error messages from possibly emerging:

PHP:
function items_recipe($item, $adopt){
  $note = "The item {$item->itemname} is a recipe item, which cannot be used on any adoptable and can only be useful if you are performing alchemy.";
  return $note;
}

You are done with the modifications now, it was easier than you thought right? Anyway you may run into some problems, and in this case please post in this thread to let me know. I will find out where the errors are and fix them for you as soon as I get a chance.
 
Simply amazing HOF =)
Thanks, might do something like this for evolution stones or something
 
I don't suppose it'd be possible to also share a .zip file? I can't work with .rar files :(
 
Sure I can, although an .rar file is not that hard to work with if you download winrar.
 

Attachments

  • Alchemy Mod v1.3.4.zip
    18.3 KB · Views: 20
Yeh that is an awesome idea, I wanted something like that on mine ages ago, but I think my coders on hiatus and my photoshops been refusing to work, and I've been busy so I havent had much time for it. ^_^' I know I was playing with the idea of using a system like this to create potions, or make jewellery and trinkets, ect. Is there any chance of this being compatible with older versions of Mysidia? >.>'
 
What version of Mysidia Adoptables are you using? It shouldnt be difficult to get it to work with Mys v1.3.3, but not sure for even older versions.
 
Lol I'm sticking with 1.3.2... unless I go insane and try to upgrade. XD I was alright until I lost contact with my coder... I'm just praying nothing breaks now. >.>' And its okay if its too hard or difficult, I'll just have to either figure out something else, or just not do it. ^_^'

EDIT: My coders still around! :D She's just busy working on her own site, she said she'll take a quick look at this sometime. ^_^
 
Last edited:
Okay, uploaded everything and tried to run the installer, but ran into this;

Warning: require(../inc/config.php): failed to open stream: No such file or directory in /home/ferrepet/public_html/classes/class_initializer.php on line 97

Warning: require(../inc/config.php): failed to open stream: No such file or directory in /home/ferrepet/public_html/classes/class_initializer.php on line 97

Fatal error: require(): Failed opening required '../inc/config.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/ferrepet/public_html/classes/class_initializer.php on line 97
 
This is strange, the url rewrite must be malfunctioning on your site. Do you have a .htaccess file in your install folder? If not, create an empty .htaccess file and upload it.
 
Oh btw, the htaccess.txt file in MyBB forum can also be used here. Just rename it as .htaccess and upload it to the install folder if you dont have one in the install directory. The mysidia root directory uses url rewrite, but the install and forum directories do not.
 
Uploaded an empty .htaccess file but I am still getting this error;

Warning: require(../inc/config.php): failed to open stream: No such file or directory in /home/ferrepet/public_html/classes/class_initializer.php on line 97

Warning: require(../inc/config.php): failed to open stream: No such file or directory in /home/ferrepet/public_html/classes/class_initializer.php on line 97

Fatal error: require(): Failed opening required '../inc/config.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/ferrepet/public_html/classes/class_initializer.php on line 97

I made sure that the file was a .htaccess and not a .txt or anything like that (notepad sometimes messes with that).
 
umm this... I remember you had a similar problem when you were installing the script, I forgot how it was resolved. Do you still remember that? And if you dont mind, send me a PM about your site ftp info and Id like to take a look on why your server is malfunctioning on .htaccess.
 
(late reply)
No, don't remember it, unfortunately. I'm having some problems connecting remotely to my site's FTP (something's wrong with the host), so I'll be changing hosts eventually (when I find an affordable one) and then will see about getting this to work again.
 
(Hopefully my questions make sense. I'm still a bit of a noob when it comes to coding and I'm having issues wording things correctly today)

I'm also having the same issue as Abronsyth with installing this mod. I had similar issues with uploading and installing the gender ratio and item drop mods, but when I manually installed those, it worked fine. Is there a way to fix the issue that's been coming up with this mod that's been discovered (and if so, I'd love to know what so I can add this mod as well!)? If not, what are the tables I need to create so I can manually install this one?
 
for those who can't create the database here is the manual install/creation or whatever you want to call it:
just use the "SQL" and copy/paste/change the following codes (remember to change `your_database` for your database name, and if you changed the adopts prefix, remember to change it too to the one you are using):

Code:
INSERT INTO `Your_database`.`adopts_acp_hooks` (`id`, `linktext`, `linkurl`, `pluginname`, `pluginstatus`) VALUES ('null', 'Alchemy Plugin v1.3.4 by Hall of Famer', 'http://www.mysidiaadoptables.com/forum/showthread.php?t=4368','alchemy', 'null')

Code:
INSERT INTO `Your_database`.`adopts_items_functions` (`ifid`, `function`, `intent`, `description`) VALUES ('null', 'recipe', 'no','This item function defines items that acts as recipe for alchemy practices.')

Code:
CREATE TABLE `adopts_alchemy` (alid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, item INT DEFAULT 0, item2 INT DEFAULT 0, newitem INT DEFAULT 0, chance INT DEFAULT 0, recipe INT DEFAULT 0)

Code:
CREATE TABLE `adopts_alchemy_settings` (asid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name varchar(20), value varchar(40))

Code:
INSERT INTO `Your_database`.`adopts_alchemy_settings` (`asid`, `name`, `value`) VALUES ('1', 'system', 'enabled'), ('2', 'chance', 'enabled'), ('3', 'recipe', 'enabled'), ('4', 'cost', '500'), ('5', 'license', ''), ('6', 'usergroup', 'all')

Please take in mind that this is how it worked for me, im using x10hosting and probably you will have to change/edit something, to make it work.
EDIT:
If you have no idea where to add the codes... I made a failed attempt of tutorial, but it will give you the idea of what to do and where to add the codes:
for me is in spanish, but most of the phpadmins are kind of similar

another thing i noticed, while looking at the intall is that the "INT" in most or all of the codes are not in Caps "int" probably this is one of the reasons the install is not working.

hope this help for those who want to install the mod.

by the way: IT WORKS!! THANKS HOF!!!!
 
Last edited:

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,118
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top