- Timestamp:
- Jan 16, 2012 7:56:19 AM (4 months ago)
- Location:
- trunk/L2J_DataPack
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
dist/game/data/scripts/ai/group_template/BeastFarm.java (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/L2J_DataPack
- Property svn:mergeinfo changed
/branches/unstable/L2J_DataPack_BETA merged: 8407-8426,8428-8480,8482-8491,8493-8588,8590-8629
- Property svn:mergeinfo changed
-
trunk/L2J_DataPack/dist/game/data/scripts/ai/group_template/BeastFarm.java
r7924 r8630 30 30 import com.l2jserver.gameserver.model.actor.instance.L2TamedBeastInstance; 31 31 import com.l2jserver.gameserver.model.quest.QuestState; 32 import com.l2jserver.gameserver.network.SystemMessageId;33 32 import com.l2jserver.gameserver.network.serverpackets.AbstractNpcInfo; 34 33 import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected; 35 import com.l2jserver.gameserver.network.serverpackets.SocialAction;36 34 import com.l2jserver.gameserver.network.serverpackets.StatusUpdate; 37 import com.l2jserver.gameserver.network.serverpackets.SystemMessage;38 35 import com.l2jserver.gameserver.skills.SkillHolder; 39 36 import com.l2jserver.gameserver.templates.chars.L2NpcTemplate; … … 43 40 /** 44 41 * Growth-capable mobs: Polymorphing upon successful feeding. 45 * @author Fulminus 46 * Updated to Freya by Gigiikun 42 * @author Fulminus Updated to Freya by Gigiikun 47 43 */ 48 44 public class BeastFarm extends L2AttackableAIScript … … 56 52 private static final int SKILL_SGRADE_GOLDEN_SPICE = 9053; 57 53 private static final int SKILL_SGRADE_CRYSTAL_SPICE = 9054; 58 private static final int[] TAMED_BEASTS = { 18869, 18870, 18871, 18872 }; 54 private static final int[] TAMED_BEASTS = 55 { 56 18869, 18870, 18871, 18872 57 }; 59 58 private static final int TAME_CHANCE = 20; 60 private static final int[] SPECIAL_SPICE_CHANCES = { 33, 75 }; 59 private static final int[] SPECIAL_SPICE_CHANCES = 60 { 61 33, 75 62 }; 61 63 62 64 // all mobs that can eat... 63 private static final int[] FEEDABLE_BEASTS = { 64 18873, 18874, 18875, 18876, 18877, 18878, 18879, 18880, 18881, 18882, 65 18883, 18884, 18885, 18886, 18887, 18888, 18889, 18890, 18891, 18892, 66 18893, 18894, 18895, 18896, 18897, 18898, 18899, 18900 65 private static final int[] FEEDABLE_BEASTS = 66 { 67 18873, 18874, 18875, 18876, 18877, 18878, 18879, 18880, 18881, 18882, 18883, 18884, 18885, 18886, 18887, 18888, 18889, 18890, 18891, 18892, 18893, 18894, 18895, 18896, 18897, 18898, 18899, 18900 67 68 }; 68 69 69 private static Map<Integer, Integer> _FeedInfo = new FastMap<Integer,Integer>();70 private static Map<Integer, GrowthCapableMob> _GrowthCapableMobs = new FastMap<Integer,GrowthCapableMob>();70 private static Map<Integer, Integer> _FeedInfo = new FastMap<Integer, Integer>(); 71 private static Map<Integer, GrowthCapableMob> _GrowthCapableMobs = new FastMap<Integer, GrowthCapableMob>(); 71 72 private static Map<String, SkillHolder[]> _TamedBeastsData = new FastMap<String, SkillHolder[]>(); 72 73 … … 74 75 private static class GrowthCapableMob 75 76 { 76 private int _chance;77 private int _growthLevel;78 private int _tameNpcId;79 private Map<Integer,Integer> _skillSuccessNpcIdList = new FastMap<Integer,Integer>();77 private final int _chance; 78 private final int _growthLevel; 79 private final int _tameNpcId; 80 private final Map<Integer, Integer> _skillSuccessNpcIdList = new FastMap<Integer, Integer>(); 80 81 81 82 public GrowthCapableMob(int chance, int growthLevel, int tameNpcId) … … 100 101 if (!_skillSuccessNpcIdList.containsKey(skillId)) 101 102 return -1; 102 else if (skillId == SKILL_BLESSED_GOLDEN_SPICE || skillId == SKILL_BLESSED_CRYSTAL_SPICE 103 || skillId == SKILL_SGRADE_GOLDEN_SPICE || skillId == SKILL_SGRADE_CRYSTAL_SPICE) 103 else if (skillId == SKILL_BLESSED_GOLDEN_SPICE || skillId == SKILL_BLESSED_CRYSTAL_SPICE || skillId == SKILL_SGRADE_GOLDEN_SPICE || skillId == SKILL_SGRADE_CRYSTAL_SPICE) 104 104 { 105 105 if (Rnd.get(100) < SPECIAL_SPICE_CHANCES[0]) … … 112 112 return _skillSuccessNpcIdList.get(SKILL_CRYSTAL_SPICE); 113 113 } 114 else 115 return -1; 114 return -1; 116 115 } 117 116 else if (_growthLevel == 2 && Rnd.get(100) < TAME_CHANCE) … … 124 123 } 125 124 126 public BeastFarm (int questId, String name, String descr)125 public BeastFarm(int questId, String name, String descr) 127 126 { 128 127 super(questId, name, descr); 129 this.registerMobs(FEEDABLE_BEASTS, QuestEventType.ON_KILL, QuestEventType.ON_SKILL_SEE);128 registerMobs(FEEDABLE_BEASTS, QuestEventType.ON_KILL, QuestEventType.ON_SKILL_SEE); 130 129 131 130 GrowthCapableMob temp; … … 237 236 // Tamed beasts data 238 237 SkillHolder[] stemp = new SkillHolder[2]; 239 stemp[0] = new SkillHolder(6432, 1);240 stemp[1] = new SkillHolder(6668, 1);238 stemp[0] = new SkillHolder(6432, 1); 239 stemp[1] = new SkillHolder(6668, 1); 241 240 _TamedBeastsData.put("%name% of Focus", stemp); 242 241 243 242 stemp = new SkillHolder[2]; 244 stemp[0] = new SkillHolder(6433, 1);245 stemp[1] = new SkillHolder(6670, 1);243 stemp[0] = new SkillHolder(6433, 1); 244 stemp[1] = new SkillHolder(6670, 1); 246 245 _TamedBeastsData.put("%name% of Guiding", stemp); 247 246 248 247 stemp = new SkillHolder[2]; 249 stemp[0] = new SkillHolder(6434, 1);250 stemp[1] = new SkillHolder(6667, 1);248 stemp[0] = new SkillHolder(6434, 1); 249 stemp[1] = new SkillHolder(6667, 1); 251 250 _TamedBeastsData.put("%name% of Swifth", stemp); 252 251 253 252 stemp = new SkillHolder[1]; 254 stemp[0] = new SkillHolder(6671, 1);253 stemp[0] = new SkillHolder(6671, 1); 255 254 _TamedBeastsData.put("Berserker %name%", stemp); 256 255 257 256 stemp = new SkillHolder[2]; 258 stemp[0] = new SkillHolder(6669, 1);259 stemp[1] = new SkillHolder(6672, 1);257 stemp[0] = new SkillHolder(6669, 1); 258 stemp[1] = new SkillHolder(6672, 1); 260 259 _TamedBeastsData.put("%name% of Protect", stemp); 261 260 262 261 stemp = new SkillHolder[2]; 263 stemp[0] = new SkillHolder(6431, 1);264 stemp[1] = new SkillHolder(6666, 1);262 stemp[0] = new SkillHolder(6431, 1); 263 stemp[1] = new SkillHolder(6666, 1); 265 264 _TamedBeastsData.put("%name% of Vigor", stemp); 266 265 } … … 275 274 } 276 275 // despawn the old mob 277 //TODO: same code? FIXED? 278 /*if (_GrowthCapableMobs.get(npc.getNpcId()).getGrowthLevel() == 0) 279 { 280 npc.deleteMe(); 281 } 282 else 283 {*/ 284 npc.deleteMe(); 285 //} 276 // TODO: same code? FIXED? 277 /* 278 * if (_GrowthCapableMobs.get(npc.getNpcId()).getGrowthLevel() == 0) { npc.deleteMe(); } else { 279 */ 280 npc.deleteMe(); 281 // } 286 282 287 283 // if this is finally a trained mob, then despawn any other trained mobs that the 288 284 // player might have and initialize the Tamed Beast. 289 if (Util.contains(TAMED_BEASTS, nextNpcId))285 if (Util.contains(TAMED_BEASTS, nextNpcId)) 290 286 { 291 287 L2NpcTemplate template = NpcTable.getInstance().getTemplate(nextNpcId); … … 294 290 String name = _TamedBeastsData.keySet().toArray(new String[_TamedBeastsData.keySet().size()])[Rnd.get(_TamedBeastsData.size())]; 295 291 SkillHolder[] skillList = _TamedBeastsData.get(name); 296 switch (nextNpcId)292 switch (nextNpcId) 297 293 { 298 294 case 18869: … … 311 307 nextNpc.setName(name); 312 308 nextNpc.broadcastPacket(new AbstractNpcInfo.NpcInfo(nextNpc, player)); 313 for (SkillHolder sh : skillList)309 for (SkillHolder sh : skillList) 314 310 nextNpc.addBeastSkill(SkillTable.getInstance().getInfo(sh.getSkillId(), sh.getSkillLvl())); 315 311 nextNpc.setRunning(); 316 312 317 313 QuestState st = player.getQuestState("20_BringUpWithLove"); 318 if (st != null && st.getInt("cond") == 1 && st.getQuestItemsCount(7185) == 0&& Rnd.get(10) == 1)314 if (st != null && st.getInt("cond") == 1 && !st.hasQuestItems(7185) && Rnd.get(10) == 1) 319 315 { 320 // if player has quest 20 going, give quest item321 // it's easier to hardcode it in here than to try and repeat this stuff in the quest322 st.giveItems(7185, 1);323 st.set("cond", "2");316 // if player has quest 20 going, give quest item 317 // it's easier to hardcode it in here than to try and repeat this stuff in the quest 318 st.giveItems(7185, 1); 319 st.set("cond", "2"); 324 320 } 325 321 } … … 328 324 // if not trained, the newly spawned mob will automatically be agro against its feeder 329 325 // (what happened to "never bite the hand that feeds you" anyway?!) 330 L2Attackable nextNpc = (L2Attackable) this.addSpawn(nextNpcId,npc);326 L2Attackable nextNpc = (L2Attackable) addSpawn(nextNpcId, npc); 331 327 332 328 // register the player in the feedinfo for the mob that just spawned 333 _FeedInfo.put(nextNpc.getObjectId(), player.getObjectId());329 _FeedInfo.put(nextNpc.getObjectId(), player.getObjectId()); 334 330 nextNpc.setRunning(); 335 nextNpc.addDamageHate(player, 0,99999);331 nextNpc.addDamageHate(player, 0, 99999); 336 332 nextNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player); 337 333 … … 346 342 347 343 @Override 348 public String onSkillSee (L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet)344 public String onSkillSee(L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet) 349 345 { 350 346 // this behavior is only run when the target of skill is the passed npc (chest) 351 347 // i.e. when the player is attempting to open the chest using a skill 352 if (!Util.contains(targets, npc))353 { 354 return super.onSkillSee(npc, caster,skill,targets,isPet);348 if (!Util.contains(targets, npc)) 349 { 350 return super.onSkillSee(npc, caster, skill, targets, isPet); 355 351 } 356 352 // gather some values on local variables 357 353 int npcId = npc.getNpcId(); 358 354 int skillId = skill.getId(); 359 // check if the npc and skills used are valid for this script. Exit if invalid. 360 if (!Util.contains(FEEDABLE_BEASTS,npcId) 361 || (skillId !=SKILL_GOLDEN_SPICE && skillId != SKILL_CRYSTAL_SPICE 362 && skillId !=SKILL_BLESSED_GOLDEN_SPICE && skillId != SKILL_BLESSED_CRYSTAL_SPICE 363 && skillId !=SKILL_SGRADE_GOLDEN_SPICE && skillId != SKILL_SGRADE_CRYSTAL_SPICE)) 364 { 365 return super.onSkillSee(npc,caster,skill,targets,isPet); 355 // check if the npc and skills used are valid for this script. Exit if invalid. 356 if (!Util.contains(FEEDABLE_BEASTS, npcId) || (skillId != SKILL_GOLDEN_SPICE && skillId != SKILL_CRYSTAL_SPICE && skillId != SKILL_BLESSED_GOLDEN_SPICE && skillId != SKILL_BLESSED_CRYSTAL_SPICE && skillId != SKILL_SGRADE_GOLDEN_SPICE && skillId != SKILL_SGRADE_CRYSTAL_SPICE)) 357 { 358 return super.onSkillSee(npc, caster, skill, targets, isPet); 366 359 } 367 360 368 361 // first gather some values on local variables 369 362 int objectId = npc.getObjectId(); 370 int growthLevel = 3; // if a mob is in FEEDABLE_BEASTS but not in _GrowthCapableMobs, then it's at max growth (3)363 int growthLevel = 3; // if a mob is in FEEDABLE_BEASTS but not in _GrowthCapableMobs, then it's at max growth (3) 371 364 if (_GrowthCapableMobs.containsKey(npcId)) 372 365 { … … 378 371 if (growthLevel == 0 && _FeedInfo.containsKey(objectId)) 379 372 { 380 return super.onSkillSee(npc,caster,skill,targets,isPet); 381 } 382 else 383 { 384 _FeedInfo.put(objectId,caster.getObjectId()); 385 } 373 return super.onSkillSee(npc, caster, skill, targets, isPet); 374 } 375 376 _FeedInfo.put(objectId, caster.getObjectId()); 386 377 387 378 // display the social action of the beast eating the food. 388 npc.broadcast Packet(new SocialAction(npc,2));379 npc.broadcastSocialAction(2); 389 380 390 381 int food = 0; … … 409 400 _FeedInfo.remove(objectId); 410 401 npc.setRunning(); 411 ((L2Attackable) npc).addDamageHate(caster,0,1);402 ((L2Attackable) npc).addDamageHate(caster, 0, 1); 412 403 npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, caster); 413 404 } 414 return super.onSkillSee(npc, caster,skill,targets,isPet);405 return super.onSkillSee(npc, caster, skill, targets, isPet); 415 406 } 416 407 else if (growthLevel > 0 && _FeedInfo.get(objectId) != caster.getObjectId()) … … 418 409 // check if this is the same player as the one who raised it from growth 0. 419 410 // if no, then do not allow a chance to raise the pet (food gets consumed but has no effect). 420 return super.onSkillSee(npc, caster,skill,targets,isPet);411 return super.onSkillSee(npc, caster, skill, targets, isPet); 421 412 } 422 spawnNext(npc, caster,newNpcId,food);413 spawnNext(npc, caster, newNpcId, food); 423 414 } 424 415 else 425 416 { 426 caster.send Packet(SystemMessage.getSystemMessage(SystemMessageId.S1).addString("The beast spit out the feed instead of eating it."));427 ((L2Attackable) npc).dropItem(caster, food, 1);428 } 429 return super.onSkillSee(npc, caster,skill,targets,isPet);417 caster.sendMessage("The beast spit out the feed instead of eating it."); 418 ((L2Attackable) npc).dropItem(caster, food, 1); 419 } 420 return super.onSkillSee(npc, caster, skill, targets, isPet); 430 421 } 431 422 432 423 @Override 433 public String onKill (L2Npc npc, L2PcInstance killer, boolean isPet)424 public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet) 434 425 { 435 426 // remove the feedinfo of the mob that got killed, if any … … 438 429 _FeedInfo.remove(npc.getObjectId()); 439 430 } 440 return super.onKill(npc, killer,isPet);431 return super.onKill(npc, killer, isPet); 441 432 } 442 433 … … 444 435 { 445 436 // now call the constructor (starts up the ai) 446 new BeastFarm(-1, "beast_farm","ai");437 new BeastFarm(-1, "beast_farm", "ai"); 447 438 } 448 439 }
Note: See TracChangeset
for help on using the changeset viewer.
