- 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/FeedableBeasts.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/FeedableBeasts.java
r7924 r8630 30 30 import com.l2jserver.gameserver.model.quest.QuestState; 31 31 import com.l2jserver.gameserver.network.serverpackets.NpcSay; 32 import com.l2jserver.gameserver.network.serverpackets.SocialAction;33 32 import com.l2jserver.gameserver.templates.chars.L2NpcTemplate; 34 33 import com.l2jserver.gameserver.util.Util; … … 49 48 50 49 // all mobs that can eat... 51 private static final int[] FEEDABLE_BEASTS = { 50 private static final int[] FEEDABLE_BEASTS = 51 { 52 52 21451,21452,21453,21454,21455,21456,21457,21458,21459,21460,21461,21462,21463, 53 53 21464,21465,21466,21467,21468,21469,21470,21471,21472,21473,21474,21475,21476, … … 59 59 60 60 private static final Map<Integer,Integer> MAD_COW_POLYMORPH = new FastMap<Integer,Integer>(); 61 61 62 static 62 63 { … … 110 111 private static class GrowthCapableMob 111 112 { 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[][]>(); 116 117 117 118 public GrowthCapableMob(int growthLevel, int chance) … … 374 375 } 375 376 // 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 // } 385 383 386 384 // if this is finally a trained mob, then despawn any other trained mobs that the 387 385 // player might have and initialize the Tamed Beast. 388 if (Util.contains(TAMED_BEASTS, nextNpcId))386 if (Util.contains(TAMED_BEASTS, nextNpcId)) 389 387 { 390 388 if (player.getTrainedBeasts() != null && !player.getTrainedBeasts().isEmpty()) 391 for (L2TamedBeastInstance oldTrained : player.getTrainedBeasts())389 for (L2TamedBeastInstance oldTrained : player.getTrainedBeasts()) 392 390 oldTrained.deleteMe(); 393 391 … … 401 399 if (st != null) 402 400 { 403 if (Rnd.get(100) <= 5 && st.getQuestItemsCount(7185) == 0)401 if (Rnd.get(100) <= 5 && !st.hasQuestItems(7185)) 404 402 { 405 // if player has quest 20 going, give quest item406 // it's easier to hardcode it in here than to try and repeat this stuff in the quest407 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"); 409 407 } 410 408 } … … 413 411 if (rand == 0) 414 412 { 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?")); 416 414 } 417 415 else if (rand == 1) 418 416 { 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.")); 420 418 } 421 419 else if (rand == 2) 422 420 { 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")); 424 422 } 425 423 else if (rand == 3) 426 424 { 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")); 428 426 } 429 427 else if (rand == 4) 430 428 { 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?")); 432 430 } 433 431 } … … 436 434 // if not trained, the newly spawned mob will automatically be agro against its feeder 437 435 // (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); 439 437 440 438 if (MAD_COW_POLYMORPH.containsKey(nextNpcId)) … … 444 442 445 443 // 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()); 447 445 nextNpc.setRunning(); 448 nextNpc.addDamageHate(player, 0,99999);446 nextNpc.addDamageHate(player, 0, 99999); 449 447 nextNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player); 450 448 } … … 452 450 453 451 @Override 454 public String onAdvEvent (String event, L2Npc npc, L2PcInstance player)452 public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) 455 453 { 456 454 if (event.equalsIgnoreCase("polymorph Mad Cow") && npc != null && player != null) 457 455 { 458 if (MAD_COW_POLYMORPH.containsKey(npc.getNpcId()))456 if (MAD_COW_POLYMORPH.containsKey(npc.getNpcId())) 459 457 { 460 458 // remove the feed info from the previous mob … … 466 464 npc.deleteMe(); 467 465 // 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); 469 467 470 468 // register the player in the feedinfo for the mob that just spawned 471 469 _FeedInfo.put(nextNpc.getObjectId(), player.getObjectId()); 472 470 nextNpc.setRunning(); 473 nextNpc.addDamageHate(player, 0,99999);471 nextNpc.addDamageHate(player, 0, 99999); 474 472 nextNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player); 475 473 } 476 474 } 477 return super.onAdvEvent(event, npc,player);475 return super.onAdvEvent(event, npc, player); 478 476 } 479 477 480 478 @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) 482 480 { 483 481 // this behavior is only run when the target of skill is the passed npc (chest) 484 482 // 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); 488 486 } 489 487 // gather some values on local variables 490 488 int npcId = npc.getNpcId(); 491 489 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); 496 494 } 497 495 498 496 // first gather some values on local variables 499 497 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) 501 499 if (_GrowthCapableMobs.containsKey(npcId)) 502 500 { … … 506 504 // prevent exploit which allows 2 players to simultaneously raise the same 0-growth beast 507 505 // 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()); 516 512 517 513 int food = 0; … … 526 522 527 523 // display the social action of the beast eating the food. 528 npc.broadcast Packet(new SocialAction(npc,2));524 npc.broadcastSocialAction(2); 529 525 530 526 // if this pet can't grow, it's all done. … … 532 528 { 533 529 // 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); 537 533 } 538 534 539 535 // 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)])); 543 539 } 544 540 … … 547 543 // check if this is the same player as the one who raised it from growth 0. 548 544 // 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); 550 546 } 551 547 … … 553 549 if (Rnd.get(100) < _GrowthCapableMobs.get(npcId).getChance()) 554 550 { 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); 561 557 if (skillId == beast.getFoodType()) 562 558 { 563 559 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); 568 564 } 569 565 570 566 @Override 571 public String onKill (L2Npc npc, L2PcInstance killer, boolean isPet)567 public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet) 572 568 { 573 569 // remove the feedinfo of the mob that got killed, if any … … 576 572 _FeedInfo.remove(npc.getObjectId()); 577 573 } 578 return super.onKill(npc, killer,isPet);574 return super.onKill(npc, killer, isPet); 579 575 } 580 576 … … 582 578 { 583 579 // now call the constructor (starts up the ai) 584 new FeedableBeasts(-1, "feedable_beasts","ai");580 new FeedableBeasts(-1, "feedable_beasts", "ai"); 585 581 } 586 582 }
Note: See TracChangeset
for help on using the changeset viewer.
