Instance System Rewrite!!
r17386 contains a complete instance system rewrite! In a nutshell this new instance system allows us to create instances in a much easier fashion as opposed to the 5+ steps it took before. With the introduction of an instance database, creating an instance within a script is as simple as a single command, as well as entering it. Everything in instance creation is now handled automatically, making scripting instances a breeze compared to before.
Features:
Separation of instances from maps and scriptsThis allows us to create a system that is independent of the main functions (killmonster, monster, warp) using a new command instance_mapname(); Now whenever specifying a map for an instance, we no longer need specific commands to have these src4instance checks. Everything related to instancing is also done on an as needed basis, which means there won't be extra processing on each script run to figure out whether you're in an instance or not.
Loading an instance automatically runs OnInstanceInitBefore it was an extra task taking generally 20-50 extra lines of unnecessary code. Now, when specifying your instance to create, this is no longer an issue.
Instance database files hold the instances to be madeWith a new database file that contains all the instances, we no longer have to manually add each instance map and attach it to the scripts. This is another way we've made a system that works for the scripters, not making the scripters work for the system. We've also added a useful @reload instancedb command to reload the instancedb in runtime.
Instances persist through @reloadscriptOne of the major reasons for this rewrite was to offer us the ability to use reloadscript and keep our instances in-tact. Now, when a reloadscript occurs, we reset all players to start of the instance and reset their timer. Instance persistence can be expanded upon later allowing us to store these into the SQL and even recreate them on server reboots!
Script commands rewrittenWith the new system, we've removed a set of commands. These include:
instance_attachmap
instance_attach
instance_set_timeout
instance_init
instance_detachmap
has_instance
Create instance of any mapIn the old system, we could only create instances of maps which were named to be instances because others would crash the client. Now you can create an instance of any map you'd like.
Usage:
To create an instance, first add it into the new database, then you can create it using instance_create and enter the instance with instance enter:
10,Instance Prontera,7200,prontera,150,150,prontera
if (instance_create("Instance Prontera") < 0) // Check for a failure in creating instance
instance_enter("Instance Prontera");
To make a monster in an instance, simply use the instance_mapname function.
areamonster instance_mapname("prontera"),155,150,160,155,"Prontera Octopus",2192,3;
You can refer to the rewritten instance scripts for more examples. Documentation for the new commands is below.
Special Thanks:
Euphy for suggesting this rewrite be done, doing hours of testing, and rewriting the scripts for the new system. It would have never been done without him.
Auriga the Japanese emulator for giving me a place to start as well as much of the code in the new system. It certainly made this task much easier.
Lemongrass for helping me out along the way and providing some code improvements in the final stages.
Lighta for help in fixing bugs.
The Future:
Expect expansions upon this project such as instance storing in SQL and possibly additional instance types such as guild instancing. Please remember to post bug reports in the proper area and if you have any questions or need help converting a script, don't hesitate to ask.
Commit 1
Commit 2