Update of /cvsroot/wpdev/wolfpack
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8972
Modified Files:
ChangeLog basechar.h basedef.cpp basedef.h npc.cpp npc.h
spawnregions.cpp
Log Message:
npc movement.
Index: npc.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/npc.h,v
retrieving revision 1.61
retrieving revision 1.62
diff -C2 -d -r1.61 -r1.62
*** npc.h 28 Sep 2004 09:48:56 -0000 1.61
--- npc.h 10 Oct 2004 17:51:24 -0000 1.62
***************
*** 130,134 ****
virtual stError* setProperty( const QString& name, const cVariant& value );
PyObject* getProperty( const QString& name );
! void setNextMoveTime( void );
virtual void callGuards(); // overriding
void makeShop();
--- 130,134 ----
virtual stError* setProperty( const QString& name, const cVariant& value );
PyObject* getProperty( const QString& name );
! void setNextMoveTime( bool changeDirection = true );
virtual void callGuards(); // overriding
void makeShop();
Index: basedef.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/basedef.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** basedef.cpp 9 Oct 2004 14:28:59 -0000 1.24
--- basedef.cpp 10 Oct 2004 17:51:24 -0000 1.25
***************
*** 126,129 ****
--- 126,131 ----
controlSlots_ = 1;
criticalHealth_ = 0;
+ wanderSpeed_ = 400;
+ actionSpeed_ = 200;
}
***************
*** 182,185 ****
--- 184,202 ----
applyDefinition( element );
}
+ else if ( node->name() == "speed" && node->hasAttribute("wander") && node->hasAttribute("action"))
+ {
+ bool ok1, ok2;
+
+ // Convert to unsigned ints
+ unsigned int wanderSpeed = node->getAttribute("wander").toUInt(&ok1);
+ unsigned int actionSpeed = node->getAttribute("action").toUInt(&ok2);
+
+ if (!ok1 || !ok2) {
+ Console::instance()->log(LOG_WARNING, tr("Base definition '%1' has invalid speed tag.\n").arg(id_));
+ } else {
+ actionSpeed_ = actionSpeed;
+ wanderSpeed_ = wanderSpeed;
+ }
+ }
else
{
Index: basedef.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/basedef.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** basedef.h 1 Oct 2004 15:15:56 -0000 1.19
--- basedef.h 10 Oct 2004 17:51:24 -0000 1.20
***************
*** 137,141 ****
QCString lootPacks_;
unsigned char controlSlots_;
! unsigned char criticalHealth_;
// Misc Properties
--- 137,143 ----
QCString lootPacks_;
unsigned char controlSlots_;
! unsigned char criticalHealth_;
! unsigned int actionSpeed_; // ms between moves
! unsigned int wanderSpeed_; // ms between moves
// Misc Properties
***************
*** 154,157 ****
--- 156,171 ----
}
+ inline unsigned int wanderSpeed()
+ {
+ load();
+ return wanderSpeed_;
+ }
+
+ inline unsigned int actionSpeed()
+ {
+ load();
+ return actionSpeed_;
+ }
+
inline unsigned char criticalHealth()
{
Index: ChangeLog
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/ChangeLog,v
retrieving revision 1.103
retrieving revision 1.104
diff -C2 -d -r1.103 -r1.104
*** ChangeLog 10 Oct 2004 12:19:09 -0000 1.103
--- ChangeLog 10 Oct 2004 17:51:24 -0000 1.104
***************
*** 40,43 ****
--- 40,45 ----
- Fixed "lingering" characters at the border of the screen if they walk away.
- Fixed bug #0000348 ( Guards should kill instantly )
+ - Improved NPC movement and allowed custom speeds per npc.
+ - Reduced network latency.
Wolfpack 12.9.11 Beta (26. September 2004)
Index: basechar.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/basechar.h,v
retrieving revision 1.88
retrieving revision 1.89
diff -C2 -d -r1.88 -r1.89
*** basechar.h 26 Sep 2004 21:36:23 -0000 1.88
--- basechar.h 10 Oct 2004 17:51:24 -0000 1.89
***************
*** 581,584 ****
--- 581,594 ----
}
+ inline unsigned int wanderSpeed()
+ {
+ return basedef_ ? basedef_->wanderSpeed() : 400;
+ }
+
+ inline unsigned int actionSpeed()
+ {
+ return basedef_ ? basedef_->actionSpeed() : 200;
+ }
+
inline unsigned short figurine()
{
Index: spawnregions.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/spawnregions.cpp,v
retrieving revision 1.76
retrieving revision 1.77
diff -C2 -d -r1.76 -r1.77
*** spawnregions.cpp 5 Oct 2004 18:20:53 -0000 1.76
--- spawnregions.cpp 10 Oct 2004 17:51:24 -0000 1.77
***************
*** 686,694 ****
{
if (active_) {
! while ( npcs() < maxNpcAmt_ )
spawnSingleNPC();
! while ( items() < maxItemAmt_ )
spawnSingleItem();
this->nextTime_ = Server::instance()->time() + RandomNum( this->minTime_, this->maxTime_ ) * MY_CLOCKS_PER_SEC;
--- 686,707 ----
{
if (active_) {
! unsigned int failed = 0;
!
! while ( npcs() < maxNpcAmt_ && failed < 50) {
! unsigned int oldamount = npcs();
spawnSingleNPC();
+ if (npcs() == oldamount) {
+ failed++;
+ }
+ }
! failed = 0;
! while ( items() < maxItemAmt_ ) {
! unsigned int oldamount = items();
spawnSingleItem();
+ if (npcs() == oldamount) {
+ failed++;
+ }
+ }
this->nextTime_ = Server::instance()->time() + RandomNum( this->minTime_, this->maxTime_ ) * MY_CLOCKS_PER_SEC;
***************
*** 735,739 ****
int respawned = 0;
iterator it( this->begin() );
! while ( it != this->end() && respawned < 50 )
{
if ( it->second->active() && it->second->nextTime() <= Server::instance()->time() ) {
--- 748,752 ----
int respawned = 0;
iterator it( this->begin() );
! while ( it != this->end() && respawned < 10 )
{
if ( it->second->active() && it->second->nextTime() <= Server::instance()->time() ) {
Index: npc.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/npc.cpp,v
retrieving revision 1.120
retrieving revision 1.121
diff -C2 -d -r1.120 -r1.121
*** npc.cpp 9 Oct 2004 14:28:59 -0000 1.120
--- npc.cpp 10 Oct 2004 17:51:24 -0000 1.121
***************
*** 69,73 ****
ai_ = new Monster_Aggressive_L1( this );
aiCheckInterval_ = ( Q_UINT16 ) floor( Config::instance()->checkAITime() * MY_CLOCKS_PER_SEC );
! aiCheckTime_ = Server::instance()->time() + aiCheckInterval_;
}
--- 69,73 ----
ai_ = new Monster_Aggressive_L1( this );
aiCheckInterval_ = ( Q_UINT16 ) floor( Config::instance()->checkAITime() * MY_CLOCKS_PER_SEC );
! aiCheckTime_ = Server::instance()->time() + aiCheckInterval_ + RandomNum(0, 1000);
}
***************
*** 252,286 ****
}
! void cNPC::setNextMoveTime()
{
unsigned int interval;
! if ( isTamed() )
! {
! interval = ( unsigned int ) Config::instance()->tamedNpcMoveTime() * MY_CLOCKS_PER_SEC;
! }
! else
! {
! interval = ( unsigned int ) Config::instance()->npcMoveTime() * MY_CLOCKS_PER_SEC;
}
// Wander slowly if wandering freely.
! if ( wanderType() == enFreely || wanderType() == enCircle || wanderType() == enRectangle || wanderType() == enWanderSpawnregion )
! {
! interval *= 3;
! interval += RandomNum(1000, 5000);
}
! // If we are moving to a targert, run!
! if (ai_ && ai_->currentAction()) {
! Human_Guard_MoveToTarget *moveToTargetG = dynamic_cast<Human_Guard_MoveToTarget*>(ai_->currentAction());
! Monster_Aggr_MoveToTarget *moveToTargetM = dynamic_cast<Monster_Aggr_MoveToTarget*>(ai_->currentAction());
! if (moveToTargetG || moveToTargetM) {
! interval = 250;
}
}
! setNextMoveTime( Server::instance()->time() + interval );
}
--- 252,320 ----
}
! void cNPC::setNextMoveTime(bool changedDirection)
{
unsigned int interval;
+ bool passive = true;
+ bool controlled = summoned() || (owner() != 0);
! if (ai_ && ai_->currentAction()) {
! passive = ai_->currentAction()->isPassive();
}
// Wander slowly if wandering freely.
! if ( passive ) {
! interval = wanderSpeed();
! } else {
! interval = actionSpeed();
}
! // Transform certain standard intervals.
! switch (interval) {
! case 200:
! interval = 300;
! break;
! case 250:
! interval = 450;
! break;
! case 300:
! interval = 600;
! break;
! case 400:
! interval = 900;
! break;
! case 500:
! interval = 1050;
! break;
! case 800:
! interval = 1500;
! break;
! default:
! break;
! };
! // Wandering creatures are even slower than usual
! if (passive) {
! interval += 200;
! }
!
! // This creature is not player or monster controlled. Thus slower.
! if (isTamed()) {
! // Creatures following their owner are a lot faster than usual
! if (wanderFollowTarget() == owner() && ai_ && dynamic_cast<Action_Wander*>(ai_->currentAction()) != 0) {
! interval >>= 1; // Half the time
}
+
+ interval -= 75; // A little faster
+ } else if (!summoned()) {
+ interval += 100; // The creature is not summoned nor tamed, make it a little slower
}
! // Creatures become slower if hurt
! if (hitpoints() < maxHitpoints()) {
! float ratio = 1.0f - QMAX(0.0f, QMIN(1.0f, (float)hitpoints() / (float)maxHitpoints())); // Range from 0.0 to 1.0
! interval += (unsigned int)(ratio * 800);
! }
!
! setNextMoveTime(Server::instance()->time() + interval);
}
|