#include "Hero.h"
+#include "Item.h"
+#include "Spell.h"
#include "../graphics/Animation.h"
#include "../graphics/Sprite.h"
#include "../loader/Interpreter.h"
, levelLadder(0)
, numLevels(0)
+, useMask(0)
+
, weapon(0)
, armor(0)
, shield(0)
}
+bool Hero::CanEquip(const Item &item) const {
+ return useMask & item.HeroMask();
+}
+
+bool Hero::CanInvoke(const Spell &spell) const {
+ return useMask & spell.HeroMask();
+}
+
+
void Hero::CreateTypeDescription() {
Hero h;
td.AddField("level", FieldDescription(((char *)&h.level) - ((char *)&h), Interpreter::NUMBER_ID));
td.AddField("ladder", FieldDescription(((char *)&h.levelLadder) - ((char *)&h), Interpreter::NUMBER_ID).SetReferenced().SetAggregate());
+ td.AddField("useMask", FieldDescription(((char *)&h.useMask) - ((char *)&h), Interpreter::NUMBER_ID));
+
td.AddField("battleSprite", FieldDescription(((char *)&h.battleSprite) - ((char *)&h), Sprite::TYPE_ID).SetReferenced().SetDescription("the sprite used for battle scenes"));
td.AddField("attackAnimation", FieldDescription(((char *)&h.attackAnimation) - ((char *)&h), Animation::TYPE_ID).SetReferenced().SetDescription("the animation played for physical attacks"));
td.AddField("spellAnimation", FieldDescription(((char *)&h.spellAnimation) - ((char *)&h), Animation::TYPE_ID).SetReferenced().SetDescription("the animation played for magical attacks"));
int Experience() const { return experience; }
int NextLevel() const;
+ bool CanEquip(const Item &) const;
+ bool CanInvoke(const Spell &) const;
+
Item *Weapon() { return weapon; }
Item *Armor() { return armor; }
Item *Shield() { return shield; }
int *levelLadder;
int numLevels;
+ int useMask;
+
Item *weapon;
Item *armor;
Item *shield;
+++ /dev/null
-/*
- * HeroGroup.h
- *
- * Created on: Aug 10, 2012
- * Author: holy
- */
-
-#ifndef COMMON_HEROGROUP_H_
-#define COMMON_HEROGROUP_H_
-
-#include <SDL.h>
-
-namespace common {
-
-class HeroGroup {
-
-public:
- HeroGroup() : members(NOBODY) { }
-
-public:
- bool HasMaxim() const { return members & MAXIM; }
- bool HasSelan() const { return members & SELAN; }
- bool HasGuy() const { return members & GUY; }
- bool HasArtea() const { return members & ARTEA; }
- bool HasTia() const { return members & TIA; }
- bool HasDekar() const { return members & DEKAR; }
- bool HasLexis() const { return members & LEXIS; }
-
- void AddMaxim() { members |= MAXIM; }
- void AddSelan() { members |= SELAN; }
- void AddGuy() { members |= GUY; }
- void AddArtea() { members |= ARTEA; }
- void AddTia() { members |= TIA; }
- void AddDekar() { members |= DEKAR; }
- void AddLexis() { members |= LEXIS; }
- void AddAll() { members = (MAXIM | SELAN | GUY | ARTEA | TIA | DEKAR | LEXIS); }
-
- void RemoveMaxim() { members &= ~MAXIM; }
- void RemoveSelan() { members &= ~SELAN; }
- void RemoveGuy() { members &= ~GUY; }
- void RemoveArtea() { members &= ~ARTEA; }
- void RemoveTia() { members &= ~TIA; }
- void RemoveDekar() { members &= ~DEKAR; }
- void RemoveLexis() { members &= ~LEXIS; }
- void RemoveAll() { members = NOBODY; }
-
-public:
- enum {
- NOBODY = 0,
- MAXIM = 1,
- SELAN = 2,
- GUY = 4,
- ARTEA = 8,
- TIA = 16,
- DEKAR = 32,
- LEXIS = 64,
- };
- Uint8 members;
-
-};
-
-}
-
-#endif /* COMMON_HEROGROUP_H_ */
, properties(0)
, equipability(0)
+, heroMask(0)
, mostUseful(false)
, cursed(false)
td.AddField("ikari", FieldDescription(((char *)&i.ikari) - ((char *)&i), Ikari::TYPE_ID).SetReferenced().SetDescription("ikari attack of the item (sensible only for equipment)"));
td.AddField("attackanimation", FieldDescription(((char *)&i.attackAnimation) - ((char *)&i), Animation::TYPE_ID).SetReferenced().SetDescription("animation that is run when the item is used for attacking"));
td.AddField("equipability", FieldDescription(((char *)&i.equipability) - ((char *)&i), Interpreter::NUMBER_ID).SetDescription("how this item can be equipped"));
+ td.AddField("heroMask", FieldDescription(((char *)&i.heroMask) - ((char *)&i), Interpreter::NUMBER_ID).SetDescription("which heroes may equip this item"));
}
void Item::Construct(void *data) {
#define COMMON_ITEM_H_
#include "fwd.h"
-#include "HeroGroup.h"
#include "TargetingMode.h"
#include "../graphics/fwd.h"
bool CanEquipRing() const { return equipability & EQUIPPABLE_RING; }
bool CanEquipJewel() const { return equipability & EQUIPPABLE_JEWEL; }
- HeroGroup &EquipableBy() { return equipableBy; }
- const HeroGroup &EquipableBy() const { return equipableBy; }
+ int HeroMask() const { return heroMask; }
bool HasEffectOnStatusScreen() const { return properties & PROPERTY_HAS_EFFECT_STATUS; }
bool HasEffectInBattle() const { return properties & PROPERTY_HAS_EFFECT_BATTLE; }
TargetingMode targettingMode;
int equipability;
- HeroGroup equipableBy;
+ int heroMask;
// TODO: turn these back into bits as soon as fields are implemented in the loader
bool mostUseful;
namespace common {
Spell::Spell()
-: name(""), value(0), cost(0), status(false), battle(false) {
+: name("")
+, value(0)
+, cost(0)
+, heroMask(0)
+, status(false)
+, battle(false) {
}
td.SetSize(sizeof(Spell));
td.AddField("name", FieldDescription(((char *)&s.name) - ((char *)&s), Interpreter::STRING_ID).SetReferenced().SetDescription("the spell's name"));
- td.AddField("cost", FieldDescription(((char *)&s.cost) - ((char *)&s), Interpreter::NUMBER_ID).SetDescription("Amount of magic points needed and deducted for invocation"));
+ td.AddField("cost", FieldDescription(((char *)&s.cost) - ((char *)&s), Interpreter::NUMBER_ID).SetDescription("amount of magic points needed and deducted for invocation"));
td.AddField("targets", FieldDescription(((char *)&s.targetingMode) - ((char *)&s), TargetingMode::TYPE_ID).SetDescription("how target selection is to be performed"));
+ td.AddField("heroMask", FieldDescription(((char *)&s.heroMask) - ((char *)&s), Interpreter::NUMBER_ID).SetDescription("which heroes can invoke this spell"));
td.AddField("status", FieldDescription(((char *)&s.status) - ((char *)&s), Interpreter::BOOLEAN_ID).SetDescription("if the spell can be used at the status screen"));
td.AddField("battle", FieldDescription(((char *)&s.battle) - ((char *)&s), Interpreter::BOOLEAN_ID).SetDescription("if the spell can be used in battle"));
}
#ifndef COMMON_SPELL_H_
#define COMMON_SPELL_H_
-#include "HeroGroup.h"
#include "TargetingMode.h"
namespace common {
TargetingMode &GetTargetingMode() { return targetingMode; }
const TargetingMode &GetTargetingMode() const { return targetingMode; }
- HeroGroup &UsableBy() { return usableBy; }
- const HeroGroup &UsableBy() const { return usableBy; }
+ int HeroMask() const { return heroMask; }
static bool Less(const Spell *, const Spell *);
int cost;
TargetingMode targetingMode;
- HeroGroup usableBy;
+ int heroMask;
bool status;
bool battle;
struct GameConfig;
struct GameState;
class Hero;
-class HeroGroup;
class Ikari;
class Inventory;
class Item;
Number single
Number multiple
+// Hero masks
+Number maskMaxim
+Number maskSelan
+Number maskGuy
+Number maskArtea
+Number maskDekar
+Number maskTia
+Number maskLexis
+Number maskAll
+
// Ikari
Boolean magical
Boolean physical
export Number multiple 1
export Number single 2
+// Hero masks
+export Number maskMaxim 1
+export Number maskSelan 2
+export Number maskGuy 4
+export Number maskArtea 8
+export Number maskDekar 16
+export Number maskTia 32
+export Number maskLexis 64
+export Number maskAll 127
+
// Ikari
export Boolean magical false
export Boolean physical true
name: "Eagle rock",
menuicon: jewelIcon,
ikari: diveIkari,
- equipability: jewel
+ equipability: jewel,
+ heroMask: maskAll
}
export Item escapeItem {
name: "Escape",
name: "Evil jewel",
menuicon: jewelIcon,
ikari: gloomyIkari,
- equipability: jewel
+ equipability: jewel,
+ heroMask: maskAll
}
export Item ghostRingItem {
name: "Ghost ring",
menuicon: ringIcon,
ikari: destroyIkari,
- equipability: ring
+ equipability: ring,
+ heroMask: maskAll
}
export Item hiPotionItem {
name: "Hi-Potion",
name: "Holy cap",
menuicon: helmetIcon,
ikari: vulnerableIkari,
- equipability: helmet
+ equipability: helmet,
+ heroMask: 42 // Selan, Artea, Tia
}
export Item holyRobeItem {
name: "Holy robe",
menuicon: armorIcon,
ikari: crisisCureIkari,
- equipability: armor
+ equipability: armor,
+ heroMask: 42 // Selan, Artea, Tia
}
export Item holyShieldItem {
name: "Holy shield",
menuicon: shieldIcon,
ikari: lightGuardIkari,
- equipability: shield
+ equipability: shield,
+ heroMask: 21 // Maxim, Guy, Dekar
}
export Item krakenRockItem {
name: "Kraken rock",
menuicon: jewelIcon,
ikari: tenLeggerIkari,
- equipability: jewel
+ equipability: jewel,
+ heroMask: maskAll
}
export Item legendHelmItem {
name: "Legend helm",
menuicon: helmetIcon,
ikari: boomerangIkari,
- equipability: helmet
+ equipability: helmet,
+ heroMask: 21 // Maxim, Guy, Dekar
}
export Item lizardBlowItem {
name: "Lizard blow",
faction: enemy,
mode: single
},
- equipability: weapon
+ equipability: weapon,
+ heroMask: maskAll
}
export Item magicJarItem {
name: "Magic jar",
name: "Mega shield",
menuicon: shieldIcon,
ikari: ironBarrierIkari,
- equipability: shield
+ equipability: shield,
+ heroMask: 20 // Guy, Dekar
}
export Item powerPotionItem {
name: "Power potion",
name: "Power ring",
menuicon: ringIcon,
ikari: trickIkari,
- equipability: ring
+ equipability: ring,
+ heroMask: maskAll
}
export Item rocketRingItem {
name: "Rocket ring",
menuicon: ringIcon,
ikari: fakeIkari,
- equipability: ring
+ equipability: ring,
+ heroMask: maskAll
}
export Item sleepBallItem {
name: "Sleep ball",
name: "S-pro ring",
menuicon: ringIcon,
ikari: courageIkari,
- equipability: ring
+ equipability: ring,
+ heroMask: maskAll
}
export Item zircoAxItem {
name: "Zirco ax",
faction: enemy,
mode: single
},
- equipability: weapon
+ equipability: weapon,
+ heroMask: 20 // Guy, Dekar
}
export Item zircoGlovesItem {
name: "Zirco gloves",
menuicon: shieldIcon,
ikari: forcefieldIkari,
- equipability: shield
+ equipability: shield,
+ heroMask: 106 // Selan, Artea, Tia, Lexis
}
export Item zircoHelmetItem {
name: "Zirco helmet",
menuicon: helmetIcon,
ikari: slowIkari,
- equipability: helmet
+ equipability: helmet,
+ heroMask: 21 // Maxim, Guy, Dekar
}
export Item zirconArmorItem {
name: "Zircon armor",
menuicon: armorIcon,
battle: false,
ikari: magicCureIkari,
- equipability: armor
+ equipability: armor,
+ heroMask: 21 // Maxim, Guy, Dekar
}
export Item zirconPlateItem {
name: "Zircon plate",
menuicon: armorIcon,
ikari: suddenCureIkari,
- equipability: armor
+ equipability: armor,
+ heroMask: 74 // Selan, Artea, Lexis
}
export Item zircoSwordItem {
name: "Zirco sword",
},
ikari: firestormIkari,
attackanimation: swordAttackAnimation,
- equipability: weapon
+ equipability: weapon,
+ heroMask: maskMaxim
}
export Item zircoWhipItem {
name: "Zirco whip",
mode: single
},
ikari: thundershriekIkari,
- equipability: weapon
+ equipability: weapon,
+ heroMask: 34 // Selan, Tia
}
ladder: [
10
],
+ useMask: maskMaxim,
attackAnimation: ComplexAnimation {
sprite: maximSprite,
frametime: frameTime,
gut: 80,
mgr: 13
},
+ useMask: maskSelan,
attackAnimation: ComplexAnimation {
sprite: selanSprite,
frametime: frameTime,
gut: 90,
mgr: 8
},
+ useMask: maskGuy,
attackAnimation: ComplexAnimation {
sprite: guySprite,
frametime: frameTime,
gut: 100,
mgr: 5
},
+ useMask: maskDekar,
attackAnimation: ComplexAnimation {
sprite: dekarSprite,
frametime: frameTime,