Thread: [637/639] Custom Guthix NPC

Results 1 to 6 of 6
  1. #1 [637/639] Custom Guthix NPC 
    Banned
    Join Date
    Nov 2012
    Posts
    21
    Thanks given
    1
    Thanks received
    3
    Rep Power
    0
    Originality is the best thing you need in your server.

    src\org\dementhium\model\npc\impl

    Code:
    package org.dementhium.model.npc.impl;
    
    import org.dementhium.model.combat.CombatAction;
    import org.dementhium.model.combat.impl.npc.GuthixAction;
    import org.dementhium.model.npc.NPC;
    
    /**
     * @author obamayolo
     *
     */
    public class Guthix extends NPC {
    
    	/**
    	 * The combat action used.
    	 */
    	private final CombatAction combatAction = new GuthixAction(this);
    	
    	/**
    	 * Constructs a new {@code Guthix} {@code Object}.
    	 * @param id The NPC id.
    	 */
    	public Guthix(int id) {
    		super(id);
    	}
    	
    	@Override
    	public CombatAction getCombatAction() {
    		return combatAction;
    	}
    
    }
    Combat -> impl

    Code:
    package org.dementhium.model.combat.impl.npc;
    
    import java.util.Random;
    
    import org.dementhium.model.Projectile;
    import org.dementhium.model.World;
    import org.dementhium.model.combat.CombatAction;
    import org.dementhium.model.combat.CombatMovement;
    import org.dementhium.model.combat.CombatTask;
    import org.dementhium.model.combat.CombatType;
    import org.dementhium.model.combat.Damage;
    import org.dementhium.model.combat.Interaction;
    import org.dementhium.model.combat.MeleeFormulae;
    import org.dementhium.model.mask.Animation;
    import org.dementhium.model.mask.Graphic;
    import org.dementhium.model.misc.ProjectileManager;
    import org.dementhium.model.misc.DamageManager.DamageType;
    import org.dementhium.util.Misc;
    import org.dementhium.model.npc.impl.Guthix;
    
    /**
     * @author obamayolo
     */
    public class GuthixAction extends CombatAction {
    
    	private final Guthix guthix;
    
    	private static Random RANDOM = new Random();
    	
    	private static enum Attack {
    		MELEE(Animation.create(402),
    				Graphic.create(-1, 96 << 16), 
    				Projectile.create(null, null, -1, 30, 32, 52, 75, 3, 11), 
    				Graphic.create(-1, 96 << 16), new CombatTask() {
    					@Override
    					public boolean execute(Interaction interaction) {
    						if (RANDOM.nextInt(15) > 12) {
    							interaction.getVictim().getPoisonManager().poison(interaction.getSource(), 80);
    						}
    						return true;
    					}
    				}
    		),
    		ICE(Animation.create(1979),
    				Graphic.create(-1, 96 << 16), 
    				Projectile.create(null, null, 368, 30, 32, 52, 75, 3, 11), 
    				Graphic.create(369), new CombatTask() {
    					@Override
    					public boolean execute(Interaction interaction) {
    						if (interaction.getVictim().getAttribute("freezeImmunity", -1) < World.getTicks()) {
    							interaction.getVictim().setAttribute("freezeTime", World.getTicks() + 24);
    							interaction.getVictim().setAttribute("freezeImmunity", World.getTicks() + 28);
    							int VictimX = interaction.getVictim().getLocation().getX();
    							int VictimY = interaction.getVictim().getLocation().getY();
    							int VictimZ = interaction.getVictim().getLocation().getZ();
    							interaction.getSource().teleportWithExtra(VictimX + Misc.random(-4, 4), VictimY + Misc.random(-4, 4), VictimZ);
    						} else {
    							interaction.getVictim().graphics(1677, 96 << 16);
    						}
    						return true;
    					}
    				}
    		),
    		BLOOD(Animation.create(1979),
    				Graphic.create(-1, 96 << 16), 
    				Projectile.create(null, null, -1, 30, 32, 52, 75, 3, 11), 
    				Graphic.create(377), new CombatTask() {
    					@Override
    					public boolean execute(Interaction interaction) {
    						interaction.getSource().heal(Misc.random(1, 300) / 3);
    						return true;
    					}
    				}
    		),
    		EAT(Animation.create(829),
    				Graphic.create(-1, 96 << 16), 
    				Projectile.create(null, null, -1, 30, 32, 52, 75, 3, 11), 
    				Graphic.create(-1), new CombatTask() {
    					@Override
    					public boolean execute(Interaction interaction) {
    						int i = Misc.random(1, 6);
    						if (i == 6)
    							interaction.getSource().heal(400); //Baked potato
    						else {
    							interaction.getSource().heal(230);
    						}
    							interaction.getSource().setFood(interaction.getSource().getFood() - 1);
    						return true;
    					}
    				}
    		),
    		SPECIAL(Animation.create(1062),
    				Graphic.create(252, 96 << 16), 
    				Projectile.create(null, null, -1, 30, 32, 52, 75, 3, 11), 
    				Graphic.create(-1, 96 << 16), new CombatTask() {
    					@Override
    					public boolean execute(Interaction interaction) {
    						interaction.getVictim().getDamageManager().miscDamage(Misc.random(1, 350), DamageType.MELEE);
    						if (RANDOM.nextInt(15) > 12) {
    							interaction.getVictim().getPoisonManager().poison(interaction.getSource(), 80);
    						}
    						return true;
    					}
    				}
    		);
    	
    		
    		private final Animation anim;
    		
    		private final Graphic start;
    		
    		private final Projectile projectile;
    
    		private final Graphic end;
    
    		private final CombatTask task;
    
    		private Attack(Animation anim, Graphic start, Projectile projectile, Graphic end, CombatTask task) {
    			this.anim = anim;
    			this.start = start;
    			this.projectile = projectile;
    			this.end = end;
    			this.task = task;
    		}
    	}
    	
    	/**
    	 * The current combat type used.
    	 */
    	private CombatType type = CombatType.MAGIC;
    	
    	/**
    	 * The current attack used.
    	 */
    	private Attack attack;
    	
    	/**
    	 * Constructs a new {@code GuthixAction} {@code Object}.
    	 */
    	public GuthixAction(Guthix guthix) {
    		super(false);
    		this.guthix = guthix;
    	}
    
    	@Override
    	public boolean commenceSession() {
    	int arg = Misc.random(1, 8);
    	int hit;
    		interaction.getSource().getCombatExecutor().setTicks(5);
    		if (CombatMovement.canMelee(guthix, interaction.getVictim()) && arg > 4) {
                type = CombatType.MELEE;
            } else {
            	type = CombatType.values()[1 + guthix.getRandom().nextInt(2)];
            }
    		if (interaction.getSource().getRandom().nextInt(10) < 5) {
    			attack = Attack.values()[interaction.getSource().getRandom().nextInt(Attack.values().length)];
    		}
    		if (CombatMovement.canMelee(interaction.getSource(), interaction.getVictim()) && arg > 4) {
    			if (RANDOM.nextInt(15) > 4) {
    				attack = Attack.MELEE;
    			} else {
    				attack = Attack.SPECIAL;
    			}
    			type = CombatType.MELEE;
    			hit = MeleeFormulae.getDamage(interaction.getSource(), interaction.getVictim());
    			interaction.setDamage(Damage.getDamage(interaction.getSource(), interaction.getVictim(), type, hit));
    			interaction.getDamage().setMaximum(350);
    		} else if (interaction.getSource().getHitPoints() < 1000 && interaction.getSource().getFood() > 0) {
    			attack = Attack.EAT;
    		} else {
    			if (RANDOM.nextInt(10) >= 5) {
    				attack = Attack.ICE;
    			} else {
    				attack = Attack.BLOOD;
    			}
    			type = CombatType.MAGIC;
    			hit = MeleeFormulae.getDamage(interaction.getSource(), interaction.getVictim());
    			interaction.setDamage(Damage.getDamage(interaction.getSource(), interaction.getVictim(), type, hit));
    			interaction.getDamage().setMaximum(320);
    		} 
    		ProjectileManager.sendProjectile(attack.projectile.transform(interaction.getSource(), interaction.getVictim()));
    		interaction.getSource().animate(attack.anim);
    		interaction.getSource().graphics(attack.start);
            int ticks = (int) Math.floor(attack.projectile.getSourceLocation().distance(interaction.getVictim().getLocation()) * 0.3);
    		interaction.setTicks(ticks);
    		return true;
    	}
    
    	@Override
    	public boolean executeSession() {
    		if (interaction.getTicks() < 2) {
    			if (interaction.isDeflected()) {
    				interaction.getVictim().graphics(2230 - type.ordinal());
    			}
    			interaction.getVictim().animate(interaction.isDeflected() ? 12573 : interaction.getVictim().getDefenceAnimation());
    		}
    		interaction.setTicks(interaction.getTicks() - 1);
    		return interaction.getTicks() < 1;
    	}
    
    	@Override
    	public boolean endSession() {
    		interaction.getVictim().graphics(attack.end);
    		if (attack.task.execute(interaction) && interaction.getDamage() != null) {
    			if (interaction.getDamage().getHit() > -1) {
    				interaction.getVictim().getDamageManager().damage(
    						interaction.getSource(), interaction.getDamage(), type.getDamageType());
    			} else {
    				interaction.getVictim().graphics(85, 96 << 16);
    			}
    			if (interaction.getDamage().getVenged() > 0) {
    				interaction.getVictim().submitVengeance(interaction.getSource(), interaction.getDamage().getVenged());
    			}
    			if (interaction.getDamage().getDeflected() > 0) {
    				interaction.getSource().getDamageManager().damage(interaction.getVictim(), 
    						interaction.getDamage().getDeflected(), 
    						interaction.getDamage().getDeflected(), DamageType.DEFLECT);
    			}
    			if (interaction.getDamage().getRecoiled() > 0) {
    				interaction.getSource().getDamageManager().damage(interaction.getVictim(), 
    						interaction.getDamage().getRecoiled(), 
    						interaction.getDamage().getRecoiled(), DamageType.DEFLECT);
    			}
    			interaction.getVictim().retaliate(interaction.getSource());
    		}
    		return true;
    	}
    
    	@Override
    	public CombatType getCombatType() {
    		return CombatType.MAGIC;
    	}
    
    }
    Trying to get people to be original, so this basically is a bridding NPC (: This npc will Barrage, move different spot, blood barrage, and dds spec, it's all in these folders (:
    Reply With Quote  
     

  2. #2  
    Banned

    Join Date
    Aug 2012
    Posts
    611
    Thanks given
    88
    Thanks received
    118
    Rep Power
    0
    lmao, nice rip. I remember my code even if it is old
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Feb 2013
    Posts
    46
    Thanks given
    1
    Thanks received
    0
    Rep Power
    11
    What is the NPC ID please?
    I also get this :/

    Compiling server...
    src\org\dementhium\model\combat\impl\npc\GuthixAct ion.java:56: error: cannot fin
    d symbol
    interaction.getSource().
    teleportWithExtra(VictimX + Misc.random(-4, 4), VictimY + Misc.random(-4, 4), Vi
    ctimZ);
    ^

    symbol: method teleportWithExtra(int,int,int)
    location: class Mob
    src\org\dementhium\model\combat\impl\npc\GuthixAct ion.java:87: error: cannot fin
    d symbol
    interaction.getSource().
    setFood(interaction.getSource().getFood() - 1);

    ^
    symbol: method getFood()
    location: class Mob
    src\org\dementhium\model\combat\impl\npc\GuthixAct ion.java:168: error: cannot fi
    nd symbol
    } else if (interaction.getSource().getHitPoints() < 1000 && inte
    raction.getSource().getFood() > 0) {

    ^
    symbol: method getFood()
    location: class Mob
    3 errors
    src\org\dementhium\model\combat\impl\npc\GuthixAct ion.java:56: error: cannot fin
    d symbol
    interaction.getSource().
    teleportWithExtra(VictimX + Misc.random(-4, 4), VictimY + Misc.random(-4, 4), Vi
    ctimZ);
    ^

    symbol: method teleportWithExtra(int,int,int)
    location: class Mob
    src\org\dementhium\model\combat\impl\npc\GuthixAct ion.java:87: error: cannot fin
    d symbol
    interaction.getSource().
    setFood(interaction.getSource().getFood() - 1);

    ^
    symbol: method getFood()
    location: class Mob
    src\org\dementhium\model\combat\impl\npc\GuthixAct ion.java:168: error: cannot fi
    nd symbol
    } else if (interaction.getSource().getHitPoints() < 1000 && inte
    raction.getSource().getFood() > 0) {

    ^
    symbol: method getFood()
    location: class Mob
    3 errors
    Complete
    Press any key to continue . . .
    Reply With Quote  
     

  4. #4  
    Registered Member

    Join Date
    Jan 2013
    Posts
    795
    Thanks given
    257
    Thanks received
    191
    Rep Power
    197
    Quote Originally Posted by macklemore View Post
    what is the npc id please?
    I also get this :/
    11-07-2012, 09:45 pm
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Feb 2013
    Posts
    46
    Thanks given
    1
    Thanks received
    0
    Rep Power
    11
    Quote Originally Posted by RuneTime718 View Post
    11-07-2012, 09:45 pm
    Umm what?
    Reply With Quote  
     

  6. #6  
    Member
    Join Date
    Aug 2012
    Posts
    264
    Thanks given
    3
    Thanks received
    39
    Rep Power
    0
    Quote Originally Posted by Macklemore View Post
    Umm what?
    He's saying that this thread is dead and you're gravedigging.
    Reply With Quote  
     

  7. Thankful user:



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. [637/639]Custom Name Colours
    By Gaaz in forum Snippets
    Replies: 22
    Last Post: 12-10-2014, 07:13 AM
  2. [637/639] Custom Special Attack
    By Arcanelights in forum Requests
    Replies: 0
    Last Post: 05-09-2012, 10:06 PM
  3. [637/639] Custom Special Attack
    By Arcanelights in forum Help
    Replies: 2
    Last Post: 04-28-2012, 10:55 AM
  4. 637/639 Custom Wilderness Spots
    By SkyMD in forum Requests
    Replies: 2
    Last Post: 04-17-2012, 02:40 AM
  5. [637/639]Dementhium Custom Titles[637/639]
    By nbness2 in forum Snippets
    Replies: 6
    Last Post: 03-10-2012, 03:42 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
  •