Jump to content
  • 0

New Instance System - how to?


Question

Posted

Hello,

i tried to make a map as instance. But i heard that there is a new instance system. How to use it? i have take a look at the script_commands.txt but dont get it... 

 

 

This is was i tried but dont work...

 

payon,150,155,1	script	NPC	723,{

set .@instance, instance_create("rent1 instanced", getcharid(1));
if( .@instance < 0 )
{
	mes "Failed to create the instance!";
	close;
}
if( instance_attachmap("rent1", .@instance) == "" )
{
 	instance_destroy(.@instance);
	mes "Failed to attach the map!";
	close;
}
instance_attach(.@instance);
instance_set_timeout(3600, 300, .@instance);
instance_init(.@instance);

warp "rent1", 20, 20;

}

 

23 answers to this question

Recommended Posts

Posted (edited)

3 rev. to eraly updated :(

 

So can you help to get the old system to run? 

 

If i click on the NPC the Loading screen come and than the client crash.

 

my code:

payon,150,155,1	script	House NPC	723,{

set .@instance, instance_create("rent1 instanced", getcharid(1));
if( .@instance < 0 )
{
	mes "Failed to create the instance!";
	close;
}
if( instance_attachmap("rent1", .@instance) == "" )
{
 	instance_destroy(.@instance);
	mes "Failed to attach the map!";
	close;
}
instance_attach(.@instance);
instance_set_timeout(3600, 300, .@instance);
instance_init(.@instance);

warp "rent1", 20, 20;

}

Message from Server:

[Info]: [Instance] Created: rent1 instanced.
[Info]: [Instance] Initialized rent1 instanced.
Edited by Loco
Posted

Functionality for maps not using the "1@instance" structure was not implemented until the rewrite. I'd really just suggest updating your SVN. ^^

Posted (edited)

Okey. For some reason(a lot of modification at the sourcecode from myself that have to be redone after update to newst rev.) i dont want to update to lastest rev. Can i only upgrade to 17386 to use the new system or is in this rev. big bugs?

Edited by Loco
Posted (edited)

Dont need to do it manualy because the only file that get a update at rev. 18387 that i modificate is /trunk/src/map/script.c so i will update and re edit the script.c. 

 

 

Thanks for your help  :)



Where can i download older rev like 17388?

Edited by Loco
Posted

So update to 17388 done.

 

Have changed the script but a error came when clicking the npc.

 

The map name is 1@rent and added to mapcache/mapindex/maps_athena.conf.

 

 

My Script:

 

payon,150,155,1    script    House NPC    723,{


instance_create ("House");
if (instance_create("House") < 0) // Check for a failure in creating instance
{
    mes "Failed to create the instance!";
    close;
}


instance_enter("House");


}
 

error:

[Debug]: mapindex_name2id: Map "houes1" not found in index list!
[Error]: instance_addmap: No maps added to instance 1.
[Info]: [Instance] Created: House.
 

 

Instance_db:

// Instance Database
//
// Structure of Database:
// ID,Name,LimitTime,EnterMap,EnterX,EnterY,Map1,Map2,Map3,Map4,Map5,Map6,Map7,Map8
//
0,Endless Tower,14400,1@tower,50,355,1@tower,2@tower,3@tower,4@tower,5@tower,6@tower
1,Sealed Catacomb,7200,1@cata,100,224,1@cata,2@cata
2,Orc's Memory,3600,1@orcs,179,15,1@orcs,2@orcs
3,Nidhoggur's Nest,14400,1@nyd,32,36,1@nyd,2@nyd
4,House,7200,1@rent,20,20,houes1,houes2,houes3,houes4,houes5,houes6,houes7,houes8,houes9

 

Posted
4,House,7200,1@rent,20,20,houes1,houes2,houes3,houes4,houes5,houes6,houes7,houes8,houes9
You need to specify map names; I don't know what 'houes1', etc. are supposed to be. If you want multiple copies of the same map, duplicate it (like Endless Tower) and add the duplicates to your database.
Posted (edited)
4,House,7200,1@rent,20,20,houes1,houes2,houes3,houes4,houes5,houes6,houes7,houes8,houes9
You need to specify map names; I don't know what 'houes1', etc. are supposed to be. If you want multiple copies of the same map, duplicate it (like Endless Tower) and add the duplicates to your database.

Yea i want mutiple copy for the map 1@rent. Have to look like these?

 

 

4,House,7200,1@rent,20,20,1@rent,2@rent,3@rent,4@rent,5@rent,6@rent,7@rent,8@rent
 

I dont get the new system to run. Can anybody make a small Tutorial what all have to do to make a custom map as instance?

Edited by Loco
Posted

if i try to @warp the client crashe's. dont know what the prob is. everything seems ok.

But you can post the script so i can use it when i fix the map problem. Also a little tutorial what all need to get configuared to make a map as instance.

Posted

Ok, so the first step is specifying the instance in your db/[pre-]re/instance_db.txt like this:

ID,Name,LimitTime,EnterMap,EnterX,EnterY,Map1,Map2,Map3,Map4,Map5,Map6,Map7,Map8

ID is the instance's numerical identifier.

Name is the instance's name.

LimitTime is the time in seconds until the instance expires.

EnterMap, EnterX, EnterY are the maps and coordinates where you enter the instance.

Map1, ..., Map8 are the real names of the maps (if you want to make an instance of izlude, Map1 would be "izlude").

 

This results in:

14,Training Ground,7200,new_1-1,53,111,new_1-1,new_1-2,new_1-3

An instance of the maps new_1-1, new_1-2, and new_1-3 will be created. You will start at new_1-1 at the coordinates 53, 111 with a time limit of 2 hours.

 

My sample script with the basic commands needed looks like this:

prontera,150,150,0    script    Instance    100,{

    .@mdName$ = "Training Ground";
    
    mes "[Guard]";
    mes "How can I help you?";
    switch(select("Create Instance:Enter Instance:Warp:Destroy Instance")) {
        
        next;
        case 1:
            if (instance_create(.@mdName$) < 0) {
                mes "^0000ff" + .@mdName$ + "^000000 cannot be opened now.";
                close;
            }
            mes "[Guard]";
            mes "I will open up the tunnel to ^0000ff" + .@mdName$ + "^000000.";
            mes "I wish you good luck.";
            close;
            
        case 2:
            if (instance_enter(.@mdName$)) {
                mes "[Guard]";
                mes "There has been a problem with entering the instance.";
                close;
            }
            end;
            
        case 3:
            mes "[Guard]";
            mes "Where do you want to go?";
            switch(select("new_1-1:new_1-2:new_1-3")) {
            
                case 1:
                    close2;
                    if (instance_enter(.@mdName$)) {
                        mes "[Guard]";
                        mes "There has been a problem with entering the instance.";
                        close;
                    }                    
                    warp instance_mapname("new_1-1"), 53, 111;
                    end;
                    
                case 2:
                    close2;
                    if (instance_enter(.@mdName$)) {
                        mes "[Guard]";
                        mes "There has been a problem with entering the instance.";
                        close;
                    }    
                    warp instance_mapname("new_1-2"), 100, 9;
                    end;
                    
                case 3:
                    close2;
                    if (instance_enter(.@mdName$)) {
                        mes "[Guard]";
                        mes "There has been a problem with entering the instance.";
                        close;
                    }    
                    warp instance_mapname("new_1-3"), 96, 20;
                    end;            
            }
            
        case 4:
            instance_destroy();
            mes "[Guard]";
            mes "The instance has been destroyed.";
            close;
    }
}

You specify the instance's name (which is also used in the instance_db) to create and enter the instance.

The first case in this NPC shows how you can create an instance, simply with instance_create("name from database").

The second case shows how you enter the instance to the starting point you defined in the database

The third case is an example how to warp between maps of the same instance.

And last, but not least, you can destroy an instance with the fourth option.

  • Upvote 1
Posted (edited)

Thanks i will try the next days :) 

 

 

EDIT: 

 

 

Ok, so the first step is specifying the instance in your db/[pre-]re/instance_db.txt like this:

 

HI,

i have tested your sript for this i have copyed your line to instance_db and the NPC to my server. But when i click open instance the npc says: "Training Ground cannot be opened now.".

 

There is no message at the mapserver. I am at rev 17388... What can be the problem?

Edited by Loco
Posted

Is your character in a party? That's a requirement for instances.

Alternatively, you could replace case 1 with this code for a more specific error reporting:

            switch(instance_create(.@mdName$)) {
            
                case -4:
                    mes "[Guard]";
                    mes "No free instances.";
                    close;
                    
                case -3:
                    mes "[Guard]";
                    mes "Instance already exists.";
                    close;
                
                case -2:
                    mes "[Guard]";
                    mes "Party not found.";
                    close;
                    
                case -1:
                    mes "[Guard]";
                    mes "Invalid type.";
                    close;
                    
                default:
                    mes "[Guard]";
                    mes "I will open up the tunnel to ^0000ff" + .@mdName$ + "^000000.";
                    close;
            }
Posted

Omg, sure i forgot the party -.- Thanks



Edit:

 

How do i use a npc for intance? Have i only to set the npc coords at the instance map like normal or use special commands?

Posted

I haven't tinkered with the new instances too much yet, but as far as I know all NPCs get cloned to the instance maps, so you can write them once for the basic map and they'll automatically be place in your instance.

Maybe one of my more skilled colleagues can answer that one :D

Posted

Here's a small example of instancing Prontera.

10,Instanced Prontera,3600,prontera,155,150,prontera
prontera,150,150,0	script	Instanced Prontera#a	101,{

set .@instance$, "Instanced Prontera";

if (instance_id()) {

if (select("Enter Instance.:Cancel.") == 2) end;

if (instance_enter(.@instance$) != 0) {

mes "Instance entrance ^FF0000failed^000000.";

close;

}

} else {

if (select("Create Instance.:Cancel.") == 2) end;

if (instance_create(.@instance$) < 0) {

mes "Instance creation ^FF0000failed^000000.";

close;

}

mes "Instance created.";

close2;

instance_enter(.@instance$);

}

end;

OnInstanceInit:

disablenpc instance_npcname(strnpcinfo(0));

end;

}

prontera,150,150,0 script Instanced Prontera#b 101,{

if (.Finished) {

specialeffect2 EF_MVP;

getitem 512,1;

dispbottom "Congratulations!";

instance_destroy;

end;

}

mes "Are you ready to begin?";

next;

if(select("Yes.:No.") == 1) {

mes "Good luck.";

donpcevent instance_npcname("#ins_prontera_mobs")+"::OnEnable";

donpcevent instance_npcname(strnpcinfo(0))+"::OnDisable";

} else

mes "Take your time.";

close;

OnInstanceInit:

enablenpc instance_npcname(strnpcinfo(0));

set .Finished,0;

waitingroom "Click me!",0;

end;

OnDisable:

disablenpc instance_npcname(strnpcinfo(0));

end;

OnEnable:

enablenpc instance_npcname(strnpcinfo(0));

set .Finished,1;

end;

OnInit:

disablenpc strnpcinfo(0);

end;

}

prontera,0,0,0 script #ins_prontera_mobs -1,{

OnEnable:

set .@map$, instance_mapname("prontera");

set .@label$, instance_npcname(strnpcinfo(0))+"::OnMyMobDead";

mapannounce .@map$,"Welcome to Instanced Prontera.",bc_all;

sleep 4000;

mapannounce .@map$,"Kill 50 monsters for a prize.",bc_all;

sleep 1000;

freeloop(1);

for(set .@j,0; .@j<10; set .@j,.@j+1) {

set .@size, query_sql("SELECT ID FROM `mob_db` WHERE left(Sprite, 4) != 'meta' AND left(Sprite, 2) != 'E_' AND ~Mode & 32 AND EXP > 0 AND MVP1id = 0 AND DropCardid > 4000 AND DropCardid < 5000 AND ID < 2000 ORDER BY rand() LIMIT 100", .@mob);

for(set .@i,0; .@i<.@size; set .@i,.@i+1)

monster .@map$,0,0,"--ja--",.@mob[.@i],1,.@label$;

set .MyMobCount, .MyMobCount + .@size;

}

freeloop(0);

end;

OnMyMobDead:

set .@map$, instance_mapname("prontera");

set .@label$, instance_npcname(strnpcinfo(0))+"::OnMyMobDead";

if (.MyMobCount - mobcount(.@map$,.@label$) >= 50) {

killmonster .@map$,.@label$;

mapannounce .@map$,"Congrats. We're done here! Please return to me as soon as possible.",bc_all;

donpcevent instance_npcname("Instanced Prontera#b")+"::OnEnable";

}

end;

}

Posted

Here's a small example of instancing Prontera.

10,Instanced Prontera,3600,prontera,155,150,prontera
prontera,150,150,0	script	Instanced Prontera#a	101,{

	set .@instance$, "Instanced Prontera";

	if (instance_id()) {
		if (select("Enter Instance.:Cancel.") == 2) end;
		if (instance_enter(.@instance$) != 0) {
			mes "Instance entrance ^FF0000failed^000000.";
			close;
		}
	} else {
		if (select("Create Instance.:Cancel.") == 2) end;
		if (instance_create(.@instance$) < 0) {
			mes "Instance creation ^FF0000failed^000000.";
			close;
		}
		mes "Instance created.";
		close2;
		instance_enter(.@instance$);
	}
	end;

OnInstanceInit:
	disablenpc instance_npcname(strnpcinfo(0));
	end;
}

prontera,150,150,0	script	Instanced Prontera#b	101,{
	if (.Finished) {
		specialeffect2 EF_MVP;
		getitem 512,1;
		dispbottom "Congratulations!";
		instance_destroy;
		end;
	}
	mes "Are you ready to begin?";
	next;
	if(select("Yes.:No.") == 1) {
		mes "Good luck.";
		donpcevent instance_npcname("#ins_prontera_mobs")+"::OnEnable";
		donpcevent instance_npcname(strnpcinfo(0))+"::OnDisable";
	} else
		mes "Take your time.";
	close;

OnInstanceInit:
	enablenpc instance_npcname(strnpcinfo(0));
	set .Finished,0;
	waitingroom "Click me!",0;
	end;
OnDisable:
	disablenpc instance_npcname(strnpcinfo(0));
	end;
OnEnable:
	enablenpc instance_npcname(strnpcinfo(0));
	set .Finished,1;
	end;
OnInit:
	disablenpc strnpcinfo(0);
	end;
}

prontera,0,0,0	script	#ins_prontera_mobs	-1,{
OnEnable:
	set .@map$, instance_mapname("prontera");
	set .@label$, instance_npcname(strnpcinfo(0))+"::OnMyMobDead";

	mapannounce .@map$,"Welcome to Instanced Prontera.",bc_all;
	sleep 4000;
	mapannounce .@map$,"Kill 50 monsters for a prize.",bc_all;
	sleep 1000;

	freeloop(1);
	for(set .@j,0; .@j<10; set .@j,.@j+1) {
		set .@size, query_sql("SELECT ID FROM `mob_db` WHERE left(Sprite, 4) != 'meta' AND left(Sprite, 2) != 'E_' AND ~Mode & 32 AND EXP > 0 AND MVP1id = 0 AND DropCardid > 4000 AND DropCardid < 5000 AND ID < 2000 ORDER BY rand() LIMIT 100", .@mob);
		for(set .@i,0; .@i<.@size; set .@i,.@i+1)
			monster .@map$,0,0,"--ja--",.@mob[.@i],1,.@label$;
		set .MyMobCount, .MyMobCount + .@size;
	}
	freeloop(0);
	end;
OnMyMobDead:
	set .@map$, instance_mapname("prontera");
	set .@label$, instance_npcname(strnpcinfo(0))+"::OnMyMobDead";

	if (.MyMobCount - mobcount(.@map$,.@label$) >= 50) {
		killmonster .@map$,.@label$;
		mapannounce .@map$,"Congrats. We're done here! Please return to me as soon as possible.",bc_all;
		donpcevent instance_npcname("Instanced Prontera#b")+"::OnEnable";
	}
	end;
}

 

script message

[Debug]: Source (NPC): Instanced Prontera#a at prontera (150,150)

 

probability

if (instance_id()) {

...

}

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...