Update of /cvsroot/wpdev/wolfpack
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1196
Modified Files:
basechar.cpp basechar.h defines.h npc.cpp npc.h player.cpp
player.h territories.cpp timers.cpp walking.cpp
Log Message:
overweight
Index: player.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/player.h,v
retrieving revision 1.57
retrieving revision 1.58
diff -C2 -d -r1.57 -r1.58
*** player.h 19 Aug 2004 01:55:56 -0000 1.57
--- player.h 29 Aug 2004 20:40:50 -0000 1.58
***************
*** 97,100 ****
--- 97,102 ----
void awardFame( short amount );
void awardKarma( P_CHAR pKilled, short amount );
+ bool isOverloaded();
+ unsigned int maxWeight();
// other public methods
***************
*** 115,118 ****
--- 117,121 ----
void createTooltip( cUOTxTooltipList& tooltip, cPlayer* player );
unsigned char controlslots() const;
+ unsigned int damage( eDamageType type, unsigned int amount, cUObject* source = 0 );
// Wrapper events
Index: defines.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/defines.h,v
retrieving revision 1.57
retrieving revision 1.58
diff -C2 -d -r1.57 -r1.58
*** defines.h 10 Aug 2004 03:15:56 -0000 1.57
--- defines.h 29 Aug 2004 20:40:50 -0000 1.58
***************
*** 127,132 ****
};
- #define WEIGHT_PER_STR 4
-
#define DEFAULTWEBPAGE "http://www.wpdev.org/"
--- 127,130 ----
Index: territories.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/territories.cpp,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -d -r1.53 -r1.54
*** territories.cpp 25 Aug 2004 17:01:23 -0000 1.53
--- territories.cpp 29 Aug 2004 20:40:50 -0000 1.54
***************
*** 389,393 ****
PyObject* args = Py_BuildValue( "(NNN)", PyGetCharObject( pc ), PyGetRegionObject( lastRegion ), PyGetRegionObject( currRegion ) );
! if ( !cPythonScript::callChainedEventHandler( EVENT_CHANGEREGION, pc->getScripts(), args ) && socket )
{
if ( lastRegion && !lastRegion->name().isEmpty() && !lastRegion->isNoEnterMessage() )
--- 389,393 ----
PyObject* args = Py_BuildValue( "(NNN)", PyGetCharObject( pc ), PyGetRegionObject( lastRegion ), PyGetRegionObject( currRegion ) );
! if ( !pc->callEventHandler( EVENT_CHANGEREGION, args ) && socket )
{
if ( lastRegion && !lastRegion->name().isEmpty() && !lastRegion->isNoEnterMessage() )
Index: basechar.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/basechar.cpp,v
retrieving revision 1.136
retrieving revision 1.137
diff -C2 -d -r1.136 -r1.137
*** basechar.cpp 27 Aug 2004 14:41:15 -0000 1.136
--- basechar.cpp 29 Aug 2004 20:40:50 -0000 1.137
***************
*** 60,63 ****
--- 60,64 ----
fights_.setAutoDelete( false );
basedef_ = 0;
+ stepsTaken_ = 0;
lastMovement_ = 0;
attackTarget_ = 0;
***************
*** 1965,1968 ****
--- 1966,1977 ----
PyObject* cBaseChar::getProperty( const QString& name )
{
+ // \rproperty char.overloaded This boolean property indicates whether the character is overloaded or not.
+ PY_PROPERTY( "overloaded", isOverloaded() )
+ // \rproperty char.maxweight The maximum weight this character can carry with his current strength.
+ PY_PROPERTY( "maxweight", maxWeight() )
+ /* \rproperty char.stepstaken The number of steps this character walked since the server started.
+ This value is not saved between server downs.
+ */
+ PY_PROPERTY( "stepstaken", stepsTaken() )
PY_PROPERTY( "orgname", orgName_ )
PY_PROPERTY( "direction", direction_ )
***************
*** 2248,2252 ****
// to modify the damage if needed
//
! if ( scriptChain )
{
PyObject* args = 0;
--- 2257,2261 ----
// to modify the damage if needed
//
! if ( canHandleEvent(EVENT_DAMAGE) )
{
PyObject* args = 0;
***************
*** 2258,2262 ****
args = Py_BuildValue( "O&iiO", PyGetCharObject, this, ( unsigned int ) type, amount, Py_None );
! PyObject* result = cPythonScript::callChainedEvent( EVENT_DAMAGE, scriptChain, args );
if ( result )
--- 2267,2271 ----
args = Py_BuildValue( "O&iiO", PyGetCharObject, this, ( unsigned int ) type, amount, Py_None );
! PyObject* result = callEvent(EVENT_DAMAGE, args);
if ( result )
Index: npc.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/npc.h,v
retrieving revision 1.58
retrieving revision 1.59
diff -C2 -d -r1.58 -r1.59
*** npc.h 19 Aug 2004 01:55:56 -0000 1.58
--- npc.h 29 Aug 2004 20:40:50 -0000 1.59
***************
*** 94,98 ****
void postload( unsigned int version );
void load( cBufferedReader& reader );
!
virtual enCharTypes objectType();
virtual void update( bool excludeself = false );
--- 94,100 ----
void postload( unsigned int version );
void load( cBufferedReader& reader );
!
! bool isOverloaded();
! unsigned int maxWeight();
virtual enCharTypes objectType();
virtual void update( bool excludeself = false );
***************
*** 121,124 ****
--- 123,127 ----
virtual bool isInnocent();
void createTooltip( cUOTxTooltipList& tooltip, cPlayer* player );
+ unsigned int damage( eDamageType type, unsigned int amount, cUObject* source = 0 );
// other public methods
Index: player.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/player.cpp,v
retrieving revision 1.122
retrieving revision 1.123
diff -C2 -d -r1.122 -r1.123
*** player.cpp 22 Aug 2004 15:12:34 -0000 1.122
--- player.cpp 29 Aug 2004 20:40:50 -0000 1.123
***************
*** 1769,1770 ****
--- 1769,1800 ----
cBaseChar::remove();
}
+
+ unsigned int cPlayer::damage( eDamageType type, unsigned int amount, cUObject* source ) {
+ amount = cBaseChar::damage(type, amount, source);
+
+ if (amount != 0) {
+ // the more stamina we have, the more we loose
+ // the more hitpoints we have, the less we loose
+ int value = (int)(amount * (100.0 / hitpoints_) * (stamina_ / 100.0)) - 5;
+ if (value > 0) {
+ stamina_ = QMAX(0, stamina_ - value);
+ if (socket_) {
+ socket_->updateStamina();
+ }
+ }
+ }
+
+ return amount;
+ }
+
+ bool cPlayer::isOverloaded() {
+ if (isDead() || isGMorCounselor()) {
+ return false;
+ }
+
+ return weight_ > maxWeight();
+ }
+
+ unsigned int cPlayer::maxWeight() {
+ return 40 + strength_ * 3.5;
+ }
Index: timers.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/timers.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** timers.cpp 25 Aug 2004 18:46:15 -0000 1.13
--- timers.cpp 29 Aug 2004 20:40:50 -0000 1.14
***************
*** 317,321 ****
void cTimers::dispel( P_CHAR pc_dest, P_CHAR pSource, bool silent )
{
! if ( cPythonScript::canChainHandleEvent( EVENT_DISPEL, pc_dest->getScripts() ) )
{
PyObject* source;
--- 317,321 ----
void cTimers::dispel( P_CHAR pc_dest, P_CHAR pSource, bool silent )
{
! if ( pc_dest->canHandleEvent( EVENT_DISPEL ) )
{
PyObject* source;
***************
*** 331,335 ****
PyObject* args = Py_BuildValue( "(NNBBsN", pc_dest->getPyObject(), source, silent ? 1 : 0, 0, "", PyTuple_New( 0 ) );
! bool result = cPythonScript::callChainedEventHandler( EVENT_DISPEL, pc_dest->getScripts(), args );
Py_DECREF( args );
--- 331,335 ----
PyObject* args = Py_BuildValue( "(NNBBsN", pc_dest->getPyObject(), source, silent ? 1 : 0, 0, "", PyTuple_New( 0 ) );
! bool result = pc_dest->callEventHandler( EVENT_DISPEL, args );
Py_DECREF( args );
Index: basechar.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/basechar.h,v
retrieving revision 1.81
retrieving revision 1.82
diff -C2 -d -r1.81 -r1.82
*** basechar.h 27 Aug 2004 14:41:15 -0000 1.81
--- basechar.h 29 Aug 2004 20:40:50 -0000 1.82
***************
*** 238,241 ****
--- 238,243 ----
virtual bool inWorld() = 0;
+ virtual unsigned int maxWeight() = 0;
+ virtual bool isOverloaded() = 0;
virtual void showName( cUOSocket* socket ) = 0;
virtual void soundEffect( UI16 soundId, bool hearAll = true ) = 0;
***************
*** 244,248 ****
virtual void log( eLogLevel, const QString& string ) = 0;
virtual void log( const QString& string ) = 0;
! unsigned int damage( eDamageType type, unsigned int amount, cUObject* source = 0 );
// other public methods
--- 246,250 ----
virtual void log( eLogLevel, const QString& string ) = 0;
virtual void log( const QString& string ) = 0;
! virtual unsigned int damage( eDamageType type, unsigned int amount, cUObject* source = 0 );
// other public methods
***************
*** 416,419 ****
--- 418,422 ----
bool isInvulnerable() const;
unsigned char direction() const;
+ unsigned int stepsTaken() const;
// advanced getters for data structures
***************
*** 463,466 ****
--- 466,470 ----
void setLastMovement( unsigned int data );
void setPoison( signed char data );
+ void setStepsTaken(unsigned int value);
void setPropertyFlags( uint data );
void setRegenHitpointsTime( uint data );
***************
*** 770,773 ****
--- 774,780 ----
QDateTime creationDate_;
+ // Number of steps taken since login.
+ unsigned int stepsTaken_;
+
// Saves the number of steps that were stealthed. value -1 indicates that
// the char will be revealed
***************
*** 896,899 ****
--- 903,915 ----
}
+ inline unsigned int cBaseChar::stepsTaken() const
+ {
+ return stepsTaken_;
+ }
+
+ inline void cBaseChar::setStepsTaken(unsigned int value) {
+ stepsTaken_ = value;
+ }
+
inline uint cBaseChar::criminalTime() const
{
Index: walking.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/walking.cpp,v
retrieving revision 1.140
retrieving revision 1.141
diff -C2 -d -r1.140 -r1.141
*** walking.cpp 28 Aug 2004 20:59:35 -0000 1.140
--- walking.cpp 29 Aug 2004 20:40:50 -0000 1.141
***************
*** 521,524 ****
--- 521,525 ----
// We moved so let's update our location
pChar->moveTo( newCoord );
+ pChar->setStepsTaken( pChar->stepsTaken() + 1 );
pChar->setLastMovement( Server::instance()->time() );
checkStealth( pChar ); // Reveals the user if neccesary
***************
*** 722,759 ****
passed character.
*/
! bool cMovement::consumeStamina( P_PLAYER pChar, bool running )
! {
! // TODO: Stamina loss is disabled for now -- Weight system needs to be rediscussed
! // return true;
! // Weight percent
! float allowedWeight = ( pChar->strength() * WEIGHT_PER_STR ) + 30;
! float load = ceilf( ( pChar->weight() / allowedWeight ) * 100 ) / 100;
! if ( running )
! load = ceilf( load * 200 ) / 100;
! // 200% load is too much
! if ( load >= 200 )
! {
! pChar->socket()->sysMessage( tr( "You are too overloaded to move." ) );
! return false;
! }
! // 20% overweight = ( 0.20 * 0.10 ) * (Weight carrying) = Stamina needed to move
! float overweight = load - 100;
! // We're not overloaded so we dont need additional stamina
! if ( overweight < 0 )
! return true;
! float requiredStamina = ceilf( ( float ) ( ( double ) ( ( double ) overweight * 0.10f ) * ( double ) pChar->weight() ) * 100 ) / 100;
! if ( pChar->stamina() < requiredStamina )
! {
! pChar->sysmessage( tr( "You are too exhausted to move" ) );
return false;
}
return true;
}
--- 723,788 ----
passed character.
*/
! bool cMovement::consumeStamina( P_PLAYER pChar, bool running ) {
! // Dead people and gms don't care about weight
! if (pChar->isDead() || pChar->isGMorCounselor()) {
! return true;
! }
! // Calculate the stones we weight too much
! int overWeight = pChar->weight() - pChar->maxWeight();
! bool mounted = pChar->atLayer(cBaseChar::Mount) != 0;
! bool update = false;
! // We carry too much
! if (overWeight > 0) {
! // How much stamina we loose
! int amount = 5 + (overWeight / 25);
! // Only one third loss if mounted
! if (mounted) {
! amount = amount / 3;
! }
! // Double loss if running
! if (running) {
! amount = amount * 2;
! }
! // Set the new stamina
! pChar->setStamina(QMAX(0, pChar->stamina() - amount), false);
! update = true;
! // We are overloaded
! if (pChar->stamina() == 0) {
! pChar->socket()->updateStamina();
! pChar->socket()->clilocMessage(500109);
! return false;
! }
! }
! // If we have less than 10% stamina left, we loose
! // stamina more quickly
! if ( (pChar->stamina() * 100) / QMAX(1, pChar->maxStamina()) < 10 ) {
! pChar->setStamina(QMAX(0, pChar->stamina() - 1), false);
! update = true;
! }
!
! // We can't move anymore because we are exhausted
! if ( pChar->stamina() == 0 ) {
! pChar->socket()->updateStamina();
! pChar->socket()->clilocMessage( 500110 );
return false;
}
+ // Normally reduce stamina every few steps
+ if ( pChar->stepsTaken() % ( mounted ? 48 : 16 ) == 0 ) {
+ pChar->setStamina( QMAX( 0, pChar->stamina() - 1 ) );
+ update = true;
+ }
+
+ if (update) {
+ pChar->socket()->updateStamina();
+ }
+
return true;
}
Index: npc.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/npc.cpp,v
retrieving revision 1.109
retrieving revision 1.110
diff -C2 -d -r1.109 -r1.110
*** npc.cpp 22 Aug 2004 02:29:50 -0000 1.109
--- npc.cpp 29 Aug 2004 20:40:50 -0000 1.110
***************
*** 1430,1431 ****
--- 1430,1454 ----
cBaseChar::remove();
}
+
+ unsigned int cNPC::damage( eDamageType type, unsigned int amount, cUObject* source ) {
+ amount = cBaseChar::damage(type, amount, source);
+
+ if (amount != 0) {
+ // the more stamina we have, the more we loose
+ // the more hitpoints we have, the less we loose
+ int value = (int)(amount * (100.0 / hitpoints_) * (stamina_ / 100.0)) - 5;
+ if (value > 0) {
+ stamina_ = QMAX(0, stamina_ - value);
+ }
+ }
+
+ return amount;
+ }
+
+ bool cNPC::isOverloaded() {
+ return false;
+ }
+
+ unsigned int cNPC::maxWeight() {
+ return 0;
+ }
|