Jump to content

r17386: Instance System Rewrite!


Akinari

Recommended Posts


  • Group:  Members
  • Topic Count:  32
  • Topics Per Day:  0.01
  • Content Count:  247
  • Reputation:   207
  • Joined:  10/23/12
  • Last Seen:  

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 scripts

This 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 OnInstanceInit

Before 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 made

With 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 @reloadscript

One 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 rewritten

With 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 map

In 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.

    *instance_create("<instance name>");
     
    Creates an instance for the party of the attached player. The instance name,
    along with all other instance data, is read from 'db/(pre-)re/instance_db.txt'.
    Upon success, the command generates a unique instance ID, duplicates all listed
    maps and NPCs, sets the alive time, and triggers the "OnInstanceInit" label in
    all NPCs inside the instance.
     
    The command returns the instance ID upon success, and these values upon failure:
     -1: Invalid type.
     -2: Party not found.
     -3: Instance already exists.
     -4: No free instances (MAX_INSTANCE exceeded).
     
    ---------------------------------------
     
    *instance_enter("<instance name>");
     
    Warps player to the specified instance after the script terminates. The map and
    coordinates are located in 'db/(pre-)re/instance_db.txt'.
     
    The command returns 0 upon success, and these values upon failure:
     1: Party not found.
     2: Party does not have an instance.
     3: Other errors (invalid instance name, instance doesn't match with party).
     
    ---------------------------------------
     
    *instance_mapname("<map name>"{,<instance id>});
     
    Returns the unique name of the instanced map. If no instance ID is specified,
    the instance the script is attached to is used. If the script is not attached to
    an instance, the instance of the currently attached player's party is used. If
    that fails, the command returns an empty string instead.
     
    ---------------------------------------

 

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

  • Upvote 8
  • Like 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

Amazing work, Akinari! Hopefully we'll see some more instance scripts in the future because of this... :3

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  27
  • Reputation:   1
  • Joined:  03/05/13
  • Last Seen:  

Amazing work!

 

Thank for hard work!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  53
  • Reputation:   4
  • Joined:  02/08/12
  • Last Seen:  

I always wonder how to easy make an instance,

this change is wonderfull!

 

Thanks Akinari

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  1443
  • Reputation:   337
  • Joined:  10/17/12
  • Last Seen:  

Oh finally, been waiting for instance to be improved, thanks for this Akinari great work.

 

I guess i can start releasing instance scripts now~

  • Upvote 1
Link to comment
Share on other sites

  • 3 weeks later...

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  5
  • Reputation:   0
  • Joined:  04/16/12
  • Last Seen:  

I don't think this is a good work

even it could make scripts easy

but some instance script have to rewrite

I hope it can keep the old system ...

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  398
  • Reputation:   140
  • Joined:  01/04/12
  • Last Seen:  

I don't think this is a good work

even it could make scripts easy

but some instance script have to rewrite

I hope it can keep the old system ...

So you're saying you don't appreciate the hard work of the coders? It's better to rewrite some instance scripts than have them complicated for no reason. You'll be thankful when you write a new instance script.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  341
  • Reputation:   43
  • Joined:  01/10/12
  • Last Seen:  

I don't think this is a good work

even it could make scripts easy

but some instance script have to rewrite

I hope it can keep the old system ...

 

It's definitely a good work. So much easier with the new instance system.

If you have problem rewriting it, you can ask around. 

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  5
  • Reputation:   0
  • Joined:  04/16/12
  • Last Seen:  

I don't think this is a good work

even it could make scripts easy

but some instance script have to rewrite

I hope it can keep the old system ...

So you're saying you don't appreciate the hard work of the coders? It's better to rewrite some instance scripts than have them complicated for no reason. You'll be thankful when you write a new instance script.

I didn't say that. I just hope so the coders can keep the old system.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  105
  • Reputation:   67
  • Joined:  04/05/13
  • Last Seen:  

That would be counterproductive and pointless to keep two instancing systems around especially when the new one is much better overall and far less resource intensive than the old system.

Link to comment
Share on other sites

  • 6 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...