Code by Shadow

If you want to help us or give some corrections / codes, put it here ;)

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

Code by Shadow

Postby rl2171 on Tue Aug 07, 2007 9:54 pm

I just felt like coding a bit again.. it's nothing special, just a few things. I wasn't testing any of it. So make sure you make a backup before applying these.

Skill-Reset (Maybe someone needs it?):

Find in your quest.cpp

  1.  
  2.                 case 2: // Skill points
  3.  


Replace it with:

  1.  
  2.                 case 2: // Skill points
  3.                      thisclient->CharInfo->SkillPoints = 0;
  4.                      for(unsigned int i=9;i<thisclient->Stats->Level;i++)
  5.                          thisclient->CharInfo->SkillPoints += 1;
  6.                      for(unsigned int j=0;j<60;j++)//60 = Max :>
  7.                          thisclient->cskills[j].thisskill = 0;
  8.                 break;
  9.  


====================

Checking the requirements for upgrading a skill

Find in your Worldpackets.cpp:

  1.  
  2.     CSkills* thisskill = GetSkillByID( skill );
  3.     if(thisskill==NULL)
  4.         return true;
  5.     if(thisclient->cskills[pos].id!=skill-thisclient->cskills[pos].level)                
  6.         return true;
  7.  


Add afterwards:

  1.  
  2.  
  3.     //Checking if the requirements are fulfilled
  4.     for(int j=0;j<3;j++)
  5.     {
  6.         if(thisskill->lskill[j]!=0)
  7.         {
  8.             for(int k=0;k<60;k++) //Maximum = 60 if I'm not mistaken
  9.             {
  10.                 if(thisclient->cskills[k].id == thisskill->rskill[j])
  11.                 {
  12.                     if( thisclient->cskills[k].level < thisskill->lskill[j]) //Current level of the required skill < required level
  13.                     {
  14.                         return true;
  15.                     }
  16.                 }
  17.             }
  18.         }
  19.     }
  20.  
  21.  



Dropped Points (HP/MP/Stamina/ (CP)). (I am not sure if obtainable points like "HP-Points" and such have been added yet, so they get immediately added. If not, add this please. If they already are, please ignore this piece of code - for your own sake xD)

Find in your WorldPackets.cpp

  1.  
  2.  
  3. bool CWorldServer::pakPickDrop( CPlayer* thisclient, CPacket* P )
  4.  
  5.  


Replace everything in it with:

  1.  
  2.  
  3. {
  4.     if(thisclient->Shop->open)
  5.         return true;  
  6.     thisclient->RestartPlayerVal( );
  7.     WORD dropid = GETWORD((*P), 0x00);
  8.     CDrop* thisdrop = GetDropByID( dropid, thisclient->Position->Map );
  9.     if (thisdrop==NULL) return true;    
  10.     bool flag = false;
  11.     BEGINPACKET( pak, 0x7a7 );
  12.     ADDWORD    ( pak, thisdrop->clientid );    
  13.     CPlayer* dropowner = 0;    
  14.     if( (thisdrop->owner==0 || thisdrop->owner==thisclient->CharInfo->charid || time(NULL)-thisdrop->droptime>=30 ) || ( thisclient->Party->party!=NULL && thisclient->Party->party == thisdrop->thisparty ))    
  15.     {
  16.         if( thisclient->Party->party!=NULL )
  17.         {
  18.             unsigned int dropparty = thisclient->Party->party->Option/0x10;
  19.             if( dropparty == 8 ) // Orderly
  20.             {
  21.                 unsigned int num = 0;
  22.                 bool dpflag = false;
  23.                 if( thisdrop->type==1 )
  24.                 {
  25.                     num = thisclient->Party->party->LastZulies;
  26.                     thisclient->Party->party->LastZulies++;
  27.                     if( thisclient->Party->party->LastZulies>=thisclient->Party->party->Members.size() )
  28.                         thisclient->Party->party->LastZulies = 0;                    
  29.                 }
  30.                 else
  31.                 if( thisdrop->type==2 )
  32.                 {
  33.                     num = thisclient->Party->party->LastItem;
  34.                     thisclient->Party->party->LastItem++;
  35.                     if( thisclient->Party->party->LastItem>=thisclient->Party->party->Members.size() )                    
  36.                         thisclient->Party->party->LastItem = 0;  
  37.                 }
  38.                 unsigned int n = 0;
  39.                 while( !dpflag )
  40.                 {
  41.                     n++;
  42.                     if( num>=thisclient->Party->party->Members.size() )
  43.                         num = 0;
  44.                     dropowner = thisclient->Party->party->Members.at( num );
  45.                     if( dropowner == NULL )
  46.                         num++;
  47.                     else
  48.                     {
  49.                         dpflag = true;
  50.                         num++;
  51.                     }
  52.                     if(n>20) // not founded yet? >.>
  53.                     {
  54.                         dropowner = thisclient;
  55.                         dpflag = true;
  56.                     }
  57.                 }
  58.             }
  59.             else // Equal Loot
  60.             {
  61.                 dropowner = thisclient;
  62.             }
  63.         }
  64.         else
  65.         {
  66.             dropowner = thisclient;
  67.         }
  68.         if( thisdrop->type == 1 ) //Zulie
  69.         {
  70.             dropowner->CharInfo->Zulies += thisdrop->amount;
  71.             ADDWORD( pak, 0 );
  72.             ADDBYTE( pak, 0 );
  73.             ADDDWORD( pak, 0xccccccdf );
  74.             ADDDWORD( pak, thisdrop->amount );
  75.             dropowner->client->SendPacket( &pak );
  76.             flag = true;            
  77.         }
  78.         else
  79.         if( thisdrop->type == 2 ) // Item
  80.         {
  81.             if(thisdrop->item.itemtype==10 && thisdrop->item.itemnum>150 && thisdrop->item.itemnum<191) //Consumables && grabable/instant points
  82.             {
  83.                 if(thisdrop->item.itemnum>150 && thisdrop->item.itemnum<161) //HP Points
  84.                 {
  85.                             if(thisdrop->item.itemnum==151)
  86.                                 dropowner->Stats->HP += 50;
  87.                             else if(thisdrop->item.itemnum==152)
  88.                                 dropowner->Stats->HP += 100;
  89.                             else if(thisdrop->item.itemnum==153)
  90.                                 dropowner->Stats->HP += 200;
  91.                             else if(thisdrop->item.itemnum==154)
  92.                                 dropowner->Stats->HP += 300;
  93.                             else if(thisdrop->item.itemnum==155)
  94.                                 dropowner->Stats->HP += 500;
  95.                             else if(thisdrop->item.itemnum==156)
  96.                                 dropowner->Stats->HP += 700;
  97.                             else if(thisdrop->item.itemnum==157)
  98.                                 dropowner->Stats->HP += 1000;
  99.                             else if(thisdrop->item.itemnum==158)
  100.                                 dropowner->Stats->HP += 1500;
  101.                             else if(thisdrop->item.itemnum==159)
  102.                                 dropowner->Stats->HP += 2000;
  103.                             else
  104.                                 dropowner->Stats->HP += 3000;
  105.                             if(dropowner->Stats->HP > dropowner->Stats->MaxHP)
  106.                                 dropowner->Stats->HP = dropowner->Stats->MaxHP;
  107.                             flag = true;
  108.                 }
  109.                 else if(thisdrop->item.itemnum>160 && thisdrop->item.itemnum<171) //MP Points
  110.                 {
  111.                             if(thisdrop->item.itemnum==161)//MP Points
  112.                                 dropowner->Stats->MP += 30;
  113.                             else if(thisdrop->item.itemnum==162)
  114.                                 dropowner->Stats->MP += 50;
  115.                             else if(thisdrop->item.itemnum==163)
  116.                                 dropowner->Stats->MP += 100;
  117.                             else if(thisdrop->item.itemnum==164)
  118.                                 dropowner->Stats->MP += 200;
  119.                             else if(thisdrop->item.itemnum==165)
  120.                                 dropowner->Stats->MP += 300;
  121.                             else if(thisdrop->item.itemnum==166)
  122.                                 dropowner->Stats->MP += 500;
  123.                             else if(thisdrop->item.itemnum==167)
  124.                                 dropowner->Stats->MP += 700;
  125.                             else if(thisdrop->item.itemnum==168)
  126.                                 dropowner->Stats->MP += 1000;
  127.                             else if(thisdrop->item.itemnum==169)
  128.                                 dropowner->Stats->MP += 1500;
  129.                             else
  130.                                 dropowner->Stats->MP += 2000;
  131.                             if(dropowner->Stats->MP > dropowner->Stats->MaxMP)
  132.                                 dropowner->Stats->MP = dropowner->Stats->MaxMP;
  133.                             flag = true;
  134.                 }
  135.                 else if(thisdrop->item.itemnum>170 && thisdrop->item.itemnum<181) //Stamina
  136.                 {
  137.                             if(thisdrop->item.itemnum==161)//Stamina Points
  138.                                 dropowner->Stats->Stamina += 50;
  139.                             else if(thisdrop->item.itemnum==162)
  140.                                 dropowner->Stats->Stamina += 75;
  141.                             else if(thisdrop->item.itemnum==163)
  142.                                 dropowner->Stats->Stamina += 100;
  143.                             else if(thisdrop->item.itemnum==164)
  144.                                 dropowner->Stats->Stamina += 150;
  145.                             else if(thisdrop->item.itemnum==165)
  146.                                 dropowner->Stats->Stamina += 200;
  147.                             else if(thisdrop->item.itemnum==166)
  148.                                 dropowner->Stats->Stamina += 300;
  149.                             else if(thisdrop->item.itemnum==167)
  150.                                 dropowner->Stats->Stamina += 400;
  151.                             else if(thisdrop->item.itemnum==168)
  152.                                 dropowner->Stats->Stamina += 500;
  153.                             else if(thisdrop->item.itemnum==169)
  154.                                 dropowner->Stats->Stamina += 700;
  155.                             else
  156.                                 dropowner->Stats->Stamina += 1000;
  157.                             if(dropowner->Stats->Stamina>5000)
  158.                                dropowner->Stats->Stamina = 5000;
  159.                             flag = true;
  160.                 }
  161.                 //Currently unsure about it... The real developers should have a look at that one for me. lol.
  162.                 /*else if(thisdrop->item.itemnum>180 && thisdrop->item.itemnum<191) //ClanPoints
  163.                 {            
  164.                       MYSQL_RES *result;
  165.                       MYSQL_ROW row;
  166.                      GServer->DB->QExecute("SELECT cp FROM list_clan WHERE id=%i", dropowner->Clan->clanid);
  167.                     result = mysql_store_result(mysql);
  168.                      if(mysql_num_rows(result)!=1)
  169.                         return true;
  170.                     row = mysql_fetch_row(result);
  171.                     dropowner->Clan->ClanPoints = atoi(row[0]); //First thing which is missing :/
  172.                                  
  173.                     if(thisdrop->item.itemnum==181)
  174.                         dropowner->Clan->ClanPoints += 1;
  175.                     else if(thisdrop->item.itemnum==182)
  176.                         dropowner->Clan->ClanPoints += 2;
  177.                     else if(thisdrop->item.itemnum==183)
  178.                         dropowner->Clan->ClanPoints += 3;
  179.                     else if(thisdrop->item.itemnum==184)
  180.                         dropowner->Clan->ClanPoints += 5;
  181.                     else if(thisdrop->item.itemnum==185)
  182.                         dropowner->Clan->ClanPoints += 7;
  183.                     else if(thisdrop->item.itemnum==186)
  184.                         dropowner->Clan->ClanPoints += 10;
  185.                     else if(thisdrop->item.itemnum==187)
  186.                         dropowner->Clan->ClanPoints += 15;
  187.                     else if(thisdrop->item.itemnum==188)
  188.                         dropowner->Clan->ClanPoints += 20;
  189.                     else if(thisdrop->item.itemnum==189)
  190.                         dropowner->Clan->ClanPoints += 25;
  191.                     else if(thisdrop->item.itemnum==190)
  192.                         dropowner->Clan->ClanPoints += 30;
  193.                     flag = true;
  194.                                    
  195.                     if(dropowner->Clan->ClanPoints > dropowner->Clan->grade*dropowner->Clan->grade*1000)//1000,4000,9000.... :)
  196.                     {
  197.                         dropowner->Clan->ClanPoints = 0;
  198.                         GServer->DB->QExecute( "UPDATE list_clan SET cp=%i,grade=%i WHERE id=%i",dropowner->Clan->ClanPoints,dropowner->Clan->grade+1,dropowner->Clan->clanid);
  199.                         BEGINPACKET( pak, 0x702 );
  200.                         ADDSTRING( pak, "Your Clangrade has been increased. Congratulations and good luck with getting the next level.");
  201.                         ADDBYTE( pak, 0 );
  202.                         thisclient->SendPacket( &pak );
  203.                           RESETPACKET( pak, 0x7e0 );
  204.                           ADDBYTE    ( pak, 0xfa ); //action to update clan informacion
  205.                          ADDWORD    ( pak, thisclient->Clan->clanid );
  206.                            ADDWORD    ( pak, thisclient->CharInfo->charid );
  207.                         cryptPacket( (char*)&pak, NULL );
  208.                           send( csock, (char*)&pak, pak.Size, 0 );
  209.                      }
  210.                      else
  211.                      {
  212.                          GServer->DB->QExecute( "UPDATE list_clan SET cp=%i WHERE id=%i", dropowner->Clan->ClanPoints,dropowner->Clan->clanid);
  213.                             RESETPACKET( pak, 0x7e0 );
  214.                             ADDBYTE    ( pak, 0xfa ); //action to update clan informacion
  215.                           ADDWORD    ( pak, thisclient->Clan->clanid );
  216.                             ADDWORD    ( pak, thisclient->CharInfo->charid );
  217.                             thisclient->SendPacket( &pak );                        
  218.                          cryptPacket( (char*)&pak, NULL );
  219.                      }
  220.                 }*/
  221.             }
  222.             else
  223.             {
  224.                 unsigned int tempslot = dropowner->AddItem( thisdrop->item );
  225.                 if(tempslot!=0xffff)// we have slot
  226.                 {
  227.                     unsigned int slot1 = tempslot;
  228.                     unsigned int slot2 = 0xffff;
  229.                     if(tempslot>MAX_INVENTORY)
  230.                     {
  231.                         slot1 = tempslot/1000;
  232.                         slot2 = tempslot%1000;
  233.                     }
  234.                     ADDBYTE    ( pak, 0x00 );
  235.                     ADDBYTE    ( pak, slot1 );
  236.                     ADDBYTE    ( pak, 0x00 );
  237.                     ADDDWORD   ( pak, BuildItemHead( dropowner->items[slot1] ) );
  238.                     ADDDWORD   ( pak, BuildItemData( dropowner->items[slot1] ) );
  239.                     dropowner->client->SendPacket( &pak );  
  240.                     dropowner->UpdateInventory( slot1, slot2 );
  241.                     flag = true;                                                                
  242.                 }
  243.                 else
  244.                 {
  245.                     ADDBYTE    (pak, 0x03);
  246.                     dropowner->client->SendPacket(&pak);                    
  247.                 }
  248.             }
  249.         }        
  250.     }
  251.     else
  252.     {
  253.         ADDBYTE    (pak, 0x02);
  254.         thisclient->client->SendPacket(&pak);    
  255.     }
  256.     if( flag )
  257.     {
  258.         if( thisclient->Party->party!=NULL )
  259.         {
  260.             unsigned int dropparty = thisclient->Party->party->Option/0x10;
  261.             if( dropparty == 8 )
  262.             {
  263.                 BEGINPACKET( pak, 0x7d3 );
  264.                 ADDWORD    ( pak, dropowner->clientid );  
  265.                 if( thisdrop->type == 1 )
  266.                 {
  267.                     ADDDWORD( pak, 0xccccccdf );
  268.                     ADDDWORD( pak, thisdrop->amount );                    
  269.                 }                
  270.                 else            
  271.                 if( thisdrop->type == 2 )
  272.                 {
  273.                     ADDDWORD   ( pak, BuildItemHead( thisdrop->item ) );
  274.                     ADDDWORD   ( pak, BuildItemData( thisdrop->item ) );  
  275.                 }
  276.                 thisclient->Party->party->SendToMembers( &pak, dropowner );                
  277.             }
  278.         }        
  279.         CMap* map = MapList.Index[thisdrop->posMap];
  280.         pthread_mutex_lock( &map->DropMutex );
  281.         map->DeleteDrop( thisdrop );        
  282.         pthread_mutex_unlock( &map->DropMutex );
  283.     }    
  284.     return true;
  285. }
  286.  
  287.  



I hope you enjoy it.
P.S.: I was "removing" the CP-thingy from the packet, because I wasn't very sure about the current "ClanPoint" stuff at all, since it was missing for me.
Another thing: Please make really sure that you've made a backup of your files before applying this stuff. I really wasn't testing any of it. I wasn't even trying to compile them yet, but it should work fine if it's compilable.
Image
rl2171
Admin
Admin
 
Posts: 1706
Joined: Mon Aug 06, 2007 5:17 pm
Location: Sacramento, CA USA - GMT-8

Return to Submit Code

Who is online

Users browsing this forum: No registered users and 1 guest

cron