Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow creating instance without timer or data #5112

Merged
merged 42 commits into from Feb 11, 2022

Conversation

sader1992
Copy link
Contributor

@sader1992 sader1992 commented Jun 16, 2020

  • Server Mode: both
  • Description of Pull Request:
    this expansion to #4914
    instead of using a new command script like the previous pull request
    now it uses the instance system

adding 2 new setting for the instance db
NoNpc will prevent coping the npcs from the source map to the instance map (Default: false)
NoMapFlag will prevent coping the mapflags from the source map to the instance map (Default: false)
Edit 2 setting for the instance db
TimeLimit and IdleTimeOut now accept 0 as a valid time , which mean the time would be infinite.

a new command script *instance_list(<instance mode>,<"map name">);
with the new command script , you can get the live instances ids that have the map passed to
the new command , with the mode passed.

not really related but it's in the PR: (maybe create a separated pr for it ?)
fix an issue where if the instance id is provided and the instance not exist , the map server will crash.

Examples:
instances_db for test

  - Id: 100
    Name: prontera instance
    TimeLimit: 0
    IdleTimeOut: 0
    NoNpc: true
    NoMapFlag: true
    Enter:
      Map: prontera
      X: 153
      Y: 180
  - Id: 101
    Name: prontera instance2
    TimeLimit: 0
    IdleTimeOut: 0
    NoNpc: false
    NoMapFlag: false
    Enter:
      Map: prontera
      X: 153
      Y: 180
  - Id: 102 #pvp system
    Name: pvp system
    TimeLimit: 0
    IdleTimeOut: 0
    NoNpc: true
    NoMapFlag: true
    Enter:
      Map: guild_vs3
      X: 153
      Y: 180
    AdditionalMaps:
      pvp_n_1-5: true
      pvp_n_1-3: true

Npcs:

//create as much as you want from prontera and check the instance_list command
prontera,153,180,0	script	mapduplicate_test	444,{
	switch( select( "Create new duplicate to prontera", "Names list" ) ) {
	case 1:
		debugmes "Instance ID: " + instance_create("prontera instance", IM_NONE);
		end;
	case 2:
		.@size = instance_list(IM_NONE, "prontera");	// save the instance IDs in .@instance_list and return the size list
		if (.@size == 0) {
			mes "No maps on the list yet";
			end;
		}
		mes "Select a map to warp to it!";
		for ( .@i = 0; .@i < .@size; ++.@i )
			.@menu$ += instance_mapname("prontera", .@instance_list[.@i]) + ":";
		.@s = select(.@menu$) -1;
		if (instance_enter("prontera instance",155,183,getcharid(0),.@instance_list[.@s]) != IE_OK) {
			mes "The map doesn't exist anymore.";
			end;
		}
	}
}
//this for testing the NoNpc and NoMapflag options
prontera,155,179,0	script	mapduplicate_test2	444,{
	if(select("nodata:data") == 1){
		switch( select( "Create:Enter:Destroy:info" ) ) {
		case 1:
			$instance_id__ = instance_create("prontera instance", IM_NONE);
			debugmes "Instance ID: " + $instance_id__;
			end;
		case 2:
			if (instance_enter("prontera instance",155,183,getcharid(0),$instance_id__ ) != IE_OK) {
				mes "The map doesn't exist anymore.";
				end;
			}
			end;
		case 3:
			instance_destroy $instance_id__ ;
			end;
		case 4:
			debugmes instance_mapname("prontera",$instance_id__ );
			end;
		}
	}else{
		
		switch( select( "Create:Enter:Destroy:info" ) ) {
		case 1:
			$instance_id__2 = instance_create("prontera instance2", IM_NONE);
			debugmes "Instance ID: " + $instance_id__2;
			end;
		case 2:
			if (instance_enter("prontera instance2",155,183,getcharid(0),$instance_id__2) != IE_OK) {
				mes "The map doesn't exist anymore.";
				end;
			}
			end;
		case 3:
			instance_destroy $instance_id__2;
			end;
		case 4:
			debugmes instance_mapname("prontera",$instance_id__2);
			end;
		}
	}
}

a last example , a pvp leader with this new system
pvp_leader.txt

TODO: make a script command to insert new instances to the database temporarily

sader1992 and others added 3 commits Jun 16, 2020
Allow creating instance with no timer
no npcs and no mapflag
this could work as a map duplucation
at the same time we can use instance commands to interact with the maps
fix an issue where trying to enter a non existing instance map with id provided.

Co-Authored-By: Atemo <atemo@users.noreply.github.com>
Co-Authored-By: Atemo <atemo@users.noreply.github.com>
Co-Authored-By: Atemo <atemo@users.noreply.github.com>
@sader1992
Copy link
Contributor Author

@sader1992 sader1992 commented Jun 16, 2020

I'm fine with the idea but I would rather use and update the current instance system since it uses it as base, unless you are against, for example with

  • allow infinite instance timer
  • a command to change the timer of a running instance eventually
  • a command to retrieve the instance id by type eventually
  • a command to keep (or not) the instance on reloadscript
  • a command to create dummy instance data, the data in instance_db.yml for dynamical script, eventually

NPC script example

  - Id: 100
    Name: prontera instance
    TimeLimit: -1
    Enter:
      Map: prontera
      X: 155
      Y: 183
prontera,153,180,0	script	mapduplicate_test	444,{
	switch( select( "Create new duplicate to prontera", "Names list" ) ) {
	case 1:
		debugmes "Instance ID: " + instance_create("prontera instance", IM_NONE);
		end;
	case 2:
		.@size = instance_list(IM_NONE, "prontera");	// save the instance IDs in .@instance_list and return the size list
		if (.@size == 0) {
			mes "No maps on the list yet";
			end;
		}
		mes "Select a map to warp to it!";
		for ( .@i = 0; .@i < .@size; ++.@i )
			.@menu$ += instance_mapname("prontera", .@instance_list[.@i]) + ":";
		.@s = select(.@menu$) -1;
		if (instance_enter("prontera instance",155,183,getcharid(0),.@instance_list[.@s]) != IE_OK) {
			mes "The map doesn't exist anymore.";
		end;
	}
}

@Atemo sorry I moved the PR
Will check the rest of the command scripts mentioned , however I think this a good start maybe

Co-Authored-By: Atemo <atemo@users.noreply.github.com>
db/import-tmpl/instance_db.yml Outdated Show resolved Hide resolved
src/map/instance.cpp Outdated Show resolved Hide resolved
src/map/script.cpp Outdated Show resolved Hide resolved
sader1992 and others added 7 commits Jun 19, 2020
Co-Authored-By: Atemo <atemo@users.noreply.github.com>
Co-Authored-By: Atemo <atemo@users.noreply.github.com>
Co-Authored-By: Atemo <atemo@users.noreply.github.com>
@attackjom
Copy link
Contributor

@attackjom attackjom commented Jun 27, 2020

if NoNPC has true , so how to make NPC inside instance ?

@sader1992
Copy link
Contributor Author

@sader1992 sader1992 commented Jun 27, 2020

@attackjom the idea is maybe later we could pr create npc commands into rathena
or the users can use duplicate npc command from the forum
this is a script example i am using right now to test the system

Branch Room
(Note: i src edit the nobranch mapflag to work the opposite way , so if a map does not have nobranch you can't use branchs)

  - Id: 50
    Name: Branch Room
    TimeLimit: 21600
    IdleTimeOut: 3600
    NoNpc: true
    NoMapFlag: true
    Enter:
      Map: guild_vs2
      X: 50
      Y: 50

(the script's mes is mostly not in English! , however you can see what happening by checking the script)
line 54
Mvp_Room.txt

this way we can use the same map for different systems without interfering with each other , and without effecting the original map.

Copy link
Contributor

@Atemo Atemo left a comment

Small review

db/import-tmpl/instance_db.yml Outdated Show resolved Hide resolved
doc/script_commands.txt Outdated Show resolved Hide resolved
src/map/instance.cpp Outdated Show resolved Hide resolved
src/map/instance.cpp Outdated Show resolved Hide resolved
src/map/instance.cpp Outdated Show resolved Hide resolved
src/map/instance.cpp Outdated Show resolved Hide resolved
src/map/instance.cpp Outdated Show resolved Hide resolved
src/map/instance.cpp Outdated Show resolved Hide resolved
src/map/script.cpp Outdated Show resolved Hide resolved
src/map/script.cpp Outdated Show resolved Hide resolved
sader1992 and others added 9 commits Jan 19, 2022
Co-authored-by: Atemo <Atemo@users.noreply.github.com>
Co-authored-by: Atemo <Atemo@users.noreply.github.com>
Co-authored-by: Atemo <Atemo@users.noreply.github.com>
Co-authored-by: Atemo <Atemo@users.noreply.github.com>
Co-authored-by: Atemo <Atemo@users.noreply.github.com>
Co-authored-by: Atemo <Atemo@users.noreply.github.com>
Co-authored-by: Atemo <Atemo@users.noreply.github.com>
remove un-needed exception
instance_list command now can accept one argument the map name , the mode is optional, if the mode is not provided all the maps with that src regardless of the mode will return their ids
instance_db.yml version is 2 now

Co-Authored-By: Lemongrass3110 <3517879+Lemongrass3110@users.noreply.github.com>
src/map/instance.hpp Outdated Show resolved Hide resolved
Allow minimum version 1 in the instance_db.yml

Co-Authored-By: Lemongrass3110 <3517879+Lemongrass3110@users.noreply.github.com>
Copy link
Member

@Lemongrass3110 Lemongrass3110 left a comment

Only small stuff now.
Rest looks perfect to me! :)

src/map/script.cpp Outdated Show resolved Hide resolved
src/map/script.cpp Outdated Show resolved Hide resolved
src/map/script.cpp Outdated Show resolved Hide resolved
src/map/script.cpp Outdated Show resolved Hide resolved
src/map/script.cpp Outdated Show resolved Hide resolved
sader1992 and others added 5 commits Jan 27, 2022
Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
@Lemongrass3110
Copy link
Member

@Lemongrass3110 Lemongrass3110 commented Jan 31, 2022

@Atemo from my side its fine. For my side you can decide when or if we want to merge it. :)

Copy link
Contributor

@aleos89 aleos89 left a comment

Just some minor things!

db/import-tmpl/instance_db.yml Outdated Show resolved Hide resolved
db/instance_db.yml Outdated Show resolved Hide resolved
db/pre-re/instance_db.yml Outdated Show resolved Hide resolved
db/re/instance_db.yml Outdated Show resolved Hide resolved
doc/yaml/db/instance_db.yml Outdated Show resolved Hide resolved
doc/script_commands.txt Outdated Show resolved Hide resolved
doc/script_commands.txt Outdated Show resolved Hide resolved
doc/script_commands.txt Outdated Show resolved Hide resolved
src/map/script.cpp Outdated Show resolved Hide resolved
sader1992 and others added 9 commits Jan 31, 2022
Co-authored-by: Aleos <aleos89@users.noreply.github.com>
Co-authored-by: Aleos <aleos89@users.noreply.github.com>
Co-authored-by: Aleos <aleos89@users.noreply.github.com>
Co-authored-by: Aleos <aleos89@users.noreply.github.com>
Co-authored-by: Aleos <aleos89@users.noreply.github.com>
Co-authored-by: Aleos <aleos89@users.noreply.github.com>
Co-authored-by: Aleos <aleos89@users.noreply.github.com>
Co-authored-by: Aleos <aleos89@users.noreply.github.com>
Co-authored-by: Aleos <aleos89@users.noreply.github.com>
@sader1992
Copy link
Contributor Author

@sader1992 sader1992 commented Jan 31, 2022

there is one thing that I keep thinking about for this PR
instead of having NoNpc and NoMapFlag option as a database entries, is to have those options in the instance_create command script.
so in that case we can use the existing instances, also we don't need to edit the database to do this.
something like

instance_create("<instance name>"{,<instance mode>{,<owner id>{,<No Data?>}}});

where "No Data" is false by default , if true there would be no npcs/mapflags in the instance.

@Atemo
Copy link
Contributor

@Atemo Atemo commented Feb 3, 2022

imo the NoNpc and NoMapFlag should be in the db, it's not something you want to change from an instance to another

@Atemo Atemo merged commit ac7292c into rathena:master Feb 11, 2022
33 checks passed
@Atemo
Copy link
Contributor

@Atemo Atemo commented Feb 11, 2022

Thanks!

@Emistry
Copy link
Contributor

@Emistry Emistry commented Mar 5, 2022

question, if the instance last forever, does it still restricted by this limit?

#define MAX_MAP_PER_SERVER 1500 /// Maximum amount of maps available on a server

if normal instance also sharing this limit, and if the server owner didn't control the amount of instances they created, all instance in game could be affected, all instance will be end up in queue i guess?
anyway this scenario probably only happen if the server didnt control the amount of instance they created.

@aleos89
Copy link
Contributor

@aleos89 aleos89 commented Mar 5, 2022

Yes that limit is still applicable. The source in rAthena is setup to start back over with using the map ID once it reaches the cap. As long as the instance is destroyed at some point, or usage of party/guild requirements to start infinite duration instances, it should be able to support a good amount.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants