- else if (strcmp(command, "go")==0) // Use SQL by Likol
- {
- if(Config.Command_Go > thisclient->Session->accesslevel)
- {
- DB->QFree( );
- return true;
- }
- if ((tmp = strtok(NULL, " ")) == NULL) tmp = 0;
- int loc = atoi(tmp);
- int x = 0;
- int y = 0;
- int map = 0;
- MYSQL_ROW row;
- MYSQL_RES *result = NULL;
- result = DB->QStore("SELECT lvlmin,map,locx,locy,mapname,lvlmax FROM list_golist WHERE isactive=1 AND loc=%i",loc);
- row = mysql_fetch_row(result);
- if (row==NULL)
- {
- SendPM(thisclient, "Please input a number after the go command, below is a list of places and their appropriate number");
- DB->QFree( );
- result = DB->QStore("SELECT loc,mapname FROM list_golist WHERE isactive=1");
- while(row = mysql_fetch_row(result)) SendPM(thisclient, "%i = %s",atoi(row[0]),row[1]);
- SendPM(thisclient, "Example; /go 1");
- DB->QFree( );
- return true;
- }
- else
- {
- if (thisclient->Stats->Level<atoi(row[0]))
- {
- SendPM(thisclient, "You need to be a least Level %i to visit %s!",atoi(row[0]),row[4]);
- DB->QFree( );
- return true;
- }
- if (thisclient->Stats->Level>atoi(row[5]))
- {
- SendPM(thisclient, "You need to be between Level %i and %i to visit %s !",atoi(row[0]),atoi(row[5]),row[4]);
- DB->QFree( );
- return true;
- }
- if ( thisclient->Stats->HP < (thisclient->Stats->MaxHP / 2) || thisclient->Stats->HP < 1 || thisclient->Session->inGame == false )
- {
- SendPM(thisclient, "You need at least 50% HP in order to warp");
- DB->QFree( );
- return true;
- }
- fPoint coord;
- int map = atoi(row[1]);
- coord.x = atoi(row[2]);
- coord.y = atoi(row[3]);
- SendPM(thisclient, "teleport to map: %i",map);
- MapList.Index[map]->TeleportPlayer( thisclient, coord, false );
- Log( MSG_GMACTION, " %s : /go %i" , thisclient->CharInfo->charname, loc);
- DB->QFree( );
- return true;
- }
- }
[REV 84](svn update 6)
- Includes the fix where repairing items now costs money. (FransK)
- Repair at Raffle in Zant now works properly. (FransK)
Because the code is usefull for i-rose, p-rose and e-rose servers, i will post the modifications below so you don't have to find out yourself.
Rip out the comments if you feel like, but i prefer to document alot.
I'm not much of a C++ coder, so if you can do better, please do.
enjoy
regards,
Frans.
Sources Added/Altered:
- Worldserver.h added function declaration
- // Repair Price (extrafunctions.cpp)
- LONG Repairprice(UINT price, UINT durability, UINT lifespan);
extrafunctions.cpp
Added function:
- LONG CWorldServer::Repairprice(UINT price, UINT durability, UINT lifespan){
- /* ---------------------------------------------------------------------------------------------
- Function RepairPrice()
- Rev: 1.0, May 2013
- This is the amount of zuly you will pay to repair any item at the NPC.
- Formula is reverse-engineered by Frans K, Converted to C++ from VB.net
- -------------------------------------------------------------------------------------------------*/
- double iDivisor = 400; // Constant, needed to get the pricefactor
- double BaseFactor = 0; // Needed to compute the Increment and Start Offset.
- double PriceFactor = 0; // Needed to rebuild the price to a constant factor
- double PriceMultiplier = -1; // Needed to compute the Multiplier Rate
- double Incrementer = 0; // Incrementer, this is the repair price per percent loss of lifespan.
- double retval = 0; // The value to be returned
- // Get The Pricefactor and Multiplier
- PriceFactor = double(price / iDivisor); // Needed for calculation of the BaseFactor
- PriceMultiplier = double(price) * 0.001; // Needed for calculation of the Multiplier
- PriceMultiplier = 1 / PriceMultiplier; // Final Touch. C++ seems to have some trouble with math.
- // Get the Base Factor. these numbers are needed to get the increment and startoffset.
- BaseFactor = (durability+10) * PriceFactor;
- BaseFactor = BaseFactor/100;
- // Get the Incrementer.
- //Incrementer = (double(PriceMultiplier) * double(BaseFactor)) + double(BaseFactor);
- Incrementer = PriceMultiplier * BaseFactor;
- Incrementer +=BaseFactor;
- // Now we know enough to calculate the repair price.
- // Start Amount = 10x Incrementer
- // You pay for the amount the item needs to be repaired, so 100-Lifespan * Incrementer
- retval = ((100-lifespan) * Incrementer) + (10 * Incrementer);
- // Finally, round the number (just convert to long) and return it.
- return long (retval);
- }
finally: worldserver.cpp; function PakRepairItem somewhere around line 3688
Replace the entire function with this code:
- bool CWorldServer::pakRepairItem( CPlayer* thisclient, CPacket* P )
- // FJMK May 2013: fixed the function, it now needs zulie.
- // Cost are calculated in function Repairprice, located in Extrafunctions.cpp
- {
- BYTE action = GETBYTE((*P),0);
- switch (action)
- {
- case 16: // The weapon dude in zant (found by FransK)
- case 108: // The weapon dude in zant (found by FransK)
- case 39:
- case 97:
- case 18:
- case 129:
- case 0x3d: //Ronk
- case 0x39: //Ronk to
- case 0x1c:
- case 0x08:
- case 0x74:
- case 0x89:
- case 0x43: //NPC Repair Item / Town
- {
- BYTE slot = GETBYTE((*P),2);
- if (!CheckInventorySlot( thisclient, slot)) return false;
- if (thisclient->items[slot].count<1) return true;
- CItem thisitem=thisclient->items[slot];
- LONG bprice = EquipList[thisitem.itemtype].Index[thisitem.itemnum]->price;
- // Get the repair cost.
- LONG bcost=Repairprice(bprice,thisitem.durability,thisitem.lifespan);
- if (thisclient->CharInfo->Zulies >= bcost){
- // Client has enough zulies
- // Take money and repair.
- thisclient->CharInfo->Zulies -=bcost;
- thisclient->items[slot].lifespan=100;
- SendSysMsg( thisclient, "The item has been repaired." );
- } else {
- SendSysMsg( thisclient, "You don't have enough zuly to repair this item." );
- return true;
- }
- // Send Packet to client.
- BEGINPACKET( pak, 0x7cd );
- ADDQWORD ( pak, thisclient->CharInfo->Zulies );
- ADDBYTE ( pak, 0x01 );
- ADDBYTE ( pak, slot );
- ADDWORD ( pak, BuildItemHead( thisclient->items[slot] ));
- ADDDWORD ( pak, BuildItemData( thisclient->items[slot] ));
- ADDBYTE ( pak, 0x00 );
- thisclient->client->SendPacket( &pak );
- thisclient->SetStats( );
- }
- break;
- default:
- Log( MSG_WARNING,"Repair Item unknown action: %i", action);
- }
- return true;
- }