KeyWorld 87 Posted July 17, 2013 ROChargenPHP ROChargenPHP is a PHP tool made for Ragnarok Online private server to help them to solved a big problem : how to display game characters on the website ? So this tool comes at the rescue, parsing game data to render as an image the character/monster of your choice, base on your database or direct informations.It required PHP5 with the PDO and GD drivers installed. And atleast your game data uploaded to the server (data or/and GRF). FeaturesCore [*]Support for .spr, .act, .pal, .grf, ... [*].act file completed support (transparency, scale, color, rotate, ...) [*]Characters fully implemented ( body, head, hats, weapon, shield, robe, mount) with palettes support. [*]Can modify action, animation and direction. [*]Class to generate : Full Character / Character Head only / Monster-NPC-Homunculus / Avatar / Signature. [*]Cache system available (and can be set off) with configurable time to cache. [*]Emblem Loader available.Client [*]Data.ini file support (to list your GRFs) [*]Support GRF (0x200 version only without DES encryption - repack before uploading) - the data folder is always read first. [*]Auto-Extract files from GRF if needed (optimize performance) [*]Updater script available to convert some lua files to PHP.How to useReally url-friendly: myserver.com/chargen/<controller>/<data> // with url-rewritingmyserver.com/chargen/index.php/<controller>/<data> // without url-rewriting Example for my character called "KeyWorld":myserver.com/chargen/avatar/KeyWorld // avatarmyserver.com/chargen/signature/KeyWorld // signaturemyserver.com/chargen/character/KeyWorld // full Charactermyserver.com/chargen/characterhead/KeyWorld // Character's head You can change the default link by modify the array $routes in the index.php file:// $routes['url'] = controller$routes['/avatar/(.*)'] = 'Avatar';$routes['/character/(.*)'] = 'Character';$routes['/characterhead/(.*)'] = 'CharacterHead';$routes['/monster/(d+)'] = 'Monster';$routes['/signature/(.*)'] = 'Signature'; Custom displayAt least, the tool is really easy to use, here an example on how to display a static character: $chargen = new CharacterRender(); $chargen->action = CharacterRender::ACTION_READYFIGHT; $chargen->direction = CharacterRender::DIRECTION_SOUTHEAST; $chargen->body_animation = 0; $chargen->doridori = 0; // Custom data: $chargen->sex = "M"; $chargen->class = 4002; $chargen->clothes_color = 0; $chargen->hair = 5; $chargen->hair_color = 12; // ... head_top, head_mid, head_bottom, robe, weapon, shield, ... // Generate Image $img = $chargen->render(); imagepng($img); Examples / Demos Sources Get the source(Thanks to report all bugs)LicenseInstead of selling it, I give a try to "Open Source project with Donation".So if you think, you would have buy it if i was selling it, think to give a donation ? Notes [*]A directory "client" is in the project, it will be a good idea to move it to a directory not accessible by the user (for example /home/client/). [*]If you use generate images from GRFs you have to know it's a little slower, i recommend you in this case to allow the "AutoExtract" option to gain performance. [*]GRFs have to be save as 0x200 version without any encryption (even the official DES), good idea is to remove unused folders ( textures, wav, models).. [*]If you use the options Cache and AutoExtract, don't forget the script need to have a write access to the client and cache folder. [*]Thanks to Khazou for the acces to his server to fully testing the tool 12 evilpuncker, milk, Xgear and 9 others reacted to this Quote Share this post Link to post Share on other sites
quesoph 105 Posted July 17, 2013 Awesome! I will try this. thank you! Quote Share this post Link to post Share on other sites
jTynne 101 Posted July 17, 2013 Very nice! Thank you for the release KeyWorld! Quote Share this post Link to post Share on other sites
Renn 0 Posted July 17, 2013 This is great! Thanks for sharing Quote Share this post Link to post Share on other sites
Xgear 44 Posted July 17, 2013 Absolutely awesome (Y) Quote Share this post Link to post Share on other sites
thanna 11 Posted July 17, 2013 10/10 great work mate Quote Share this post Link to post Share on other sites
Angelmelody 221 Posted July 17, 2013 amazing....!!!! Quote Share this post Link to post Share on other sites
unknown 5 Posted July 17, 2013 where can i put the custom display can someone teach me Quote Share this post Link to post Share on other sites
KeyWorld 87 Posted July 17, 2013 Happy to see you like it ! where can i put the custom display can someone teach me Without using the core files and controllers, you have to do this (good to build a char simulator as ratemyserver has) : <?php define('__ROOT__', dirname(__FILE__) . '/'); // Loading CORE files require_once( __ROOT__ . 'core/class.Controller.php'); require_once( __ROOT__ . 'core/class.Cache.php'); require_once( __ROOT__ . 'core/class.Client.php'); require_once( __ROOT__ . 'core/class.DB.php'); // Initialize the client (load GRF, load DB, etc.) Client::init(); // What do you want to display ? // Full Character ? // So include the render needed require_once( __ROOT__ . 'render/class.CharacterRender.php' ); // Set up the header header('Content-type:image/png'); // Since you use class.CharacterRender, use it : $chargen = new CharacterRender(); // Set your datas here $chargen->action = CharacterRender::ACTION_READYFIGHT; // You can see constants in $chargen->direction = CharacterRender::DIRECTION_SOUTHEAST; // render/class.RORender.php $chargen->body_animation = 0; $chargen->doridori = 0; $chargen->sex = "M"; $chargen->class = 4002; $chargen->clothes_color = 0; $chargen->hair = 5; $chargen->hair_color = 12; $chargen->head_top = 0; $chargen->head_mid = 0; $chargen->head_bottom = 0; $chargen->weapon = 0; $chargen->shield = 0; $chargen->robe = 0; $chargen->option = 0; // Generate the image and display it $img = $chargen->render(); imagepng($img); ?> Quote Share this post Link to post Share on other sites
unknown 5 Posted July 17, 2013 why i cant see the avatar of my character? Quote Share this post Link to post Share on other sites
KeyWorld 87 Posted July 17, 2013 (edited) why i cant see the avatar of my character? Maybe it can't connect to your DB, or you don't have any files set in the client folder ? Try using the debug mode, uncomment the two lines in index.php to know if there is an error: ini_set('display_errors', 1); error_reporting(E_ALL); Edited July 17, 2013 by KeyWorld Quote Share this post Link to post Share on other sites
unknown 5 Posted July 17, 2013 why there is no picture of my character in my avatar only level and offline i can see Quote Share this post Link to post Share on other sites
KeyWorld 87 Posted July 17, 2013 Ok so it's a problem of data. You have to put a data folder with all your sprites and palette on client/data/. Or add your GRFs in client/ and modify data.ini with your grf files to load. If you don't have data, it can't render anything. Quote Share this post Link to post Share on other sites
unknown 5 Posted July 17, 2013 i add it already and paste also my grf but still not showing, gm account supported or not? Quote Share this post Link to post Share on other sites
unknown 5 Posted July 17, 2013 even monster not showing also, btw i dl the zip file in your github, later i will try the git Quote Share this post Link to post Share on other sites
KeyWorld 87 Posted July 17, 2013 GMs accounts are supported but don't render the GM skin (just the basic job). Try to remove the cache (index.php) during the test: Cache::$time = 15 * 60 ; // cache for 15 mins (set to 0 if you want to disable cache). Set it to 0, so if there is a change, you will see it in an instant instead of waiting 15 minutes. Try to check that your data files are in the proper location. You can also add a little check on core/class.Client.php to see if some files are not properly loaded: Replace: return "data://application/octet-stream;base64," . base64_encode($content); } } return false; } By return "data://application/octet-stream;base64," . base64_encode($content); } } header('Content-type:text/plain'); exit("Exiting. File not found {$local_path}."); return false; } Quote Share this post Link to post Share on other sites
unknown 5 Posted July 17, 2013 thanks its working now.... Quote Share this post Link to post Share on other sites
KeyWorld 87 Posted July 17, 2013 You're welcome Quote Share this post Link to post Share on other sites
Hyvraine 34 Posted July 18, 2013 Awesome! Thank you very much KeyWorld! Quote Share this post Link to post Share on other sites
KeyWorld 87 Posted July 18, 2013 Awesome! Thank you very much KeyWorld! You're welcome ! I forget to talk about three known problems related to PHP GD (it sucks !). I show you this problems in only one monster : The Bloody Knight ! [*]Do you see the fire ? There is a white rectangle around. this problems occurs on RGBA images in Sprite files when you try to merge them with the main image. [*]Check the shield, there is a white border around it. When rotating an image it's possible to have this problem : the image border is merging with the transparent background (which is white) and cause this bug. I replace the transparent background by a transparent white background to avoid getting a magenta border (or other flashy border). [*]Check the shield again, poor quality ! Due to image rotation + image scale. The problem n°1 just occurred in some monsters (effects), I don't think there is one hat or character using RGBA frames for now in RO. The problem n°2 and 3 can occurred in all monsters/characters, depend of the scale and rotation. To conclude, PHP GD sucks, I have noone of this problems in javascript (<3). Quote Share this post Link to post Share on other sites
Emistry 145 Posted July 18, 2013 this is amazing.. Quote Share this post Link to post Share on other sites
KeyWorld 87 Posted July 31, 2013 Addded a debug mode to trace errors in the latest version if you have problem installing it.Just open index.php and uncomment the line: // Set on the debug//Debug::enable(); Once it's done you will have access to all debugs, infos and errors: Hope it helps 1 evilpuncker reacted to this Quote Share this post Link to post Share on other sites
pr3p 39 Posted July 31, 2013 (edited) awesome release Keyword ... where to upload the grf's? Edited July 31, 2013 by pr3p Quote Share this post Link to post Share on other sites
KeyWorld 87 Posted July 31, 2013 awesome release Keyword ... where to upload the grf's? Thank you You have to upload it in the client folder (and complete the data.ini file). Quote Share this post Link to post Share on other sites
KeyWorld 87 Posted August 2, 2013 Updates : [*]Correct 3rd job file name. [*]Robes are now fully working (it was missing the inherent job list). [*]Background color can be change in RORender::$background_color. [*]Add htaccess to avoid access to client directory (if you have content you don't want to share...) Suggestions ? Bugs ? Problems ? Report it Quote Share this post Link to post Share on other sites