v0.6.3: moved many resistances and immunities to character properties

This commit is contained in:
Evan Debenham 2018-01-27 21:03:03 -05:00 committed by Evan Debenham
parent 80d19ac2d0
commit 5529239973
38 changed files with 100 additions and 108 deletions

View File

@ -23,10 +23,16 @@ package com.shatteredpixel.shatteredpixeldungeon.actors;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Electricity;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bless;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Charm;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Chill;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Corruption;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Cripple;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Doom;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.EarthImbue;
@ -34,14 +40,24 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FireImbue;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MagicalSleep;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Ooze;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Preparation;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Slow;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Speed;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Venom;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Vertigo;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Potential;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfPsionicBlast;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfFireblast;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfLightning;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Blazing;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Grim;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Shocking;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.features.Door;
@ -56,6 +72,7 @@ import com.watabou.utils.GameMath;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Random;
import java.util.Arrays;
import java.util.HashSet;
public abstract class Char extends Actor {
@ -277,10 +294,10 @@ public abstract class Char extends Actor {
}
Class<?> srcClass = src.getClass();
if (immunities().contains( srcClass )) {
if (isImmune( srcClass )) {
dmg = 0;
} else if (resistances().contains( srcClass )) {
dmg = Random.IntRange( 0, dmg );
} else {
dmg = Math.round( dmg * resist( srcClass ));
}
if (buff( Paralysis.class ) != null) {
@ -493,6 +510,16 @@ public abstract class Char extends Actor {
return result;
}
public float resist( Class effect ){
float result = 1f;
for (Class c : resistances()){
if (c.isAssignableFrom(effect)){
result *= Random.Float();
}
}
return result;
}
protected final HashSet<Class> immunities = new HashSet<>();
public HashSet<Class> immunities() {
@ -506,6 +533,15 @@ public abstract class Char extends Actor {
return result;
}
public boolean isImmune(Class effect ){
for (Class c : immunities()){
if (c.isAssignableFrom(effect)){
return true;
}
}
return false;
}
protected HashSet<Property> properties = new HashSet<>();
public HashSet<Property> properties() {
@ -513,10 +549,22 @@ public abstract class Char extends Actor {
}
public enum Property{
BOSS,
MINIBOSS,
BOSS ( new HashSet<Class>( Arrays.asList(Grim.class, ScrollOfPsionicBlast.class)),
new HashSet<Class>( Arrays.asList(Corruption.class) )),
MINIBOSS ( new HashSet<Class>(),
new HashSet<Class>( Arrays.asList(Corruption.class) )),
UNDEAD,
DEMONIC,
INORGANIC ( new HashSet<Class>(),
new HashSet<Class>( Arrays.asList(Bleeding.class, ToxicGas.class, Poison.class, Venom.class) )),
BLOB_IMMUNE ( new HashSet<Class>(),
new HashSet<Class>( Arrays.asList(Blob.class) )),
FIERY ( new HashSet<Class>( Arrays.asList(WandOfFireblast.class)),
new HashSet<Class>( Arrays.asList(Burning.class, Blazing.class))),
ACIDIC ( new HashSet<Class>( Arrays.asList(ToxicGas.class)),
new HashSet<Class>( Arrays.asList(Ooze.class))),
ELECTRIC ( new HashSet<Class>( Arrays.asList(WandOfLightning.class, Shocking.class, Potential.class, Electricity.class)),
new HashSet<Class>()),
IMMOVABLE;
private HashSet<Class> resistances;

View File

@ -43,8 +43,9 @@ public class ConfusionGas extends Blob {
for (int j = area.top; j < area.bottom; j++){
cell = i + j*Dungeon.level.width();
if (cur[cell] > 0 && (ch = Actor.findChar( cell )) != null) {
if (!ch.immunities().contains(this.getClass()))
Buff.prolong( ch, Vertigo.class, 2 );
if (!ch.isImmune(this.getClass())) {
Buff.prolong(ch, Vertigo.class, 2);
}
}
}
}

View File

@ -63,7 +63,7 @@ public class Electricity extends Blob {
cell = i + j*Dungeon.level.width();
if (cur[cell] > 0) {
Char ch = Actor.findChar( cell );
if (ch != null && !ch.immunities().contains(this.getClass())) {
if (ch != null && !ch.isImmune(this.getClass())) {
Buff.prolong( ch, Paralysis.class, 1f);
if (cur[cell] % 2 == 1) {
ch.damage(Math.round(Random.Float(2 + Dungeon.depth / 5f)), this);

View File

@ -98,7 +98,7 @@ public class Fire extends Blob {
private void burn( int pos ) {
Char ch = Actor.findChar( pos );
if (ch != null && !ch.immunities().contains(this.getClass())) {
if (ch != null && !ch.isImmune(this.getClass())) {
Buff.affect( ch, Burning.class ).reignite( ch );
}

View File

@ -56,7 +56,7 @@ public class Freezing extends Blob {
}
Char ch = Actor.findChar( cell );
if (ch != null && !ch.immunities().contains(this.getClass())) {
if (ch != null && !ch.isImmune(this.getClass())) {
if (ch.buff(Frost.class) != null){
Buff.affect(ch, Frost.class, 2f);
} else {

View File

@ -43,7 +43,7 @@ public class ParalyticGas extends Blob {
for (int j = area.top; j < area.bottom; j++) {
cell = i + j * Dungeon.level.width();
if (cur[cell] > 0 && (ch = Actor.findChar(cell)) != null) {
if (!ch.immunities().contains(this.getClass()))
if (!ch.isImmune(this.getClass()))
Buff.prolong(ch, Paralysis.class, Paralysis.duration(ch));
}
}

View File

@ -60,7 +60,7 @@ public class Regrowth extends Blob {
Char ch = Actor.findChar( cell );
if (ch != null
&& !ch.immunities().contains(this.getClass())
&& !ch.isImmune(this.getClass())
&& off[cell] > 1) {
Buff.prolong( ch, Roots.class, TICK );
}

View File

@ -43,7 +43,7 @@ public class StenchGas extends Blob {
for (int j = area.top; j < area.bottom; j++){
cell = i + j*Dungeon.level.width();
if (cur[cell] > 0 && (ch = Actor.findChar( cell )) != null) {
if (!ch.immunities().contains(this.getClass()))
if (!ch.isImmune(this.getClass()))
Buff.prolong( ch, Paralysis.class, Paralysis.duration( ch )/5 );
}
}

View File

@ -47,7 +47,7 @@ public class ToxicGas extends Blob implements Hero.Doom {
for (int j = area.top; j < area.bottom; j++){
cell = i + j*Dungeon.level.width();
if (cur[cell] > 0 && (ch = Actor.findChar( cell )) != null) {
if (!ch.immunities().contains(this.getClass())) {
if (!ch.isImmune(this.getClass())) {
int damage = (ch.HT + levelDamage) / 40;
if (Random.Int( 40 ) < (ch.HT + levelDamage) % 40) {

View File

@ -49,7 +49,7 @@ public class VenomGas extends Blob {
for (int j = area.top; j < area.bottom; j++){
cell = i + j*Dungeon.level.width();
if (cur[cell] > 0 && (ch = Actor.findChar( cell )) != null) {
if (!ch.immunities().contains(this.getClass()))
if (!ch.isImmune(this.getClass()))
Buff.affect(ch, Venom.class).set(2f, strength);
}
}

View File

@ -47,7 +47,7 @@ public class Web extends Blob {
volume += off[cell];
Char ch = Actor.findChar( cell );
if (ch != null && !ch.immunities().contains(this.getClass())) {
if (ch != null && !ch.isImmune(this.getClass())) {
Buff.prolong( ch, Roots.class, TICK );
}
}

View File

@ -21,6 +21,7 @@
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ConfusionGas;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Electricity;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire;
@ -55,16 +56,7 @@ public class BlobImmunity extends FlavourBuff {
}
{
immunities.add( ParalyticGas.class );
immunities.add( ToxicGas.class );
immunities.add( ConfusionGas.class );
immunities.add( StenchGas.class );
immunities.add( VenomGas.class );
immunities.add( Fire.class );
immunities.add( Freezing.class );
immunities.add( Electricity.class );
immunities.add( Regrowth.class );
immunities.add( Web.class );
immunities.add( Blob.class );
}
@Override

View File

@ -57,7 +57,7 @@ public class Buff extends Actor {
public boolean attachTo( Char target ) {
if (target.immunities().contains( getClass() )) {
if (target.isImmune( getClass() )) {
return false;
}

View File

@ -38,7 +38,7 @@ public class Drowsy extends Buff {
}
public boolean attachTo( Char target ) {
if (!target.immunities().contains(Sleep.class) && super.attachTo(target)) {
if (!target.isImmune(Sleep.class) && super.attachTo(target)) {
if (cooldown() == 0)
spend(Random.Int(3, 6));
return true;

View File

@ -34,7 +34,7 @@ public class MagicalSleep extends Buff {
@Override
public boolean attachTo( Char target ) {
if (!target.immunities().contains(Sleep.class) && super.attachTo( target )) {
if (!target.isImmune(Sleep.class) && super.attachTo( target )) {
if (target instanceof Hero)
if (target.HP == target.HT) {

View File

@ -93,5 +93,6 @@ public class ToxicImbue extends Buff {
{
immunities.add( ToxicGas.class );
immunities.add( Poison.class );
immunities.add( Venom.class );
}
}

View File

@ -33,6 +33,8 @@ public class Acidic extends Scorpio {
{
spriteClass = AcidicSprite.class;
properties.add(Property.ACIDIC);
}
@Override

View File

@ -89,7 +89,4 @@ public class Bat extends Mob {
return super.createLoot();
}
{
resistances.add( Vampiric.class );
}
}

View File

@ -65,6 +65,7 @@ public class DM300 extends Mob {
lootChance = 0.333f;
properties.add(Property.BOSS);
properties.add(Property.INORGANIC);
}
@Override
@ -136,7 +137,7 @@ public class DM300 extends Mob {
public void damage(int dmg, Object src) {
super.damage(dmg, src);
LockedFloor lock = Dungeon.hero.buff(LockedFloor.class);
if (lock != null && !immunities().contains(src.getClass())) lock.addTime(dmg*1.5f);
if (lock != null && !isImmune(src.getClass())) lock.addTime(dmg*1.5f);
}
@Override
@ -164,11 +165,6 @@ public class DM300 extends Mob {
yell( Messages.get(this, "notice") );
}
{
resistances.add( Grim.class );
resistances.add( ScrollOfPsionicBlast.class );
}
{
immunities.add( ToxicGas.class );
immunities.add( Terror.class );

View File

@ -50,7 +50,7 @@ public class Elemental extends Mob {
loot = new PotionOfLiquidFlame();
lootChance = 0.1f;
properties.add(Property.DEMONIC);
properties.add(Property.FIERY);
}
@Override
@ -80,12 +80,7 @@ public class Elemental extends Mob {
@Override
public void add( Buff buff ) {
if (buff instanceof Burning) {
if (HP < HT) {
HP++;
sprite.emitter().burst( Speck.factory( Speck.HEALING ), 1 );
}
} else if (buff instanceof Frost || buff instanceof Chill) {
if (buff instanceof Frost || buff instanceof Chill) {
if (Dungeon.level.water[this.pos])
damage( Random.NormalIntRange( HT / 2, HT ), buff );
else
@ -95,9 +90,4 @@ public class Elemental extends Mob {
}
}
{
immunities.add( Burning.class );
immunities.add( Blazing.class );
immunities.add( WandOfFireblast.class );
}
}

View File

@ -219,7 +219,6 @@ public class Eye extends Mob {
{
resistances.add( WandOfDisintegration.class );
resistances.add( Grim.class );
resistances.add( Vampiric.class );
}
{

View File

@ -39,6 +39,8 @@ public class Golem extends Mob {
EXP = 12;
maxLvl = 22;
properties.add(Property.INORGANIC);
}
@Override

View File

@ -64,6 +64,7 @@ public class Goo extends Mob {
properties.add(Property.BOSS);
properties.add(Property.DEMONIC);
properties.add(Property.ACIDIC);
}
private int pumpedUp = 0;
@ -271,9 +272,4 @@ public class Goo extends Mob {
}
{
resistances.add( ToxicGas.class );
resistances.add( Grim.class );
resistances.add( ScrollOfPsionicBlast.class );
}
}

View File

@ -56,7 +56,7 @@ public class Guard extends Mob {
loot = null; //see createloot.
lootChance = 0.25f;
properties.add(Property.DEMONIC);
properties.add(Property.UNDEAD);
HUNTING = new Hunting();
}

View File

@ -228,9 +228,6 @@ public class King extends Mob {
}
{
resistances.add( ToxicGas.class );
resistances.add( Grim.class );
resistances.add( ScrollOfPsionicBlast.class );
resistances.add( WandOfDisintegration.class );
}
@ -255,6 +252,7 @@ public class King extends Mob {
state = WANDERING;
properties.add(Property.UNDEAD);
properties.add(Property.INORGANIC);
}
@Override

View File

@ -51,6 +51,8 @@ public class Piranha extends Mob {
lootChance = 1f;
HUNTING = new Hunting();
properties.add(Property.BLOB_IMMUNE);
}
public Piranha() {
@ -133,11 +135,6 @@ public class Piranha extends Mob {
{
immunities.add( Burning.class );
immunities.add( Paralysis.class );
immunities.add( ToxicGas.class );
immunities.add( VenomGas.class );
immunities.add( Roots.class );
immunities.add( Frost.class );
}
private class Hunting extends Mob.Hunting{

View File

@ -104,8 +104,4 @@ public class Scorpio extends Mob {
}
}
{
resistances.add( Vampiric.class );
resistances.add( Poison.class );
}
}

View File

@ -52,6 +52,8 @@ public class Shaman extends Mob implements Callback {
loot = Generator.Category.SCROLL;
lootChance = 0.33f;
properties.add(Property.ELECTRIC);
}
@Override
@ -122,9 +124,4 @@ public class Shaman extends Mob implements Callback {
next();
}
{
resistances.add( WandOfLightning.class );
resistances.add( Shocking.class );
resistances.add( Potential.class );
}
}

View File

@ -51,6 +51,7 @@ public class Skeleton extends Mob {
lootChance = 0.2f;
properties.add(Property.UNDEAD);
properties.add(Property.INORGANIC);
}
@Override

View File

@ -100,7 +100,7 @@ public class Spinner extends Mob {
}
{
immunities.add(Roots.class);
immunities.add(Web.class);
}
private class Fleeing extends Mob.Fleeing {

View File

@ -43,6 +43,8 @@ public class Statue extends Mob {
EXP = 0;
state = PASSIVE;
properties.add(Property.INORGANIC);
}
protected Weapon weapon;
@ -153,12 +155,7 @@ public class Statue extends Mob {
}
{
resistances.add(ToxicGas.class);
resistances.add(Poison.class);
resistances.add(Grim.class);
}
{
immunities.add( Vampiric.class );
}
}

View File

@ -137,10 +137,6 @@ public class Succubus extends Mob {
return Random.NormalIntRange(0, 10);
}
{
resistances.add( Vampiric.class );
}
{
immunities.add( Sleep.class );
}

View File

@ -237,8 +237,6 @@ public class Tengu extends Mob {
{
resistances.add( ToxicGas.class );
resistances.add( Poison.class );
resistances.add( Grim.class );
resistances.add( ScrollOfPsionicBlast.class );
}
@Override

View File

@ -59,7 +59,7 @@ public class Thief extends Mob {
WANDERING = new Wandering();
FLEEING = new Fleeing();
properties.add(Property.DEMONIC);
properties.add(Property.UNDEAD);
}
private static final String ITEM = "item";

View File

@ -216,6 +216,7 @@ public class Yog extends Mob {
properties.add(Property.BOSS);
properties.add(Property.DEMONIC);
properties.add(Property.ACIDIC);
}
@Override
@ -263,12 +264,6 @@ public class Yog extends Mob {
if (lock != null) lock.addTime(dmg*0.5f);
}
{
resistances.add( ToxicGas.class );
resistances.add( Grim.class );
resistances.add( ScrollOfPsionicBlast.class );
}
{
immunities.add( Amok.class );
immunities.add( Sleep.class );
@ -292,6 +287,7 @@ public class Yog extends Mob {
properties.add(Property.BOSS);
properties.add(Property.DEMONIC);
properties.add(Property.FIERY);
}
@Override
@ -363,16 +359,12 @@ public class Yog extends Mob {
{
resistances.add( ToxicGas.class );
resistances.add( Grim.class );
}
{
immunities.add( Amok.class );
immunities.add( Sleep.class );
immunities.add( Terror.class );
immunities.add( Burning.class );
immunities.add( ScrollOfPsionicBlast.class );
immunities.add( Vertigo.class );
}
}

View File

@ -385,6 +385,8 @@ public class DriedRose extends Artifact {
//before other mobs
actPriority = MOB_PRIO + 1;
properties.add(Property.UNDEAD);
}
private DriedRose rose = null;

View File

@ -69,8 +69,5 @@ public class RingOfElements extends Ring {
public class Resistance extends RingBuff {
public float durationFactor() {
return level() < 0 ? 1 : (1 + 0.5f * level()) / (1 + level());
}
}
}

View File

@ -61,7 +61,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Swarm;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Wraith;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Yog;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC;
import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
@ -194,7 +193,7 @@ public class WandOfCorruption extends Wand {
}
}
for (Class<?extends Buff> toAssign : debuffs.keySet()){
if (debuffs.get(toAssign) > 0 && enemy.immunities().contains(toAssign)){
if (debuffs.get(toAssign) > 0 && enemy.isImmune(toAssign)){
debuffs.put(toAssign, 0f);
}
}
@ -218,9 +217,7 @@ public class WandOfCorruption extends Wand {
return;
}
if (!enemy.properties().contains(Char.Property.BOSS) &&
!enemy.properties().contains(Char.Property.MINIBOSS) &&
!enemy.immunities().contains(Corruption.class)){
if (!enemy.isImmune(Corruption.class)){
enemy.HP = enemy.HT;
for (Buff buff : enemy.buffs()) {
if (buff.type == Buff.buffType.NEGATIVE