Jump to content

Dungeon Module


Recommended Posts

  • Active+ Member
This is the hidden content, please

Alternative download links → 

This is the hidden content, please

 

I like Aeldra's Nilay Dungeon so I made it.

Allows you to hit a metinstone up to 50% health and start a stage within the stage.

The logic is simple, do this to bosses etc. You can also adapt it.

I added an example dungeon quest usage, you can easily understand the logic.

 

Spoiler

 

 

  • Metin2 Dev 75
  • Good 14
  • Love 2
  • Love 37
Link to comment
Share on other sites

  • Premium

A couple heads-up:

  1. You don't need to clear a server_timer inside its own trigger unless it's a server_loop_timer. Normal timers get cleared upon triggering.
  2. You could've just used another dungeon flag to get the state, instead of using c++ shenanigans. The immunity part is also easily achievable without any source-sided input.
  3. Never forget something like the in_dungeon check I made in the kill trigger, it's very important that every code gets only triggered in our dungeon and not in other dungeons that share a similiar flag name for the level.


 

define DUNGEON_INDEX 999

define FLOOR2_METINSTONE_VNUM 42069
define FLOOR2_METINSTONE_SPAWN_LOCAL_X 333
define FLOOR2_METINSTONE_SPAWN_LOCAL_Y 666
define FLOOR2_METINSTONE_HP_THRESHOLD 50
define FLOOR2_REGEN_PATH "example_dungeon/x.txt"
define TIME_TO_WARP_NEXT 10

function new_zodiac_notice(str)
    d.zodiac_notice_clear();
    d.zodiac_notice(str);
end -- function

function in_dungeon(map_index)
    local pc_index = pc.get_map_index();
    return pc_index >= map_index*10000 and pc_index < (map_index+1)*10000;
end -- function

when dungeon_warp_to_2floor.server_timer begin
    local instance_arg = get_server_timer_arg();
    if (d.select(instance_arg)) then
        d.setf("level", 2);
        d.setf("2floor_metinstone_vid", d.spawn_mob(FLOOR2_METINSTONE_VNUM, FLOOR2_METINSTONE_SPAWN_LOCAL_X, FLOOR2_METINSTONE_SPAWN_LOCAL_Y));
        d.set_unique("2floor_metinstone", d.getf("2floor_metinstone_vid"));
        server_loop_timer("dungeon_2floor_control_metinstone_hp", 1, instance_arg);
        dungeon_name.new_zodiac_notice(string.format("<Floor 2 | Stage 1> Bring the Metinstone down to %d%% HPs", FLOOR2_METINSTONE_HP_THRESHOLD))
    end -- if
end -- when

when dungeon_2floor_control_metinstone_hp.server_timer begin
    local instance_arg = get_server_timer_arg();
    if (d.select(instance_arg)) then
        if (d.unique_get_hp_perc("2floor_metinstone") <= FLOOR2_METINSTONE_HP_THRESHOLD) then
            clear_server_timer("dungeon_2floor_control_metinstone_hp", instance_arg);
            npc.set_vid_damage_mul(d.getf("2floor_metinstone_vid"), 0.0001);
            d.regen_file(FLOOR2_REGEN_PATH);
            server_loop_timer("dungeon_2floor_control_monster_count", 3, instance_arg);
            dungeon_name.new_zodiac_notice("<Floor 2 | Stage 2> Kill all the monsters")
        end -- if
    end -- if
end -- when

when dungeon_2floor_control_monster_count.server_timer begin
    local instance_arg = get_server_timer_arg();
    if (d.select(instance_arg)) then
        if (d.count_monster() == 0) then
            clear_server_timer("dungeon_2floor_control_monster_count", instance_arg);
            npc.set_vid_damage_mul(d.getf("2floor_metinstone_vid"), 1.0);
            dungeon_name.new_zodiac_notice("<Floor 2 | Stage 3> Destroy the Metinstone")
        end -- if
    end -- if
end -- when

when kill with npc.get_race() == FLOOR2_METINSTONE_VNUM and dungeon_name.in_dungeon(DUNGEON_INDEX) and d.getf("level") == 2 begin
    d.clear_regen();
    d.kill_all();
    d.kill_all(); -- If there are resurrecting units.
    
    dungeon_name.new_zodiac_notice(string.format("<Floor 2 Completed> Warping to next floor in %d seconds..", TIME_TO_WARP_NEXT))
    server_timer("dungeon_warp_to_3floor", TIME_TO_WARP_NEXT, d.get_map_index());
end -- when

when dungeon_warp_to_3floor.server_timer begin
    local instance_arg = get_server_timer_arg();
    if (d.select(instance_arg)) then
        d.setf("level", 3);
        --
    end -- if
end -- when

This snippet behaves exactly the same and does not require any C++ input.

Edited by Syreldar
  • Love 1

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

  • Active+ Member
12 minutes ago, Syreldar said:

A couple heads-up:

  1. You don't need to clear a server_timer inside its own trigger unless it's a server_loop_timer. Normal timers get cleared upon triggering.
  2. You could've just used another dungeon flag to get the state, instead of using c++ shenanigans. The immunity part is also easily achievable without any source-sided input.


 

define FLOOR2_METINSTONE_VNUM 42069
define FLOOR2_METINSTONE_SPAWN_LOCAL_X 333
define FLOOR2_METINSTONE_SPAWN_LOCAL_Y 666
define FLOOR2_METINSTONE_HP_THRESHOLD 50
define FLOOR2_REGEN_PATH "example_dungeon/x.txt"
define TIME_TO_WARP_NEXT 10

function new_zodiac_notice(str)
    d.zodiac_notice_clear();
    d.zodiac_notice(str);
end -- function

when dungeon_warp_to_2floor.server_timer begin
    if (d.select(get_server_timer_arg())) then
        d.setf("level", 2);
        d.setf("2floor_metinstone_vid", d.spawn_mob(FLOOR2_METINSTONE_VNUM, FLOOR2_METINSTONE_SPAWN_LOCAL_X, FLOOR2_METINSTONE_SPAWN_LOCAL_Y));
        d.set_unique("2floor_metinstone", d.getf("2floor_metinstone_vid"));
        server_loop_timer("dungeon_2floor_control_metinstone_hp", 2, get_server_timer_arg())
        dungeon_name.new_zodiac_notice(string.format("<Floor 2 | Stage 1> Bring the Metinstone down to %d%% HPs", FLOOR2_METINSTONE_HP_THRESHOLD))
    end -- if
end -- when

when dungeon_2floor_control_metinstone_hp.server_timer begin
    if (d.select(get_server_timer_arg())) then
        if (d.unique_get_hp_perc("2floor_metinstone") <= FLOOR2_METINSTONE_HP_THRESHOLD) then
            clear_server_timer("dungeon_2floor_control_metinstone_hp", get_server_timer_arg());
            npc.set_vid_damage_mul(d.getf("2floor_metinstone_vid"), 0.0001);
            d.regen_file(FLOOR2_REGEN_PATH);
            server_loop_timer("dungeon_2floor_control_monster_count", 2, d.get_map_index());
            dungeon_name.new_zodiac_notice("<Floor 2 | Stage 2> Kill all the monsters")
        end -- if
    end -- if
end -- when

when dungeon_2floor_control_monster_count.server_timer begin
    if (d.select(get_server_timer_arg())) then
        if (d.count_monster() == 0) then
            clear_server_timer("dungeon_2floor_control_monster_count", get_server_timer_arg());
            npc.set_vid_damage_mul(d.getf("2floor_metinstone_vid"), 1.0);
            dungeon_name.new_zodiac_notice("<Floor 2 | Stage 3> Destroy the Metinstone")
        end -- if
    end -- if
end -- if

when kill with npc.get_race() == FLOOR2_METINSTONE_VNUM and d.getf("level") == 2 begin
    d.clear_regen();
    d.kill_all();
    d.kill_all(); -- If there are resurrecting units.
    
    dungeon_name.new_zodiac_notice(string.format("<Floor 2 Completed> Warping to next floor in %d seconds..", TIME_TO_WARP_NEXT))
    server_timer("dungeon_warp_to_3floor", TIME_TO_WARP_NEXT, d.get_map_index());
end -- when

when dungeon_warp_to_3floor.server_timer begin
    if (d.select(get_server_timer_arg())) then
        d.setf("level", 3);
        --
    end -- if
end -- when

This snippet behaves exactly the same and does not require any C++ input.

Thank you for your suggestions and corrections. 

Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.