Jump to content

How to add a restriction to speed shoes


Recommended Posts

Version of Files XXX

1. Description of the problem / Question :

I installed three pair of speed shoes on my server, and I want to know how to make an restriction when trying to equip a second pair of shoes, with that error message: "You cannot equip this item twice."

I already tried something in item.cpp :

 

else if (GetType() == ITEM_UNIQUE)
    {
        if (ch->GetWear(SPEED_SHOES))
            return SPEED_SHOES2;
        else
            return SPEED_SHOES;

        else
            return SPEED_SHOES3;
    }

 

but when I'm trying to compile the source I get:  'SPEED_SHOES1/2/3' was not declared in this scope

I allready added UNIQUE_ITEM_SPEED_SHOES = 72701, UNIQUE_ITEM_SPEED_SHOES2 = 72702, UNIQUE_ITEM_SPEED_SHOES3 = 72703,   in unique_item.h.

 

Sorry for my bad english.

 

Thanks, Sincerly,
Cristian

 

Link to comment
Share on other sites

Hi Cristian,

 

item.cpp isn't probably the best place to add this restriction.

What I would do to implement this is :

in char_item.cpp

Above bool CHARACTER::CanEquipNow(const LPITEM item, const TItemPos& srcCell, const TItemPos& destCell)
add



bool isSpeedShoe(DWORD itemVnum)
{
	return (itemVnum == UNIQUE_ITEM_SPEED_SHOES) || (itemVnum == UNIQUE_ITEM_SPEED_SHOES2) || (itemVnum == UNIQUE_ITEM_SPEED_SHOES3); 
}

 

in bool CHARACTER::CanEquipNow(const LPITEM item, const TItemPos& srcCell, const TItemPos& destCell)

in if (item->GetWearFlag() & WEARABLE_UNIQUE)

add

		if (isSpeedShoe(item->GetVnum))
		{
			if ((GetWear(WEAR_UNIQUE1) && isSpeedShoe(GetWear(WEAR_UNIQUE1)->GetVnum())) ||
				(GetWear(WEAR_UNIQUE2) && isSpeedShoe(GetWear(WEAR_UNIQUE2)->GetVnum())))
			{
				ChatPacket(CHAT_TYPE_INFO, "You cannot equip this item twice");
				return false;
			}
		}

 

 

 

 

32 minutes ago, CristianDragan said:

Version of Files XXX

1. Description of the problem / Question :

I installed three pair of speed shoes on my server, and I want to know how to make an restriction when trying to equip a second pair of shoes, with that error message: "You cannot equip this item twice."

I already tried something in item.cpp :

 

else if (GetType() == ITEM_UNIQUE)
    {
        if (ch->GetWear(SPEED_SHOES))
            return SPEED_SHOES2;
        else
            return SPEED_SHOES;

        else
            return SPEED_SHOES3;
    }

 

but when I'm trying to compile the source I get:  'SPEED_SHOES1/2/3' was not declared in this scope

I allready added UNIQUE_ITEM_SPEED_SHOES = 72701, UNIQUE_ITEM_SPEED_SHOES2 = 72702, UNIQUE_ITEM_SPEED_SHOES3 = 72703,   in unique_item.h.

 

Sorry for my bad english.

 

Thanks, Sincerly,
Cristian

 

 

Edited by anon
fixed if condition
  • Love 1
Link to comment
Share on other sites

Tried with your latest edit, and I get this error when compiling

char_item.cpp: In member function 'bool CHARACTER::CanEquipNow(CItem*, const TItemPos&, const TItemPos&)':
char_item.cpp:7768: error: argument of type 'DWORD (CItem::)()const' does not match 'DWORD'

 

Line 7768:      if (isSpeedShoe(item->GetVnum))

 

You forgot to add an "(" near Vnum and one at the end :D 

if (isSpeedShoe(item->GetVnum()))

Now it's working.


Thank you.

Edited by CristianDragan
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.