aboutsummaryrefslogtreecommitdiffstats
path: root/src/mob.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mob.cpp')
-rw-r--r--src/mob.cpp80
1 files changed, 63 insertions, 17 deletions
diff --git a/src/mob.cpp b/src/mob.cpp
index 526d7b1..4cafa09 100644
--- a/src/mob.cpp
+++ b/src/mob.cpp
@@ -65,8 +65,13 @@ void Page::createFromXML(XMLElement *e, World *w=nullptr)
cId = e->StrAttribute("cid");
cValue = e->StrAttribute("cvalue");
+
+ xmle = e;
}
+void Page::saveToXML(void)
+{}
+
Door::Door(void) : Mob()
{
ridable = false;
@@ -101,6 +106,9 @@ void Door::createFromXML(XMLElement *e, World *w=nullptr)
loc.x = Xlocx;
}
+void Door::saveToXML(void)
+{}
+
Cat::Cat(void) : Mob()
{
ridable = true;
@@ -154,9 +162,23 @@ bool Cat::bindTex(void)
void Cat::createFromXML(XMLElement *e, World *w=nullptr)
{
(void)w;
- float Xlocx;
- if (e->QueryFloatAttribute("x", &Xlocx) == XML_NO_ERROR)
- loc.x = Xlocx;
+ float spawnc;
+
+ if (e->QueryFloatAttribute("x", &spawnc) == XML_NO_ERROR)
+ loc.x = spawnc;
+ else
+ loc.x = e->FloatAttribute("spawnx");
+
+ if (e->QueryFloatAttribute("y", &spawnc) == XML_NO_ERROR)
+ loc.y = spawnc;
+
+ xmle = e;
+}
+
+void Cat::saveToXML(void)
+{
+ E_SAVE_COORDS;
+ xmle->SetAttribute("alive", alive);
}
Rabbit::Rabbit(void) : Mob()
@@ -210,16 +232,27 @@ bool Rabbit::bindTex(void)
void Rabbit::createFromXML(XMLElement *e, World *w=nullptr)
{
(void)w;
- float Xlocx, Xhealth;
- if (e->QueryFloatAttribute("x", &Xlocx) == XML_NO_ERROR)
- loc.x = Xlocx;
- if (e->QueryFloatAttribute("health", &Xhealth) == XML_NO_ERROR)
- maxHealth = health = Xhealth;
- if (e->QueryBoolAttribute("aggressive", &aggressive) != XML_NO_ERROR) {
- aggressive = false;
- }
+ float spawnc;
xmle = e;
+
+ if (e->QueryFloatAttribute("x", &spawnc) == XML_NO_ERROR)
+ loc.x = spawnc;
+ else
+ loc.x = e->FloatAttribute("spawnx");
+
+ if (e->QueryFloatAttribute("y", &spawnc) == XML_NO_ERROR)
+ loc.y = spawnc;
+
+ E_LOAD_HEALTH;
+
+ if (e->QueryBoolAttribute("aggressive", &aggressive) != XML_NO_ERROR)
+ aggressive = false;
+}
+
+void Rabbit::saveToXML(void)
+{
+ E_SAVE_HEALTH;
}
Bird::Bird(void) : Mob()
@@ -269,16 +302,26 @@ void Bird::createFromXML(XMLElement *e, World *w=nullptr)
{
(void)w;
float Xlocx, Xhealth;
- if (e->QueryFloatAttribute("x", &Xlocx) == XML_NO_ERROR)
- loc.x = Xlocx;
- if (e->QueryFloatAttribute("health", &Xhealth) == XML_NO_ERROR)
- maxHealth = health = Xhealth;
- if (e->QueryFloatAttribute("y", &initialY) != XML_NO_ERROR)
- initialY = 300;
+
+ xmle = e;
+
+ if (e->QueryFloatAttribute("x", &Xlocx) == XML_NO_ERROR)
+ loc.x = Xlocx;
+ if (e->QueryFloatAttribute("y", &initialY) != XML_NO_ERROR)
+ initialY = 300;
+
+ E_LOAD_HEALTH;
+
if (e->QueryBoolAttribute("aggressive", &aggressive) != XML_NO_ERROR)
aggressive = false;
}
+void Bird::saveToXML(void)
+{
+ E_SAVE_COORDS;
+ E_SAVE_HEALTH;
+}
+
Trigger::Trigger(void) : Mob()
{
ridable = false;
@@ -351,6 +394,9 @@ void Trigger::createFromXML(XMLElement *e, World *w=nullptr)
id = e->StrAttribute("id");
}
+void Trigger::saveToXML(void)
+{}
+
Mob::~Mob()
{
delete inv;