From d1f105c21573bb98bf88628849bf71ecd71935d5 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Mon, 7 Jan 2008 23:01:46 +0000 Subject: Player characters and monsters now attack with different ranges and angles (preparation for getting attack zone from weapon properties or monster database). --- ChangeLog | 6 ++++++ src/game-server/being.cpp | 8 +++----- src/game-server/being.hpp | 2 +- src/game-server/character.cpp | 6 +++++- src/game-server/monster.cpp | 15 +++++++++------ src/game-server/monster.hpp | 2 ++ 6 files changed, 26 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index e57fe9b1..f219f23a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,12 @@ * src/game-server/character.cpp: The clients now only receive attribute change messages when the attribute actually changed. + * src/game-server/being.cpp, src/beinggame-server/.hpp, + src/game-server/character.cpp, src/game-server/monster.cpp, + src/game-server/monster.hpp: + Player characters and monsters now attack with different ranges + and angles (preparation for getting attack zone from weapon + properties or monster database). 2007-12-18 Philipp Sehmisch diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp index c969daf5..ce7f06db 100644 --- a/src/game-server/being.cpp +++ b/src/game-server/being.cpp @@ -131,10 +131,8 @@ void Being::move() } } -void Being::performAttack(Damage const &damage) +void Being::performAttack(Damage const &damage, int range, int angle) { - int SHORT_RANGE = 60; - int SMALL_ANGLE = 35; Point ppos = getPosition(); int dir = getDirection(); @@ -159,7 +157,7 @@ void Being::performAttack(Damage const &damage) } for (MovingObjectIterator - i(getMap()->getAroundObjectIterator(this, SHORT_RANGE)); i; ++i) + i(getMap()->getAroundObjectIterator(this, range)); i; ++i) { MovingObject *o = *i; if (o == this) continue; @@ -172,7 +170,7 @@ void Being::performAttack(Damage const &damage) if (Collision::diskWithCircleSector( opos, o->getSize(), - ppos, SHORT_RANGE, SMALL_ANGLE, attackAngle) + ppos, range, angle, attackAngle) ) { static_cast< Being * >(o)->damage(this, damage); diff --git a/src/game-server/being.hpp b/src/game-server/being.hpp index 15a3e54e..55aa603e 100644 --- a/src/game-server/being.hpp +++ b/src/game-server/being.hpp @@ -157,7 +157,7 @@ class Being : public MovingObject /** * Performs an attack. */ - void performAttack(Damage const &); + void performAttack(Damage const &, int range, int angle); /** * Sets the current action. diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp index 04f3d52b..694b4adf 100644 --- a/src/game-server/character.cpp +++ b/src/game-server/character.cpp @@ -84,7 +84,11 @@ void Character::perform() // No-weapon fighting. damage.element = ELEMENT_NEUTRAL; } - performAttack(damage); + + int attackRange = 60; //TODO: get from weapon + int attackAngle = 30; //TODO: get from weapon + + performAttack(damage, attackRange, attackAngle); } int Character::getMapId() const diff --git a/src/game-server/monster.cpp b/src/game-server/monster.cpp index b65ee3de..188c8781 100644 --- a/src/game-server/monster.cpp +++ b/src/game-server/monster.cpp @@ -59,15 +59,18 @@ Monster::Monster(MonsterClass *specy): mSpecy(specy), mCountDown(0), mTargetListener(&monsterTargetEventDispatch), - mAttackTime(0), - mAttackPreDelay(5), - mAttackAftDelay(10) + mAttackTime(0) { LOG_DEBUG("Monster spawned!"); - mAgressive = false; // TODO: Get from monster database - mAgressionRange = 10; // TODO: Get from monster database // Some bogus stats for testing. + // TODO: Get all this stuff from the monster database. + mAgressive = false; + mAgressionRange = 10; + mAttackPreDelay = 10; + mAttackAftDelay = 10; + mAttackRange = 32; + mAttackAngle = 10; setSpeed(300); setSize(8); setAttribute(BASE_ATTR_HP, 100); @@ -107,7 +110,7 @@ void Monster::perform() damage.cth = getModifiedAttribute(BASE_ATTR_HIT); damage.element = ELEMENT_NEUTRAL; damage.type = DAMAGE_PHYSICAL; - performAttack(damage); + performAttack(damage, mAttackRange, mAttackAngle); } void Monster::update() diff --git a/src/game-server/monster.hpp b/src/game-server/monster.hpp index 40ab2047..af1d241e 100644 --- a/src/game-server/monster.hpp +++ b/src/game-server/monster.hpp @@ -151,6 +151,8 @@ class Monster : public Being // to save memory. int mAttackPreDelay; /**< time between decision to make an attack and performing the attack */ int mAttackAftDelay; /**< time it takes to perform an attack */ + int mAttackRange; /**< range of the monsters attacks in pixel */ + int mAttackAngle; /**< angle of the monsters attacks in degree */ bool mAgressive; /**< Does the monster attack without being provoked? */ unsigned mAgressionRange; /**< Distance the monster tracks enemies in */ std::list mAttackPositions; /**< set positions relative to target from which the monster can attack */ -- cgit v1.2.3-70-g09d2