Update of /cvsroot/wpdev/wolfpack
In directory sc8-pr-cvs1:/tmp/cvs-serv21016
Modified Files:
ai.cpp basechar.cpp basechar.h combat.cpp coord.cpp coord.h
dbl_single_click.cpp dragdrop.cpp npc.cpp npc.h player.cpp
player.h prototypes.h targetrequests.cpp wolf.dsp wolfpack.cpp
wolfpack.pro
Removed Files:
LoS.cpp
Log Message:
Removed LOS.Cpp (moved to coord.cpp)
and some legacy functions from wolfpack.cpp
Index: ai.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/ai.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** ai.cpp 20 Aug 2003 17:10:48 -0000 1.15
--- ai.cpp 3 Sep 2003 14:44:21 -0000 1.16
***************
*** 421,425 ****
UINT16 rndy = RandomNum( m_npc->wanderY1(), m_npc->wanderY2() );
! UINT8 dir = chardirxyz( m_npc, rndx, rndy );
m_npc->setDirection( dir );
Movement::instance()->Walking( m_npc, dir, 0xFF );
--- 421,425 ----
UINT16 rndy = RandomNum( m_npc->wanderY1(), m_npc->wanderY2() );
! UINT8 dir = m_npc->pos().direction( Coord_cl( rndx, rndy ) );
m_npc->setDirection( dir );
Movement::instance()->Walking( m_npc, dir, 0xFF );
***************
*** 439,443 ****
pos.y = pos.y + (INT16)floor( sin( rndphi ) * rnddist );
! UINT8 dir = chardirxyz( m_npc, pos.x, pos.y );
m_npc->setDirection( dir );
Movement::instance()->Walking( m_npc, dir, 0xFF );
--- 439,443 ----
pos.y = pos.y + (INT16)floor( sin( rndphi ) * rnddist );
! UINT8 dir = m_npc->pos().direction( pos );
m_npc->setDirection( dir );
Movement::instance()->Walking( m_npc, dir, 0xFF );
***************
*** 477,481 ****
{
// simply move towards the target
! UINT8 dir = chardirxyz( m_npc, pos.x, pos.y );
Coord_cl newPos = Movement::instance()->calcCoordFromDir( dir, m_npc->pos() );
if( !mayWalk( m_npc, newPos ) )
--- 477,481 ----
{
// simply move towards the target
! UINT8 dir = m_npc->pos().direction( pos );
Coord_cl newPos = Movement::instance()->calcCoordFromDir( dir, m_npc->pos() );
if( !mayWalk( m_npc, newPos ) )
***************
*** 530,534 ****
waitForPathCalculation = 0;
Coord_cl nextmove = m_npc->nextMove();
! UINT8 dir = chardirxyz( m_npc, nextmove.x, nextmove.y );
m_npc->setDirection( dir );
Movement::instance()->Walking( m_npc, dir, 0xFF );
--- 530,534 ----
waitForPathCalculation = 0;
Coord_cl nextmove = m_npc->nextMove();
! UINT8 dir = m_npc->pos().direction( nextmove );
m_npc->setDirection( dir );
Movement::instance()->Walking( m_npc, dir, 0xFF );
Index: basechar.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/basechar.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** basechar.cpp 27 Aug 2003 21:11:41 -0000 1.38
--- basechar.cpp 3 Sep 2003 14:44:21 -0000 1.39
***************
*** 545,549 ****
changed( TOOLTIP );
changed_ = true;
! Fame( this, 0 );
soundEffect( 0x0214 );
setBodyID( orgBodyID_ );
--- 545,549 ----
changed( TOOLTIP );
changed_ = true;
! awardFame( 0 );
soundEffect( 0x0214 );
setBodyID( orgBodyID_ );
Index: basechar.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/basechar.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** basechar.h 28 Aug 2003 04:05:42 -0000 1.28
--- basechar.h 3 Sep 2003 14:44:21 -0000 1.29
***************
*** 146,149 ****
--- 146,151 ----
virtual void callGuards();
virtual void flagUnchanged();
+ virtual void awardFame( short amount ) = 0;
+ virtual void awardKarma( P_CHAR pKilled, short amount ) = 0;
// Wrapper events
Index: combat.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/combat.cpp,v
retrieving revision 1.145
retrieving revision 1.146
diff -C2 -d -r1.145 -r1.146
*** combat.cpp 2 Sep 2003 02:06:34 -0000 1.145
--- combat.cpp 3 Sep 2003 14:44:21 -0000 1.146
***************
*** 307,311 ****
// Can we see our target.
// I don't know what the +z 13 means...
! bool los = lineOfSight( pAttacker->pos() + Coord_cl( 0, 0, 13 ), pDefender->pos(), WALLS_CHIMNEYS+DOORS+FLOORS_FLAT_ROOFING );
hit( pAttacker, pDefender, los );
--- 307,311 ----
// Can we see our target.
// I don't know what the +z 13 means...
! bool los = pAttacker->pos().lineOfSight( pDefender->pos(), true );
hit( pAttacker, pDefender, los );
***************
*** 939,943 ****
{
// Only shot if our "head" can see the opponent
! if( !lineOfSight( pAttacker->pos() + Coord_cl( 0, 0, 13 ), pDefender->pos(), WALLS_CHIMNEYS+DOORS+FLOORS_FLAT_ROOFING ) )
mayAttack = false;
}
--- 939,943 ----
{
// Only shot if our "head" can see the opponent
! if( !pAttacker->pos().lineOfSight( pDefender->pos() ) )
mayAttack = false;
}
Index: coord.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/coord.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** coord.cpp 29 Jun 2003 22:52:01 -0000 1.25
--- coord.cpp 3 Sep 2003 14:44:21 -0000 1.26
***************
*** 37,40 ****
--- 37,46 ----
#include "player.h"
#include "network.h"
+ #include "sectors.h"
+ #include "items.h"
+ #include "multiscache.h"
+ #include "maps.h"
+ #include "globals.h"
+ #include "tilecache.h"
#include "network/uotxpackets.h"
#include "network/uosocket.h"
***************
*** 42,48 ****
// System Includes
#include <math.h>
!
! #undef DBGFILE
! #define DBGFILE "coord.cpp"
Coord_cl::Coord_cl(void)
--- 48,52 ----
// System Includes
#include <math.h>
! #include <set>
Coord_cl::Coord_cl(void)
***************
*** 74,78 ****
* @return UI32 : distance result
*/
! UI32 Coord_cl::distance( const Coord_cl &src) const
{
UI32 uiResult = ~0U; // Initialize with *infinite*
--- 78,82 ----
* @return UI32 : distance result
*/
! unsigned int Coord_cl::distance( const Coord_cl &src ) const
{
UI32 uiResult = ~0U; // Initialize with *infinite*
***************
*** 156,158 ****
--- 160,410 ----
mSock->send( &effect );
}
+ }
+
+ // Calculates the direction from one location to another
+ unsigned char Coord_cl::direction( const Coord_cl &dest ) const
+ {
+ unsigned char dir;
+ short xdif, ydif;
+
+ xdif = dest.x - x;
+ ydif = dest.y - y;
+
+ if ((xdif==0)&&(ydif<0)) dir=0;
+ else if ((xdif>0)&&(ydif<0)) dir=1;
+ else if ((xdif>0)&&(ydif==0)) dir=2;
+ else if ((xdif>0)&&(ydif>0)) dir=3;
+ else if ((xdif==0)&&(ydif>0)) dir=4;
+ else if ((xdif<0)&&(ydif>0)) dir=5;
+ else if ((xdif<0)&&(ydif==0)) dir=6;
+ else if ((xdif<0)&&(ydif<0)) dir=7;
+ else dir=-1;
+
+ return dir;
+ }
+
+ // This didn't change much yet
+ // I just copied over the old code
+ bool Coord_cl::lineOfSight( const Coord_cl &target, bool touch )
+ {
+ if( target.map != map )
+ return false;
+
+ if( (x == target.x) && (y == target.y) && (z == target.z) )
+ return true; // if source and target are on the same position
+
+ SI32 n = ( target.x - x ), m = ( target.y - y ), i = 0;
+ SI08 sgn_x = ( x <= target.x ) ? 1 : (-1); // signum for x
+ SI08 sgn_y = ( y <= target.y ) ? 1 : (-1); // signum for y
+ SI08 sgn_z = ( z <= target.z ) ? 1 : (-1); // signum for z
+ if( x == target.x )
+ sgn_x = 0;
+ if( y == target.y )
+ sgn_y = 0;
+ if( z == target.z )
+ sgn_z = 0;
+
+ UI32 distance = this->distance( target );
+
+ if( distance > 18 )
+ return false;
+
+ QValueList< Coord_cl > collisions;
+
+ double dz_x = ( sgn_x == 0 ) ? ( (double)target.z - (double)z ) : ( ( (double)target.z - (double)z ) / ( (double)target.x - (double)x ) );
+ double dz_y = ( sgn_y == 0 ) ? ( (double)target.z - (double)z ) : ( ( (double)target.z - (double)z ) / ( (double)target.y - (double)y ) );
+ SI32 dz = 0; // dz is needed later for collisions of the ray with floor tiles
+ if( sgn_x == 0 || m > n )
+ dz = (SI32)floor( dz_y );
+ else
+ dz = (SI32)floor( dz_x );
+
+
+ if( sgn_x == 0 && sgn_y == 0 && !sgn_z == 0 ) // should fix shooting through floor issues
+ for( i = 0; i < abs( target.z - z ); ++i )
+ {
+ collisions.push_back( Coord_cl( x, y, z + sgn_z, map ) );
+ }
+ else if( sgn_x == 0 ) // if we are on the same x-level, just push every x/y coordinate in y-direction from src to trg into the array
+ for( i = 0; i < (sgn_y * m); ++i )
+ {
+ collisions.push_back( Coord_cl( x, y + (sgn_y * i), z + (SI08)floor( dz_y * (double)i ), map ) );
+ }
+ else if ( sgn_y == 0 ) // if we are on the same y-level, just push every x/y coordinate in x-direction from src to trg into the array
+ for( i = 0; i < (sgn_x * n); ++i )
+ {
+ collisions.push_back( Coord_cl( x + (sgn_x * i), y, z + (SI08)floor( dz_x * (double)i ), map ) );
+ }
+ else
+ {
+ for( i = 0; (sgn_x * n >= sgn_y * m) && (i < (sgn_x * n)); i++ )
+ {
+ SI32 gridx = x + (sgn_x * i);
+ if( ( ( n == 0 ) && ( gridx == 0 ) ) ||
+ ( ( n + ( gridx * m ) == 0 ) ) )
+ continue;
+ else
+ {
+ // linear evaluation of extended 2x2 matrix, abbreviated
+ double t = (double)sgn_x * (double)i * (double)m / (double)n + (double)y;
+
+ // the next one is somewhat tricky, if the line of sight exactly cuts a coordinate,
+ // we just have to take that coordinate...
+ if( floor( t ) == t )
+ {
+ collisions.push_back( Coord_cl( gridx, floor( t ), z + (SI08)floor( dz_x * (double)i ), map ) );
+ }
+ // but if not, we have to take BOTH coordinates, which the calculated collision is between!
+ else
+ {
+ collisions.push_back( Coord_cl( gridx, floor( t ), z + (SI08)floor( dz_x * (double)i ), map ) );
+ collisions.push_back( Coord_cl( gridx, ceil( t ), z + (SI08)floor( dz_x * (double)i ), map ) );
+ }
+ }
+ }
+
+ for( i = 0; (sgn_y * m > sgn_x * n) && (i < (sgn_y * m)); ++i )
+ {
+ SI32 gridy = y + (sgn_y * i);
+ if( ( ( m == 0 ) && ( gridy == 0 ) ) ||
+ ( ( m + ( gridy * n ) == 0 ) ) )
+ continue;
+ else
+ {
+ double t = (double)x + (double)n / (double)m * (double)sgn_y * (double)i;
+
+ // the next one is somewhat tricky, if the line of sight exactly cuts a coordinate,
+ // we just have to take that coordinate...
+ if( floor( t ) == t )
+ {
+ collisions.push_back( Coord_cl( floor( t ), gridy, z + (SI08)floor( dz_y * (double)i ), map ) );
+ }
+ // but if not, we have to take BOTH coordinates, which the calculated collision is between!
+ else
+ {
+ collisions.push_back( Coord_cl( floor( t ), gridy, z + (SI08)floor( dz_y * (double)i ), map ) );
+ collisions.push_back( Coord_cl( ceil( t ), gridy, z + (SI08)floor( dz_y * (double)i ), map ) );
+ }
+ }
+ }
+ }
+
+ // the next will search for multis
+ QPtrList< cItem > multis;
+ RegionIterator4Items ri( *this );
+ for( ri.Begin(); !ri.atEnd(); ri++ )
+ {
+ P_ITEM pi = ri.GetData();
+ if( pi && pi->id() >= 0x4000 )
+ {
+ multis.append( pi );
+ }
+ }
+
+ map_st map1, map2;
+ std::set< unsigned short > itemids;
+ SI32 j;
+
+ QValueList< Coord_cl >::iterator pit = collisions.begin();
+ while( pit != collisions.end() )
+ {
+ // Texture mapping
+ map1 = Map->seekMap( *pit );
+ map2 = Map->seekMap( Coord_cl( (*pit).x + sgn_x, (*pit).y + sgn_y, (*pit).z, map ) );
+
+ StaticsIterator msi = Map->staticsIterator( *pit );
+ if( (map1.id != 2) && (map2.id != 2) )
+ {
+ // Mountain walls
+ if( ( ( map1.z < map2.z ) && // 1) lineofsight collides with a map "wall"
+ ( (*pit).z < ( map2.z ) ) &&
+ ( (*pit).z >= ( map1.z ) ) ) ||
+ ( ( map1.z > map2.z ) &&
+ ( (*pit).z < ( map1.z ) ) &&
+ ( (*pit).z >= ( map2.z ) ) ) ||
+ // ( ( (*pit).z == map1.z ) && // 2) lineofsight cuts a map "floor"
+ // ( dz != 0 ) ) ||
+ ( ( ( map1.id >= 431 && map1.id <= 432 ) || // 3) lineofsight cuts a mountain
+ ( map1.id >= 467 && map1.id <= 475 ) ||
+ ( map1.id >= 543 && map1.id <= 560 ) ||
+ ( map1.id >= 1754 && map1.id <= 1757 ) ||
+ ( map1.id >= 1787 && map1.id <= 1789 ) ||
+ ( map1.id >= 1821 && map1.id <= 1824 ) ||
+ ( map1.id >= 1851 && map1.id <= 1854 ) ||
+ ( map1.id >= 1881 && map1.id <= 1884 ) ) &&
+ ( msi.atEnd() ) ) ) // make sure there is no static item!
+ return false;
+ }
+
+ // Statics
+ tile_st tile;
+ while( !msi.atEnd() )
+ {
+ tile = TileCache::instance()->getTile( msi->itemid );
+ if( ( (*pit).z >= msi->zoff && (*pit).z <= ( msi->zoff + tile.height ) ) )
+ // || ( tile.height <= 2 && abs( (*pit).z - msi->zoff ) <= abs( dz ) ) )
+ itemids.insert( msi->itemid );
+
+ ++msi;
+ }
+
+
+ // Items
+ RegionIterator4Items rj( (*pit), 0 );
+ for( rj.Begin(); !rj.atEnd(); rj++ )
+ {
+ P_ITEM pi = rj.GetData();
+ if( pi && pi->id() < 0x4000 )
+ {
+ tile = TileCache::instance()->getTile( pi->id() );
+ if( ( (*pit).z >= pi->pos().z ) && ( (*pit).z <= ( pi->pos().z + tile.height ) ) && ( pi->visible() == 0 ) )
+ itemids.insert( pi->id() );
+ }
+ }
+
+ // Multis
+ QPtrListIterator< cItem > mit( multis );
+ P_ITEM pi;
+ while( ( pi = mit.current() ) )
+ {
+ MultiDefinition* def = MultiCache::instance()->getMulti( pi->id() - 0x4000 );
+ if ( !def )
+ continue;
+ QValueVector<multiItem_st> multi = def->getEntries();
+ for( j = 0; j < multi.size(); ++j )
+ {
+ if( ( multi[j].visible ) && ( pi->pos().x + multi[j].x == (*pit).x ) &&
+ ( pi->pos().y + multi[j].y == (*pit).y ) )
+ {
+ tile = TileCache::instance()->getTile( multi[j].tile );
+ if( ( (*pit).z >= pi->pos().z + multi[j].z ) &&
+ ( (*pit).z <= pi->pos().z + multi[j].z + tile.height ) )
+ itemids.insert( multi[j].tile );
+ }
+ }
+ ++mit;
+ }
+ ++pit;
+ }
+
+ std::set< UI16 >::iterator sit = itemids.begin();
+ while( sit != itemids.end() )
+ {
+ /*
+ if touch, then ignore missing noshoot
+ */
+ tile_st tile = TileCache::instance()->getTile( *sit );
+
+ // No Shoot
+ if( tile.flag2 & 0x20 )
+ return false;
+
+ // Touch & Impassable
+ if( touch && tile.flag1 & 0x40 )
+ return false;
+
+ ++sit;
+ }
+
+ return true;
}
Index: coord.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/coord.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** coord.h 19 May 2003 13:51:40 -0000 1.13
--- coord.h 3 Sep 2003 14:44:21 -0000 1.14
***************
*** 50,54 ****
Coord_cl(void);
Coord_cl(const Coord_cl& clCoord);
! Coord_cl(UI16, UI16, SI08, UI08 uiMap = 0, UI08 uiPlane = 0);
// Operators
Coord_cl& operator= (const Coord_cl& clCoord);
--- 50,54 ----
Coord_cl(void);
Coord_cl(const Coord_cl& clCoord);
! Coord_cl(UI16, UI16, SI08 = 0, UI08 uiMap = 0, UI08 uiPlane = 0);
// Operators
Coord_cl& operator= (const Coord_cl& clCoord);
***************
*** 57,61 ****
Coord_cl operator+(const Coord_cl& src) const;
Coord_cl operator-(const Coord_cl& src) const;
! UI32 distance( const Coord_cl &src) const;
static UI32 distance ( const Coord_cl &a, const Coord_cl &b );
--- 57,63 ----
Coord_cl operator+(const Coord_cl& src) const;
Coord_cl operator-(const Coord_cl& src) const;
! unsigned int distance( const Coord_cl &src) const;
! unsigned char direction( const Coord_cl &dest ) const;
! bool lineOfSight( const Coord_cl &target, bool touch = false );
static UI32 distance ( const Coord_cl &a, const Coord_cl &b );
Index: dbl_single_click.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/dbl_single_click.cpp,v
retrieving revision 1.218
retrieving revision 1.219
diff -C2 -d -r1.218 -r1.219
*** dbl_single_click.cpp 2 Sep 2003 02:23:51 -0000 1.218
--- dbl_single_click.cpp 3 Sep 2003 14:44:21 -0000 1.219
***************
*** 199,203 ****
}
! else if( !lineOfSight( pc_currchar->pos(), pi->pos(), WALLS_CHIMNEYS|DOORS|FLOORS_FLAT_ROOFING ) )
{
socket->clilocMessage( 0x7A258, "", 0x3b2 ); // You cannot reach that
--- 199,203 ----
}
! else if( !pc_currchar->pos().lineOfSight( pi->pos(), true ) )
{
socket->clilocMessage( 0x7A258, "", 0x3b2 ); // You cannot reach that
Index: dragdrop.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/dragdrop.cpp,v
retrieving revision 1.195
retrieving revision 1.196
diff -C2 -d -r1.195 -r1.196
*** dragdrop.cpp 28 Aug 2003 20:56:16 -0000 1.195
--- dragdrop.cpp 3 Sep 2003 14:44:21 -0000 1.196
***************
*** 516,522 ****
return;
}
!
// Are we in range of our target
! if( !inrange1p( pChar, pOtherChar ) )
{
socket->bounceItem( pItem, BR_OUT_OF_REACH );
--- 516,522 ----
return;
}
!
// Are we in range of our target
! if( !pChar->inRange( pOtherChar, 3 ) )
{
socket->bounceItem( pItem, BR_OUT_OF_REACH );
***************
*** 525,529 ****
// Can wee see our target
! if( !lineOfSight( pChar->pos(), pOtherChar->pos(), TREES_BUSHES|WALLS_CHIMNEYS|DOORS|ROOFING_SLANTED|FLOORS_FLAT_ROOFING|LAVA_WATER ) )
{
socket->bounceItem( pItem, BR_OUT_OF_SIGHT );
--- 525,529 ----
// Can wee see our target
! if( !pChar->pos().lineOfSight( pOtherChar->pos() ) )
{
socket->bounceItem( pItem, BR_OUT_OF_SIGHT );
***************
*** 592,596 ****
// Check if the destination is in line of sight
! if( !lineOfSight( pChar->pos(), pos, WALLS_CHIMNEYS|DOORS|LAVA_WATER ) )
{
socket->bounceItem( pItem, BR_OUT_OF_SIGHT );
--- 592,596 ----
// Check if the destination is in line of sight
! if( !pChar->pos().lineOfSight( pos, false ) )
{
socket->bounceItem( pItem, BR_OUT_OF_SIGHT );
Index: npc.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/npc.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** npc.cpp 30 Aug 2003 21:30:05 -0000 1.37
--- npc.cpp 3 Sep 2003 14:44:21 -0000 1.38
***************
*** 466,471 ****
if( pc_t->objectType() == enPlayer && !pc_t->inGuardedArea() )
{
! Karma( pc_t, this, ( 0 - ( karma_ ) ) );
! Fame( pc_t, fame_ );
}
--- 466,471 ----
if( pc_t->objectType() == enPlayer && !pc_t->inGuardedArea() )
{
! pc_t->awardKarma( this, ( 0 - ( karma_ ) ) );
! pc_t->awardFame( fame_ );
}
***************
*** 1490,1493 ****
--- 1490,1550 ----
}
+ void cNPC::awardKarma( P_CHAR pKilled, short amount )
+ {
+ int nCurKarma = 0, nChange = 0, nEffect = 0;
+
+ nCurKarma = karma();
+ if( nCurKarma < amount && amount > 0 )
+ {
+ nChange=((amount-nCurKarma)/75);
+ setKarma(nCurKarma+nChange);
+ nEffect=1;
+ }
+ if( ( nCurKarma > amount ) && ( !pKilled ) )
+ {
+ nChange = ( ( nCurKarma - amount ) / 50 );
+ setKarma( nCurKarma - nChange );
+ nEffect = 0;
+ }
+ else if( ( nCurKarma > amount ) && ( pKilled->karma() > 0 ) )
+ {
+ nChange= ( ( nCurKarma - amount ) / 50 );
+ setKarma( nCurKarma - nChange );
+ nEffect=0;
+ }
+
+ // Cap at 10000 or -10000
+ if( karma_ > 10000 )
+ karma_ = 10000;
+ else if( karma_ < -10000 )
+ karma_ = -10000;
+ }
+
+ void cNPC::awardFame( short amount )
+ {
+ int nCurFame, nChange=0;
+
+ setFame( QMIN( 10000, fame() ) );
+
+ nCurFame = fame();
+
+ // We already have more than that.
+ if( nCurFame > amount )
+ return;
+
+ // Loose Fame when we died
+ if( isDead() )
+ {
+ // Fame / 25 is our loss
+ nChange = nCurFame / 25;
+ setFame( QMAX( 0, nCurFame - nChange ) );
+ setDeaths( deaths() + 1 );
+ }
+ else
+ {
+ nChange = ( amount - nCurFame ) / 75;
+ setFame( nCurFame+nChange );
+ }
+ }
Index: npc.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/npc.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** npc.h 30 Aug 2003 21:30:05 -0000 1.22
--- npc.h 3 Sep 2003 14:44:21 -0000 1.23
***************
*** 102,105 ****
--- 102,107 ----
virtual void applyDefinition( const cElement* );
virtual void flagUnchanged() { cNPC::changed_ = false; cBaseChar::flagUnchanged(); }
+ void awardFame( short amount );
+ void awardKarma( P_CHAR pKilled, short amount );
// other public methods
Index: player.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/player.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** player.cpp 31 Aug 2003 20:06:42 -0000 1.33
--- player.cpp 3 Sep 2003 14:44:21 -0000 1.34
***************
*** 455,460 ****
{
P_PLAYER pp_t = dynamic_cast<P_PLAYER>(pc_t);
! Karma( pp_t, this, ( 0 - ( karma_ ) ) );
! Fame( pp_t, fame_ );
if( isInnocent() && pp_t->attackFirst() )
--- 455,460 ----
{
P_PLAYER pp_t = dynamic_cast<P_PLAYER>(pc_t);
! pp_t->awardKarma( this, ( 0 - ( karma_ ) ) );
! pp_t->awardFame( fame_ );
if( isInnocent() && pp_t->attackFirst() )
***************
*** 1638,1639 ****
--- 1638,1774 ----
}
+ void cPlayer::awardFame( short amount )
+ {
+ int nCurFame, nChange=0;
+ bool gain = false;
+
+ setFame( QMIN( 10000, fame() ) );
+
+ nCurFame = fame();
+
+ // We already have more than that.
+ if( nCurFame > amount )
+ return;
+
+ // Loose Fame when we died
+ if( isDead() )
+ {
+ // Fame / 25 is our loss
+ nChange = nCurFame / 25;
+ setFame( QMAX( 0, nCurFame - nChange ) );
+ setDeaths( deaths() + 1 );
+ gain = false;
+ }
+ else
+ {
+ nChange = ( amount - nCurFame ) / 75;
+ setFame( nCurFame+nChange );
+ gain = true;
+ }
+
+ // Nothing changed or we can't recieve the message
+ if( !nChange || !socket() )
+ return;
+
+ uint message;
+
+ if( nChange <= 25 )
+ {
+ if( gain )
+ message = 1019051; //"You have gained a little fame."
+ else
+ message = 1019055; //"You have lost a little fame."
+ }
+ else if( nChange <= 75 )
+ {
+ if( gain )
+ message = 1019052; //"You have gained some fame."
+ else
+ message = 1019056; //"You have lost some fame."
+ }
+ else if( nChange <= 100 )
+ {
+ if( gain )
+ message = 1019053; // You have gained a good amount of fame.
+ else
+ message = 1019057; // You have lost a good amount of fame.
+ }
+ else if( nChange > 100 )
+ {
+ if( gain )
+ message = 1019054; //"You have gained alot of fame."
+ else
+ message = 1019058; //"You have lost alot of fame."
+ }
+
+ socket()->clilocMessage( message );
+ }
+
+ void cPlayer::awardKarma( P_CHAR pKilled, short amount )
+ {
+ int nCurKarma = 0, nChange = 0, nEffect = 0;
+
+ nCurKarma = karma();
+
+ if( nCurKarma < amount && amount > 0 )
+ {
+ nChange=((amount-nCurKarma)/75);
+ setKarma(nCurKarma+nChange);
+ nEffect=1;
+ }
+
+ if( ( nCurKarma > amount ) && ( !pKilled ) )
+ {
+ nChange = ( ( nCurKarma - amount ) / 50 );
+ setKarma( nCurKarma - nChange );
+ nEffect = 0;
+ }
+ else if( ( nCurKarma > amount ) && ( pKilled->karma() > 0 ) )
+ {
+ nChange= ( ( nCurKarma - amount ) / 50 );
+ setKarma( nCurKarma - nChange );
+ nEffect=0;
+ }
+
+ // Cap at 10000 or -10000
+ if( karma_ > 10000 )
+ karma_ = 10000;
+ else if( karma_ < -10000 )
+ karma_ = -10000;
+
+ if( !nChange || !socket() )
+ return;
+
+ UINT32 message;
+
+ if( nChange <= 25 )
+ {
+ if( nEffect )
+ message = 0xF8CB3; // You have gained a little karma.
+ else
+ message = 0xF8CB7; // You have lost a little karma.
+ }
+ else if( nChange <= 75 )
+ {
+ if( nEffect )
+ message = 0xF8CB4; // You have gained some karma.
+ else
+ message = 0xF8CB8; // You have lost some karma.
+ }
+ else if( nChange <= 100 )
+ {
+ if( nEffect )
+ message = 0xF8CB5; // You have gained a good amount of karma.
+ else
+ message = 0xF8CB9; // You have lost a good amount of karma.
+ }
+ else if( nChange > 100 )
+ {
+ if( nEffect )
+ message = 0xF8CB6; // You have gained a lot of karma.
+ else
+ message = 0xF8CBA; // You have lost a lot of karma.
+ }
+
+ socket()->clilocMessage( message );
+ }
Index: player.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/player.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** player.h 28 Aug 2003 04:05:42 -0000 1.20
--- player.h 3 Sep 2003 14:44:21 -0000 1.21
***************
*** 80,83 ****
--- 80,85 ----
virtual UINT32 takeGold( UINT32 amount, bool useBank = false );
virtual void flagUnchanged();
+ void awardFame( short amount );
+ void awardKarma( P_CHAR pKilled, short amount );
// other public methods
Index: prototypes.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/prototypes.h,v
retrieving revision 1.105
retrieving revision 1.106
diff -C2 -d -r1.105 -r1.106
*** prototypes.h 2 Sep 2003 02:23:51 -0000 1.105
--- prototypes.h 3 Sep 2003 14:44:21 -0000 1.106
***************
*** 33,53 ****
#define __PROTOTYPES_H__
-
- // Wolfpack Includes
-
- // Forward class declarations
-
class QString;
class cUOSocket;
class Coord_cl;
- // Function Declarations
- //
-
QString hex2dec( const QString& value );
void showPaperdoll( cUOSocket *socket, P_CHAR pTarget, bool hotkey );
void savelog(const char *msg, char *logfile);
- void Karma(P_CHAR pc_toChange, P_CHAR pc_Killed, int nKarma);
- void Fame(P_CHAR pc_toChange, int nFame);
void endmessage(int x);
--- 33,43 ----
***************
*** 58,73 ****
void delequan(P_CHAR pc, short id, int amount, int *not_deleted = NULL);
void playmonstersound(P_CHAR monster, unsigned short id, int sfx);
-
- bool inVisRange(int x1, int y1, int x2, int y2);
-
int DeleBankItem( P_PLAYER pc, unsigned short itemid, unsigned short color, int amt );
- int lineOfSight( const Coord_cl&, const Coord_cl&, int checkfor );
void reloadScripts();
- // Guildstone related functions
- int chardirxyz(P_CHAR pc, int x, int y); // direction from character a to char b
- bool inrange1p (PC_CHAR pca, P_CHAR pcb);
- //unsigned char tempeffect(P_CHAR pc_source, P_CHAR pc_dest, int num, unsigned char more1, unsigned char more2, unsigned char more3,short dur=-1);
- //unsigned char tempeffect2(P_CHAR source, P_ITEM piDest, int num, unsigned char more1, unsigned char more2, unsigned char more3);
void setcharflag(P_CHAR pc);
--- 48,54 ----
Index: targetrequests.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/targetrequests.cpp,v
retrieving revision 1.74
retrieving revision 1.75
diff -C2 -d -r1.74 -r1.75
*** targetrequests.cpp 30 Aug 2003 17:00:09 -0000 1.74
--- targetrequests.cpp 3 Sep 2003 14:44:21 -0000 1.75
***************
*** 282,286 ****
for ( cUOSocket *mSock = cNetwork::instance()->first(); mSock; mSock = cNetwork::instance()->next())
{
! if( mSock != socket && inrange1p( pc_currchar, mSock->player() ) && (rand()%10+10==17|| (rand()%2==1 && mSock->player()->intelligence() >= pc_currchar->intelligence())))
mSock->sysMessage(temp2);
}
--- 282,286 ----
for ( cUOSocket *mSock = cNetwork::instance()->first(); mSock; mSock = cNetwork::instance()->next())
{
! if( mSock != socket && mSock->player() && mSock->player()->inRange( pc_currchar, mSock->viewRange() ) && (rand()%10+10==17|| (rand()%2==1 && mSock->player()->intelligence() >= pc_currchar->intelligence())))
mSock->sysMessage(temp2);
}
Index: wolf.dsp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/wolf.dsp,v
retrieving revision 1.213
retrieving revision 1.214
diff -C2 -d -r1.213 -r1.214
*** wolf.dsp 2 Sep 2003 02:31:32 -0000 1.213
--- wolf.dsp 3 Sep 2003 14:44:21 -0000 1.214
***************
*** 1,23 ****
# Microsoft Developer Studio Project File - Name="wolf" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
! # ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=wolf - Win32 Debug
! !MESSAGE This is not a valid makefile. To build this project using NMAKE,
! !MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "wolf.mak".
!MESSAGE
! !MESSAGE You can specify a configuration when running NMAKE
! !MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "wolf.mak" CFG="wolf - Win32 Debug"
!MESSAGE
! !MESSAGE Possible choices for configuration are:
!MESSAGE
! !MESSAGE "wolf - Win32 Release" (based on "Win32 (x86) Console Application")
! !MESSAGE "wolf - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
--- 1,23 ----
# Microsoft Developer Studio Project File - Name="wolf" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
! # ** NICHT BEARBEITEN **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=wolf - Win32 Debug
! !MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE
! !MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl
!MESSAGE
!MESSAGE NMAKE /f "wolf.mak".
!MESSAGE
! !MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben
! !MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel:
!MESSAGE
!MESSAGE NMAKE /f "wolf.mak" CFG="wolf - Win32 Debug"
!MESSAGE
! !MESSAGE Für die Konfiguration stehen zur Auswahl:
!MESSAGE
! !MESSAGE "wolf - Win32 Release" (basierend auf "Win32 (x86) Console Application")
! !MESSAGE "wolf - Win32 Debug" (basierend auf "Win32 (x86) Console Application")
!MESSAGE
***************
*** 26,30 ****
# PROP Scc_ProjName "wolf"
# PROP Scc_LocalPath "."
! CPP=xicl6.exe
RSC=rc.exe
--- 26,30 ----
# PROP Scc_ProjName "wolf"
# PROP Scc_LocalPath "."
! CPP=cl.exe
RSC=rc.exe
***************
*** 50,54 ****
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
! LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib $(QTDIR)\lib\qt-mt312.lib libmysql.lib /nologo /subsystem:console /map /machine:I386 /nodefaultlib:"libcmt MSVCRTD" /out:"D:\wolfpack\wolfpack.exe" /libpath:"lib\ZThread\lib" /libpath:"lib\Python\lib" /libpath:"lib\bugreport\lib" /libpath:"flatstore\Release" /opt:ref /opt:nowin98
--- 50,54 ----
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
! LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib $(QTDIR)\lib\qt-mt312.lib libmysql.lib /nologo /subsystem:console /map /machine:I386 /nodefaultlib:"libcmt MSVCRTD" /out:"D:\wolfpack\wolfpack.exe" /libpath:"lib\ZThread\lib" /libpath:"lib\Python\lib" /libpath:"lib\bugreport\lib" /libpath:"flatstore\Release" /opt:ref /opt:nowin98
***************
*** 75,79 ****
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
! LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib $(QTDIR)\lib\qt-mt312.lib /nologo /version:12.9 /subsystem:console /map /debug /machine:I386 /out:"..\Wolfpack.exe" /pdbtype:sept /libpath:"lib\bugreport\lib" /libpath:"flatstore\Debug"
--- 75,79 ----
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
! LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib $(QTDIR)\lib\qt-mt312.lib /nologo /version:12.9 /subsystem:console /map /debug /machine:I386 /out:"..\Wolfpack.exe" /pdbtype:sept /libpath:"lib\bugreport\lib" /libpath:"flatstore\Debug"
***************
*** 204,211 ****
SOURCE=.\items.cpp
- # End Source File
- # Begin Source File
-
- SOURCE=.\LoS.cpp
# End Source File
# Begin Source File
--- 204,207 ----
Index: wolfpack.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/wolfpack.cpp,v
retrieving revision 1.450
retrieving revision 1.451
diff -C2 -d -r1.450 -r1.451
*** wolfpack.cpp 2 Sep 2003 18:53:08 -0000 1.450
--- wolfpack.cpp 3 Sep 2003 14:44:21 -0000 1.451
***************
*** 864,887 ****
}
- int chardirxyz(P_CHAR pc, int x, int y) // direction from character a to char b
- {
- int dir, xdif, ydif;
-
- xdif = x-pc->pos().x;
- ydif = y-pc->pos().y;
-
- if ((xdif==0)&&(ydif<0)) dir=0;
- else if ((xdif>0)&&(ydif<0)) dir=1;
- else if ((xdif>0)&&(ydif==0)) dir=2;
- else if ((xdif>0)&&(ydif>0)) dir=3;
- else if ((xdif==0)&&(ydif>0)) dir=4;
- else if ((xdif<0)&&(ydif>0)) dir=5;
- else if ((xdif<0)&&(ydif==0)) dir=6;
- else if ((xdif<0)&&(ydif<0)) dir=7;
- else dir=-1;
-
- return dir;
- }
-
void goldsfx( cUOSocket *socket, UINT16 amount, bool hearall )
{
--- 864,867 ----
***************
*** 953,1111 ****
/*!
- Give karma credit for killing someone.
- */
- void Karma( P_CHAR pc_toChange, P_CHAR pc_Killed, int nKarma )
- {
- // nEffect = 1 positive karma effect
- int nCurKarma = 0, nChange = 0, nEffect = 0;
-
- nCurKarma = pc_toChange->karma();
-
- if((nCurKarma>10000)||(nCurKarma<-10000))
- if(nCurKarma>10000)
- pc_toChange->setKarma(10000);
- else
- pc_toChange->setKarma(-10000);
-
- if( nCurKarma < nKarma && nKarma > 0 )
- {
- nChange=((nKarma-nCurKarma)/75);
- pc_toChange->setKarma(nCurKarma+nChange);
- nEffect=1;
- }
-
- //AntiChrist - modified to avoid crashes
- //the nKilledID==-1 check and the chars[nKilledID] check were in the same line
- //That may cause some crash with some compilator caus there's no a defined
- //order in executing these if checks
- if( ( nCurKarma > nKarma ) && ( !pc_Killed ) )
- {
- nChange = ( ( nCurKarma - nKarma ) / 50 );
- pc_toChange->setKarma( nCurKarma - nChange );
- nEffect = 0;
- }
- else if( ( nCurKarma > nKarma ) && ( pc_Killed->karma() > 0 ) )
- {
- nChange=((nCurKarma-nKarma)/50);
- pc_toChange->setKarma(nCurKarma-nChange);
- nEffect=0;
- }
-
- // For NPCs we dont need to send a message
- // If nothing changed we dont need to do that either
- P_PLAYER pp = dynamic_cast<P_PLAYER>(pc_toChange);
-
- if( !nChange || !pp || !pp->socket() )
- return;
-
- UINT32 message;
-
- if( nChange <= 25 )
- {
- if( nEffect )
- message = 0xF8CB3; // You have gained a little karma.
- else
- message = 0xF8CB7; // You have lost a little karma.
- }
- else if( nChange <= 75 )
- {
- if( nEffect )
- message = 0xF8CB4; // You have gained some karma.
- else
- message = 0xF8CB8; // You have lost some karma.
- }
- else if( nChange <= 100 )
- {
- if( nEffect )
- message = 0xF8CB5; // You have gained a good amount of karma.
- else
- message = 0xF8CB9; // You have lost a good amount of karma.
- }
- else if( nChange > 100 )
- {
- if( nEffect )
- message = 0xF8CB6; // You have gained a lot of karma.
- else
- message = 0xF8CBA; // You have lost a lot of karma.
- }
-
- pp->socket()->clilocMessage( message );
- }
-
- /*!
- Give fame credit for killing someone.
- */
- void Fame( P_CHAR pChar, int nFame )
- {
- P_PLAYER pc_toChange = dynamic_cast<P_PLAYER>( pChar );
- if( !pc_toChange )
- return;
-
- int nCurFame, nChange=0;
- bool gain = false;
-
- pc_toChange->setFame( QMIN( 10000, pc_toChange->fame() ) );
-
- nCurFame = pc_toChange->fame();
-
- // We already have more than that.
- if( nCurFame > nFame )
- return;
-
- // Loose Fame when we died
- if( pc_toChange->isDead() )
- {
- // Fame / 25 is our loss
- nChange = nCurFame / 25;
- pc_toChange->setFame( QMAX( 0, nCurFame - nChange ) );
- pc_toChange->setDeaths( pc_toChange->deaths() + 1 );
- gain = false;
- }
- else
- {
- nChange = ( nFame - nCurFame ) / 75;
- pc_toChange->setFame( nCurFame+nChange );
- gain = true;
- }
-
- // Nothing changed or we can't recieve the message
- if( !nChange || !pc_toChange->socket() )
- return;
-
- uint message;
-
- if( nChange <= 25 )
- {
- if( gain )
- message = 1019051; //"You have gained a little fame."
- else
- message = 1019055; //"You have lost a little fame."
- }
- else if( nChange <= 75 )
- {
- if( gain )
- message = 1019052; //"You have gained some fame."
- else
- message = 1019056; //"You have lost some fame."
- }
- else if( nChange <= 100 )
- {
- if( gain )
- message = 1019053; // You have gained a good amount of fame.
- else
- message = 1019057; // You have lost a good amount of fame.
- }
- else if( nChange > 100 )
- {
- if( gain )
- message = 1019054; //"You have gained alot of fame."
- else
- message = 1019058; //"You have lost alot of fame."
- }
-
- pc_toChange->socket()->clilocMessage( message );
- }
-
- /*!
Update the flagging of this character based
on his reputation.
--- 933,936 ----
***************
*** 1209,1238 ****
}
- ///////////
- // Name: inVisRange
- // Purpose: checks if position 1 and 2 are in visual range
- // history: by Duke, 18.11.2000
- //
- bool inVisRange(int x1, int y1, int x2, int y2)
- {
- return (QMAX(abs(x1-x2), abs(y1-y2)) <= VISRANGE);
- }
-
- bool inrange1p (PC_CHAR pca, P_CHAR pcb) // Are characters a and b in visual range
- {
- if (pca == NULL || pcb == NULL) return false;
-
- return inVisRange(pca->pos().x, pca->pos().y, pcb->pos().x, pcb->pos().y);
- }
-
- ///////////
- // Name: inRange
- // Purpose: checks if position 1 and 2 are in given range
- // history: by Duke, 19.11.2000
- //
- bool inRange(int x1, int y1, int x2, int y2, int range)
- {
- return (QMAX(abs(x1-x2), abs(y1-y2)) <= range);
- }
void savelog(const char *msg, char *logfile)
--- 1034,1037 ----
Index: wolfpack.pro
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/wolfpack.pro,v
retrieving revision 1.146
retrieving revision 1.147
diff -C2 -d -r1.146 -r1.147
*** wolfpack.pro 2 Sep 2003 03:04:13 -0000 1.146
--- wolfpack.pro 3 Sep 2003 14:44:21 -0000 1.147
***************
*** 149,153 ****
itemid.cpp \
items.cpp \
- LoS.cpp \
makemenus.cpp \
maps.cpp \
--- 149,152 ----
--- LoS.cpp DELETED ---
|