]> git.localhorst.tv Git - l2e.git/blobdiff - src/common/Hero.cpp
use referenced flag of array types
[l2e.git] / src / common / Hero.cpp
index 8222e124ce8e81686a876fbc94c23dd25c99a95f..cca9d43f812eba77b89c039fc10990889c97645c 100644 (file)
@@ -1,24 +1,23 @@
-/*
- * Hero.cpp
- *
- *  Created on: Oct 7, 2012
- *      Author: holy
- */
-
 #include "Hero.h"
 
+#include "Item.h"
+#include "Spell.h"
 #include "../graphics/Animation.h"
 #include "../graphics/Sprite.h"
 #include "../loader/Interpreter.h"
 #include "../loader/TypeDescription.h"
 #include "../map/Entity.h"
 
+#include <cstring>
+
 using graphics::Animation;
 using graphics::Sprite;
 using loader::FieldDescription;
 using loader::Interpreter;
 using loader::TypeDescription;
 using map::Entity;
+using std::memset;
+
 
 namespace common {
 
@@ -36,18 +35,13 @@ Hero::Hero()
 , levelLadder(0)
 , numLevels(0)
 
-, weapon(0)
-, armor(0)
-, shield(0)
-, helmet(0)
-, ring(0)
-, jewel(0)
+, useMask(0)
 
 , battleSprite(0)
 , meleeAnimation(0)
 , attackAnimation(0)
 , spellAnimation(0) {
-
+       memset(equipment, 0, sizeof(equipment));
 }
 
 
@@ -76,6 +70,15 @@ int Hero::NextLevel() const {
 }
 
 
+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;
 
@@ -94,7 +97,9 @@ void Hero::CreateTypeDescription() {
        td.AddField("stats", FieldDescription(((char *)&h.stats) - ((char *)&h), Stats::TYPE_ID));
 
        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("ladder", FieldDescription(((char *)&h.levelLadder) - ((char *)&h), Interpreter::NUMBER_ID).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"));