Thread: Corp Beast Attacking Familiars

Results 1 to 5 of 5
  1. #1 Corp Beast Attacking Familiars 
    Registered Member
    Join Date
    Jan 2015
    Posts
    27
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    so in the the Corp Beast Attack method i've put

    Code:
    if (target instanceof NPC) {
    			return;
    			}
    but it's coming up with an error saying this code must return an int
    Reply With Quote  
     

  2. #2  
    Registered Member

    Join Date
    Oct 2012
    Posts
    1,463
    Thanks given
    560
    Thanks received
    323
    Rep Power
    122
    Post the whole method so we can see where you've put that, and I see you want the corp not to attack npc's right?

    “I have not failed. I've just found 10,000 ways that won't work.”
    ― Thomas A. Edison


    [Only registered and activated users can see links. ]


    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Jan 2015
    Posts
    27
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    Code:
    package com.rs.game.npc.combat.impl;
    
    import java.util.ArrayList;
    
    import com.rs.game.Animation;
    import com.rs.game.Entity;
    import com.rs.game.Graphics;
    import com.rs.game.World;
    import com.rs.game.WorldTile;
    import com.rs.game.npc.NPC;
    import com.rs.game.npc.combat.CombatScript;
    import com.rs.game.npc.combat.NPCCombatDefinitions;
    import com.rs.game.npc.corp.CorporealBeast;
    import com.rs.game.player.Player;
    import com.rs.game.player.Skills;
    import com.rs.game.tasks.WorldTask;
    import com.rs.game.tasks.WorldTasksManager;
    import com.rs.utils.Utils;
    
    public class CorporealBeastCombat extends CombatScript {
    
    	@Override
    	public Object[] getKeys() {
    		return new Object[] { 8133 };
    	}
    
    	@Override
    	public int attack(final NPC npc, final Entity target) {
    		if (target instanceof NPC) {
    			return;
    			}
    	
    		final NPCCombatDefinitions defs = npc.getCombatDefinitions();
    		if (Utils.getRandom(40) == 0) {
    			CorporealBeast beast = (CorporealBeast) npc;
    			beast.spawnDarkEnergyCore();
    		}
    		int size = npc.getSize();
    		final ArrayList<Entity> possibleTargets = npc.getPossibleTargets();
    		boolean stomp = false;
    		for (Entity t : possibleTargets) {
    			int distanceX = t.getX() - npc.getX();
    			int distanceY = t.getY() - npc.getY();
    			if (distanceX < size && distanceX > -1 && distanceY < size
    					&& distanceY > -1) {
    				stomp = true;
    				delayHit(
    						npc,
    						0,
    						t,
    						getRegularHit(
    								npc,
    								getRandomMaxHit(npc, defs.getMaxHit(),
    										NPCCombatDefinitions.MELEE, t)));
    			}
    		}
    		if (stomp) {
    			npc.setNextAnimation(new Animation(10496));
    			npc.setNextGraphics(new Graphics(1834));
    			return defs.getAttackDelay();
    		}
    		int attackStyle = Utils.getRandom(4);
    		if (attackStyle == 0 || attackStyle == 1) { // melee
    			int distanceX = target.getX() - npc.getX();
    			int distanceY = target.getY() - npc.getY();
    			
    			if (distanceX > size || distanceX < -1 || distanceY > size
    					|| distanceY < -1)
    				attackStyle = 2 + Utils.getRandom(2); // set mage
    			else {
    				npc.setNextAnimation(new Animation(attackStyle == 0 ? defs
    						.getAttackEmote() : 10058));
    				delayHit(
    						npc,
    						0,
    						target,
    						getMeleeHit(
    								npc,
    								getRandomMaxHit(npc, defs.getMaxHit(),
    										NPCCombatDefinitions.MELEE, target)));
    				
    				return defs.getAttackDelay();
    				
    			}
    		}
    		if (attackStyle == 2) { // powerfull mage spiky ball
    			npc.setNextAnimation(new Animation(10410));
    			delayHit(
    					npc,
    					1,
    					target,
    					getMagicHit(
    							npc,
    							getRandomMaxHit(npc, 650,
    									NPCCombatDefinitions.MAGE, target)));
    			World.sendProjectile(npc, target, 1825, 41, 16, 41, 0, 16, 0);
    		} else if (attackStyle == 3) { // translucent ball of energy
    			npc.setNextAnimation(new Animation(10410));
    			delayHit(
    					npc,
    					1,
    					target,
    					getMagicHit(
    							npc,
    							getRandomMaxHit(npc, 550,
    									NPCCombatDefinitions.MAGE, target)));
    			
    			if (target instanceof Player) {
    				WorldTasksManager.schedule(new WorldTask() {
    					@Override
    					public void run() {
    						int skill = Utils.getRandom(2);
    						skill = skill == 0 ? Skills.MAGIC
    								: (skill == 1 ? Skills.SUMMONING
    										: Skills.PRAYER);
    						Player player = (Player) target;
    						if (skill == Skills.PRAYER)
    							player.getPrayer().drainPrayer(
    									10 + Utils.getRandom(40));
    						else {
    							int lvl = player.getSkills().getLevel(skill);
    							lvl -= 1 + Utils.getRandom(4);
    							player.getSkills().set(skill, lvl < 0 ? 0 : lvl);
    						}
    						player.getPackets().sendGameMessage(
    								"Your " + Skills.SKILL_NAME[skill]
    										+ " has been slighly drained!");
    					}
    
    				}, 1);
    				World.sendProjectile(npc, target, 1823, 41, 16, 41, 0, 16, 0);
    			}
    		} else if (attackStyle == 4) {
    			npc.setNextAnimation(new Animation(10410));
    			final WorldTile tile = new WorldTile(target);
    			World.sendProjectile(npc, tile, 1824, 41, 16, 30, 0, 16, 0);
    			WorldTasksManager.schedule(new WorldTask() {
    				@Override
    				public void run() {
    					for (int i = 0; i < 6; i++) {
    						final WorldTile newTile = new WorldTile(tile, 3);
    						if (!World.canMoveNPC(newTile.getPlane(),
    								newTile.getX(), newTile.getY(), 1))
    							continue;
    						World.sendProjectile(npc, tile, newTile, 1824, 0, 0,
    								25, 0, 30, 0);
    						for (Entity t : possibleTargets) {
    							if (Utils.getDistance(newTile.getX(),
    									newTile.getY(), t.getX(), t.getY()) > 1
    									|| !t.clipedProjectile(newTile, false))
    								continue;
    							delayHit(
    									npc,
    									0,
    									t,
    									getMagicHit(
    											npc,
    											getRandomMaxHit(npc, 350,
    													NPCCombatDefinitions.MAGE,
    													t)));
    						}
    						WorldTasksManager.schedule(new WorldTask() {
    							@Override
    							public void run() {
    								World.sendGraphics(npc, new Graphics(1806),
    										newTile);
    							}
    							
    							
    
    						});
    					}
    				}
    			}, 1);
    		}
    		
    		return defs.getAttackDelay();
    		
    	}
    }
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Jan 2015
    Posts
    172
    Thanks given
    94
    Thanks received
    28
    Rep Power
    18
    Code:
    public int attack(...)
    Code:
    int
    Man do you know java? And btw it'd be easier simply to make corp insta kill any familiar that goes in (as it should do) and then you wouldn't need to worry about it attacking them cause they'd be dead.
    Spoiler for Careful seizure:
    penis
    Reply With Quote  
     

  5. #5  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,556
    Thanks given
    652
    Thanks received
    640
    Rep Power
    358
    Try this:

    Code:
    package com.rs.game.npc.combat.impl;
    
    import java.util.ArrayList;
    
    import com.rs.game.Animation;
    import com.rs.game.Entity;
    import com.rs.game.Graphics;
    import com.rs.game.World;
    import com.rs.game.WorldTile;
    import com.rs.game.npc.NPC;
    import com.rs.game.npc.combat.CombatScript;
    import com.rs.game.npc.combat.NPCCombatDefinitions;
    import com.rs.game.npc.corp.CorporealBeast;
    import com.rs.game.player.Player;
    import com.rs.game.player.Skills;
    import com.rs.game.tasks.WorldTask;
    import com.rs.game.tasks.WorldTasksManager;
    import com.rs.utils.Utils;
    
    public class CorporealBeastCombat extends CombatScript {
    
    	@Override
    	public Object[] getKeys() {
    		return new Object[] { 8133 };
    	}
    
    	@Override
    	public int attack(final NPC npc, final Entity target) {
    		final NPCCombatDefinitions defs = npc.getCombatDefinitions();
                    if (target instanceof NPC) {
    		    for (Entity t : possibleTargets) {
                            if (t instanceof Player) {
                                npc.setTarget(t);
                            }
                        }
                    return defs.getAttackDelay();
                    }
    		if (Utils.getRandom(40) == 0) {
    			CorporealBeast beast = (CorporealBeast) npc;
    			beast.spawnDarkEnergyCore();
    		}
    		int size = npc.getSize();
    		final ArrayList<Entity> possibleTargets = npc.getPossibleTargets();
    		boolean stomp = false;
    		for (Entity t : possibleTargets) {
    			int distanceX = t.getX() - npc.getX();
    			int distanceY = t.getY() - npc.getY();
    			if (distanceX < size && distanceX > -1 && distanceY < size
    					&& distanceY > -1) {
    				stomp = true;
    				delayHit(
    						npc,
    						0,
    						t,
    						getRegularHit(
    								npc,
    								getRandomMaxHit(npc, defs.getMaxHit(),
    										NPCCombatDefinitions.MELEE, t)));
    			}
    		}
    		if (stomp) {
    			npc.setNextAnimation(new Animation(10496));
    			npc.setNextGraphics(new Graphics(1834));
    			return defs.getAttackDelay();
    		}
    		int attackStyle = Utils.getRandom(4);
    		if (attackStyle == 0 || attackStyle == 1) { // melee
    			int distanceX = target.getX() - npc.getX();
    			int distanceY = target.getY() - npc.getY();
    			
    			if (distanceX > size || distanceX < -1 || distanceY > size
    					|| distanceY < -1)
    				attackStyle = 2 + Utils.getRandom(2); // set mage
    			else {
    				npc.setNextAnimation(new Animation(attackStyle == 0 ? defs
    						.getAttackEmote() : 10058));
    				delayHit(
    						npc,
    						0,
    						target,
    						getMeleeHit(
    								npc,
    								getRandomMaxHit(npc, defs.getMaxHit(),
    										NPCCombatDefinitions.MELEE, target)));
    				
    				return defs.getAttackDelay();
    				
    			}
    		}
    		if (attackStyle == 2) { // powerfull mage spiky ball
    			npc.setNextAnimation(new Animation(10410));
    			delayHit(
    					npc,
    					1,
    					target,
    					getMagicHit(
    							npc,
    							getRandomMaxHit(npc, 650,
    									NPCCombatDefinitions.MAGE, target)));
    			World.sendProjectile(npc, target, 1825, 41, 16, 41, 0, 16, 0);
    		} else if (attackStyle == 3) { // translucent ball of energy
    			npc.setNextAnimation(new Animation(10410));
    			delayHit(
    					npc,
    					1,
    					target,
    					getMagicHit(
    							npc,
    							getRandomMaxHit(npc, 550,
    									NPCCombatDefinitions.MAGE, target)));
    			
    			if (target instanceof Player) {
    				WorldTasksManager.schedule(new WorldTask() {
    					@Override
    					public void run() {
    						int skill = Utils.getRandom(2);
    						skill = skill == 0 ? Skills.MAGIC
    								: (skill == 1 ? Skills.SUMMONING
    										: Skills.PRAYER);
    						Player player = (Player) target;
    						if (skill == Skills.PRAYER)
    							player.getPrayer().drainPrayer(
    									10 + Utils.getRandom(40));
    						else {
    							int lvl = player.getSkills().getLevel(skill);
    							lvl -= 1 + Utils.getRandom(4);
    							player.getSkills().set(skill, lvl < 0 ? 0 : lvl);
    						}
    						player.getPackets().sendGameMessage(
    								"Your " + Skills.SKILL_NAME[skill]
    										+ " has been slighly drained!");
    					}
    
    				}, 1);
    				World.sendProjectile(npc, target, 1823, 41, 16, 41, 0, 16, 0);
    			}
    		} else if (attackStyle == 4) {
    			npc.setNextAnimation(new Animation(10410));
    			final WorldTile tile = new WorldTile(target);
    			World.sendProjectile(npc, tile, 1824, 41, 16, 30, 0, 16, 0);
    			WorldTasksManager.schedule(new WorldTask() {
    				@Override
    				public void run() {
    					for (int i = 0; i < 6; i++) {
    						final WorldTile newTile = new WorldTile(tile, 3);
    						if (!World.canMoveNPC(newTile.getPlane(),
    								newTile.getX(), newTile.getY(), 1))
    							continue;
    						World.sendProjectile(npc, tile, newTile, 1824, 0, 0,
    								25, 0, 30, 0);
    						for (Entity t : possibleTargets) {
    							if (Utils.getDistance(newTile.getX(),
    									newTile.getY(), t.getX(), t.getY()) > 1
    									|| !t.clipedProjectile(newTile, false))
    								continue;
    							delayHit(
    									npc,
    									0,
    									t,
    									getMagicHit(
    											npc,
    											getRandomMaxHit(npc, 350,
    													NPCCombatDefinitions.MAGE,
    													t)));
    						}
    						WorldTasksManager.schedule(new WorldTask() {
    							@Override
    							public void run() {
    								World.sendGraphics(npc, new Graphics(1806),
    										newTile);
    							}
    							
    							
    
    						});
    					}
    				}
    			}, 1);
    		}
    		
    		return defs.getAttackDelay();
    		
    	}
    }
    Project thread
    [Only registered and activated users can see links. ]
    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. Corp beast attack styles
    By Hellenic in forum Help
    Replies: 1
    Last Post: 03-07-2012, 06:46 AM
  2. Corp Beast Melee Attack + Death Emotes
    By comboed in forum Requests
    Replies: 2
    Last Post: 10-06-2010, 02:12 PM
  3. Corp Beast Coords
    By SilentZPrO in forum Requests
    Replies: 13
    Last Post: 10-28-2009, 08:37 PM
  4. Death Emote For Corp Beast
    By Two Face in forum Requests
    Replies: 6
    Last Post: 05-16-2009, 12:31 AM
  5. Corp beast prob on 317 server.
    By mudvayne5493 in forum Help
    Replies: 0
    Last Post: 02-01-2009, 07:08 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
  •