Thread: [2006Scape] Pet cat aggressive upon login

Results 1 to 5 of 5
  1. #1 [2006Scape] Pet cat aggressive upon login 
    Registered Member
    Join Date
    Feb 2021
    Posts
    115
    Thanks given
    31
    Thanks received
    8
    Rep Power
    62


    https://github.com/2006-Scape/2006Scape Pets.java

    Code:
    package com.rs2.game.npcs.impl;
    
    import com.rs2.GameEngine;
    import com.rs2.game.npcs.Npc;
    import com.rs2.game.npcs.NpcHandler;
    import com.rs2.game.players.Player;
    import com.rs2.game.players.PlayerSave;
    import com.rs2.world.clip.Region;
    
    public class Pets {
    	
    	public static final int RATS_NEEDED_TO_GROW = 10;
    
    	//npc id, item id
    	private final static int[][] CATS = { 
    			{ 3505, 7583 }, //hell kitten
    			{ 3504, 7582 }, //hellcat
    			{ 3503, 7581 }, //overgrown hellcat
    			{ 3506, 7584 }, //lazy hellcat
    			{ 3507, 7585 }, //wily hellcat
    			{ 993, 1491 }, //witch's cat
    			{ 766, 1560 }, //pet kitten
    			{ 765, 1559 }, //pet kitten
    			{ 764, 1558 }, //pet kitten
    			{ 763, 1557 }, //pet kitten
    			{ 762, 1556 }, //pet kitten
    			{ 761, 1555 }, //pet kitten
    			{ 768, 1561 }, //pet cat
    			{ 769, 1562 }, //pet cat
    			{ 770, 1563 }, //pet cat
    			{ 2640, 1564 }, //pet cat #771
    			{ 772, 1565 }, //pet cat
    			{ 773, 1566 } //pet cat
    		};
    
    	public static final int[] CAT_ITEMS = { 
    			1491, 1555, 1556, 1557, 1558, 1559, 1560,
    			1561, 1562, 1563, 1564, 1565, 7585, 7581, 7582, 7583, 7584
    		};
    	
    	public static boolean isCatItem(int itemId) {
    		for (int i = 0; i < CAT_ITEMS.length; i++) {
    			if (itemId == CAT_ITEMS[i]) {
    				return true;
    			}
    		}
    		return false;
    	}
    	
    	public static boolean isCat(int npcId) {
    		for (int i = 0; i < CATS.length; i++) {
    			if (npcId == CATS[i][0]) {
    				return true;
    			}
    		}
    		return false;
    	}
    
    
    	public static void dropPet(Player player, int itemId, int slot) {
    		if (player.hasNpc) {
    			player.getPacketSender().sendMessage("You already dropped your " + NpcHandler.getNpcListName(summonItemId(itemId)) + ".");
    			return;
    		}
    		player.getItemAssistant().deleteItem(itemId, slot, player.playerItemsN[slot]);
    		player.hasNpc = true;
    		player.getPacketSender().sendMessage("You drop your " + NpcHandler.getNpcListName(summonItemId(itemId)) + ".");
    		int offsetX = 0;
    		int offsetY = 0;
    		if (Region.getClipping(player.getX() - 1, player.getY(), player.heightLevel, -1, 0)) {
    			offsetX = -1;
    		} else if (Region.getClipping(player.getX() + 1, player.getY(), player.heightLevel, 1, 0)) {
    			offsetX = 1;
    		} else if (Region.getClipping(player.getX(), player.getY() - 1, player.heightLevel, 0, -1)) {
    			offsetY = -1;
    		} else if (Region.getClipping(player.getX(), player.getY() + 1, player.heightLevel, 0, 1)) {
    			offsetY = 1;
    		}
    		GameEngine.npcHandler.spawnNpc3(player, summonItemId(itemId), player.absX+offsetX, player.absY+offsetY, player.heightLevel, 0, 120, 25, 200, 200, false, false, true);			
    		PlayerSave.saveGame(player);
    	}
    	
    	public void quickPickup(Player player, int id) {
    			for (Npc i : NpcHandler.npcs) {
    				if (i == null) {
    					continue;
    				}
    				if (i.npcType == id) {
    					i.absX = 0;
    					i.absY = 0;
    					i = null;
    				}
    			}
    	}
    
    
    	public void pickUpPet(Player player, int id) {
    		if (player.getItemAssistant().hasFreeSlots(1)) {
    			for (Npc i : NpcHandler.npcs) {
    				if (i == null) {
    					continue;
    				}
    				if (i.npcType == id) {
    					player.startAnimation(827);
    					i.absX = 0;
    					i.absY = 0;
    					i = null;
    					for (int[] element : CATS) {
    						if (element[0] == id) {
    							player.getItemAssistant().addItem(element[1], 1);
    						}
    					}
    				}
    			}
    		} else {
    			player.getPacketSender().sendMessage("You do not have enough space in your inventory to do that.");
    		}
    	}
    
    	public static int summonItemId(int itemId) {
    		for (int i = 0; i < CATS.length; i++) {
    			if (itemId == CATS[i][1]) {
    				return CATS[i][0];
    			}
    		}
    		return 0;
    	}
    	
    }



    First attempt at 'fixing' THIS DIDN'T WORK!
    Attached image
    Reply With Quote  
     

  2. #2  
    Registered Member
    Syles's Avatar
    Join Date
    Oct 2013
    Posts
    404
    Thanks given
    51
    Thanks received
    63
    Rep Power
    180
    While I understand what you're looking for with this post, you've just posted an 8 second clip, and linked to the 2006Scape github.

    I would suggest modifying this thread and either linking to the actual code on the github, or posting the code you have and some more information.
    Reply With Quote  
     

  3. #3  
    Community Veteran


    Arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,950
    Thanks given
    210
    Thanks received
    349
    Rep Power
    1376
    You most likely had configurated them to be aggressive in your npcDefinitions aka when you added the npc's data.


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Feb 2021
    Posts
    115
    Thanks given
    31
    Thanks received
    8
    Rep Power
    62
    Quote Originally Posted by Arch337 View Post
    You most likely had configurated them to be aggressive in your npcDefinitions aka when you added the npc's data.
    Interesting, because somehow the pets ended up with 120hp, 25 max, 200 attack and defence,

    but I checked npcDefinitions.xml and the npc ID's were set to <aggressive>false</aggressive>

    EDIT: Made an attempt at adding pets to NpcData.java -> NpcCantAttack (THIS DIDNT WORK)

    BUT, if I wanted to add Slayer Pets using the item id's from Slayer guide (skill guide from stats menu interface)
    then I would have to handle SummonNPC to distinguish a natural Abyssal demon, from a spawned Pet Abyssal demon.

    I think there needs to be a bit of code making sure a SummonNPC won't attack the player or be attackable

    Attached image
    Reply With Quote  
     

  5. #5  
    Community Veteran


    Arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,950
    Thanks given
    210
    Thanks received
    349
    Rep Power
    1376
    Quote Originally Posted by Monomoy View Post
    Interesting, because somehow the pets ended up with 120hp, 25 max, 200 attack and defence,

    but I checked npcDefinitions.xml and the npc ID's were set to <aggressive>false</aggressive>

    EDIT: Made an attempt at adding pets to NpcData.java -> NpcCantAttack (THIS DIDNT WORK)

    BUT, if I wanted to add Slayer Pets using the item id's from Slayer guide (skill guide from stats menu interface)
    then I would have to handle SummonNPC to distinguish a natural Abyssal demon, from a spawned Pet Abyssal demon.

    I think there needs to be a bit of code making sure a SummonNPC won't attack the player or be attackable

    [img]
    https://cdn.discordapp.com/attachmen...66/unknown.png
    [/img]
    Then it is your spawn npc method whenever you login.
    Check your login method to see which one, it is currently using to spawn your pet.


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    Reply With Quote  
     


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. T3 Error Upon Login? *Mad*
    By Noosy in forum Help
    Replies: 3
    Last Post: 04-21-2009, 05:15 PM
  2. Fixing "Jad Attack Randomly Upon Login"
    By mm_naruto in forum Snippets
    Replies: 19
    Last Post: 04-19-2009, 05:03 PM
  3. 317 deob crashes upon login.
    By Colby in forum Help
    Replies: 4
    Last Post: 01-19-2009, 01:02 AM
  4. DIE Upon Login :\
    By Lost.Legacy in forum Help
    Replies: 10
    Last Post: 01-07-2009, 02:05 PM
  5. Replies: 0
    Last Post: 11-30-2008, 12:47 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
  •