Slyke
Joined: 5th Jan 2010
Posts: 24
Item to Change Title
Is there any way to make an item that can set custom title once used?
6 years, 22 weeks ago
|
DanScott
Joined: 19th Aug 2010
Posts: 1212
Re: Item to Change Title
Sure you can. In item.cpp around line 203 "case EIF::EffectPotion:" make a new effect potion in your .eif file note down its id and then decide what you want the title to be and then the code will look something like
-
case EIF::EffectPotion:
-
{
-
character->DelItem(id, 1);
-
if (id == YOUR_ITEM_ID) character->title = "This is a cool title";
-
-
reply.ReserveMore(8);
-
reply.AddInt(character->HasItem(id));
-
reply.AddChar(character->weight);
-
reply.AddChar(character->maxweight);
-
reply.AddShort(item.effect);
-
-
character->Effect(item.effect, false);
-
-
character->Send(reply);
-
-
QuestUsedItems(character, id);
-
}
-
break;
---
If money doesn't grow on trees, then why do banks have branches?
6 years, 22 weeks ago
|
Sordie
Joined: 3rd Apr 2009
Posts: 2044
Re: Item to Change Title
DanScott posted: (27th Nov 2017, 02:37 pm)
Sure you can. In item.cpp around line 203 "case EIF::EffectPotion:" make a new effect potion in your .eif file note down its id and then decide what you want the title to be and then the code will look something like
-
case EIF::EffectPotion:
-
{
-
character->DelItem(id, 1);
-
if (id == YOUR_ITEM_ID) character->title = "This is a cool title";
-
-
reply.ReserveMore(8);
-
reply.AddInt(character->HasItem(id));
-
reply.AddChar(character->weight);
-
reply.AddChar(character->maxweight);
-
reply.AddShort(item.effect);
-
-
character->Effect(item.effect, false);
-
-
character->Send(reply);
-
-
QuestUsedItems(character, id);
-
}
-
break;
You should probably define a new item sub-type to recognise the item as a "title potion" rather than hard coding item ID's. Don't be Vult. ;]
Add the new sub type to eodata.hpp:
enum SubType
{
None,
Ranged,
Arrows,
Wings,
TwoHanded,
TitlePotion
};
Change the line you added to:
if (item.SubType == EIF::TitlePotion) character->title = "This is a cool title";
Edit your pubs accordingly. This way you don't have horrible hard coded ID's that will break if you insert new items. ---
http://sordie.co.uk
http://twitter.com/@SordieEO
6 years, 22 weeks ago
|
Apollo
Administrator
Joined: 14th Apr 2009
Posts: 2759
Re: Item to Change Title
Sordie posted: (27th Nov 2017, 08:05 pm)
DanScott posted: (27th Nov 2017, 02:37 pm)
Sure you can. In item.cpp around line 203 "case EIF::EffectPotion:" make a new effect potion in your .eif file note down its id and then decide what you want the title to be and then the code will look something like
-
case EIF::EffectPotion:
-
{
-
character->DelItem(id, 1);
-
if (id == YOUR_ITEM_ID) character->title = "This is a cool title";
-
-
reply.ReserveMore(8);
-
reply.AddInt(character->HasItem(id));
-
reply.AddChar(character->weight);
-
reply.AddChar(character->maxweight);
-
reply.AddShort(item.effect);
-
-
character->Effect(item.effect, false);
-
-
character->Send(reply);
-
-
QuestUsedItems(character, id);
-
}
-
break;
You should probably define a new item sub-type to recognise the item as a "title potion" rather than hard coding item ID's. Don't be Vult. ;]
Add the new sub type to eodata.hpp:
enum SubType
{
None,
Ranged,
Arrows,
Wings,
TwoHanded,
TitlePotion
};
Change the line you added to:
if (item.SubType == EIF::TitlePotion) character->title = "This is a cool title";
Edit your pubs accordingly. This way you don't have horrible hard coded ID's that will break if you insert new items.
Finally a good idea. I think they really need access to more sub type values in the pub editor. I think that might be a drop down box. Good idea though.
6 years, 22 weeks ago
|
DanScott
Joined: 19th Aug 2010
Posts: 1212
Re: Item to Change Title
I never work with the EOSERV codebase any more, I just based this answer on quickly opening the SVN to see where items are consumed =P If he has access to the source of his revision I don't see why making an item subtype is any less work than hardcoding a few item id's ---
If money doesn't grow on trees, then why do banks have branches?
6 years, 22 weeks ago
|
Cirras
Joined: 11th Mar 2011
Posts: 1221
Re: Item to Change Title
Sordie posted: (27th Nov 2017, 08:05 pm)
DanScott posted: (27th Nov 2017, 02:37 pm)
Sure you can. In item.cpp around line 203 "case EIF::EffectPotion:" make a new effect potion in your .eif file note down its id and then decide what you want the title to be and then the code will look something like
-
case EIF::EffectPotion:
-
{
-
character->DelItem(id, 1);
-
if (id == YOUR_ITEM_ID) character->title = "This is a cool title";
-
-
reply.ReserveMore(8);
-
reply.AddInt(character->HasItem(id));
-
reply.AddChar(character->weight);
-
reply.AddChar(character->maxweight);
-
reply.AddShort(item.effect);
-
-
character->Effect(item.effect, false);
-
-
character->Send(reply);
-
-
QuestUsedItems(character, id);
-
}
-
break;
You should probably define a new item sub-type to recognise the item as a "title potion" rather than hard coding item ID's. Don't be Vult. ;]
Add the new sub type to eodata.hpp:
enum SubType
{
None,
Ranged,
Arrows,
Wings,
TwoHanded,
TitlePotion
};
Change the line you added to:
if (item.SubType == EIF::TitlePotion) character->title = "This is a cool title";
Edit your pubs accordingly. This way you don't have horrible hard coded ID's that will break if you insert new items.
I've had a metric fuckton of fun doing stuff like this with both items and NPCs. Since I use ini-based pubs serverside it's really easy to implement too instead of working with a certain set of unknown values and other stuff.
For a lot of these types I things I use the new item or npc type as an "internal type" and then there's a corresponding external type (assigned automatically) that is officially sent to clients pubs for certain functionality. For instance, my pets have an internal type of ENF::Pet and an
external type of ENF::Quest so the client will view them as a quest NPC and send a quest packet for handling. Then it's just a matter of intercepting in the handler with a check on the internal type, and the pet menu function handles the rest.
It's a lot cleaner than most implementations I've seen and I wish more people's code looked the way you suggest.
---
Want to learn to pixel?
Pixelsource.org
6 years, 22 weeks ago
|
Re: Item to Change Title
Sordie posted: (27th Nov 2017, 08:05 pm)
DanScott posted: (27th Nov 2017, 02:37 pm)
Sure you can. In item.cpp around line 203 "case EIF::EffectPotion:" make a new effect potion in your .eif file note down its id and then decide what you want the title to be and then the code will look something like
-
case EIF::EffectPotion:
-
{
-
character->DelItem(id, 1);
-
if (id == YOUR_ITEM_ID) character->title = "This is a cool title";
-
-
reply.ReserveMore(8);
-
reply.AddInt(character->HasItem(id));
-
reply.AddChar(character->weight);
-
reply.AddChar(character->maxweight);
-
reply.AddShort(item.effect);
-
-
character->Effect(item.effect, false);
-
-
character->Send(reply);
-
-
QuestUsedItems(character, id);
-
}
-
break;
You should probably define a new item sub-type to recognise the item as a "title potion" rather than hard coding item ID's. Don't be Vult. ;]
Add the new sub type to eodata.hpp:
enum SubType
{
None,
Ranged,
Arrows,
Wings,
TwoHanded,
TitlePotion
};
Change the line you added to:
if (item.SubType == EIF::TitlePotion) character->title = "This is a cool title";
Edit your pubs accordingly. This way you don't have horrible hard coded ID's that will break if you insert new items.
I'd go even further with that and change the line to,
if (item.SubType == EIF::TitlePotion) <function call to title potion handler with a ptr to the item ID being used>;
where a title potion handler is created with a switch table of item IDs so that different title potion items can give different titles.
---
I not hacker
“Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its
whole life believing that it is stupid.†- Albert Einstein : Really Great Quote Ramy!
6 years, 19 weeks ago
|
Callum
Joined: 16th Oct 2011
Posts: 609
Re: Item to Change Title
Cirras posted: (28th Nov 2017, 04:21 am)
Sordie posted: (27th Nov 2017, 08:05 pm)
DanScott posted: (27th Nov 2017, 02:37 pm)
Sure you can. In item.cpp around line 203 "case EIF::EffectPotion:" make a new effect potion in your .eif file note down its id and then decide what you want the title to be and then the code will look something like
-
case EIF::EffectPotion:
-
{
-
character->DelItem(id, 1);
-
if (id == YOUR_ITEM_ID) character->title = "This is a cool title";
-
-
reply.ReserveMore(8);
-
reply.AddInt(character->HasItem(id));
-
reply.AddChar(character->weight);
-
reply.AddChar(character->maxweight);
-
reply.AddShort(item.effect);
-
-
character->Effect(item.effect, false);
-
-
character->Send(reply);
-
-
QuestUsedItems(character, id);
-
}
-
break;
You should probably define a new item sub-type to recognise the item as a "title potion" rather than hard coding item ID's. Don't be Vult. ;]
Add the new sub type to eodata.hpp:
enum SubType
{
None,
Ranged,
Arrows,
Wings,
TwoHanded,
TitlePotion
};
Change the line you added to:
if (item.SubType == EIF::TitlePotion) character->title = "This is a cool title";
Edit your pubs accordingly. This way you don't have horrible hard coded ID's that will break if you insert new items.
I've had a metric fuckton of fun doing stuff like this with both items and NPCs. Since I use ini-based pubs serverside it's really easy to implement too instead of working with a certain set of unknown values and other stuff.
For a lot of these types I things I use the new item or npc type as an "internal type" and then there's a corresponding external type (assigned automatically) that is officially sent to clients pubs for certain functionality. For instance, my pets have an internal type of ENF::Pet and an
external type of ENF::Quest so the client will view them as a quest NPC and send a quest packet for handling. Then it's just a matter of intercepting in the handler with a check on the internal type, and the pet menu function handles the rest.
It's a lot cleaner than most implementations I've seen and I wish more people's code looked the way you suggest.
Iâve never understood why people made pets an npc type.. I made my latest system a simple Boolean and it allowed me to use any npc (quest and shops) as pets, only took a few edits in the actual npc act and a new attack function. Not to mention it lets me âtameâ npcsas pets too if I wanted that.
6 years, 19 weeks ago
| | | | | | | | |