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/FeedableBeasts.java

    r7924 r8630  
    3030import com.l2jserver.gameserver.model.quest.QuestState; 
    3131import com.l2jserver.gameserver.network.serverpackets.NpcSay; 
    32 import com.l2jserver.gameserver.network.serverpackets.SocialAction; 
    3332import com.l2jserver.gameserver.templates.chars.L2NpcTemplate; 
    3433import com.l2jserver.gameserver.util.Util; 
     
    4948         
    5049        // all mobs that can eat... 
    51         private static final int[] FEEDABLE_BEASTS = { 
     50        private static final int[] FEEDABLE_BEASTS =  
     51        { 
    5252                21451,21452,21453,21454,21455,21456,21457,21458,21459,21460,21461,21462,21463, 
    5353                21464,21465,21466,21467,21468,21469,21470,21471,21472,21473,21474,21475,21476, 
     
    5959         
    6060        private static final Map<Integer,Integer> MAD_COW_POLYMORPH = new FastMap<Integer,Integer>(); 
     61         
    6162        static 
    6263        { 
     
    110111        private static class GrowthCapableMob 
    111112        { 
    112                 private int _growthLevel; 
    113                 private int _chance; 
    114                  
    115                 private Map<Integer, int[][]> _spiceToMob = new FastMap<Integer,int[][]>(); 
     113                private final int _growthLevel; 
     114                private final int _chance; 
     115                 
     116                private final Map<Integer, int[][]> _spiceToMob = new FastMap<Integer,int[][]>(); 
    116117                 
    117118                public GrowthCapableMob(int growthLevel, int chance) 
     
    374375                } 
    375376                // despawn the old mob 
    376                 //TODO: same code? FIXED? 
    377                 /*if (_GrowthCapableMobs.get(npcId).getGrowthLevel() == 0) 
    378                 { 
    379                         npc.deleteMe(); 
    380                 } 
    381                 else 
    382                 {*/ 
    383                         npc.deleteMe(); 
    384                 //} 
     377                // TODO: same code? FIXED? 
     378                /* 
     379                 * if (_GrowthCapableMobs.get(npcId).getGrowthLevel() == 0) { npc.deleteMe(); } else { 
     380                 */ 
     381                npc.deleteMe(); 
     382                // } 
    385383                 
    386384                // if this is finally a trained mob, then despawn any other trained mobs that the 
    387385                // player might have and initialize the Tamed Beast. 
    388                 if (Util.contains(TAMED_BEASTS,nextNpcId)) 
     386                if (Util.contains(TAMED_BEASTS, nextNpcId)) 
    389387                { 
    390388                        if (player.getTrainedBeasts() != null && !player.getTrainedBeasts().isEmpty()) 
    391                                 for(L2TamedBeastInstance oldTrained : player.getTrainedBeasts()) 
     389                                for (L2TamedBeastInstance oldTrained : player.getTrainedBeasts()) 
    392390                                        oldTrained.deleteMe(); 
    393391                         
     
    401399                        if (st != null) 
    402400                        { 
    403                                 if (Rnd.get(100) <= 5 && st.getQuestItemsCount(7185) == 0) 
     401                                if (Rnd.get(100) <= 5 && !st.hasQuestItems(7185)) 
    404402                                { 
    405                                         //if player has quest 20 going, give quest item 
    406                                         //it's easier to hardcode it in here than to try and repeat this stuff in the quest 
    407                                         st.giveItems(7185,1); 
    408                                         st.set("cond","2"); 
     403                                        // if player has quest 20 going, give quest item 
     404                                        // it's easier to hardcode it in here than to try and repeat this stuff in the quest 
     405                                        st.giveItems(7185, 1); 
     406                                        st.set("cond", "2"); 
    409407                                } 
    410408                        } 
     
    413411                        if (rand == 0) 
    414412                        { 
    415                                 npc.broadcastPacket(new NpcSay(objectId,0,nextNpc.getNpcId(), player.getName()+", will you show me your hideaway?")); 
     413                                npc.broadcastPacket(new NpcSay(objectId, 0, nextNpc.getNpcId(), player.getName() + ", will you show me your hideaway?")); 
    416414                        } 
    417415                        else if (rand == 1) 
    418416                        { 
    419                                 npc.broadcastPacket(new NpcSay(objectId,0,nextNpc.getNpcId(), player.getName()+", whenever I look at spice, I think about you.")); 
     417                                npc.broadcastPacket(new NpcSay(objectId, 0, nextNpc.getNpcId(), player.getName() + ", whenever I look at spice, I think about you.")); 
    420418                        } 
    421419                        else if (rand == 2) 
    422420                        { 
    423                                 npc.broadcastPacket(new NpcSay(objectId,0,nextNpc.getNpcId(), player.getName()+", you do not need to return to the village.  I will give you strength")); 
     421                                npc.broadcastPacket(new NpcSay(objectId, 0, nextNpc.getNpcId(), player.getName() + ", you do not need to return to the village.  I will give you strength")); 
    424422                        } 
    425423                        else if (rand == 3) 
    426424                        { 
    427                                 npc.broadcastPacket(new NpcSay(objectId,0,nextNpc.getNpcId(), "Thanks, "+player.getName()+".  I hope I can help you")); 
     425                                npc.broadcastPacket(new NpcSay(objectId, 0, nextNpc.getNpcId(), "Thanks, " + player.getName() + ".  I hope I can help you")); 
    428426                        } 
    429427                        else if (rand == 4) 
    430428                        { 
    431                                 npc.broadcastPacket(new NpcSay(objectId,0,nextNpc.getNpcId(), player.getName()+", what can I do to help you?")); 
     429                                npc.broadcastPacket(new NpcSay(objectId, 0, nextNpc.getNpcId(), player.getName() + ", what can I do to help you?")); 
    432430                        } 
    433431                } 
     
    436434                        // if not trained, the newly spawned mob will automatically be agro against its feeder 
    437435                        // (what happened to "never bite the hand that feeds you" anyway?!) 
    438                         L2Attackable nextNpc = (L2Attackable) this.addSpawn(nextNpcId,npc); 
     436                        L2Attackable nextNpc = (L2Attackable) addSpawn(nextNpcId, npc); 
    439437                         
    440438                        if (MAD_COW_POLYMORPH.containsKey(nextNpcId)) 
     
    444442                         
    445443                        // register the player in the feedinfo for the mob that just spawned 
    446                         _FeedInfo.put(nextNpc.getObjectId(),player.getObjectId()); 
     444                        _FeedInfo.put(nextNpc.getObjectId(), player.getObjectId()); 
    447445                        nextNpc.setRunning(); 
    448                         nextNpc.addDamageHate(player,0,99999); 
     446                        nextNpc.addDamageHate(player, 0, 99999); 
    449447                        nextNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player); 
    450448                } 
     
    452450         
    453451        @Override 
    454         public String onAdvEvent (String event, L2Npc npc, L2PcInstance player) 
     452        public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) 
    455453        { 
    456454                if (event.equalsIgnoreCase("polymorph Mad Cow") && npc != null && player != null) 
    457455                { 
    458                         if( MAD_COW_POLYMORPH.containsKey(npc.getNpcId())) 
     456                        if (MAD_COW_POLYMORPH.containsKey(npc.getNpcId())) 
    459457                        { 
    460458                                // remove the feed info from the previous mob 
     
    466464                                npc.deleteMe(); 
    467465                                // spawn the new mob 
    468                                 L2Attackable nextNpc = (L2Attackable) this.addSpawn(MAD_COW_POLYMORPH.get(npc.getNpcId()),npc); 
     466                                L2Attackable nextNpc = (L2Attackable) addSpawn(MAD_COW_POLYMORPH.get(npc.getNpcId()), npc); 
    469467                                 
    470468                                // register the player in the feedinfo for the mob that just spawned 
    471469                                _FeedInfo.put(nextNpc.getObjectId(), player.getObjectId()); 
    472470                                nextNpc.setRunning(); 
    473                                 nextNpc.addDamageHate(player,0,99999); 
     471                                nextNpc.addDamageHate(player, 0, 99999); 
    474472                                nextNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player); 
    475473                        } 
    476474                } 
    477                 return super.onAdvEvent(event,npc,player); 
     475                return super.onAdvEvent(event, npc, player); 
    478476        } 
    479477         
    480478        @Override 
    481         public String onSkillSee (L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet) 
     479        public String onSkillSee(L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet) 
    482480        { 
    483481                // this behavior is only run when the target of skill is the passed npc (chest) 
    484482                // i.e. when the player is attempting to open the chest using a skill 
    485                 if (!Util.contains(targets,npc)) 
    486                 { 
    487                         return super.onSkillSee(npc,caster,skill,targets,isPet); 
     483                if (!Util.contains(targets, npc)) 
     484                { 
     485                        return super.onSkillSee(npc, caster, skill, targets, isPet); 
    488486                } 
    489487                // gather some values on local variables 
    490488                int npcId = npc.getNpcId(); 
    491489                int skillId = skill.getId(); 
    492                 // check if the npc and skills used are valid for this script.  Exit if invalid. 
    493                 if (!Util.contains(FEEDABLE_BEASTS,npcId) || (skillId !=SKILL_GOLDEN_SPICE && skillId != SKILL_CRYSTAL_SPICE)) 
    494                 { 
    495                         return super.onSkillSee(npc,caster,skill,targets,isPet); 
     490                // check if the npc and skills used are valid for this script. Exit if invalid. 
     491                if (!Util.contains(FEEDABLE_BEASTS, npcId) || (skillId != SKILL_GOLDEN_SPICE && skillId != SKILL_CRYSTAL_SPICE)) 
     492                { 
     493                        return super.onSkillSee(npc, caster, skill, targets, isPet); 
    496494                } 
    497495                 
    498496                // first gather some values on local variables 
    499497                int objectId = npc.getObjectId(); 
    500                 int growthLevel = 3;  // if a mob is in FEEDABLE_BEASTS but not in _GrowthCapableMobs, then it's at max growth (3) 
     498                int growthLevel = 3; // if a mob is in FEEDABLE_BEASTS but not in _GrowthCapableMobs, then it's at max growth (3) 
    501499                if (_GrowthCapableMobs.containsKey(npcId)) 
    502500                { 
     
    506504                // prevent exploit which allows 2 players to simultaneously raise the same 0-growth beast 
    507505                // If the mob is at 0th level (when it still listens to all feeders) lock it to the first feeder! 
    508                 if (growthLevel==0 && _FeedInfo.containsKey(objectId)) 
    509                 { 
    510                         return super.onSkillSee(npc,caster,skill,targets,isPet); 
    511                 } 
    512                 else 
    513                 { 
    514                         _FeedInfo.put(objectId,caster.getObjectId()); 
    515                 } 
     506                if (growthLevel == 0 && _FeedInfo.containsKey(objectId)) 
     507                { 
     508                        return super.onSkillSee(npc, caster, skill, targets, isPet); 
     509                } 
     510                 
     511                _FeedInfo.put(objectId, caster.getObjectId()); 
    516512                 
    517513                int food = 0; 
     
    526522                 
    527523                // display the social action of the beast eating the food. 
    528                 npc.broadcastPacket(new SocialAction(npc,2)); 
     524                npc.broadcastSocialAction(2); 
    529525                 
    530526                // if this pet can't grow, it's all done. 
     
    532528                { 
    533529                        // do nothing if this mob doesn't eat the specified food (food gets consumed but has no effect). 
    534                         if (_GrowthCapableMobs.get(npcId).getMob(food, 0, 0) == null ) 
    535                         { 
    536                                 return super.onSkillSee(npc,caster,skill,targets,isPet); 
     530                        if (_GrowthCapableMobs.get(npcId).getMob(food, 0, 0) == null) 
     531                        { 
     532                                return super.onSkillSee(npc, caster, skill, targets, isPet); 
    537533                        } 
    538534                         
    539535                        // rare random talk... 
    540                         if (Rnd.get(20) == 0 ) 
    541                         { 
    542                                 npc.broadcastPacket(new NpcSay(objectId,0,npc.getNpcId(),TEXT[growthLevel][Rnd.get(TEXT[growthLevel].length)])); 
     536                        if (Rnd.get(20) == 0) 
     537                        { 
     538                                npc.broadcastPacket(new NpcSay(objectId, 0, npc.getNpcId(), TEXT[growthLevel][Rnd.get(TEXT[growthLevel].length)])); 
    543539                        } 
    544540                         
     
    547543                                // check if this is the same player as the one who raised it from growth 0. 
    548544                                // if no, then do not allow a chance to raise the pet (food gets consumed but has no effect). 
    549                                 return super.onSkillSee(npc,caster,skill,targets,isPet); 
     545                                return super.onSkillSee(npc, caster, skill, targets, isPet); 
    550546                        } 
    551547                         
     
    553549                        if (Rnd.get(100) < _GrowthCapableMobs.get(npcId).getChance()) 
    554550                        { 
    555                                 this.spawnNext(npc, growthLevel,caster,food); 
    556                         } 
    557                 } 
    558                 else if (Util.contains(TAMED_BEASTS,npcId) && npc instanceof L2TamedBeastInstance) 
    559                 { 
    560                         L2TamedBeastInstance beast = ((L2TamedBeastInstance)npc); 
     551                                this.spawnNext(npc, growthLevel, caster, food); 
     552                        } 
     553                } 
     554                else if (Util.contains(TAMED_BEASTS, npcId) && npc instanceof L2TamedBeastInstance) 
     555                { 
     556                        L2TamedBeastInstance beast = ((L2TamedBeastInstance) npc); 
    561557                        if (skillId == beast.getFoodType()) 
    562558                        { 
    563559                                beast.onReceiveFood(); 
    564                                 beast.broadcastPacket(new NpcSay(objectId,0,npcId,TAMED_TEXT[Rnd.get(TAMED_TEXT.length)])); 
    565                         } 
    566                 } 
    567                 return super.onSkillSee(npc,caster,skill,targets,isPet); 
     560                                beast.broadcastPacket(new NpcSay(objectId, 0, npcId, TAMED_TEXT[Rnd.get(TAMED_TEXT.length)])); 
     561                        } 
     562                } 
     563                return super.onSkillSee(npc, caster, skill, targets, isPet); 
    568564        } 
    569565         
    570566        @Override 
    571         public String onKill (L2Npc npc, L2PcInstance killer, boolean isPet) 
     567        public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet) 
    572568        { 
    573569                // remove the feedinfo of the mob that got killed, if any 
     
    576572                        _FeedInfo.remove(npc.getObjectId()); 
    577573                } 
    578                 return super.onKill(npc,killer,isPet); 
     574                return super.onKill(npc, killer, isPet); 
    579575        } 
    580576         
     
    582578        { 
    583579                // now call the constructor (starts up the ai) 
    584                 new FeedableBeasts(-1,"feedable_beasts","ai"); 
     580                new FeedableBeasts(-1, "feedable_beasts", "ai"); 
    585581        } 
    586582} 
Note: See TracChangeset for help on using the changeset viewer.