]> git.localhorst.tv Git - l2e.git/commitdiff
added upgrade items for capsule's final class
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 19 Dec 2012 21:26:50 +0000 (22:26 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 19 Dec 2012 21:47:33 +0000 (22:47 +0100)
src/common/Capsule.cpp
src/common/Capsule.h
src/main.cpp
src/menu/CapsuleFeedMenu.cpp
test-data/capsules.l2s
test-data/items.l2h
test-data/items.l2s

index 487958596fe767b94a75ad20d6e403a04a3f9b4c..c8a490eb0f4631d9075f00d1dda11d5baecff98a 100644 (file)
@@ -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));
index ef4caf687a36af03385b4f4726444da2105a6b93..bf99cfa1ad376660c322c97640515ec9b71f4dce 100644 (file)
@@ -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;
 
index dc4c669caadb90d8da52837680bf030b534c3d5d..7bde641ebba369596f215c779e7ed80e543d2ed3 100644 (file)
@@ -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);
index f2631b90aecad4b40fbf6fb305a3362f2a01355c..e0789285e1be92b67a1fe647028e527ef265e28c 100644 (file)
@@ -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
        }
 }
 
index dfc36a7d7d91fc30c75b99531b57bcd6d207ebd9..968b51bd1c3208c6f7c34684ffe5d7adfccb1103 100644 (file)
@@ -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 {
index c2461ecdf9fd6f5cc6b6fae2c3230df3dca9512f..a7bf6f05aad518b95705035c2e9b07258bd11160 100644 (file)
@@ -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
index 231aa3f626f498c93b51369b10f4c9396121cae4..0ef31a2f05d4ab127893a23ee81bb932e0a3a858 100644 (file)
@@ -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,