Jump to content

"when kill begin" doesnt work with regen but works with spawned mobs (/m 8001)


Go to solution Solved by Ace,

Recommended Posts

Hi!

 

I have a bug with my stonemap dungeon quest code.. i have this code:

		when kill with d.getf("nv") == 1 begin
			if pc.get_map_index() >= 4000000 and pc.get_map_index() < 4010000 then
				if d.count_monster() == 0 then
					d.notice("You Killed all Monster. You will teleport in 5 Seconds to Stage 2.")
					timer("get_out_dung_stonea", 5)
					d.setf("nv", 2)
					d.clear_regen()
					d.kill_all()
					clear_server_timer("leave_trt_fv", d.get_map_index())
				end
			end
		end

i kill all the stones and it doesnt trigger the d.notice()

when i spawn one more after ingame that one triggers..

when i spawn one with all the others alive, still not triggers.. what should i use to trigger the kill function?

  • Solution

ChatGPT:

 

Spoiler

Your issue is likely due to how d.count_monster() functions. The problem is that d.count_monster() may still be returning a non-zero value even after you kill all the stones, meaning the condition inside your if statement never evaluates to true.

Possible Solutions:

Use a Debug Notice to Check d.count_monster() Before your if d.count_monster() == 0 condition, add a debug notice:

when kill with d.getf("nv") == 1 begin
    if pc.get_map_index() >= 4000000 and pc.get_map_index() < 4010000 then
        d.notice("Remaining Monsters: "..d.count_monster()) -- Debugging
        if d.count_monster() == 0 then
            d.notice("You Killed all Monsters. You will teleport in 5 Seconds to Stage 2.")
            timer("get_out_dung_stonea", 5)
            d.setf("nv", 2)
            d.clear_regen()
            d.kill_all()
            clear_server_timer("leave_trt_fv", d.get_map_index())
        end
    end
end

This will show the actual monster count in real time.

Introduce a Short Delay Before Checking d.count_monster() Sometimes, Metin2's system does not immediately update d.count_monster(). You can add a small delay:

timer("check_monsters", 1)

And then create a separate event to check if d.count_monster() == 0 after a short delay.

Track Monsters Manually Instead of relying on d.count_monster(), you can track the remaining monsters manually:

when kill with d.getf("nv") == 1 begin
    if pc.get_map_index() >= 4000000 and pc.get_map_index() < 4010000 then
        local remaining = d.getf("monster_count") - 1
        d.setf("monster_count", remaining)
        d.notice("Remaining Monsters: "..remaining)
        if remaining <= 0 then
            d.notice("You Killed all Monsters. You will teleport in 5 Seconds to Stage 2.")
            timer("get_out_dung_stonea", 5)
            d.setf("nv", 2)
            d.clear_regen()
            d.kill_all()
            clear_server_timer("leave_trt_fv", d.get_map_index())
        end
    end
end

At the start of the dungeon, you should initialize d.setf("monster_count", total_monsters_spawned).

Summary:

Use d.notice() to debug d.count_monster()

Add a slight delay before checking d.count_monster()

Manually track monster count using d.setf()

Try debugging first to see if d.count_monster() updates correctly. Let me know what the debug output says! 🚀

 

  • Love 1

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • 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.