Thread: [RUSE] Having troubles getting my pet battle system to engage (Get no errors)

Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17
  1. #11  
    Registered Member

    Join Date
    Oct 2016
    Posts
    158
    Thanks given
    76
    Thanks received
    39
    Rep Power
    105
    Quote Originally Posted by Jhin 7F View Post
    He just has to modify the way pets are processed while summoned.
    @Jrage

    Look in Summoning.java class for Ruse base then modify conditions in the processFamiliar() method for pets to attack. Just tested and was able to have pet tormented demon's attack each other. Don't forget to give pet attack speed/hitpoints though.
    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

    Quote Originally Posted by Nand0 View Post
    you commented out
    Code:
    //String player = command[1];
    i think that is used to get the players name
    nah that was more of an experiment, commands are already set for player, I had to get player2.
    Reply With Quote  
     

  2. #12  
    Registered Member
    Join Date
    Jan 2019
    Posts
    26
    Thanks given
    4
    Thanks received
    16
    Rep Power
    29
    Quote Originally Posted by Jrage View Post
    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
    @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.
    Reply With Quote  
     

  3. #13  
    Registered Member

    Join Date
    Oct 2016
    Posts
    158
    Thanks given
    76
    Thanks received
    39
    Rep Power
    105
    Quote Originally Posted by Jhin 7F View Post
    @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);
    Reply With Quote  
     

  4. #14  
    Registered Member
    Join Date
    Jan 2019
    Posts
    26
    Thanks given
    4
    Thanks received
    16
    Rep Power
    29
    Quote Originally Posted by Jrage View Post
    @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);
    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++;
    				}
    			}
    		});
    	}
    Should work, but remember to do setIsBattling(true) for both pets. Just a variable to know when player's pets are battling.
    Reply With Quote  
     

  5. #15  
    Registered Member

    Join Date
    Oct 2016
    Posts
    158
    Thanks given
    76
    Thanks received
    39
    Rep Power
    105
    Quote Originally Posted by Jhin 7F View Post
    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++;
    				}
    			}
    		});
    	}
    Should work, but remember to do setIsBattling(true) for both pets. Just a variable to know when player's pets are battling.
    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 follows
    Code:
    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());
    		}
    That 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 7F
    Last edited by Jrage; 11-21-2019 at 08:37 AM. Reason: Letting Jhin know it worked for me!
    Reply With Quote  
     

  6. #16  
    Registered Member

    Join Date
    Sep 2016
    Posts
    181
    Thanks given
    84
    Thanks received
    74
    Rep Power
    452
    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.
    Reply With Quote  
     

  7. #17  
    Registered Member

    Join Date
    Oct 2016
    Posts
    158
    Thanks given
    76
    Thanks received
    39
    Rep Power
    105
    Quote Originally Posted by knd6060 View Post
    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.
    Reply With Quote  
     

Page 2 of 2 FirstFirst 12

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 0
    Last Post: 11-27-2012, 03:46 AM
  2. I'm having trouble configuring my OS
    By X r4ng3r X in forum Software
    Replies: 3
    Last Post: 08-01-2012, 07:16 AM
  3. Having trouble with my client maybe jaring
    By Zonebird in forum Help
    Replies: 4
    Last Post: 07-12-2012, 05:50 AM
  4. having trouble starting my server on a linux vps
    By OodlesOfNoodles in forum Help
    Replies: 0
    Last Post: 12-23-2011, 07:25 AM
  5. [PI] having trouble with my interface
    By Xseil in forum Help
    Replies: 7
    Last Post: 11-04-2011, 03:33 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •