From: Daniel Karbach Date: Wed, 19 Dec 2012 21:26:50 +0000 (+0100) Subject: added upgrade items for capsule's final class X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=c5e56f45e08fcc6c4dceb586ce3d671a3f3907ab;p=l2e.git added upgrade items for capsule's final class --- diff --git a/src/common/Capsule.cpp b/src/common/Capsule.cpp index 4879585..c8a490e 100644 --- a/src/common/Capsule.cpp +++ b/src/common/Capsule.cpp @@ -1,5 +1,6 @@ #include "Capsule.h" +#include "../common/Item.h" #include "../common/Spell.h" #include "../common/Stats.h" #include "../graphics/Animation.h" @@ -86,6 +87,9 @@ void Capsule::UpgradeClass() { } void Capsule::NextClass() { + if (maxClass == numClasses) { + return; + } ++curClass; if (curClass >= maxClass) { curClass = 0; @@ -93,6 +97,9 @@ void Capsule::NextClass() { } void Capsule::PreviousClass() { + if (maxClass == numClasses) { + return; + } --curClass; if (curClass < 0) { curClass = maxClass - 1; @@ -100,6 +107,9 @@ void Capsule::PreviousClass() { } void Capsule::SetClass(int index) { + if (maxClass == numClasses) { + return; + } curClass = index; if (curClass < 0 ) { curClass = 0; @@ -158,7 +168,7 @@ bool Capsule::IsHungry() const { return HungerEmpty(); } -void Capsule::Feed(const common::Item *) { +void Capsule::Feed(const common::Item *item) { // TODO: find out how to calculate an item's feed value // TODO: an item the capsule favors (changes on every feed and after every // battle) doubles the value @@ -170,6 +180,15 @@ void Capsule::Feed(const common::Item *) { } } +const common::Item *Capsule::UpgradeItem() const { + return GetClass().upgradeItem; +} + +void Capsule::UpgradeSpecial() { + maxClass = GetClass().upgradeClass + 1; + curClass = GetClass().upgradeClass; +} + Capsule::Class::Class() : name(0) @@ -179,6 +198,9 @@ Capsule::Class::Class() , attackAnimation(0) , spellAnimation(0) + +, upgradeItem(0) +, upgradeClass(0) , hunger(32) , hungerFull(0) @@ -242,6 +264,8 @@ void Capsule::Class::CreateTypeDescription() { td.AddField("attackAnimation", FieldDescription(((char *)&c.attackAnimation) - ((char *)&c), Animation::TYPE_ID).SetReferenced()); td.AddField("spellAnimation", FieldDescription(((char *)&c.spellAnimation) - ((char *)&c), Animation::TYPE_ID).SetReferenced()); + td.AddField("upgradeItem", FieldDescription(((char *)&c.upgradeItem) - ((char *)&c), common::Item::TYPE_ID).SetReferenced()); + td.AddField("upgradeClass", FieldDescription(((char *)&c.upgradeClass) - ((char *)&c), Interpreter::NUMBER_ID)); td.AddField("hunger", FieldDescription(((char *)&c.hunger) - ((char *)&c), Interpreter::NUMBER_ID)); td.AddField("healthBoost", FieldDescription(((char *)&c.healthBoost) - ((char *)&c), Interpreter::NUMBER_ID)); diff --git a/src/common/Capsule.h b/src/common/Capsule.h index ef4caf6..bf99cfa 100644 --- a/src/common/Capsule.h +++ b/src/common/Capsule.h @@ -54,6 +54,9 @@ public: bool IsHungry() const; void Feed(const common::Item *); + const common::Item *UpgradeItem() const; + void UpgradeSpecial(); + Uint16 MaxHealth() const; Stats GetStats() const; @@ -88,6 +91,8 @@ private: graphics::Animation *attackAnimation; graphics::Animation *spellAnimation; + const common::Item *upgradeItem; + int upgradeClass; int hunger; int hungerFull; diff --git a/src/main.cpp b/src/main.cpp index dc4c669..7bde641 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -234,6 +234,8 @@ int main(int argc, char **argv) { gameState.heroes[1].AddSpell(valorSpell); gameState.inventory.Add(caster.GetItem("zirconPlateItem"), 32); + gameState.inventory.Add(caster.GetItem("holyFruitItem")); + gameState.inventory.Add(caster.GetItem("darkFruitItem")); gameState.inventory.Add(caster.GetItem("antidoteItem"), 9); gameState.inventory.Add(caster.GetItem("powerRingItem")); gameState.inventory.Add(caster.GetItem("magicJarItem"), 4); diff --git a/src/menu/CapsuleFeedMenu.cpp b/src/menu/CapsuleFeedMenu.cpp index f2631b9..e078928 100644 --- a/src/menu/CapsuleFeedMenu.cpp +++ b/src/menu/CapsuleFeedMenu.cpp @@ -132,11 +132,19 @@ void CapsuleFeedMenu::HandleEvents(const Input &input) { void CapsuleFeedMenu::FeedSelected() { if (itemMenu.Selected()) { // TODO: feed and grow animations - GetCapsule().Feed(itemMenu.Selected()); - parent->Game().state->inventory.Remove(itemMenu.Selected(), 1); - LoadInventory(); + if (GetCapsule().IsHungry()) { + GetCapsule().Feed(itemMenu.Selected()); + parent->Game().state->inventory.Remove(itemMenu.Selected(), 1); + LoadInventory(); + } else if (itemMenu.Selected() == GetCapsule().UpgradeItem()) { + GetCapsule().UpgradeSpecial(); + parent->Game().state->inventory.Remove(itemMenu.Selected(), 1); + LoadInventory(); + } else { + // error beep + } } else { - // beep + // also beep } } diff --git a/test-data/capsules.l2s b/test-data/capsules.l2s index dfc36a7..968b51b 100644 --- a/test-data/capsules.l2s +++ b/test-data/capsules.l2s @@ -1,3 +1,5 @@ +include "items.l2h" + Sprite flashSprite1 { image: :"flash.png", size: <96, 96> @@ -162,6 +164,8 @@ export Capsule flash { { column: 0, row: 0, disposition: < 0, -16> } ] }, + upgradeItem: darkFruitItem, + upgradeClass: 4, hunger: 0, healthBoost: 208, statBoost: Stats { @@ -198,6 +202,8 @@ export Capsule flash { { column: 0, row: 0, disposition: < 0, -16> } ] }, + upgradeItem: holyFruitItem, + upgradeClass: 3, hunger: 0, healthBoost: 208, statBoost: Stats { diff --git a/test-data/items.l2h b/test-data/items.l2h index c2461ec..a7bf6f0 100644 --- a/test-data/items.l2h +++ b/test-data/items.l2h @@ -3,6 +3,7 @@ Sprite armorIcon Sprite axIcon Sprite ballIcon Sprite crankIcon +Item darkFruitItem Item eagleRockItem Item escapeItem Item evilJewelItem @@ -10,6 +11,7 @@ Item ghostRingItem Sprite helmetIcon Item hiPotionItem Item holyCapItem +Item holyFruitItem Item holyRobeItem Item holyShieldItem Sprite jewelIcon diff --git a/test-data/items.l2s b/test-data/items.l2s index 231aa3f..0ef31a2 100644 --- a/test-data/items.l2s +++ b/test-data/items.l2s @@ -81,6 +81,10 @@ export Item antidoteItem { }, mostUseful: true } +export Item darkFruitItem { + name: "Dark Fruit", + battle: false +} export Item eagleRockItem { name: "Eagle rock", menuicon: jewelIcon, @@ -124,6 +128,10 @@ export Item holyCapItem { equipability: helmet, heroMask: 42 // Selan, Artea, Tia } +export Item holyFruitItem { + name: "Holy Fruit", + battle: false +} export Item holyRobeItem { name: "Holy robe", menuicon: armorIcon,