@Jrage I didn't have to make the players attack. Once I altered the code for processFamiliar(), they stopped following the players and started to attack each other.
|
Is that really what has been making them not work????? I shoulda known because that's where I've reffrenced for most of my data, but I figured since its not player attacking, I could make them target only each other, did your player have to attack anything to make it work? @Jhin 7F
nah that was more of an experiment, commands are already set for player, I had to get player2.
@Jrage I didn't have to make the players attack. Once I altered the code for processFamiliar(), they stopped following the players and started to attack each other.
@Jhin 7F Was this what you altered? My command didn't do anything (YET again lmao) when I commented this bit out
Code:if(n.getCombatBuilder().isAttacking()) { n.getCombatBuilder().reset(true); } n.setSummoningCombat(false); n.setEntityInteraction(player); n.getMovementQueue().setFollowCharacter(player);
Should work, but remember to do setIsBattling(true) for both pets. Just a variable to know when player's pets are battling.Code:private boolean isBattling = false; public boolean getIsBattling() { return isBattling; } public void setIsBattling(boolean b) { isBattling = b; } public void processFamiliar() { final NPC n = familiar.getSummonNpc(); TaskManager.submit(new Task(1, n, true) { int clockTimer = 2; @Override protected void execute() { if (familiar == null || n == null || n.getConstitution() <= 0 || !n.isRegistered() || player.getConstitution() <= 0 || !player.isRegistered()) { unsummon(true, true); stop(); return; } boolean underAttack = player.getCombatBuilder().isBeingAttacked() && player.getCombatBuilder().getLastAttacker() != null && player.getCombatBuilder().getLastAttacker().getCombatBuilder().getVictim() != null && player.getCombatBuilder().getLastAttacker().getCombatBuilder().getVictim() == player; boolean attacking = player.getCombatBuilder().isAttacking(); if (!familiar.isPet() && n.getDefinition().isAttackable() && (underAttack || attacking)) { if (n.getLocation() != Location.WILDERNESS || Location.inMulti(player)) { n.setSummoningCombat(true); n.getCombatBuilder().attack(attacking ? player.getCombatBuilder().getVictim() : player.getCombatBuilder().getLastAttacker()); n.setEntityInteraction(n.getCombatBuilder().getVictim()); } } else { if (!isBattling) { n.getCombatBuilder().reset(true); n.setSummoningCombat(false); n.setEntityInteraction(player); n.getMovementQueue().setFollowCharacter(player); } else { n.setSummoningCombat(true); n.setEntityInteraction(n.getCombatBuilder().getVictim()); } } if (!familiar.isPet()) { if (clockTimer >= 2) { if (familiar.getDeathTimer() > 0) { familiar.setDeathTimer(getFamiliar().getDeathTimer() - 1); if (familiar.getDeathTimer() == 60) player.getPacketSender() .sendMessage("@red@Warning: Your familiar will fade away in one minute."); player.getPacketSender().sendString(54043, "" + Summoning.getTimer(familiar.getDeathTimer() > 0 ? familiar.getDeathTimer() : 0)); // player.getPacketSender().sendString(54024, // ""+SummoningData.calculateScrolls(player)); } else { unsummon(true, true); stop(); player.getPacketSender().sendMessage("Your summoning familiar has died."); } clockTimer = 0; } clockTimer++; } } }); }
Oh my friend, gonna go test it now I'll let ya know, thank you so much!!!!
EDIT: SO, I fixed the command to read like followsThat makes the pet attack each other once, which is okay, the command was just to see if I could get the pets to do it. I have to rework my petbattle class a little bit to make the fight till one dies, but I already have it figured out as to how I'm gonna do it! I owe you big time! Thank you so much, I'll post the full fix on the original post shortly. Thank you again! @Jhin 7FCode:if(command[0].equalsIgnoreCase("petbattle")) { String playertobattle = wholeCommand.substring(command[0].length()+1); Player player2 = World.getPlayerByName(playertobattle); if (player2 == null) { player.getPacketSender().sendMessage("Target does not exist. Unable to start PetBattle."); return; } NPC npc = player.getSummoning().getFamiliar().getSummonNpc(); NPC npc2 = player2.getSummoning().getFamiliar().getSummonNpc(); if (!player.getSummoning().getFamiliar().isPet() && !player2.getSummoning().getFamiliar().isPet() || !player.getSummoning().getFamiliar().isPet() || !player2.getSummoning().getFamiliar().isPet()) { player.getPacketSender().sendMessage("Only Pets May Be Used Here!"); player2.getPacketSender().sendMessage("Only Pets May Be Used Here!"); return; } player.getSummoning().setIsBattling(true); player2.getSummoning().setIsBattling(true); player.getPacketSender().sendMessage("This is a test!"); player2.getPacketSender().sendMessage("This is a test!"); npc.setSummoningCombat(true); npc2.setSummoningCombat(true); npc.getCombatBuilder().attack(npc2); npc2.getCombatBuilder().attack(npc); npc.setEntityInteraction(npc.getCombatBuilder().getVictim()); npc2.setEntityInteraction(npc2.getCombatBuilder().getVictim()); }
Last edited by Jrage; 11-21-2019 at 08:37 AM. Reason: Letting Jhin know it worked for me!
Lol, there's a fair amount that would have to change to make this work. Also add some null checks in the command to make sure the players' familiars exists. Might be better to just write separate summoning vs summoning combat if you're struggling. There's lots of places in the combat code where it returns and doesn't process if the entities are summoning npcs and/or pets.
There is really not all that much work to be done, I loaded up the backup from before I added jhin's Boolean, used the newest command that I have posted right above you're post, and as long as the pets definiations have stats set, and attackable true, it works just fine. I'm using his Boolean as well as one of my own isWinner simply because I have a lot more going on with this than simply having pets attack. It's a tie in for my zookeeper skill. I had my first command screwed up, but it works.
EDIT: The combat system is designed for any type of combat between entities, you can even have world npcs attack each other. You DO NOT have to modify anything in the cobat system.
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |