diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Item.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Item.java index 032b91a..265a52f 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Item.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Item.java @@ -36,6 +36,8 @@ public class Item extends JSONElement { public String description = null; public HitEffect hit_effect = null; public HitReceivedEffect hit_received_effect = null; + public HitReceivedEffect miss_effect = null; + public HitReceivedEffect miss_received_effect = null; public DeathEffect kill_effect = null; public EquipEffect equip_effect = null; @@ -193,6 +195,16 @@ public class Item extends JSONElement { this.hit_received_effect = parseHitReceivedEffect(hitReceivedEffect); } + Map missEffect = (Map) itemJson.get("missEffect"); + if (missEffect != null) { + this.miss_effect = parseHitReceivedEffect(missEffect); + } + + Map missReceivedEffect = (Map) itemJson.get("missReceivedEffect"); + if (missReceivedEffect != null) { + this.miss_received_effect = parseHitReceivedEffect(missReceivedEffect); + } + Map killEffect = (Map) itemJson.get("killEffect"); if (killEffect == null) { killEffect = (Map) itemJson.get("useEffect"); @@ -225,6 +237,8 @@ public class Item extends JSONElement { linkEffects(this.hit_effect, proj, this); linkEffects(this.hit_received_effect, proj, this); + linkEffects(this.miss_effect, proj, this); + linkEffects(this.miss_received_effect, proj, this); linkEffects(this.kill_effect, proj, this); this.state = State.linked; } @@ -294,6 +308,14 @@ public class Item extends JSONElement { clone.hit_received_effect = new HitReceivedEffect(); copyHitReceivedEffectValues(clone.hit_received_effect, this.hit_received_effect, clone); } + if (this.miss_effect != null) { + clone.miss_effect = new HitReceivedEffect(); + copyHitReceivedEffectValues(clone.miss_effect, this.miss_effect, clone); + } + if (this.miss_received_effect != null) { + clone.miss_received_effect = new HitReceivedEffect(); + copyHitReceivedEffectValues(clone.miss_received_effect, this.miss_received_effect, clone); + } if (this.kill_effect != null) { clone.kill_effect = new DeathEffect(); copyDeathEffectValues(clone.kill_effect, this.kill_effect, clone); @@ -317,6 +339,18 @@ public class Item extends JSONElement { actorConditionElementChanged(this.hit_effect.conditions_source, oldOne, newOne, this); actorConditionElementChanged(this.hit_effect.conditions_target, oldOne, newOne, this); } + if (this.hit_received_effect != null) { + actorConditionElementChanged(this.hit_received_effect.conditions_source, oldOne, newOne, this); + actorConditionElementChanged(this.hit_received_effect.conditions_target, oldOne, newOne, this); + } + if (this.miss_effect != null) { + actorConditionElementChanged(this.miss_effect.conditions_source, oldOne, newOne, this); + actorConditionElementChanged(this.miss_effect.conditions_target, oldOne, newOne, this); + } + if (this.miss_received_effect != null) { + actorConditionElementChanged(this.miss_received_effect.conditions_source, oldOne, newOne, this); + actorConditionElementChanged(this.miss_received_effect.conditions_target, oldOne, newOne, this); + } if (this.kill_effect != null) { actorConditionElementChanged(this.kill_effect.conditions_source, oldOne, newOne, this); @@ -381,6 +415,8 @@ public class Item extends JSONElement { } writeHitEffectToMap(itemJson, this.hit_effect, "hitEffect"); writeHitReceivedEffectToMap(itemJson, this.hit_received_effect, "hitReceivedEffect"); + writeHitReceivedEffectToMap(itemJson, this.miss_effect, "missEffect"); + writeHitReceivedEffectToMap(itemJson, this.miss_received_effect, "missReceivedEffect"); String key; if (this.category != null && this.category.action_type != null && this.category.action_type == ItemCategory.ActionType.equip) { diff --git a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ItemEditor.java b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ItemEditor.java index 3557bf2..6c7fa43 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ItemEditor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ItemEditor.java @@ -79,6 +79,8 @@ public class ItemEditor extends JSONElementEditor { private final CommonEditor.HitEffectPane hitEffectPane = new CommonEditor.HitEffectPane<>("Effect on every hit: ", this, null, "npc"); private final CommonEditor.DeathEffectPane killEffectPane = new CommonEditor.DeathEffectPane<>(killLabel, this, null); private final CommonEditor.HitReceivedEffectPane hitReceivedEffectPane = new CommonEditor.HitReceivedEffectPane<>("Effect on every hit received: ", this, "player", "npc"); + private final CommonEditor.HitReceivedEffectPane missEffectPane = new CommonEditor.HitReceivedEffectPane<>("Effect on every miss: ", this, "player", "npc"); + private final CommonEditor.HitReceivedEffectPane missReceivedEffectPane = new CommonEditor.HitReceivedEffectPane<>("Effect on every miss received: ", this, "player", "npc"); public ItemEditor(Item item) { super(item, item.getDesc(), item.getIcon()); @@ -170,16 +172,27 @@ public class ItemEditor extends JSONElementEditor { hitReceivedEffectPane.createHitReceivedEffectPaneContent(listener, item.writable, hitReceivedEffect); pane.add(hitReceivedEffectPane.effectPane, JideBoxLayout.FIX); + HitReceivedEffect missEffect = Objects.requireNonNullElseGet(item.miss_effect, HitReceivedEffect::new); + missEffectPane.createHitEffectPaneContent(listener, item.writable, missEffect); + pane.add(missEffectPane.effectPane, JideBoxLayout.FIX); + + HitReceivedEffect missReceivedEffect = Objects.requireNonNullElseGet(item.miss_received_effect, HitReceivedEffect::new); + missReceivedEffectPane.createHitReceivedEffectPaneContent(listener, item.writable, missReceivedEffect); + pane.add(missReceivedEffectPane.effectPane, JideBoxLayout.FIX); if (item.category == null || item.category.action_type == null || item.category.action_type == ItemCategory.ActionType.none) { equipEffectPane.setVisible(false); hitEffectPane.effectPane.setVisible(false); hitReceivedEffectPane.effectPane.setVisible(false); + missEffectPane.effectPane.setVisible(false); + missReceivedEffectPane.effectPane.setVisible(false); killEffectPane.effectPane.setVisible(false); } else if (item.category.action_type == ItemCategory.ActionType.use) { equipEffectPane.setVisible(false); hitEffectPane.effectPane.setVisible(false); hitReceivedEffectPane.effectPane.setVisible(false); + missEffectPane.effectPane.setVisible(false); + missReceivedEffectPane.effectPane.setVisible(false); killEffectPane.effectPane.setVisible(true); killEffectPane.effectPane.setTitle(useLabel); killEffectPane.effectPane.revalidate(); @@ -188,6 +201,8 @@ public class ItemEditor extends JSONElementEditor { equipEffectPane.setVisible(true); hitEffectPane.effectPane.setVisible(true); hitReceivedEffectPane.effectPane.setVisible(true); + missEffectPane.effectPane.setVisible(true); + missReceivedEffectPane.effectPane.setVisible(true); killEffectPane.effectPane.setVisible(true); killEffectPane.effectPane.setTitle(killLabel); killEffectPane.effectPane.revalidate(); @@ -284,8 +299,8 @@ public class ItemEditor extends JSONElementEditor { @Override public void valueChanged(JComponent source, Object value) { Item item = (Item) target; - boolean updatePrice, updateEquip, updateHit, updateKill, updateHitReceived; - updatePrice = updateEquip = updateHit = updateKill = updateHitReceived = false; + boolean updatePrice, updateEquip, updateHit, updateMiss, updateKill, updateHitReceived, updateMissReceived; + updatePrice = updateEquip = updateHit = updateMiss = updateKill = updateHitReceived = updateMissReceived = false; if (source == idField) { //Events caused by cancel an ID edition. Dismiss. if (skipNext) { @@ -352,10 +367,14 @@ public class ItemEditor extends JSONElementEditor { item.equip_effect = null; hitEffectPane.effectPane.setVisible(false); item.hit_effect = null; + missEffectPane.effectPane.setVisible(false); + item.miss_effect = null; killEffectPane.effectPane.setVisible(false); item.kill_effect = null; hitReceivedEffectPane.effectPane.setVisible(false); item.hit_received_effect = null; + missReceivedEffectPane.effectPane.setVisible(false); + item.miss_received_effect = null; ItemEditor.this.revalidate(); ItemEditor.this.repaint(); } else if (item.category.action_type == ItemCategory.ActionType.use) { @@ -363,10 +382,14 @@ public class ItemEditor extends JSONElementEditor { item.equip_effect = null; hitEffectPane.effectPane.setVisible(false); item.hit_effect = null; + missEffectPane.effectPane.setVisible(false); + item.miss_effect = null; killEffectPane.effectPane.setVisible(true); updateKill = true; hitReceivedEffectPane.effectPane.setVisible(false); item.hit_received_effect = null; + missReceivedEffectPane.effectPane.setVisible(false); + item.miss_received_effect = null; updateHitReceived = true; updateEquip = true; killEffectPane.effectPane.setTitle(useLabel); @@ -375,9 +398,11 @@ public class ItemEditor extends JSONElementEditor { } else if (item.category.action_type == ItemCategory.ActionType.equip) { equipEffectPane.setVisible(true); hitEffectPane.effectPane.setVisible(true); + missEffectPane.effectPane.setVisible(true); killEffectPane.effectPane.setVisible(true); updateKill = true; hitReceivedEffectPane.effectPane.setVisible(true); + missReceivedEffectPane.effectPane.setVisible(true); updateHitReceived = true; updateEquip = true; killEffectPane.effectPane.setTitle(killLabel); @@ -459,12 +484,18 @@ public class ItemEditor extends JSONElementEditor { } else if (hitEffectPane.valueChanged(source, value, item)) { updatePrice = true; updateHit = true; + } else if (missEffectPane.valueChanged(source, value, item)) { + updatePrice = true; + updateMiss = true; } else if (killEffectPane.valueChanged(source, value, item)) { updatePrice = true; updateKill = true; } else if (hitReceivedEffectPane.valueChanged(source, value, item)) { updatePrice = true; updateHitReceived = true; + } else if (missReceivedEffectPane.valueChanged(source, value, item)) { + updatePrice = true; + updateMissReceived = true; } if (updateEquip) { @@ -481,6 +512,13 @@ public class ItemEditor extends JSONElementEditor { item.hit_effect = hitEffectPane.effect; } } + if (updateMiss) { + if (missEffectPane.effect.isNull()) { + item.miss_effect = null; + } else { + item.miss_effect = missEffectPane.effect; + } + } if (updateKill) { if (killEffectPane.effect.isNull()) { item.kill_effect = null; @@ -495,6 +533,13 @@ public class ItemEditor extends JSONElementEditor { item.hit_received_effect = hitReceivedEffectPane.effect; } } + if (updateMissReceived) { + if (missReceivedEffectPane.effect.isNull()) { + item.miss_received_effect = null; + } else { + item.miss_received_effect = missReceivedEffectPane.effect; + } + } if (updatePrice && !manualPriceBox.isSelected()) { baseCostField.setValue(item.computePrice()); }