Jump to content
  • 0
Sign in to follow this  
Hibari

Question regarding Instance Limitations

Question

Hi, I'm currently running through some ideas and I just want to see if I am thinking correctly on this:

 

 

I am attempting to create an NPC that creates instances for whoever talks to it (after performing level checks and asking if they want to SOLO or PARTY run) and so far I cannot figure out how to allow a single script to control multiple instances. Is this natively possible with Hercules? For example, the player character talks to the NPC, the NPC after some dialogue options will create the dungeon instance and send the player or party to the instance, however, I also want other characters on the server to be able to make instances simultaneously with that same NPC script.

 

So the NPC can handle the player/party who created instance already, in addition to anyone else who wants to create their own instances at the same time. Multiple instances managed by one script, potentially using the same emulated map or instance map. I do not refer to a player being able to join an instance in progress. So far most of the code I have seen works around limiting instance creation to one every 4 hours or some other hard limit, but I wish not to do that. Let me reiterate that I would like for the script to create many, perhaps dozens of instances for whoever wants to create one at any given moment simultaneously and uniquely.

 

Ultimately my tests so far have brought me to only being able to create a single instance-- when another player comes and tries to create an instance, it fails because presumably there is already an instance created. I just want to know if it is possible given Hercules scripting engine to handle this, and if it is possible, what kind of method would I use?

 

 

Thanks for any input. I hope I am clear, if not please allow me to make clearer examples.

 

 

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Umm... so actually you're asking if instances can do the single thing they were created for?

 

Yes, one NPC can create as many instances at once as possible, be it solo or party. The only hard limit on instances iirc is that their *total* amount must not exceed 1000 at once.

 

Generally check out npc/instances folder.

Share this post


Link to post
Share on other sites
  • 0

Thanks for your response,

 

I've been studying the Endless Tower and other instances inside of that folder to get a better understanding of how they work, but so far my very basic instance script seems not to allow another to be created. As it is, this script will not allow the creation of multiple instances, am I correct?

 

prontera,155,191,6	script	Instancer	4_F_OPERATION,{

	//NPC Settings
	set npcname$,"^339999[Instancer]^000000";

	mes npcname$;
	mes "Bear with me while I initiate the first sequence.";
	next;

	//Define instance
	set .@instance, instance_create("AmatsuInstance", getcharid(3), IOT_CHAR);
	
	//Check if it was successful, then check if attaching is problematic
	if( .@instance < 0 ) {
	mes npcname$;
	mes "Failed to create the instance!";
	close;
	} if( instance_attachmap("amatsu", .@instance, 1, "amatsu2") == "" ) {
 	instance_destroy(.@instance);
 	mes npcname$;
	mes "Failed to attach Amatsu as a map!";
	close;
	}

//Finally initialize it
instance_attach(.@instance);
instance_set_timeout(300, 10, .@instance);
instance_init(.@instance);

//Success, let them know
mes npcname$;
mes "Initialization successful. Sending you off!";
next;

//Warp the player to this new instance.
warp "amatsu2", 198, 90;

}

 

I mean I realize this script is the most basic possible, but I did it to understand how instances are handled. This script under my understanding should be re-executable even if someone else created an instance simultaneously.. but when one player uses it, then another tries, it fails with "Failed to Initialize," at that stage. I know for sure I am missing something..

Edited by Hibari

Share this post


Link to post
Share on other sites
  • 0

hibari add me on skype; itzmichaelmorici. Im pretty familiar with instancing :D

Share this post


Link to post
Share on other sites
  • 0
if( instance_attachmap("amatsu", .@instance, 1, "amatsu2") == "" ) {

This line is your problem. If you use <new map name> ("amatsu2" in that case), the map will *always* be called that, so you need to either generate unique name each call, or leave it out ^_^

if( instance_attachmap("amatsu", .@instance, 1) == "" ) {

ETA: Also, never warp exactly to map unless you'll know resulting name, it's better to use instance_mapname.

warp instance_mapname("amatsu"), 198, 90;
Edited by Garr

Share this post


Link to post
Share on other sites
  • 0

@Aeromesi:

 

Thanks, I'll add you in a little while, I'm at work for most of the day now.

 

@@Garr

 

What a glaring error in my coding logic. Thank you very much. I'll revise and test based on that concept, but I'm sure it will work in that case.

 

 

Thanks for being so helpful and understanding.

Share this post


Link to post
Share on other sites

Join the conversation

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

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.