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: http://i.imgur.com/FyN6mnF.gif 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:
PHP Code:
PHP Code:
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:
After you add that, add this in just like we did for the other files: PHP Code:
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 Code:
Then, to change the charge, scroll to where you see the line PHP Code:
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:
This goes in the view folder. PHP Code:
PHP Code:
PHP Code:
Also note lines 49, 108, and 169: PHP Code:
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! |
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:
PHP Code:
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:
Where you see the line $table->buildHeaders...replace it with this: PHP Code:
PHP Code:
PHP Code:
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 |
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!! |
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 |
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 ... |
This looks amazing! :D
|
I'm stoked for this! Can't wait to use it! Thanks, Abronsyth!
|
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!
|
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! |
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:
|
Good news is, I partly found the answer to my question. For whatever reason, it can't pull from "currentlevel". Changing it to "AdoptLevel", "Level", and "CurrentLevel" allows the page to load, but doesn't allow me to battle, nor does it show my "favpet", insisting that my pet isn't level 1 or higher.
Looking at the error log after each save, seems like it keeps bumping on how to call the level of the pet. x.x So, now what? |
I can't get this to work either. I can get to the page just fine, but it keeps insisting that my favpet isn't level 3.
|
Quote:
I responded via PM but I'll paste this here for other's sakes: Try going into class_ownedadoptable.php and changing the line here: PHP Code:
PHP Code:
Everyone having the issue please make sure this has been done and then, once done, get back to me on it. |
THANK YOU! <3 Okay, so it didn't like that both the "currentlevel" and "name" were protected, instead of public. Changing that made it work for me!
|
Now that I have this working, I'd like to add some graphics and such to make it more fun to look at and give their opponent a "face". So, my question here is, how would I go about perhaps using random images above the "random opponent side? I know how to post the image of the pet, but a random image code would be awesome. 8D Would be neat to also use this to make it seem like the "battleground" as changed. Just a thought!
|
Oh yeah, that is totally doable! I actually originally had it set up that way but was having issues with aligning it in a way that looked really good...but the random opponent image isn't too difficult. You just need the images...so, where you add opponent stats add in this:
PHP Code:
PHP Code:
PHP Code:
Now I will note that I just wrote this without testing it at all, so I don't guarantee it'll work as is, but it should give you the general idea! |
Hey all! I updated the main post so that it now includes the training section! My method of training is very lazy at the moment, just spend some money, click a button, raise the stats.
I hope you all enjoy it <3 |
Finally updated!
Now includes a Trophies section, and a little extras section :) |
couple questions- I tried adding in the OP image coding but it keeps giving me errors... WHERE exactly do I put those? CAn you explain a little better please?
Also the trophies- where exactly and on which file do I put the calling code? As well as How would I get my fave pets image for battling as well? {$Favepet} does not seem to work lol (And how would I flip the images so they're actually facing each other?) EDIT: one more question- how would I make it so that they actually recieve items for winning? whether random or not so random lol... (Apologies as I am a super noob at this) |
1. In the battleview.php file find this:
PHP Code:
PHP Code:
2. You put the calling code wherever you want to display the trophies. So if you want to display it for the owner of a pet when they go to manage it, you can go to myadoptsview.php and add it within the manage function. This works best if you already have "profiles" set up. But for a quick example, here is the manage function with it added in: PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
|
Okay- I got it to mostly work XD Im still havign issues though- For example I did the calling codes etc- but It still wont show me the amount-
Instead for my pet it says "Spooka has Trophies" No number..I must be missing something... Heres my adoptsview.php file- PHP Code:
But my coder added stuff and Im not sure how to do that.. I want it in the "Skills" Tab... Here's my Petviewphp.. PHP Code:
|
In the myadopts.view I see that you place {$trophies} but I do not see anywhere that you actually designated what $trophies means, so that script basically doesn't know what you're asking it to show. Here's a version I modified of your manage function, try using it and let me know if it works:
PHP Code:
PHP Code:
|
Okay the one for myadopts.php gives me this error
Fatal error: Call to a member function getAdoptID() on null in /home/atrocity/public_html/view/myadoptsview.php on line 157 second one works like a charm ^^ |
Did you put it into myadoptsview.php or myadopts.php?
|
in myadoptsview
|
Alright, try changing the manage function in myadoptsview.php to this:
PHP Code:
|
That worked thanks!
|
Great! Let me know if you have other problems.
|
I'm not sure if I did something wrong when I changed the price of training but I absentmindedly pressed the button for training while I testing and noticed my money was in the negative.
|
@Corsair
Try adding this to see if it'll help (make sure to define $traincost): PHP Code:
Came up with a code to automatically change an adopt's stats emulating $mysidia->user->changecash(). This should be helpful updating the db with less code. Add it to /classes/class_ownedadoptable.php PHP Code:
PHP Code:
|
I'm not sure if I did something wrong when I changed the price of training but I absentmindedly pressed the button for training while I testing and noticed my money was in the negative.
need help with this |
Quote:
Quote:
|
ok :smile: and would you like to work with me an make a battling system where two user can battle online ??
|
Sorry, that is quite beyond my capabilities!
|
What would you suggest to limit the amount of training?
Say, you can only train any pet up to 5 times (regardless of stat) so you don't end up with a billion highly trained pets? It forces you to breed and train for better stats? |
I would add a new column to the owned_adoptables table in phpMyAdmin and call it something like "timestrained," with the default set to 0. Then each time that pet is trained add +1 to that column...then just include an if/else statement to exclude any pets that have been trained 5 times. So...something like...
http://orig01.deviantart.net/862c/f/...re-dbd0s8e.jpg Add this under the list of defined variables for training: PHP Code:
PHP Code:
PHP Code:
Let me know if that makes sense/works out! |
For what its worth, going back in all this time later, this brilliant Mod just needs all the attributes (sense, etc) changed to public instead of private.
I am much more php savvy a few years in -- and found it easy to get it working just fine! Highly recommend this awesome and fun Mod! Thanks again for it! |
All times are GMT -5. The time now is 01:35 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.