Page 1 of 1

Skill damage fixed

PostPosted: Tue May 13, 2008 7:08 pm
by PurpleYouko
I can't remember precisely what was changed here so i will just give you the whole function.
This is working fine now.

in battle.cpp
find
  1.  
  2. // use skill attack
  3. void CCharacter::UseAtkSkill( CCharacter* Enemy, CSkills* skill )
  4.  

Replace entire function with
  1.  
  2. // use skill attack
  3. void CCharacter::UseAtkSkill( CCharacter* Enemy, CSkills* skill )
  4. {
  5.     long int skillpower = skill->atkpower + (long int)floor(((double)GetInt( )/2));
  6.     skillpower -= Enemy->Stats->Magic_Defense;
  7.     bool bflag = false;          
  8.     Enemy->OnBeAttacked( this );  
  9.     if(skillpower<=0) skillpower = 0;
  10.     if(IsPlayer())
  11.     {
  12.         skillpower+=((skillpower*(Stats->ExtraDamage))/100);
  13.     }
  14.     if(!Enemy->IsSummon( ) && Enemy->IsMonster( ))
  15.     {
  16.         Enemy->AddDamage( this, skillpower );
  17.     }
  18.     Enemy->Stats->HP -= skillpower;  
  19.     BEGINPACKET( pak, 0x7b6 );
  20.     ADDWORD    ( pak, Enemy->clientid );            
  21.     ADDWORD    ( pak, clientid );
  22.     ADDDWORD   ( pak, 0x000007f8 );
  23.     ADDBYTE    ( pak, 0x00 );
  24.     if (Enemy->Stats->HP<1)
  25.     {
  26.         ADDWORD   ( pak, skillpower+0x8000 );
  27.     }
  28.     else
  29.     {
  30.         ADDWORD   ( pak, skillpower+0x2000 );
  31.     }
  32.     if(Enemy->IsDead())
  33.     {
  34.         CDrop* thisdrop = NULL;
  35.         ADDDWORD   ( pak, 16 );  
  36.         if(!Enemy->IsSummon( ) && !Enemy->IsPlayer( ))
  37.         {
  38.             thisdrop = Enemy->GetDrop( );
  39.             if(thisdrop!=NULL)
  40.             {                
  41.                 ADDFLOAT   ( pak, thisdrop->pos.x*100 );
  42.                 ADDFLOAT   ( pak, thisdrop->pos.y*100 );    
  43.                 if(thisdrop->type==1)
  44.                 {                        
  45.                     ADDWORD( pak, 0xccdf );
  46.                     ADDDWORD( pak, thisdrop->amount );                        
  47.                 }
  48.                 else
  49.                 {
  50.                     ADDWORD   ( pak, GServer->BuildItemHead( thisdrop->item ) );
  51.                     ADDDWORD   ( pak, GServer->BuildItemData( thisdrop->item ) );
  52.                 }
  53.                 ADDWORD    ( pak, thisdrop->clientid );                    
  54.                 ADDWORD    ( pak, thisdrop->owner );  
  55.                 CMap* map = GServer->MapList.Index[thisdrop->posMap];
  56.                 map->AddDrop( thisdrop );
  57.             }
  58.         }
  59.         GServer->SendToVisible( &pak, Enemy, thisdrop );        
  60.         OnEnemyDie( Enemy );        
  61.     }
  62.     else
  63.     {
  64.         ADDDWORD   ( pak, 4 );
  65.         GServer->SendToVisible( &pak, Enemy );  
  66.         bflag = GServer->AddDeBuffs( skill, Enemy, GetInt( ) );
  67.         if(skill->nbuffs>0 && bflag)
  68.         {
  69.             BEGINPACKET( pak, 0x7b5 );
  70.             ADDWORD    ( pak, Battle->skilltarget );
  71.             ADDWORD    ( pak, clientid );    
  72.             ADDWORD    ( pak, Battle->skillid );
  73.             ADDBYTE    ( pak, GetInt( ) );
  74.             GServer->SendToVisible( &pak, Enemy );
  75.         }  
  76.     }                  
  77.     RESETPACKET( pak, 0x7b9);
  78.     ADDWORD    ( pak, clientid);
  79.     ADDWORD    ( pak, Battle->skillid);
  80.     GServer->SendToVisible( &pak, this );           
  81. }


With this, you get the correct damage sent when you use an attack skill so you no longer get annoying undead zombie monsters chasing you around and refusing to die till you leave the map.
The problem was that the wrong damage value was being sent in the skill packet so the client did not recognize that the monster had died, even though the server had long since moved on.

Re: Skill damage fixed

PostPosted: Tue May 13, 2008 7:14 pm
by Blah4
Wow nice, this bug haas been annoying me forqutie some time.

Re: Skill damage fixed

PostPosted: Tue May 13, 2008 7:54 pm
by pepu
I was investigating on this, and didnĀ“t find the error!!, thx purple :P

Re: Skill damage fixed

PostPosted: Thu Jun 04, 2009 1:52 pm
by amaedict
this exact bug exists in osrose still.

but code different, cannot use above code. get compile errors.