Changeset 5166


Ignore:
Timestamp:
Feb 6, 2012 3:33:55 AM (3 months ago)
Author:
Zoey76
Message:

BETA: Simplified support for daily quests by UnAfraid?.
Spelling fixes in L2Character comments by me.

Usage: Exit quests using exitQuest(QuestType?.DAILY); the quest will be completed and a penalty will be added, use isNowAvailable() to verify if the quest is available.

Location:
branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/model
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/L2Character.java

    r5165 r5166  
    343343        } 
    344344         
    345         // Overrided in L2PcInstance 
     345        /** 
     346         * Overridden in L2PcInstance. 
     347         * @return the access level. 
     348         */ 
    346349        public L2AccessLevel getAccessLevel() 
    347350        { 
     
    349352        } 
    350353         
    351         // ========================================================= 
    352         // Constructor 
    353         /** 
    354          * Constructor of L2Character.<BR><BR> 
    355          * 
     354        /** 
     355         * Constructor of L2Character.<br> 
    356356         * <B><U> Concept</U> :</B><BR><BR> 
    357357         * Each L2Character owns generic and static properties (ex : all Keltir have the same number of HP...). 
     
    363363         * <B><U> Actions</U> :</B><BR><BR> 
    364364         * <li>Set the _template of the L2Character </li> 
    365          * <li>Set _overloaded to false (the charcater can take more items)</li><BR><BR> 
     365         * <li>Set _overloaded to false (the character can take more items)</li><BR><BR> 
    366366         * 
    367367         * <li>If L2Character is a L2NPCInstance, copy skills from template to object</li> 
     
    391391                else if (template != null && this instanceof L2Npc) 
    392392                { 
    393                         // Copy the Standard Calcultors of the L2NPCInstance in _calculators 
     393                        // Copy the Standard Calculators of the L2NPCInstance in _calculators 
    394394                        _calculators = NPC_STD_CALCULATOR; 
    395395                         
     
    751751         * 
    752752         * <B><U> Actions</U> :</B><BR><BR> 
    753          * <li>Get the active weapon (always equiped in the right hand) </li><BR><BR> 
     753         * <li>Get the active weapon (always equipped in the right hand) </li><BR><BR> 
    754754         * <li>If weapon is a bow, check for arrows, MP and bow re-use delay (if necessary, equip the L2PcInstance with arrows in left hand)</li> 
    755755         * <li>If weapon is a bow, consume MP and set the new period of bow non re-use </li><BR><BR> 
     
    854854                L2ItemInstance weaponInst = getActiveWeaponInstance(); 
    855855                 
    856                 // Get the active weapon item corresponding to the active weapon instance (always equiped in the right hand) 
     856                // Get the active weapon item corresponding to the active weapon instance (always equipped in the right hand) 
    857857                L2Weapon weaponItem = getActiveWeaponItem(); 
    858858                 
     
    10711071                                { 
    10721072                                        if (target instanceof L2PcInstance && ((L2PcInstance) target).isCursedWeaponEquipped()) 
    1073                                                 // If a cursed weapon is hitted by a Hero, Cp is reduced to 0 
     1073                                                // If a cursed weapon is hit by a Hero, Cp is reduced to 0 
    10741074                                                target.setCurrentCp(0); 
    10751075                                } 
     
    15361536         * 
    15371537         * <B><U> Actions</U> :</B><BR><BR> 
    1538          * <li>Verify the possibilty of the the cast : skill is a spell, caster isn't muted... </li> 
     1538         * <li>Verify the possibility of the the cast : skill is a spell, caster isn't muted... </li> 
    15391539         * <li>Get the list of all targets (ex : area effects) and define the L2Charcater targeted (its stats will be used in calculation)</li> 
    15401540         * <li>Calculate the casting time (base + modifier of MAtkSpd), interrupt time and re-use delay</li> 
    1541          * <li>Send a Server->Client packet MagicSkillUser (to diplay casting animation), a packet SetupGauge (to display casting bar) and a system message </li> 
     1541         * <li>Send a Server->Client packet MagicSkillUser (to display casting animation), a packet SetupGauge (to display casting bar) and a system message </li> 
    15421542         * <li>Disable all skills during the casting time (create a task EnableAllSkills)</li> 
    15431543         * <li>Disable the skill during the re-use delay (create a task EnableSkill)</li> 
     
    20512051         * @param skill 
    20522052         * @return True if casting is possible 
    2053          *  
    2054          *  
    20552053         */ 
    20562054        protected boolean checkDoCastConditions(L2Skill skill) 
     
    28692867         
    28702868        /** 
    2871          * Task lauching the function onHitTimer().<BR><BR> 
     2869         * Task launching the function onHitTimer().<BR><BR> 
    28722870         * 
    28732871         * <B><U> Actions</U> :</B><BR><BR> 
     
    29112909        } 
    29122910         
    2913         /** Task lauching the magic skill phases */ 
     2911        /** Task launching the magic skill phases */ 
    29142912        class MagicUseTask implements Runnable 
    29152913        { 
     
    30213019         
    30223020        // ========================================================= 
    3023         /** Task lauching the magic skill phases */ 
     3021        /** Task launching the magic skill phases */ 
    30243022        class FlyToLocationTask implements Runnable 
    30253023        { 
     
    32193217        public final void startSleeping() 
    32203218        { 
    3221                 /* Aborts any attacks/casts if sleeped */ 
     3219                /* Aborts any attacks/casts if asleep */ 
    32223220                abortAttack(); 
    32233221                abortCast(); 
     
    35933591         
    35943592        /** 
    3595          * Updates Effect Icons for this character(palyer/summon) and his party if any<BR> 
     3593         * Updates Effect Icons for this character(player/summon) and his party if any<BR> 
    35963594         *  
    35973595         * Overridden in:<BR> 
  • branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/model/quest/Quest.java

    r5146 r5166  
    9191        private static final String DEFAULT_ALREADY_COMPLETED_MSG = 
    9292                "<html><body>This quest has already been completed.</body></html>"; 
     93         
     94        private static final int RESET_HOUR = 6; 
     95        private static final int RESET_MINUTES = 30; 
     96         
     97        /** 
     98         * @return the reset hour for a daily quest, could be overridden on a script. 
     99         */ 
     100        public int getResetHour() 
     101        { 
     102                return RESET_HOUR; 
     103        } 
     104         
     105        /** 
     106         * @return the reset minutes for a daily quest, could be overridden on a script. 
     107         */ 
     108        public int getResetMinutes() 
     109        { 
     110                return RESET_MINUTES; 
     111        } 
    93112         
    94113        /** 
  • branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/model/quest/QuestState.java

    r5146 r5166  
    1818import java.sql.PreparedStatement; 
    1919import java.sql.ResultSet; 
     20import java.util.Calendar; 
    2021import java.util.Map; 
    2122import java.util.logging.Level; 
     
    4849import com.l2jserver.gameserver.network.serverpackets.TutorialEnableClientEvent; 
    4950import com.l2jserver.gameserver.network.serverpackets.TutorialShowHtml; 
     51import com.l2jserver.gameserver.util.Util; 
    5052import com.l2jserver.gameserver.network.serverpackets.TutorialShowQuestionMark; 
    5153import com.l2jserver.util.Rnd; 
     
    7274        /** boolean flag letting QuestStateManager know to exit quest when cleaning up */ 
    7375        private boolean _isExitQuestOnCleanUp = false; 
     76         
     77        /** 
     78         * This enumerate represent the different quest types. 
     79         */ 
     80        public static enum QuestType 
     81        { 
     82                REPEATABLE, 
     83                ONE_TIME, 
     84                DAILY 
     85        } 
    7486         
    7587        /** 
     
    10971109         
    10981110        /** 
     1111         * @param type the type of the quest, {@link com.l2jserver.gameserver.model.quest.QuestState.QuestType}. 
     1112         * @return this quest state. 
     1113         */ 
     1114        public QuestState exitQuest(QuestType type) 
     1115        { 
     1116                switch (type) 
     1117                { 
     1118                        case REPEATABLE: 
     1119                        case ONE_TIME: 
     1120                        { 
     1121                                exitQuest(type == QuestType.REPEATABLE); 
     1122                                break; 
     1123                        } 
     1124                        case DAILY: 
     1125                        { 
     1126                                exitQuest(false); 
     1127                                setRestartTime(); 
     1128                                break; 
     1129                        } 
     1130                } 
     1131                return this; 
     1132        } 
     1133         
     1134        /** 
    10991135         * Destroy element used by quest when quest is exited 
    11001136         * @param repeatable 
     
    11781214                npc.dropItem(player, itemId, count); 
    11791215        } 
     1216         
     1217        /** 
     1218         * Set the restart time for the daily quests.<br> 
     1219         * The time is hardcoded at {@link Quest#getResetHour()} hours, {@link Quest#getResetMinutes()} minutes of the following day.<br> 
     1220         * It can be overridden in scripts (quests). 
     1221         */ 
     1222        public void setRestartTime() 
     1223        { 
     1224                final Calendar reDo = Calendar.getInstance(); 
     1225                if (reDo.get(Calendar.HOUR_OF_DAY) >= getQuest().getResetHour()) 
     1226                { 
     1227                        reDo.add(Calendar.DATE, 1); 
     1228                } 
     1229                reDo.set(Calendar.HOUR_OF_DAY, getQuest().getResetHour()); 
     1230                reDo.set(Calendar.MINUTE, getQuest().getResetMinutes()); 
     1231                set("restartTime", String.valueOf(reDo.getTimeInMillis())); 
     1232        } 
     1233         
     1234        /** 
     1235         * @return {@code true} if the quest is available, for example daily quests, {@code false} otherwise. 
     1236         */ 
     1237        public boolean isNowAvailable() 
     1238        { 
     1239                final String val = get("restartTime"); 
     1240                return ((val == null) || !Util.isDigit(val)) || (Long.parseLong(val) <= System.currentTimeMillis()); 
     1241        } 
    11801242} 
Note: See TracChangeset for help on using the changeset viewer.