Thread: Making an Npc aggressive

Results 1 to 3 of 3
  1. #1 Making an Npc aggressive 
    Registered Member
    Join Date
    Feb 2018
    Posts
    1
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    I'm trying to make an npc aggressive, but it won't work. I have this

    Code:
    {
    "id": 131,
    "name": "Penguin",
    "examine": "A penguin.",
    "combat": 2,
    "size": 1,
    "attackable": true,
    "aggressive": true, // I set it to true
    "retreats": false,
    "poisonous": false,
    "respawn": 15,
    "maxHit": 10,
    "hitpoints": 200,
    "attackSpeed": 7,
    "attackAnim": 237,
    "defenceAnim": 234,
    "deathAnim": 0,
    "attackBonus": 100,
    "defenceMelee": 0,
    "defenceRange": 0,
    "defenceMage": 0
    },
    I'm using Ruse v2.

    npcaggression.java
    Code:
    package com.world.entity.impl.npc;
    
    import com.model.Locations;
    import com.model.Locations.Location;
    import com.world.content.combat.CombatFactory;
    import com.world.content.combat.strategy.impl.Nex;
    import com.world.content.skill.impl.dungeoneering.Dungeoneering;
    import com.world.entity.impl.player.Player;
    
    /**
     * Handles the behavior of aggressive {@link Npc}s around players within the
     * <code>NPC_TARGET_DISTANCE</code> radius.
     * 
     * @author lare96
     */
    public final class NpcAggression {
    
    	/**
    	 * Time that has to be spent in a region before npcs stop acting aggressive
    	 * toward a specific player.
    	 */
    	public static final int NPC_TOLERANCE_SECONDS = 300; //5 mins
    
    	public static void target(Player player) {
    
    		if(player.isPlayerLocked())
    			return;
    		
    		final boolean dung = Dungeoneering.doingDungeoneering(player);
    
    		// Loop through all of the aggressive npcs.
    		for (NPC npc : player.getLocalNpcs()) {
    
    			if(npc == null || npc.getConstitution() <= 0)
    				continue;
    			
    			NPCFacing.updateFacing(player, npc);
    			
    			if(!(dung && npc.getId() != 11226) && !npc.getDefinition().isAggressive()) {
    				continue;
    			}
    			
    			if(npc.getSpawnedFor() != null && npc.getSpawnedFor() != player)
    				continue;
    			
    			if(!npc.findNewTarget()) {
    				if(npc.getCombatBuilder().isAttacking() || npc.getCombatBuilder().isBeingAttacked()) {
    					continue;
    				}
    			}
    
    			/** GWD **/
    			boolean gwdMob = Nex.nexMob(npc.getId()) || npc.getId() == 6260 || npc.getId() == 6261 || npc.getId() == 6263 || npc.getId() == 6265 || npc.getId() == 6222 || npc.getId() == 6223 || npc.getId() == 6225 || npc.getId() == 6227 || npc.getId() == 6203 || npc.getId() == 6208 || npc.getId() == 6204 || npc.getId() == 6206 || npc.getId() == 6247 || npc.getId() == 6248 || npc.getId() == 6250 || npc.getId() == 6252;
    			if(gwdMob) {
    				if(!player.getMinigameAttributes().getGodwarsDungeonAttributes().hasEnteredRoom()) {
    					continue;
    				}
    			}
    
    			// Check if the entity is within distance.
    			if (Locations.goodDistance(npc.getPosition(), player.getPosition(), npc.getAggressionDistance()) || gwdMob) {
    		
    				if (player.getTolerance().elapsed() > (NPC_TOLERANCE_SECONDS * 1000) && player.getLocation() != Location.GODWARS_DUNGEON && player.getLocation() != Location.DAGANNOTH_DUNGEON && !dung) {
    					break;
    				}
    
    				boolean multi = Location.inMulti(player);
    
    				if(player.isTargeted()) {
    					if(!player.getCombatBuilder().isBeingAttacked()) {
    						player.setTargeted(false);
    					} else if(!multi) {
    						break;
    					}
    				}
    
    
    				if (player.getSkillManager().getCombatLevel() > (npc.getDefinition().getCombatLevel() * 2) && player.getLocation() != Location.WILDERNESS && !dung) {
    					continue;
    				}
    
    				if(Location.ignoreFollowDistance(npc) || gwdMob || npc.getDefaultPosition().getDistance(player.getPosition()) < 7 + npc.getMovementCoordinator().getCoordinator().getRadius() || dung) {
    					if(CombatFactory.checkHook(npc, player)) {
    						player.setTargeted(true);
    						npc.getCombatBuilder().attack(player);
    						npc.setFindNewTarget(false);
    						break;
    					}
    				}
    			}
    		}
    	}
    
    }
    Reply With Quote  
     

  2. #2  
    Donator


    Join Date
    Nov 2011
    Posts
    784
    Thanks given
    108
    Thanks received
    705
    Rep Power
    5000
    Try increasing the combat level server-sided (npcdefinitions.json) to 100, may be a cheap fix but should work.
    Reply With Quote  
     

  3. #3  
    Extreme Donator


    Join Date
    Oct 2010
    Posts
    2,853
    Thanks given
    1,213
    Thanks received
    1,622
    Rep Power
    5000
    Code:
    				if (player.getSkillManager().getCombatLevel() > (npc.getDefinition().getCombatLevel() * 2) && player.getLocation() != Location.WILDERNESS && !dung) {
    					continue;
    				}
    This piece of code won't allow players to be aggroed by npcs with lower combat levels.
    [Today 01:29 AM] RSTrials: Nice 0.97 Win/Loss Ratio luke. That's pretty bad.
    [Today 01:30 AM] Luke132: Ok u fucking moron i forgot i could influence misc.random
    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. How to make NPC's Non-Aggressive (317)
    By lilshootout in forum Help
    Replies: 9
    Last Post: 11-14-2013, 03:52 AM
  2. Monsters aren't aggressive? PI
    By brutally in forum Help
    Replies: 6
    Last Post: 08-30-2013, 01:01 AM
  3. Npcs aren't respawning.
    By wildernessX in forum Help
    Replies: 0
    Last Post: 06-20-2011, 05:18 PM
  4. [PI] NPCs Aren't Correct
    By Vault in forum Help
    Replies: 7
    Last Post: 04-04-2011, 02:43 AM
  5. Make NPC's Non-Aggressive?
    By Vault in forum Help
    Replies: 2
    Last Post: 12-06-2009, 10:14 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •