Ignore:
Timestamp:
Jan 16, 2012 7:56:19 AM (4 months ago)
Author:
MELERIX
Message:

STABLE: Sync with BETA [8629]

Location:
trunk/L2J_DataPack
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/L2J_DataPack

  • trunk/L2J_DataPack/dist/game/data/scripts/ai/group_template/Chests.java

    r7665 r8630  
    3434        private static final int SKILL_DELUXE_KEY = 2229; 
    3535         
    36         //Base chance for BOX to be opened 
     36        // Base chance for BOX to be opened 
    3737        private static final int BASE_CHANCE = 100; 
    3838         
     
    4343        private static final int IS_BOX = 40; 
    4444         
    45         private static final int[] NPC_IDS = { 18265,18266,18267,18268,18269,18270,18271, 
    46                 18272,18273,18274,18275,18276,18277,18278,18279,18280,18281, 
    47                 18282,18283,18284,18285,18286,18287,18288,18289,18290,18291, 
    48                 18292,18293,18294,18295,18296,18297,18298,21671,21694,21717, 
    49                 21740,21763,21786,21801,21802,21803,21804,21805,21806,21807, 
    50                 21808,21809,21810,21811,21812,21813,21814,21815,21816,21817, 
    51                 21818,21819,21820,21821,21822 }; 
     45        private static final int[] NPC_IDS = 
     46        { 
     47                18265, 
     48                18266, 
     49                18267, 
     50                18268, 
     51                18269, 
     52                18270, 
     53                18271, 
     54                18272, 
     55                18273, 
     56                18274, 
     57                18275, 
     58                18276, 
     59                18277, 
     60                18278, 
     61                18279, 
     62                18280, 
     63                18281, 
     64                18282, 
     65                18283, 
     66                18284, 
     67                18285, 
     68                18286, 
     69                18287, 
     70                18288, 
     71                18289, 
     72                18290, 
     73                18291, 
     74                18292, 
     75                18293, 
     76                18294, 
     77                18295, 
     78                18296, 
     79                18297, 
     80                18298, 
     81                21671, 
     82                21694, 
     83                21717, 
     84                21740, 
     85                21763, 
     86                21786, 
     87                21801, 
     88                21802, 
     89                21803, 
     90                21804, 
     91                21805, 
     92                21806, 
     93                21807, 
     94                21808, 
     95                21809, 
     96                21810, 
     97                21811, 
     98                21812, 
     99                21813, 
     100                21814, 
     101                21815, 
     102                21816, 
     103                21817, 
     104                21818, 
     105                21819, 
     106                21820, 
     107                21821, 
     108                21822 
     109        }; 
    52110         
    53111        public Chests(int questId, String name, String descr) 
     
    56114                // mechanisms etc. 
    57115                super(questId, name, descr); 
    58                 this.registerMobs(NPC_IDS, QuestEventType.ON_ATTACK, QuestEventType.ON_SKILL_SEE); 
     116                registerMobs(NPC_IDS, QuestEventType.ON_ATTACK, QuestEventType.ON_SKILL_SEE); 
    59117        } 
    60118         
    61119        @Override 
    62         public String onSkillSee (L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet) 
     120        public String onSkillSee(L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet) 
    63121        { 
    64122                if (npc instanceof L2ChestInstance) 
     
    66124                        // this behavior is only run when the target of skill is the passed npc (chest) 
    67125                        // i.e. when the player is attempting to open the chest using a skill 
    68                         if (!Util.contains(targets,npc)) 
    69                         { 
    70                                 return super.onSkillSee(npc,caster,skill,targets,isPet); 
    71                         } 
    72                         L2ChestInstance chest = ((L2ChestInstance)npc); 
     126                        if (!Util.contains(targets, npc)) 
     127                        { 
     128                                return super.onSkillSee(npc, caster, skill, targets, isPet); 
     129                        } 
     130                        L2ChestInstance chest = ((L2ChestInstance) npc); 
    73131                        int npcId = chest.getNpcId(); 
    74132                        int skillId = skill.getId(); 
    75                         int skillLevel= skill.getLevel(); 
     133                        int skillLevel = skill.getLevel(); 
    76134                         
    77                         // check if the chest and skills used are valid for this script.  Exit if invalid. 
    78                         if (!Util.contains(NPC_IDS,npcId)) 
    79                         { 
    80                                 return super.onSkillSee(npc,caster,skill,targets,isPet); 
     135                        // check if the chest and skills used are valid for this script. Exit if invalid. 
     136                        if (!Util.contains(NPC_IDS, npcId)) 
     137                        { 
     138                                return super.onSkillSee(npc, caster, skill, targets, isPet); 
    81139                        } 
    82140                        // if this has already been interacted, no further ai decisions are needed 
     
    91149                                        { 
    92150                                                // check the chance to open the box 
    93                                                 int keyLevelNeeded = chest.getLevel()/10; 
     151                                                int keyLevelNeeded = chest.getLevel() / 10; 
    94152                                                keyLevelNeeded -= skillLevel; 
    95153                                                if (keyLevelNeeded < 0) 
     
    97155                                                int chance = BASE_CHANCE - keyLevelNeeded * LEVEL_DECREASE; 
    98156                                                 
    99                                                 // success, pretend-death with rewards:  chest.reduceCurrentHp(99999999, player) 
     157                                                // success, pretend-death with rewards: chest.reduceCurrentHp(99999999, player) 
    100158                                                if (Rnd.get(100) < chance) 
    101159                                                { 
     
    111169                                else 
    112170                                { 
    113                                         L2Character originalCaster = isPet? caster.getPet(): caster; 
     171                                        L2Character originalCaster = isPet ? caster.getPet() : caster; 
    114172                                        chest.setRunning(); 
    115                                         chest.addDamageHate(originalCaster,0,999); 
     173                                        chest.addDamageHate(originalCaster, 0, 999); 
    116174                                        chest.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalCaster); 
    117175                                } 
    118176                        } 
    119177                } 
    120                 return super.onSkillSee(npc,caster,skill,targets,isPet); 
     178                return super.onSkillSee(npc, caster, skill, targets, isPet); 
    121179        } 
    122180         
    123181        @Override 
    124         public String onAttack (L2Npc npc, L2PcInstance attacker, int damage, boolean isPet) 
     182        public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isPet) 
    125183        { 
    126184                if (npc instanceof L2ChestInstance) 
    127185                { 
    128                         L2ChestInstance chest = ((L2ChestInstance)npc); 
     186                        L2ChestInstance chest = ((L2ChestInstance) npc); 
    129187                        int npcId = chest.getNpcId(); 
    130                         // check if the chest and skills used are valid for this script.  Exit if invalid. 
     188                        // check if the chest and skills used are valid for this script. Exit if invalid. 
    131189                        if (!Util.contains(NPC_IDS, npcId)) 
    132190                        { 
    133                                 return super.onAttack(npc,attacker,damage,isPet); 
     191                                return super.onAttack(npc, attacker, damage, isPet); 
    134192                        } 
    135193                         
     
    146204                                        // if this weren't a box, upon interaction start the mimic behaviors... 
    147205                                        // todo: perhaps a self-buff (skill id 4245) with random chance goes here? 
    148                                         L2Character originalAttacker = isPet? attacker.getPet(): attacker; 
     206                                        L2Character originalAttacker = isPet ? attacker.getPet() : attacker; 
    149207                                        chest.setRunning(); 
    150                                         chest.addDamageHate(originalAttacker,0,(damage*100)/(chest.getLevel()+7)); 
     208                                        chest.addDamageHate(originalAttacker, 0, (damage * 100) / (chest.getLevel() + 7)); 
    151209                                        chest.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalAttacker); 
    152210                                } 
    153211                        } 
    154212                } 
    155                 return super.onAttack(npc,attacker,damage,isPet); 
     213                return super.onAttack(npc, attacker, damage, isPet); 
    156214        } 
    157215         
     
    159217        { 
    160218                // now call the constructor (starts up the ai) 
    161                 new Chests(-1,"chests","ai"); 
     219                new Chests(-1, "chests", "ai"); 
    162220        } 
    163221} 
Note: See TracChangeset for help on using the changeset viewer.