Update of /cvsroot/wpdev/wolfpack/ai
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29663/ai
Modified Files:
ai.cpp ai.h ai_animals.cpp ai_humans.cpp ai_mage.cpp
ai_monsters.cpp
Log Message:
New sectors code and more. A changelog will be sent to the mailing list.
Index: ai_animals.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/ai/ai_animals.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** ai_animals.cpp 16 Oct 2004 04:53:23 -0000 1.18
--- ai_animals.cpp 3 Nov 2004 02:09:30 -0000 1.19
***************
*** 31,36 ****
#include "../serverconfig.h"
- #include "../sectors.h"
#include "../basics.h"
#include "../targetrequests.h"
--- 31,36 ----
#include "../serverconfig.h"
#include "../basics.h"
+ #include "../mapobjects.h"
#include "../targetrequests.h"
***************
*** 78,85 ****
return 0.0f;
! RegionIterator4Chars ri( m_npc->pos(), Config::instance()->animalWildFleeRange() );
! for ( ri.Begin(); !ri.atEnd(); ri++ )
{
! P_PLAYER pPlayer = dynamic_cast<P_PLAYER>( ri.GetData() );
if ( pPlayer && !pPlayer->free && !pPlayer->isGMorCounselor() && !pPlayer->isHidden() && !pPlayer->isInvisible() )
{
--- 78,85 ----
return 0.0f;
! MapCharsIterator ri = MapObjects::instance()->listCharsInCircle( m_npc->pos(), Config::instance()->animalWildFleeRange() );
! for ( P_CHAR pChar = ri.first(); pChar; pChar = ri.next() )
{
! P_PLAYER pPlayer = dynamic_cast<P_PLAYER>( pChar );
if ( pPlayer && !pPlayer->free && !pPlayer->isGMorCounselor() && !pPlayer->isHidden() && !pPlayer->isInvisible() )
{
***************
*** 109,117 ****
return 1.0f;
- RegionIterator4Chars ri( m_npc->pos(), Config::instance()->animalWildFleeRange() );
bool found = false;
! for ( ri.Begin(); !ri.atEnd(); ri++ )
{
! P_PLAYER pPlayer = dynamic_cast<P_PLAYER>( ri.GetData() );
if ( pPlayer && !pPlayer->free && !pPlayer->isGMorCounselor() && !pPlayer->isHidden() && !pPlayer->isInvisible() )
found = true;
--- 109,117 ----
return 1.0f;
bool found = false;
! MapCharsIterator ri = MapObjects::instance()->listCharsInCircle( m_npc->pos(), Config::instance()->animalWildFleeRange() );
! for ( P_CHAR pChar = ri.first(); pChar; pChar = ri.next() )
{
! P_PLAYER pPlayer = dynamic_cast<P_PLAYER>( pChar );
if ( pPlayer && !pPlayer->free && !pPlayer->isGMorCounselor() && !pPlayer->isHidden() && !pPlayer->isInvisible() )
found = true;
Index: ai_humans.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/ai/ai_humans.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** ai_humans.cpp 2 Nov 2004 20:45:40 -0000 1.28
--- ai_humans.cpp 3 Nov 2004 02:09:30 -0000 1.29
***************
*** 37,44 ****
#include "../console.h"
- #include "../sectors.h"
#include "../world.h"
- #include "../inlines.h"
#include "../basics.h"
// library includes
--- 37,44 ----
#include "../console.h"
#include "../world.h"
#include "../basics.h"
+ #include "../inlines.h"
+ #include "../mapobjects.h"
// library includes
***************
*** 209,213 ****
//pPet->free = true;
- MapObjects::instance()->remove( pPet );
pPet->setStablemasterSerial( this->m_npc->serial() );
pPet->setOwner(0); // Remove ownership from this player since it's stabled
--- 209,212 ----
***************
*** 382,389 ****
{
// Get a criminal or murderer in range to attack it
! RegionIterator4Chars ri( m_npc->pos(), VISRANGE );
! for ( ri.Begin(); !ri.atEnd(); ri++ )
{
- P_CHAR pChar = ri.GetData();
if ( pChar && !pChar->free && pChar != m_npc && !pChar->isInvulnerable() && !pChar->isHidden() && !pChar->isInvisible() && !pChar->isDead() )
{
--- 381,387 ----
{
// Get a criminal or murderer in range to attack it
! MapCharsIterator ri = MapObjects::instance()->listCharsInCircle( m_npc->pos(), VISRANGE );
! for ( P_CHAR pChar = ri.first(); pChar; pChar = ri.next() )
{
if ( pChar && !pChar->free && pChar != m_npc && !pChar->isInvulnerable() && !pChar->isHidden() && !pChar->isInvisible() && !pChar->isDead() )
{
Index: ai_monsters.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/ai/ai_monsters.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** ai_monsters.cpp 27 Oct 2004 14:07:08 -0000 1.29
--- ai_monsters.cpp 3 Nov 2004 02:09:30 -0000 1.30
***************
*** 30,35 ****
#include "../npc.h"
#include "../factory.h"
- #include "../sectors.h"
#include "../player.h"
#include "../serverconfig.h"
#include "../basics.h"
--- 30,35 ----
#include "../npc.h"
#include "../factory.h"
#include "../player.h"
+ #include "../mapobjects.h"
#include "../serverconfig.h"
#include "../basics.h"
***************
*** 118,126 ****
// If we're not tamed, we attack other players as well.
if (!npc->isTamed()) {
! RegionIterator4Chars ri(npc->pos(), VISRANGE);
! for ( ri.Begin(); !ri.atEnd(); ri++ ) {
// We limit ourself to players and pets owned by players.
! P_PLAYER victim = dynamic_cast<P_PLAYER>( ri.GetData() );
! P_NPC npcVictim = dynamic_cast<P_NPC>( ri.GetData() );
// We don't already attack the target, right?
--- 118,127 ----
// If we're not tamed, we attack other players as well.
if (!npc->isTamed()) {
! MapCharsIterator ri = MapObjects::instance()->listCharsInCircle( npc->pos(), VISRANGE );
! for ( P_CHAR pChar = ri.first(); pChar; pChar = ri.next() )
! {
// We limit ourself to players and pets owned by players.
! P_PLAYER victim= dynamic_cast<P_PLAYER>( pChar );
! P_NPC npcVictim = dynamic_cast<P_NPC>( pChar );
// We don't already attack the target, right?
***************
*** 269,273 ****
// 1.0 = Full Health, 0.0 = Dead
! float diff = 1.0 - QMAX( 0, ( m_npc->maxHitpoints() - m_npc->hitpoints() ) / ( float ) m_npc->maxHitpoints() );
if ( diff <= m_npc->criticalHealth() / 100.0 )
--- 270,274 ----
// 1.0 = Full Health, 0.0 = Dead
! float diff = 1.0 - wpMax<float>( 0, ( m_npc->maxHitpoints() - m_npc->hitpoints() ) / ( float ) m_npc->maxHitpoints() );
if ( diff <= m_npc->criticalHealth() / 100.0 )
***************
*** 314,318 ****
// 1.0 = Full Health, 0.0 = Dead
! float diff = 1.0 - QMAX( 0, ( m_npc->maxHitpoints() - m_npc->hitpoints() ) / ( float ) m_npc->maxHitpoints() );
if ( diff <= m_npc->criticalHealth() / 100.0 )
--- 315,319 ----
// 1.0 = Full Health, 0.0 = Dead
! float diff = 1.0 - wpMax<float>( 0, ( m_npc->maxHitpoints() - m_npc->hitpoints() ) / ( float ) m_npc->maxHitpoints() );
if ( diff <= m_npc->criticalHealth() / 100.0 )
***************
*** 394,398 ****
// 1.0 = Full Health, 0.0 = Dead
! float diff = 1.0 - QMAX( 0, ( m_npc->maxHitpoints() - m_npc->hitpoints() ) / ( float ) m_npc->maxHitpoints() );
if ( diff <= m_npc->criticalHealth() / 100.0 )
--- 395,399 ----
// 1.0 = Full Health, 0.0 = Dead
! float diff = 1.0 - wpMax<float>( 0, ( m_npc->maxHitpoints() - m_npc->hitpoints() ) / ( float ) m_npc->maxHitpoints() );
if ( diff <= m_npc->criticalHealth() / 100.0 )
***************
*** 438,442 ****
// 1.0 = Full Health, 0.0 = Dead
! float diff = 1.0 - QMAX( 0, ( m_npc->maxHitpoints() - m_npc->hitpoints() ) / ( float ) m_npc->maxHitpoints() );
if ( diff <= m_npc->criticalHealth() / 100.0 )
--- 439,443 ----
// 1.0 = Full Health, 0.0 = Dead
! float diff = 1.0 - wpMax<float>( 0, ( m_npc->maxHitpoints() - m_npc->hitpoints() ) / ( float ) m_npc->maxHitpoints() );
if ( diff <= m_npc->criticalHealth() / 100.0 )
Index: ai_mage.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/ai/ai_mage.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ai_mage.cpp 17 Oct 2004 15:48:56 -0000 1.6
--- ai_mage.cpp 3 Nov 2004 02:09:30 -0000 1.7
***************
*** 4,9 ****
#include "../npc.h"
#include "../combat.h"
! #include "../serverconfig.h"
#include "../walking.h"
/*
--- 4,10 ----
#include "../npc.h"
#include "../combat.h"
! #include "../inlines.h"
#include "../walking.h"
+ #include "../serverconfig.h"
/*
***************
*** 98,102 ****
int spell;
cUObject *objTarget;
! Coord_cl posTarget;
public:
--- 99,103 ----
int spell;
cUObject *objTarget;
! Coord posTarget;
public:
***************
*** 105,109 ****
spell = -1; // Current Spell
objTarget = 0;
! posTarget = Coord_cl::null;
}
--- 106,110 ----
spell = -1; // Current Spell
objTarget = 0;
! posTarget = Coord::null;
}
***************
*** 174,181 ****
Get the id of a random damage spell
*/
! int getRandomHarmfulSpell() {
! static const float mageryPerCircle = (1000.0 / 7.0);
! unsigned char maxCircle = QMIN(8, QMAX(1, (unsigned char)((m_npc->skillValue(MAGERY) + 200) / mageryPerCircle)));
! int selected = RandomNum(1, maxCircle * 2) - 1; // Select a random spell
// 5: Magic Arrow
--- 175,183 ----
Get the id of a random damage spell
*/
! int getRandomHarmfulSpell()
! {
! static const ushort mageryPerCircle = ( 1000 / 7 );
! int maxCircle = wpMin<int>( 8, wpMax<int>( 1, ( ( m_npc->skillValue( MAGERY ) + 200 ) / mageryPerCircle ) ) );
! int selected = RandomNum( 1, maxCircle * 2 ) - 1; // Select a random spell
// 5: Magic Arrow
***************
*** 195,199 ****
Chose a random spell
*/
! void chooseSpell(int &spell, cUObject *&objTarget, Coord_cl &posTarget, P_CHAR currentVictim) {
// If we are not summoned, try healing
if (m_npc->hitpoints() < m_npc->maxHitpoints() // Only try to heal if we're not at full health
--- 197,201 ----
Chose a random spell
*/
! void chooseSpell(int &spell, cUObject *&objTarget, Coord &posTarget, P_CHAR currentVictim) {
// If we are not summoned, try healing
if (m_npc->hitpoints() < m_npc->maxHitpoints() // Only try to heal if we're not at full health
***************
*** 233,237 ****
spell = -1;
objTarget = 0;
! posTarget = Coord_cl::null;
// We dont have a spell ready, are ready to cast.
--- 235,239 ----
spell = -1;
objTarget = 0;
! posTarget = Coord::null;
// We dont have a spell ready, are ready to cast.
Index: ai.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/ai/ai.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** ai.h 16 Oct 2004 18:19:41 -0000 1.21
--- ai.h 3 Nov 2004 02:09:30 -0000 1.22
***************
*** 46,50 ****
// forward declarations
! class Coord_cl;
class AbstractAI;
--- 46,50 ----
// forward declarations
! class Coord;
class AbstractAI;
***************
*** 181,185 ****
};
! typedef SingletonHolder<cAIFactory> AIFactory;
class Action_Wander : public AbstractAction
--- 181,185 ----
};
! typedef Singleton<cAIFactory> AIFactory;
class Action_Wander : public AbstractAction
***************
*** 203,208 ****
protected:
! bool moveTo( const Coord_cl& pos, bool run = false );
! bool movePath( const Coord_cl& pos, bool run = false );
int waitForPathCalculation;
};
--- 203,208 ----
protected:
! bool moveTo( const Coord& pos, bool run = false );
! bool movePath( const Coord& pos, bool run = false );
int waitForPathCalculation;
};
Index: ai.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/ai/ai.cpp,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -d -r1.41 -r1.42
*** ai.cpp 26 Oct 2004 18:37:33 -0000 1.41
--- ai.cpp 3 Nov 2004 02:09:30 -0000 1.42
***************
*** 30,35 ****
#include "ai.h"
#include "../npc.h"
- #include "../sectors.h"
#include "../player.h"
#include "../serverconfig.h"
--- 30,35 ----
#include "ai.h"
#include "../npc.h"
#include "../player.h"
+ #include "../mapobjects.h"
#include "../serverconfig.h"
***************
*** 582,586 ****
}
! Coord_cl newpos = Movement::instance()->calcCoordFromDir( dir, m_npc->pos() );
// Calculate a new direction.
--- 582,586 ----
}
! Coord newpos = Movement::instance()->calcCoordFromDir( dir, m_npc->pos() );
// Calculate a new direction.
***************
*** 650,654 ****
Q_UINT16 rndy = RandomNum( m_npc->wanderY1(), m_npc->wanderY2() );
! Q_UINT8 dir = m_npc->pos().direction( Coord_cl( rndx, rndy ) );
Movement::instance()->Walking( m_npc, dir, 0xFF );
break;
--- 650,654 ----
Q_UINT16 rndy = RandomNum( m_npc->wanderY1(), m_npc->wanderY2() );
! Q_UINT8 dir = m_npc->pos().direction( Coord( rndx, rndy ) );
Movement::instance()->Walking( m_npc, dir, 0xFF );
break;
***************
*** 656,660 ****
case enCircle:
{
! Coord_cl pos = m_npc->pos();
pos.x = m_npc->wanderX1();
pos.y = m_npc->wanderY1();
--- 656,660 ----
case enCircle:
{
! Coord pos = m_npc->pos();
pos.x = m_npc->wanderX1();
pos.y = m_npc->wanderY1();
***************
*** 711,719 ****
}
! bool Action_Wander::moveTo( const Coord_cl& pos, bool run )
{
// simply move towards the target
Q_UINT8 dir = m_npc->pos().direction( pos );
! Coord_cl newPos = Movement::instance()->calcCoordFromDir( dir, m_npc->pos() );
if ( !mayWalk( m_npc, newPos ) )
--- 711,719 ----
}
! bool Action_Wander::moveTo( const Coord& pos, bool run )
{
// simply move towards the target
Q_UINT8 dir = m_npc->pos().direction( pos );
! Coord newPos = Movement::instance()->calcCoordFromDir( dir, m_npc->pos() );
if ( !mayWalk( m_npc, newPos ) )
***************
*** 759,763 ****
}
! bool Action_Wander::movePath( const Coord_cl& pos, bool run )
{
if ( waitForPathCalculation <= 0 && !m_npc->hasPath() )
--- 759,763 ----
}
! bool Action_Wander::movePath( const Coord& pos, bool run )
{
if ( waitForPathCalculation <= 0 && !m_npc->hasPath() )
***************
*** 787,791 ****
{
waitForPathCalculation = 0;
! Coord_cl nextmove = m_npc->nextMove();
Q_UINT8 dir = m_npc->pos().direction( nextmove );
--- 787,791 ----
{
waitForPathCalculation = 0;
! Coord nextmove = m_npc->nextMove();
Q_UINT8 dir = m_npc->pos().direction( nextmove );
***************
*** 826,831 ****
if ( !m_npc->hasPath() )
{
! Coord_cl newPos = m_npc->pos();
! Coord_cl fleePos = pFleeFrom->pos();
// find a valid spot in a circle of flee_radius fields to move to
--- 826,831 ----
if ( !m_npc->hasPath() )
{
! Coord newPos = m_npc->pos();
! Coord fleePos = pFleeFrom->pos();
// find a valid spot in a circle of flee_radius fields to move to
***************
*** 873,877 ****
// 1.0 = Full Health, 0.0 = Dead
! float diff = 1.0 - QMAX( 0, ( m_npc->maxHitpoints() - m_npc->hitpoints() ) / ( float ) m_npc->maxHitpoints() );
if ( diff <= m_npc->criticalHealth() / 100.0 )
--- 873,877 ----
// 1.0 = Full Health, 0.0 = Dead
! float diff = 1.0 - wpMax<float>( 0, ( m_npc->maxHitpoints() - m_npc->hitpoints() ) / ( float ) m_npc->maxHitpoints() );
if ( diff <= m_npc->criticalHealth() / 100.0 )
***************
*** 901,905 ****
// 1.0 = Full Health, 0.0 = Dead
! float diff = 1.0 - QMAX( 0, ( m_npc->maxHitpoints() - m_npc->hitpoints() ) / ( float ) m_npc->maxHitpoints() );
if ( diff <= m_npc->criticalHealth() / 100.0 )
--- 901,905 ----
// 1.0 = Full Health, 0.0 = Dead
! float diff = 1.0 - wpMax<float>( 0, ( m_npc->maxHitpoints() - m_npc->hitpoints() ) / ( float ) m_npc->maxHitpoints() );
if ( diff <= m_npc->criticalHealth() / 100.0 )
***************
*** 946,950 ****
// 1.0 = Full Health, 0.0 = Dead
! float diff = 1.0 - QMAX( 0, ( m_npc->maxHitpoints() - m_npc->hitpoints() ) / ( float ) m_npc->maxHitpoints() );
if ( diff <= m_npc->criticalHealth() / 100.0 )
--- 946,950 ----
// 1.0 = Full Health, 0.0 = Dead
! float diff = 1.0 - wpMax<float>( 0, ( m_npc->maxHitpoints() - m_npc->hitpoints() ) / ( float ) m_npc->maxHitpoints() );
if ( diff <= m_npc->criticalHealth() / 100.0 )
***************
*** 988,992 ****
// 1.0 = Full Health, 0.0 = Dead
! float diff = 1.0 - QMAX( 0, ( m_npc->maxHitpoints() - m_npc->hitpoints() ) / ( float ) m_npc->maxHitpoints() );
if ( diff <= m_npc->criticalHealth() / 100.0 )
--- 988,992 ----
// 1.0 = Full Health, 0.0 = Dead
! float diff = 1.0 - wpMax<float>( 0, ( m_npc->maxHitpoints() - m_npc->hitpoints() ) / ( float ) m_npc->maxHitpoints() );
if ( diff <= m_npc->criticalHealth() / 100.0 )
|