v0.8.2: Player can now equip 3 misc items, but not all of the same type

This commit is contained in:
Evan Debenham 2020-07-10 00:35:41 -04:00
parent a33fe02f53
commit 29f730f21f
11 changed files with 172 additions and 89 deletions

View File

@ -1661,7 +1661,7 @@ items.item.rankings_desc=Killed by: %s
items.item.curse=curse
items.kindofmisc.unequip_title=Unequip one item
items.kindofmisc.unequip_message=You can only wear two misc items at a time.
items.kindofmisc.unequip_message=You must unequip one of these items first. Select an item to swap with.
items.kindofweapon.equip_cursed=Your grip involuntarily tightens around the weapon.

View File

@ -72,7 +72,7 @@ public class Bones {
private static Item pickItem(Hero hero){
Item item = null;
if (Random.Int(3) != 0) {
switch (Random.Int(6)) {
switch (Random.Int(7)) {
case 0:
item = hero.belongings.weapon;
break;
@ -80,12 +80,15 @@ public class Bones {
item = hero.belongings.armor;
break;
case 2:
item = hero.belongings.misc1;
item = hero.belongings.artifact;
break;
case 3:
item = hero.belongings.misc2;
item = hero.belongings.misc;
break;
case 4: case 5:
case 4:
item = hero.belongings.ring;
break;
case 5: case 6:
item = Dungeon.quickslot.randomNonePlaceholder();
break;
}

View File

@ -154,9 +154,9 @@ public enum Rankings {
Bundle handler = new Bundle();
Scroll.saveSelectively(handler, belongings.backpack.items);
Potion.saveSelectively(handler, belongings.backpack.items);
//include worn rings
if (belongings.misc1 != null) belongings.backpack.items.add(belongings.misc1);
if (belongings.misc2 != null) belongings.backpack.items.add(belongings.misc2);
//include potentially worn rings
if (belongings.misc != null) belongings.backpack.items.add(belongings.misc);
if (belongings.ring != null) belongings.backpack.items.add(belongings.ring);
Ring.saveSelectively(handler, belongings.backpack.items);
rec.gameData.put( HANDLERS, handler);

View File

@ -45,11 +45,11 @@ public class ArtifactRecharge extends Buff {
if (target instanceof Hero){
Belongings b = ((Hero) target).belongings;
if (b.misc1 instanceof Artifact){
((Artifact)b.misc1).charge((Hero)target);
if (b.artifact instanceof Artifact){
((Artifact)b.artifact).charge((Hero)target);
}
if (b.misc2 instanceof Artifact){
((Artifact)b.misc2).charge((Hero)target);
if (b.misc instanceof Artifact){
((Artifact)b.misc).charge((Hero)target);
}
}

View File

@ -28,8 +28,10 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon;
import com.shatteredpixel.shatteredpixeldungeon.items.KindofMisc;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact;
import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag;
import com.shatteredpixel.shatteredpixeldungeon.items.keys.Key;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRemoveCurse;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
@ -47,8 +49,9 @@ public class Belongings implements Iterable<Item> {
public KindOfWeapon weapon = null;
public Armor armor = null;
public KindofMisc misc1 = null;
public KindofMisc misc2 = null;
public Artifact artifact = null;
public KindofMisc misc = null;
public Ring ring = null;
public Belongings( Hero owner ) {
this.owner = owner;
@ -72,8 +75,9 @@ public class Belongings implements Iterable<Item> {
private static final String WEAPON = "weapon";
private static final String ARMOR = "armor";
private static final String MISC1 = "misc1";
private static final String MISC2 = "misc2";
private static final String ARTIFACT = "artifact";
private static final String MISC = "misc";
private static final String RING = "ring";
public void storeInBundle( Bundle bundle ) {
@ -81,8 +85,9 @@ public class Belongings implements Iterable<Item> {
bundle.put( WEAPON, weapon );
bundle.put( ARMOR, armor );
bundle.put( MISC1, misc1);
bundle.put( MISC2, misc2);
bundle.put( ARTIFACT, artifact );
bundle.put( MISC, misc );
bundle.put( RING, ring );
}
public void restoreFromBundle( Bundle bundle ) {
@ -100,15 +105,37 @@ public class Belongings implements Iterable<Item> {
armor.activate( owner );
}
misc1 = (KindofMisc)bundle.get(MISC1);
if (misc1 != null) {
misc1.activate( owner );
//pre-0.8.2
if (bundle.contains("misc1") || bundle.contains("misc2")){
artifact = null;
misc = null;
ring = null;
KindofMisc m = (KindofMisc)bundle.get("misc1");
if (m instanceof Artifact){
artifact = (Artifact) m;
} else if (m instanceof Ring) {
ring = (Ring) m;
}
misc2 = (KindofMisc)bundle.get(MISC2);
if (misc2 != null) {
misc2.activate( owner );
m = (KindofMisc)bundle.get("misc2");
if (m instanceof Artifact){
if (artifact == null) artifact = (Artifact) m;
else misc = (Artifact) m;
} else if (m instanceof Ring) {
if (ring == null) ring = (Ring) m;
else misc = (Ring) m;
}
} else {
artifact = (Artifact) bundle.get(ARTIFACT);
misc = (KindofMisc) bundle.get(MISC);
ring = (Ring) bundle.get(RING);
}
if (artifact != null) artifact.activate(owner);
if (misc != null) misc.activate( owner );
if (ring != null) ring.activate( owner );
}
public static void preview( GamesInProgress.Info info, Bundle bundle ) {
@ -180,13 +207,17 @@ public class Belongings implements Iterable<Item> {
armor.identify();
Badges.validateItemLevelAquired( armor );
}
if (misc1 != null) {
misc1.identify();
Badges.validateItemLevelAquired(misc1);
if (artifact != null) {
artifact.identify();
Badges.validateItemLevelAquired(artifact);
}
if (misc2 != null) {
misc2.identify();
Badges.validateItemLevelAquired(misc2);
if (misc != null) {
misc.identify();
Badges.validateItemLevelAquired(misc);
}
if (ring != null) {
ring.identify();
Badges.validateItemLevelAquired(ring);
}
for (Item item : backpack) {
if (item instanceof EquipableItem || item instanceof Wand) {
@ -196,7 +227,7 @@ public class Belongings implements Iterable<Item> {
}
public void uncurseEquipped() {
ScrollOfRemoveCurse.uncurse( owner, armor, weapon, misc1, misc2);
ScrollOfRemoveCurse.uncurse( owner, armor, weapon, artifact, misc, ring);
}
public Item randomUnequipped() {
@ -232,13 +263,17 @@ public class Belongings implements Iterable<Item> {
armor.activate( owner );
}
if (misc1 != null) {
misc1.cursed = false;
misc1.activate( owner );
if (artifact != null) {
artifact.cursed = false;
artifact.activate( owner );
}
if (misc2 != null) {
misc2.cursed = false;
misc2.activate( owner );
if (misc != null) {
misc.cursed = false;
misc.activate( owner );
}
if (ring != null) {
ring.cursed = false;
ring.activate( owner );
}
}
@ -265,7 +300,7 @@ public class Belongings implements Iterable<Item> {
private Iterator<Item> backpackIterator = backpack.iterator();
private Item[] equipped = {weapon, armor, misc1, misc2};
private Item[] equipped = {weapon, armor, artifact, misc, ring};
private int backpackIndex = equipped.length;
@Override
@ -303,10 +338,13 @@ public class Belongings implements Iterable<Item> {
equipped[1] = armor = null;
break;
case 2:
equipped[2] = misc1 = null;
equipped[2] = artifact = null;
break;
case 3:
equipped[3] = misc2 = null;
equipped[3] = misc = null;
break;
case 4:
equipped[4] = ring = null;
break;
default:
backpackIterator.remove();

View File

@ -163,8 +163,8 @@ public enum HeroClass {
(hero.belongings.weapon = new Dagger()).identify();
CloakOfShadows cloak = new CloakOfShadows();
(hero.belongings.misc1 = cloak).identify();
hero.belongings.misc1.activate( hero );
(hero.belongings.artifact = cloak).identify();
hero.belongings.artifact.activate( hero );
ThrowingKnife knives = new ThrowingKnife();
knives.quantity(3).collect();

View File

@ -23,6 +23,8 @@ package com.shatteredpixel.shatteredpixeldungeon.items;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
@ -36,10 +38,28 @@ public abstract class KindofMisc extends EquipableItem {
@Override
public boolean doEquip(final Hero hero) {
if (hero.belongings.misc1 != null && hero.belongings.misc2 != null) {
boolean equipFull = false;
if ( this instanceof Artifact
&& hero.belongings.artifact != null
&& hero.belongings.misc != null){
equipFull = true;
} else if (this instanceof Ring
&& hero.belongings.misc != null
&& hero.belongings.ring != null){
equipFull = true;
}
final KindofMisc m1 = hero.belongings.misc1;
final KindofMisc m2 = hero.belongings.misc2;
if (equipFull) {
final KindofMisc m1;
final KindofMisc m2;
if (this instanceof Artifact){
m1 = hero.belongings.artifact;
m2 = hero.belongings.misc;
} else {
m1 = hero.belongings.misc;
m2 = hero.belongings.ring;
}
GameScene.show(
new WndOptions(Messages.get(KindofMisc.class, "unequip_title"),
@ -66,10 +86,12 @@ public abstract class KindofMisc extends EquipableItem {
} else {
if (hero.belongings.misc1 == null) {
hero.belongings.misc1 = this;
} else {
hero.belongings.misc2 = this;
if (this instanceof Artifact){
if (hero.belongings.artifact == null) hero.belongings.artifact = (Artifact) this;
else hero.belongings.misc = (Artifact) this;
} else if (this instanceof Ring){
if (hero.belongings.ring == null) hero.belongings.ring = (Ring) this;
else hero.belongings.misc = (Ring) this;
}
detach( hero.belongings.backpack );
@ -93,10 +115,12 @@ public abstract class KindofMisc extends EquipableItem {
public boolean doUnequip(Hero hero, boolean collect, boolean single) {
if (super.doUnequip(hero, collect, single)){
if (hero.belongings.misc1 == this) {
hero.belongings.misc1 = null;
} else {
hero.belongings.misc2 = null;
if (hero.belongings.artifact == this) {
hero.belongings.artifact = null;
} else if (hero.belongings.misc == this) {
hero.belongings.misc = null;
} else if (hero.belongings.ring == this){
hero.belongings.ring = null;
}
return true;
@ -110,7 +134,9 @@ public abstract class KindofMisc extends EquipableItem {
@Override
public boolean isEquipped( Hero hero ) {
return hero.belongings.misc1 == this || hero.belongings.misc2 == this;
return hero.belongings.artifact == this
|| hero.belongings.misc == this
|| hero.belongings.ring == this;
}
}

View File

@ -58,8 +58,8 @@ public class Artifact extends KindofMisc {
@Override
public boolean doEquip( final Hero hero ) {
if ((hero.belongings.misc1 != null && hero.belongings.misc1.getClass() == this.getClass())
|| (hero.belongings.misc2 != null && hero.belongings.misc2.getClass() == this.getClass())){
if ((hero.belongings.artifact != null && hero.belongings.artifact.getClass() == this.getClass())
|| (hero.belongings.misc != null && hero.belongings.misc.getClass() == this.getClass())){
GLog.w( Messages.get(Artifact.class, "cannot_wear_two") );
return false;

View File

@ -59,8 +59,8 @@ public class WildEnergy extends TargetedSpell {
hero.belongings.charge(1f);
for (int i = 0; i < 4; i++){
if (hero.belongings.misc1 instanceof Artifact) ((Artifact) hero.belongings.misc1).charge(hero);
if (hero.belongings.misc2 instanceof Artifact) ((Artifact) hero.belongings.misc2).charge(hero);
if (hero.belongings.artifact instanceof Artifact) ((Artifact) hero.belongings.artifact).charge(hero);
if (hero.belongings.misc instanceof Artifact) ((Artifact) hero.belongings.misc).charge(hero);
}
Buff.affect(hero, Recharging.class, 8f);

View File

@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.windows;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.SPDAction;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem;
@ -94,11 +95,15 @@ public class WndBag extends WndTabbed {
NOT_EQUIPPED
}
protected static final int COLS_P = 4;
protected static final int COLS_L = 6;
protected static final int COLS_P = 5;
protected static final int COLS_L = 5;
protected static int SLOT_WIDTH_P = 24;
protected static int SLOT_WIDTH_L = 28;
protected static int SLOT_HEIGHT_P = 28;
protected static int SLOT_HEIGHT_L = 24;
protected static final int SLOT_WIDTH = 28;
protected static final int SLOT_HEIGHT = 28;
protected static final int SLOT_MARGIN = 1;
protected static final int TITLE_HEIGHT = 14;
@ -109,6 +114,9 @@ public class WndBag extends WndTabbed {
private int nCols;
private int slotWidth;
private int slotHeight;
protected int count;
protected int col;
protected int row;
@ -132,14 +140,17 @@ public class WndBag extends WndTabbed {
lastMode = mode;
lastBag = bag;
slotWidth = PixelScene.landscape() ? SLOT_WIDTH_L : SLOT_WIDTH_P;
slotHeight = PixelScene.landscape() ? SLOT_HEIGHT_L : SLOT_HEIGHT_P;
nCols = PixelScene.landscape() ? COLS_L : COLS_P;
int slotsWidth = SLOT_WIDTH * nCols + SLOT_MARGIN * (nCols - 1);
int slotsWidth = slotWidth * nCols + SLOT_MARGIN * (nCols - 1);
placeTitle( bag, slotsWidth );
placeItems( bag );
int slotsHeight = SLOT_HEIGHT * row + SLOT_MARGIN * (row - 1);
int slotsHeight = slotHeight * row + SLOT_MARGIN * (row - 1);
resize( slotsWidth, slotsHeight + TITLE_HEIGHT );
@ -217,8 +228,9 @@ public class WndBag extends WndTabbed {
Belongings stuff = Dungeon.hero.belongings;
placeItem( stuff.weapon != null ? stuff.weapon : new Placeholder( ItemSpriteSheet.WEAPON_HOLDER ) );
placeItem( stuff.armor != null ? stuff.armor : new Placeholder( ItemSpriteSheet.ARMOR_HOLDER ) );
placeItem( stuff.misc1 != null ? stuff.misc1 : new Placeholder( ItemSpriteSheet.RING_HOLDER ) );
placeItem( stuff.misc2 != null ? stuff.misc2 : new Placeholder( ItemSpriteSheet.RING_HOLDER ) );
placeItem( stuff.artifact != null ? stuff.artifact : new Placeholder( ItemSpriteSheet.ARTIFACT_HOLDER ) );
placeItem( stuff.misc != null ? stuff.misc : new Placeholder( ItemSpriteSheet.SOMETHING ) );
placeItem( stuff.ring != null ? stuff.ring : new Placeholder( ItemSpriteSheet.RING_HOLDER ) );
//the container itself if it's not the root backpack
if (container != Dungeon.hero.belongings.backpack){
@ -236,7 +248,7 @@ public class WndBag extends WndTabbed {
}
// Free Space
while ((count - 4) < container.capacity()) {
while ((count - 5) < container.capacity()) {
placeItem( null );
}
}
@ -245,8 +257,8 @@ public class WndBag extends WndTabbed {
count++;
int x = col * (SLOT_WIDTH + SLOT_MARGIN);
int y = TITLE_HEIGHT + row * (SLOT_HEIGHT + SLOT_MARGIN);
int x = col * (slotWidth + SLOT_MARGIN);
int y = TITLE_HEIGHT + row * (slotHeight + SLOT_MARGIN);
add( new ItemButton( item ).setPos( x, y ) );
@ -357,13 +369,13 @@ public class WndBag extends WndTabbed {
bg.visible = false;
}
width = SLOT_WIDTH;
height = SLOT_HEIGHT;
width = slotWidth;
height = slotHeight;
}
@Override
protected void createChildren() {
bg = new ColorBlock( SLOT_WIDTH, SLOT_HEIGHT, NORMAL );
bg = new ColorBlock( 1, 1, NORMAL );
add( bg );
super.createChildren();
@ -371,6 +383,7 @@ public class WndBag extends WndTabbed {
@Override
protected void layout() {
bg.size(width, height);
bg.x = x;
bg.y = y;

View File

@ -238,11 +238,14 @@ public class WndRanking extends WndTabbed {
if (stuff.armor != null) {
addItem( stuff.armor );
}
if (stuff.misc1 != null) {
addItem( stuff.misc1);
if (stuff.artifact != null) {
addItem( stuff.artifact );
}
if (stuff.misc2 != null) {
addItem( stuff.misc2);
if (stuff.misc != null) {
addItem( stuff.misc );
}
if (stuff.ring != null) {
addItem( stuff.ring );
}
pos = 0;
@ -250,14 +253,14 @@ public class WndRanking extends WndTabbed {
if (Dungeon.quickslot.getItem(i) != null){
QuickSlotButton slot = new QuickSlotButton(Dungeon.quickslot.getItem(i));
slot.setRect( pos, 116, 28, 28 );
slot.setRect( pos, 120, 28, 23 );
add(slot);
} else {
ColorBlock bg = new ColorBlock( 28, 28, 0x9953564D );
ColorBlock bg = new ColorBlock( 28, 23, 0x9953564D );
bg.x = pos;
bg.y = 116;
bg.y = 120;
add(bg);
}
pos += 29;
@ -289,7 +292,7 @@ public class WndRanking extends WndTabbed {
private class ItemButton extends Button {
public static final int HEIGHT = 28;
public static final int HEIGHT = 23;
private Item item;
@ -316,7 +319,7 @@ public class WndRanking extends WndTabbed {
@Override
protected void createChildren() {
bg = new ColorBlock( HEIGHT, HEIGHT, 0x9953564D );
bg = new ColorBlock( 28, HEIGHT, 0x9953564D );
add( bg );
slot = new ItemSlot();
@ -333,7 +336,7 @@ public class WndRanking extends WndTabbed {
bg.x = x;
bg.y = y;
slot.setRect( x, y, HEIGHT, HEIGHT );
slot.setRect( x, y, 28, HEIGHT );
PixelScene.align(slot);
name.maxWidth((int)(width - slot.width() - 2));
@ -365,7 +368,7 @@ public class WndRanking extends WndTabbed {
private class QuickSlotButton extends ItemSlot{
public static final int HEIGHT = 28;
public static final int HEIGHT = 23;
private Item item;
private ColorBlock bg;
@ -377,7 +380,7 @@ public class WndRanking extends WndTabbed {
@Override
protected void createChildren() {
bg = new ColorBlock( HEIGHT, HEIGHT, 0x9953564D );
bg = new ColorBlock( 28, HEIGHT, 0x9953564D );
add( bg );
super.createChildren();