summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPhilipp Sehmisch <crush@themanaworld.org>2009-08-20 01:18:57 +0200
committerPhilipp Sehmisch <crush@themanaworld.org>2009-08-20 01:20:47 +0200
commit936c2d31127871e86918cf4e735da75186582543 (patch)
treeae9c80d6b2c8675fe230145dd70c52de9fd63d06 /src
parente706c092f3b28ff4e5bd229ce3a00e604828ce89 (diff)
downloadmanaserv-936c2d31127871e86918cf4e735da75186582543.tar.gz
manaserv-936c2d31127871e86918cf4e735da75186582543.tar.bz2
manaserv-936c2d31127871e86918cf4e735da75186582543.tar.xz
manaserv-936c2d31127871e86918cf4e735da75186582543.zip
Removed remnants of attack zones. Monsters AI now works properly again.
Diffstat (limited to 'src')
-rw-r--r--src/game-server/attackzone.cpp0
-rw-r--r--src/game-server/attackzone.hpp44
-rw-r--r--src/game-server/character.cpp1
-rw-r--r--src/game-server/item.cpp1
-rw-r--r--src/game-server/monster.cpp15
-rw-r--r--src/game-server/monster.hpp7
-rw-r--r--src/game-server/monstermanager.cpp8
7 files changed, 12 insertions, 64 deletions
diff --git a/src/game-server/attackzone.cpp b/src/game-server/attackzone.cpp
deleted file mode 100644
index e69de29b..00000000
--- a/src/game-server/attackzone.cpp
+++ /dev/null
diff --git a/src/game-server/attackzone.hpp b/src/game-server/attackzone.hpp
deleted file mode 100644
index 1f611ba9..00000000
--- a/src/game-server/attackzone.hpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * The Mana World Server
- * Copyright 2008 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * The Mana World is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _TMWSERV_ATTACKZONE
-#define _TMWSERV_ATTACKZONE
-
-
-/**
- * Enumeration of different types of attack damage zones
- */
-enum AttackZoneShape
-{
- ATTZONESHAPE_CONE,
- ATTZONESHAPE_RECT
-};
-
-struct AttackZone
-{
- AttackZoneShape shape;
- bool multiTarget;
- int range;
- int angle;
-};
-
-
-#endif // _TMWSERV_ATTACKZONE
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp
index a519686c..2d022a1c 100644
--- a/src/game-server/character.cpp
+++ b/src/game-server/character.cpp
@@ -28,7 +28,6 @@
#include "defines.h"
#include "common/configuration.hpp"
#include "game-server/accountconnection.hpp"
-#include "game-server/attackzone.hpp"
#include "game-server/buysell.hpp"
#include "game-server/eventlistener.hpp"
#include "game-server/inventory.hpp"
diff --git a/src/game-server/item.cpp b/src/game-server/item.cpp
index 3b0296aa..357874ff 100644
--- a/src/game-server/item.cpp
+++ b/src/game-server/item.cpp
@@ -25,7 +25,6 @@
#include "game-server/item.hpp"
-#include "game-server/attackzone.hpp"
#include "game-server/being.hpp"
#include "scripting/script.hpp"
diff --git a/src/game-server/monster.cpp b/src/game-server/monster.cpp
index 6b57ff42..2de90787 100644
--- a/src/game-server/monster.cpp
+++ b/src/game-server/monster.cpp
@@ -121,8 +121,8 @@ void Monster::perform()
damage.cth = getModifiedAttribute(BASE_ATTR_HIT);
damage.element = mCurrentAttack->element;
damage.type = mCurrentAttack->type;
- // todo: get the attack range from monster DB
- performAttack(mTarget, 64, damage);
+
+ performAttack(mTarget, mCurrentAttack->range, damage);
}
if (!mAttackTime)
{
@@ -227,11 +227,11 @@ void Monster::update()
i != allAttacks.end();
i++)
{
- const int attackAngle = directionToAngle(bestAttackDirection);
-
- if (Collision::diskWithCircleSector(
- bestAttackTarget->getPosition(), bestAttackTarget->getSize(),
- getPosition(), (*i)->attackZone.range, (*i)->attackZone.angle, attackAngle))
+ int distx = this->getPosition().x - bestAttackTarget->getPosition().x;
+ int disty = this->getPosition().y - bestAttackTarget->getPosition().y;
+ int distSquare = (distx * distx + disty * disty);
+ int maxDist = (*i)->range + bestAttackTarget->getSize();
+ if (maxDist * maxDist >= distSquare)
{
prioritySum += (*i)->priority;
workingAttacks[prioritySum] = (*i);
@@ -243,6 +243,7 @@ void Monster::update()
}
else
{
+ //prepare for using a random attack which can hit the enemy
//stop movement
setDestination(getPosition());
//turn into direction of enemy
diff --git a/src/game-server/monster.hpp b/src/game-server/monster.hpp
index c25d853e..21b6cf2c 100644
--- a/src/game-server/monster.hpp
+++ b/src/game-server/monster.hpp
@@ -24,7 +24,6 @@
#include <map>
#include <vector>
-#include "game-server/attackzone.hpp"
#include "game-server/being.hpp"
#include "game-server/eventlistener.hpp"
@@ -52,9 +51,9 @@ struct MonsterAttack
float damageFactor;
int element;
int type;
- int preDelay;
- int aftDelay;
- AttackZone attackZone;
+ unsigned preDelay;
+ unsigned aftDelay;
+ unsigned range;
};
typedef std::vector< MonsterAttack *> MonsterAttacks;
diff --git a/src/game-server/monstermanager.cpp b/src/game-server/monstermanager.cpp
index d7f301c8..426a2249 100644
--- a/src/game-server/monstermanager.cpp
+++ b/src/game-server/monstermanager.cpp
@@ -24,7 +24,6 @@
#include "game-server/monstermanager.hpp"
#include "defines.h"
-#include "game-server/attackzone.hpp"
#include "game-server/itemmanager.hpp"
#include "game-server/monster.hpp"
#include "game-server/resourcemanager.hpp"
@@ -222,17 +221,12 @@ void MonsterManager::reload()
else if (xmlStrEqual(subnode->name, BAD_CAST "attack"))
{
MonsterAttack *att = new MonsterAttack;
- AttackZone attackZone;
att->id = XML::getProperty(subnode, "id", 0);
att->priority = XML::getProperty(subnode, "priority", 1);
att->damageFactor = XML::getFloatProperty(subnode, "damage-factor", 1.0f);
att->preDelay = XML::getProperty(subnode, "pre-delay", 1);
att->aftDelay = XML::getProperty(subnode, "aft-delay", 0);
- attackZone.multiTarget = true;
- attackZone.shape = ATTZONESHAPE_CONE;
- attackZone.range = XML::getProperty(subnode, "range", 1);
- attackZone.angle = XML::getProperty(subnode, "angle", 1);
- att->attackZone = attackZone;
+ att->range = XML::getProperty(subnode, "range", 0);
std::string sElement = XML::getProperty(subnode, "element", "neutral");
att->element = elementFromString(sElement);
std::string sType = XML::getProperty(subnode, "type", "physical");