Modified the code that works for return scrolls to exclude charm scrolls that strangely have values in the "warp zone" field
This will fix the error with the charm scrolls warping but might possibly leave them doing nothing at all in which case i will need to spend a lot more time than I currently have available to me in rewriting the code in worldpackets.cpp
for anyone attempting to figure it out for themselves the way that most useitems work is this.
First this function is called in extrafunctions.cpp
// Get Consumible Item Info
CUseInfo* CWorldServer::GetUseItemInfo(CPlayer* thisclient, unsigned int slot )It creates a use-script and use-value variable for the consumable item that is used but does nothing else with it. Go look up the code to see what I mean. IMO this is highly unsatisfactory so I began changing it to remove this function altogether.
The use-script and use-value variables are then passed to function
// Consumible Items
bool CWorldServer::pakUseItem ( CPlayer* thisclient, CPacket* P )in worldpackets.cpp and that is where i have started to rebuild the code using a more sensible approach.
here is the code that I wrote for return scrolls so that they can read directly from the STB
- //if the useitem has an attached skill.....
- if( thisuse->skillid != 0 )
- {
- CSkills* thisskill = GetSkillByID( thisuse->skillid );
- //This one line of code should replace almost the entire switch below
- thisclient->StartAction( NULL, thisskill->skilltype, thisskill->id );
-
- if( thisskill->WarpZone != 0 && thisskill->target == 0) //return scrolls or any other item that runs a warp in the skill. this is NOT handled in skill handling for some reason
- {
- BEGINPACKET( pak,0x7a3 );
- ADDWORD ( pak,thisclient->clientid );
- ADDWORD ( pak, thisuse->itemnum );
- ADDBYTE ( pak,slot );
- thisclient->client->SendPacket( &pak );
- fPoint thispoint;
- thispoint.x = thisskill->WarpX * 10;
- thispoint.y = thisskill->WarpY * 10;
- TeleportTo ( thisclient, thisskill->WarpZone, thispoint );
- thisuse->usescript = 999;
- }
- flag = true;
- }
I added "&& thisskill->target == 0" to stop it trying to warp the player when they use charm scrolls
As you can probably tell though, there are WAY more use-items that are associated with skills so this is just the very start of a large number of cases that need to be rewritten.
Further down the code I found that I had commented out charm scrolls and cherry berries, indicating that they were covered by the code above. I'm no longer sure what I was thinking at the time because they do not appear to be covered at all so I suspect they will not work at all unless they are recoded in the new section OR uncommented