Jump to content
  • 0

[Help] Daily/Weekly quest


Question

Posted

Hello!!

I'm trying to make a quest to kill X mobs and give you a reward. I already have it ready, or so I think.

 

Now I would like to add the function of making it daily or weekly. I've tried to control this in the same java file of the quest, but I haven't been able to...

 

I was thinking of putting a marker on the quest so that it is "daily" or "weekly" and ¿generating another java program? that is in charge of restarting all the quests with the daily marker at 9 in the morning every day and on Wednesdays at 9 every Wednesday.

 

Since I'm new to java programming (I had already programmed in bash) and developing l2j I don't know where I should create that program. Could it be in the java folder with a name like "org.l2jmobius.xxx.xxx"?

 

I don't know how to approach it because I don't understand the logic of the files and that how runs every day to reset quest with marker.

 

Could anyone help me understand this and explain how I should do it? I'm not asking for ready-made code, I can do that myself, but how to deal with it 😛

 

I also don't know if this method is better or in the java file itself (but I haven't managed to do it this way).

 

See you guys and thanks for all. 

2 answers to this question

Recommended Posts

  • 0
Posted (edited)
16 hours ago, gripao said:

Hello!!

I'm trying to make a quest to kill X mobs and give you a reward. I already have it ready, or so I think.

 

Now I would like to add the function of making it daily or weekly. I've tried to control this in the same java file of the quest, but I haven't been able to...

 

I was thinking of putting a marker on the quest so that it is "daily" or "weekly" and ¿generating another java program? that is in charge of restarting all the quests with the daily marker at 9 in the morning every day and on Wednesdays at 9 every Wednesday.

 

Since I'm new to java programming (I had already programmed in bash) and developing l2j I don't know where I should create that program. Could it be in the java folder with a name like "org.l2jmobius.xxx.xxx"?

 

I don't know how to approach it because I don't understand the logic of the files and that how runs every day to reset quest with marker.

 

Could anyone help me understand this and explain how I should do it? I'm not asking for ready-made code, I can do that myself, but how to deal with it 😛

 

I also don't know if this method is better or in the java file itself (but I haven't managed to do it this way).

 

See you guys and thanks for all. 


If you are this new to java, I would strongly recommend using IntelliJ Community Edition (free) instead of Eclipse since it indexes your entire source and makes it extremely easy to navigate forward and backward dependencies and method calls.

Now, on the topic.

Unless your Mobius sources are ancient, they should already have native support. It is called `DailyTaskManager`.
It would be impossible to give you a mould without such a DailyTaskManager. I would suggest you parse/adapt it from a newer source version if you don't have it.

The logic is rather simple once you get to understand it.
1. You need a handler to count the mobs and give rewards, etc.
2. You need to keep mission status for each individual player in the database.
3. You need to INSERT the data when a player takes the mission, UPDATE it whenever you like, be it on every single mob or not (I would only update the DB on player disconnect/log out, or on mission completion), and SELECT/extract it when the player logs in (EnterWorld.java).
4. You need a way to get the Mission Reset Type (Daily/Weekly), and you should call a reset method similar to the one at the bottom of my post from within the DailyTaskManager every day at 9am or whenever you like.

Keep in mind that the above is not an exhaustive list, but some generalised approach aimed at helping you see the bigger picture.
 

public synchronized void reset()
    {
        DailyMissionResetType reset = _holder.getResetType(); 
        switch (reset)
        {
            case NEVER ->
            {
                return;
            }
            case MONTHLY ->
            {
                if (Calendar.getInstance().get(Calendar.DAY_OF_MONTH) != 1)
                {
                    return;
                }
            }
            case WEEKLY ->
            {
                if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY)
                {
                    return;
                }
            }
            case WEEKEND ->
            {
                if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY)
                {
                    return;
                }
            }
            case DAILY ->
            {
            }
            default ->
            {
                LOGGER.warning("Unhandled daily mission reset type: " + reset);
                return;
            }
        }

        try (
                Connection con = DatabaseFactory.getConnection();
                PreparedStatement ps = con.prepareStatement("DELETE FROM character_daily_rewards WHERE missionId = ? AND status = ?"))
        {
            ps.setInt(1, _holder.getId());
            ps.setInt(2, DailyMissionStatus.COMPLETED.getClientId());
            ps.execute();
        }
        catch (SQLException e)
        {
            LOGGER.log(Level.WARNING, "Error while clearing data for: " + getClass().getSimpleName(), e);
        }
        finally
        {
            _entries.clear();
            // resets the entries in the Manager.
            DailyMissionsManager.getInstance().clearEntries();
        }
    }


*Disclaimer: The provided code snippet is just an adaptation of Mobius' implementation on newer chronicles.
 

Edited by Salty Mike
  • 0
Posted
18 hours ago, gripao said:

Hello!!

I'm trying to make a quest to kill X mobs and give you a reward. I already have it ready, or so I think.

 

Now I would like to add the function of making it daily or weekly. I've tried to control this in the same java file of the quest, but I haven't been able to...

 

I was thinking of putting a marker on the quest so that it is "daily" or "weekly" and ¿generating another java program? that is in charge of restarting all the quests with the daily marker at 9 in the morning every day and on Wednesdays at 9 every Wednesday.

 

Since I'm new to java programming (I had already programmed in bash) and developing l2j I don't know where I should create that program. Could it be in the java folder with a name like "org.l2jmobius.xxx.xxx"?

 

I don't know how to approach it because I don't understand the logic of the files and that how runs every day to reset quest with marker.

 

Could anyone help me understand this and explain how I should do it? I'm not asking for ready-made code, I can do that myself, but how to deal with it 😛

 

I also don't know if this method is better or in the java file itself (but I haven't managed to do it this way).

 

See you guys and thanks for all. 

make an item that expires either a week or a day when u press the accept , if u try to redo it and u have the item it wont let you, can be in quest items and not destroyable... 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • 🔥 Upgrade Your Server's Visual Identity 🔥 Hello Community! We are proud to present the Shadowbane Collection – a premium, oriental-style visual suite designed specifically for Metin2 and Silkroad private servers. Forget about static, boring pages. Give your players a true "AAA" experience with a fully animated video header and a professional brand identity. 🎥 VIDEO PREVIEW   🐉 1. Shadowbane – Animated HTML Website Template A fully coded, responsive website template with a stunning video background. No coding skills required – just upload and configure! 🚀 Technology: HTML5 / CSS3 / JS (No PSD, ready code) 🎥 Animated Header: Loopable video background included (.mp4) 📱 Responsive: Works perfectly on Mobile & Desktop 📂 Pages Included: Home, Rankings, Register, Download, News 👉 DOWNLOAD WEBSITE TEMPLATE HERE       ⚔️ 2. Shadowbane – Game Logo & Text Effect Complete your branding with this matching Logo Template. It works as a Photoshop Text Effect – just type your server name! 🎨 Style: Oriental Gold & Brush Ink ⚡ Easy Edit: Smart Objects (One-click change) 🎁 Bonus: Social Media Kit included (Banner + Avatar) 👉 DOWNLOAD LOGO TEMPLATE HERE 🎁 SPECIAL LAUNCH DISCOUNT 🎁 For forum members, we have prepared a special code. Get 20% OFF on your entire order! CODE: LOVEM2 Elevate your server today with Pixarts.store  
    • Contact me on discord have an offer for you. l2avalon.net  
    • At this point, you’re better off buying server files that have actually been heavily tested by you or that you’ve personally played on. Working with public sources is a waste of time. These days, it’s also a waste of time to deal with files that have never powered a live server, or with people trying to sell you a story without real proof or a solid player base to back it up.
    • Hope someone someday will release this 😄
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and 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..