v0.4.0: adjusted cursing trap

This commit is contained in:
Evan Debenham 2016-06-09 06:53:46 -04:00 committed by Evan Debenham
parent 99760aac86
commit 6a3de8c7ab
2 changed files with 71 additions and 6 deletions

View File

@ -31,10 +31,17 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon; import com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon;
import com.shatteredpixel.shatteredpixeldungeon.items.KindofMisc; import com.shatteredpixel.shatteredpixeldungeon.items.KindofMisc;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor; import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.TrapSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.TrapSprite;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.noosa.audio.Sample; import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Random;
import java.util.ArrayList;
import java.util.Collections;
public class CursingTrap extends Trap { public class CursingTrap extends Trap {
@ -54,22 +61,80 @@ public class CursingTrap extends Trap {
if (heap != null){ if (heap != null){
for (Item item : heap.items){ for (Item item : heap.items){
if (item.isUpgradable()) if (item.isUpgradable())
item.cursed = item.cursedKnown = true; curse(item);
} }
} }
if (Dungeon.hero.pos == pos){ if (Dungeon.hero.pos == pos){
Hero hero = Dungeon.hero; Hero hero = Dungeon.hero;
//items the trap wants to curse because it will create a more negative effect
ArrayList<Item> priorityCurse = new ArrayList<>();
//items the trap can curse if nothing else is available.
ArrayList<Item> canCurse = new ArrayList<>();
KindOfWeapon weapon = hero.belongings.weapon; KindOfWeapon weapon = hero.belongings.weapon;
if (weapon instanceof Weapon && !weapon.cursed){
if (((Weapon) weapon).enchantment == null)
priorityCurse.add(weapon);
else
canCurse.add(weapon);
}
Armor armor = hero.belongings.armor; Armor armor = hero.belongings.armor;
if (!armor.cursed){
if (armor.glyph == null)
priorityCurse.add(armor);
else
canCurse.add(armor);
}
KindofMisc misc1 = hero.belongings.misc1; KindofMisc misc1 = hero.belongings.misc1;
if (misc1 instanceof Artifact){
priorityCurse.add(misc1);
} else if (misc1 instanceof Ring){
canCurse.add(misc1);
}
KindofMisc misc2 = hero.belongings.misc2; KindofMisc misc2 = hero.belongings.misc2;
if (weapon != null) weapon.cursed = weapon.cursedKnown = true; if (misc2 instanceof Artifact){
if (armor != null) armor.cursed = armor.cursedKnown = true; priorityCurse.add(misc2);
if (misc1 != null) misc1.cursed = misc1.cursedKnown = true; } else if (misc2 instanceof Ring){
if (misc2 != null) misc2.cursed = misc2.cursedKnown = true; canCurse.add(misc2);
}
Collections.shuffle(priorityCurse);
Collections.shuffle(canCurse);
int numCurses = Random.Int(3) == 0 ? 1 : 2;
for (int i = 0; i < numCurses; i++){
if (!priorityCurse.isEmpty()){
curse(priorityCurse.remove(0));
} else if (!canCurse.isEmpty()){
curse(canCurse.remove(0));
}
}
EquipableItem.equipCursed(hero); EquipableItem.equipCursed(hero);
GLog.n( Messages.get(this, "curse") ); GLog.n( Messages.get(this, "curse") );
} }
} }
private void curse(Item item){
item.cursed = item.cursedKnown = true;
if (item instanceof Weapon){
Weapon w = (Weapon) item;
if (w.enchantment == null){
w.enchantment = Weapon.Enchantment.randomCurse();
}
}
if (item instanceof Armor){
Armor a = (Armor) item;
if (a.glyph == null){
a.glyph = Armor.Glyph.randomCurse();
}
}
}
} }

View File

@ -66,7 +66,7 @@ levels.traps.confusiontrap.desc=Triggering this trap will set a cloud of confusi
levels.traps.cursingtrap.name=Cursing trap levels.traps.cursingtrap.name=Cursing trap
levels.traps.cursingtrap.curse=Your worn equipment becomes cursed! levels.traps.cursingtrap.curse=Your worn equipment becomes cursed!
levels.traps.cursingtrap.desc=This trap contains the same malevolent magic found in cursed equipment. Triggering it will curse all worn items, and all items in the immediate area. levels.traps.cursingtrap.desc=This trap contains the same malevolent magic found in cursed equipment. Triggering it will curse some items in the immediate area.
levels.traps.disarmingtrap.name=Disarming trap levels.traps.disarmingtrap.name=Disarming trap
levels.traps.disarmingtrap.disarm=Your weapon is teleported away! levels.traps.disarmingtrap.disarm=Your weapon is teleported away!