pai
							
								
									8509794eeb
								
							
						
					
					
						commit
						49b327b951
					
				| Antes Largura: | Altura: | Tamanho: 1.5 KiB Depois Largura: | Altura: | Tamanho: 2.9 KiB | 
									
										Arquivo binário não exibido.
									
								
							
						| @ -0,0 +1,48 @@ | |||||||
|  | package mightypork.rogue.world.entity.entities; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | import mightypork.rogue.world.entity.AiTimer; | ||||||
|  | import mightypork.rogue.world.entity.Entity; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | public class BossRatAi extends GrayRatAi { | ||||||
|  | 	 | ||||||
|  | 	private final AiTimer healTimer = new AiTimer(0.5) { | ||||||
|  | 		 | ||||||
|  | 		@Override | ||||||
|  | 		public void run() | ||||||
|  | 		{ | ||||||
|  | 			entity.health.addHealth(1); // heal
 | ||||||
|  | 		} | ||||||
|  | 	}; | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	public BossRatAi(Entity entity) | ||||||
|  | 	{ | ||||||
|  | 		super(entity); | ||||||
|  | 		 | ||||||
|  | 		setAttackTime(0.6); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	protected int getAttackStrength() | ||||||
|  | 	{ | ||||||
|  | 		return 5 + rand.nextInt(4); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	protected int getPreyAbandonDistance() | ||||||
|  | 	{ | ||||||
|  | 		return 15 + rand.nextInt(4); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	public void update(double delta) | ||||||
|  | 	{ | ||||||
|  | 		super.update(delta); | ||||||
|  | 		healTimer.update(delta); | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @ -0,0 +1,37 @@ | |||||||
|  | package mightypork.rogue.world.entity.entities; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | import mightypork.rogue.world.entity.Entity; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | public class BrownRatAi extends GrayRatAi { | ||||||
|  | 	 | ||||||
|  | 	public BrownRatAi(Entity entity) | ||||||
|  | 	{ | ||||||
|  | 		super(entity); | ||||||
|  | 		 | ||||||
|  | 		setAttackTime(0.8); | ||||||
|  | 		setScanTime(1); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	protected double getScanRadius() | ||||||
|  | 	{ | ||||||
|  | 		return isSleeping() ? 3 + rand.nextInt(3) : 5 + rand.nextInt(3); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	protected int getAttackStrength() | ||||||
|  | 	{ | ||||||
|  | 		return 3 + rand.nextInt(2); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	protected int getPreyAbandonDistance() | ||||||
|  | 	{ | ||||||
|  | 		return 11 + rand.nextInt(4); | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @ -0,0 +1,92 @@ | |||||||
|  | package mightypork.rogue.world.entity.entities; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | import mightypork.gamecore.util.math.algo.pathfinding.PathFinder; | ||||||
|  | import mightypork.rogue.world.entity.Entity; | ||||||
|  | import mightypork.rogue.world.entity.EntityModel; | ||||||
|  | import mightypork.rogue.world.entity.EntityPathFinder; | ||||||
|  | import mightypork.rogue.world.entity.EntityRenderer; | ||||||
|  | import mightypork.rogue.world.entity.EntityType; | ||||||
|  | import mightypork.rogue.world.entity.render.EntityRendererMobLR; | ||||||
|  | import mightypork.rogue.world.item.Items; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | public class EntityBossRat extends Entity { | ||||||
|  | 	 | ||||||
|  | 	private EntityRenderer renderer; | ||||||
|  | 	 | ||||||
|  | 	/** Navigation PFC */ | ||||||
|  | 	private final PathFinder pathf = new EntityPathFinder(this); | ||||||
|  | 	 | ||||||
|  | 	private final BossRatAi ai = new BossRatAi(this); | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	public EntityBossRat(EntityModel model, int eid) | ||||||
|  | 	{ | ||||||
|  | 		super(model, eid); | ||||||
|  | 		 | ||||||
|  | 		addModule("ai", ai); | ||||||
|  | 		pos.addMoveListener(ai); | ||||||
|  | 		 | ||||||
|  | 		pos.setStepTime(0.4); | ||||||
|  | 		setDespawnDelay(1); | ||||||
|  | 		 | ||||||
|  | 		health.setMaxHealth(80); | ||||||
|  | 		health.setHealth(80); | ||||||
|  | 		health.setHitCooldownTime(0.35); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	protected EntityRenderer getRenderer() | ||||||
|  | 	{ | ||||||
|  | 		if (renderer == null) { | ||||||
|  | 			renderer = new EntityRendererMobLR(this, "sprite.rat.boss"); | ||||||
|  | 		} | ||||||
|  | 		 | ||||||
|  | 		return renderer; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	public EntityType getType() | ||||||
|  | 	{ | ||||||
|  | 		return EntityType.MONSTER; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	public PathFinder getPathFinder() | ||||||
|  | 	{ | ||||||
|  | 		return pathf; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	public void onCorpseRemoved() | ||||||
|  | 	{ | ||||||
|  | 		// TODO drop rare stuff & fire event.
 | ||||||
|  | 		 | ||||||
|  | 		if (rand.nextInt(8) == 0) { | ||||||
|  | 			getLevel().dropNear(getCoord(), Items.BONE.createItem()); | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  | 		 | ||||||
|  | 		if (rand.nextInt(3) == 0) { | ||||||
|  | 			getLevel().dropNear(getCoord(), Items.MEAT.createItem()); | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  | 		 | ||||||
|  | 		if (rand.nextInt(6) == 0) { | ||||||
|  | 			getLevel().dropNear(getCoord(), Items.CHEESE.createItem()); | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	public String getVisualName() | ||||||
|  | 	{ | ||||||
|  | 		return "Rat Boss"; | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @ -0,0 +1,92 @@ | |||||||
|  | package mightypork.rogue.world.entity.entities; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | import mightypork.gamecore.util.math.Calc; | ||||||
|  | import mightypork.gamecore.util.math.algo.pathfinding.PathFinder; | ||||||
|  | import mightypork.rogue.world.entity.Entity; | ||||||
|  | import mightypork.rogue.world.entity.EntityModel; | ||||||
|  | import mightypork.rogue.world.entity.EntityPathFinder; | ||||||
|  | import mightypork.rogue.world.entity.EntityRenderer; | ||||||
|  | import mightypork.rogue.world.entity.EntityType; | ||||||
|  | import mightypork.rogue.world.entity.render.EntityRendererMobLR; | ||||||
|  | import mightypork.rogue.world.item.Items; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | public class EntityBrownRat extends Entity { | ||||||
|  | 	 | ||||||
|  | 	private EntityRenderer renderer; | ||||||
|  | 	 | ||||||
|  | 	private final PathFinder pathf = new EntityPathFinder(this); | ||||||
|  | 	 | ||||||
|  | 	private final BrownRatAi ai = new BrownRatAi(this); | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	public EntityBrownRat(EntityModel model, int eid) | ||||||
|  | 	{ | ||||||
|  | 		super(model, eid); | ||||||
|  | 		 | ||||||
|  | 		addModule("ai", ai); | ||||||
|  | 		pos.addMoveListener(ai); | ||||||
|  | 		 | ||||||
|  | 		pos.setStepTime(0.37); // faster than gray rat
 | ||||||
|  | 		setDespawnDelay(1); | ||||||
|  | 		 | ||||||
|  | 		health.setMaxHealth(14); | ||||||
|  | 		health.setHealth(Calc.randInt(rand, 8, 14)); // tougher to kill
 | ||||||
|  | 		health.setHitCooldownTime(0.35); // a bit longer than gray rat
 | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	protected EntityRenderer getRenderer() | ||||||
|  | 	{ | ||||||
|  | 		if (renderer == null) { | ||||||
|  | 			renderer = new EntityRendererMobLR(this, "sprite.rat.brown"); | ||||||
|  | 		} | ||||||
|  | 		 | ||||||
|  | 		return renderer; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	public EntityType getType() | ||||||
|  | 	{ | ||||||
|  | 		return EntityType.MONSTER; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	public PathFinder getPathFinder() | ||||||
|  | 	{ | ||||||
|  | 		return pathf; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	public void onCorpseRemoved() | ||||||
|  | 	{ | ||||||
|  | 		// drop rat stuff
 | ||||||
|  | 		 | ||||||
|  | 		if (rand.nextInt(8) == 0) { | ||||||
|  | 			getLevel().dropNear(getCoord(), Items.BONE.createItemDamaged(10)); | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  | 		 | ||||||
|  | 		if (rand.nextInt(3) == 0) { | ||||||
|  | 			getLevel().dropNear(getCoord(), Items.MEAT.createItem()); | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  | 		 | ||||||
|  | 		if (rand.nextInt(6) == 0) { | ||||||
|  | 			getLevel().dropNear(getCoord(), Items.CHEESE.createItem()); | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	public String getVisualName() | ||||||
|  | 	{ | ||||||
|  | 		return "Brown Rat"; | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @ -0,0 +1,34 @@ | |||||||
|  | package mightypork.rogue.world.gen; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Error in world generation | ||||||
|  |  *  | ||||||
|  |  * @author MightyPork | ||||||
|  |  */ | ||||||
|  | public class WorldGenError extends RuntimeException { | ||||||
|  | 	 | ||||||
|  | 	public WorldGenError() | ||||||
|  | 	{ | ||||||
|  | 		super(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	public WorldGenError(String message, Throwable cause) | ||||||
|  | 	{ | ||||||
|  | 		super(message, cause); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	public WorldGenError(String message) | ||||||
|  | 	{ | ||||||
|  | 		super(message); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	public WorldGenError(Throwable cause) | ||||||
|  | 	{ | ||||||
|  | 		super(cause); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
| @ -0,0 +1,36 @@ | |||||||
|  | package mightypork.rogue.world.gen.rooms; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | import java.util.Random; | ||||||
|  | 
 | ||||||
|  | import mightypork.gamecore.util.math.algo.Coord; | ||||||
|  | import mightypork.rogue.world.entity.Entities; | ||||||
|  | import mightypork.rogue.world.entity.Entity; | ||||||
|  | import mightypork.rogue.world.gen.MapTheme; | ||||||
|  | import mightypork.rogue.world.gen.ScratchMap; | ||||||
|  | import mightypork.rogue.world.gen.WorldGenError; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | public class BossRoom extends SecretRoom { | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	protected int getDoorCount(Random rand) | ||||||
|  | 	{ | ||||||
|  | 		return 2; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	protected void buildExtras(ScratchMap map, MapTheme theme, Random rand, Coord min, Coord max) | ||||||
|  | 	{ | ||||||
|  | 		final Entity boss = Entities.RAT_BOSS.createEntity(); | ||||||
|  | 		if (!map.putEntityInArea(boss, min, max, 100)) { | ||||||
|  | 			 | ||||||
|  | 			// just place it anywhere then
 | ||||||
|  | 			if (!map.putEntityInMap(boss, 100)) { | ||||||
|  | 				throw new WorldGenError("Could not place boss."); | ||||||
|  | 			} | ||||||
|  | 			 | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
					Carregando…
					
					
				
		Referência em uma nova issue