EOSERV Forum > EO Server Building > Item to Change Title
Page: << 1 >>
Item to Change Title
Author Message
Post #203907 Item to Change Title

Is there any way to make an item that can set custom title once used?

6 years, 22 weeks ago
Post #203908 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 

  1. case EIF::EffectPotion:
  2.             {
  3.                 character->DelItem(id, 1);
  4.                  if (id == YOUR_ITEM_ID) character->title = "This is a cool title";
  5.  
  6.                 reply.ReserveMore(8);
  7.                 reply.AddInt(character->HasItem(id));
  8.                 reply.AddChar(character->weight);
  9.                 reply.AddChar(character->maxweight);
  10.                 reply.AddShort(item.effect);
  11.  
  12.                 character->Effect(item.effect, false);
  13.  
  14.                 character->Send(reply);
  15.  
  16.                 QuestUsedItems(character, id);
  17.             }
  18.             break;
---
If money doesn't grow on trees, then why do banks have branches?
6 years, 22 weeks ago
Post #203909 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 

  1. case EIF::EffectPotion:
  2.             {
  3.                 character->DelItem(id, 1);
  4.                  if (id == YOUR_ITEM_ID) character->title = "This is a cool title";
  5.  
  6.                 reply.ReserveMore(8);
  7.                 reply.AddInt(character->HasItem(id));
  8.                 reply.AddChar(character->weight);
  9.                 reply.AddChar(character->maxweight);
  10.                 reply.AddShort(item.effect);
  11.  
  12.                 character->Effect(item.effect, false);
  13.  
  14.                 character->Send(reply);
  15.  
  16.                 QuestUsedItems(character, id);
  17.             }
  18.             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
Post #203910 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 

  1. case EIF::EffectPotion:
  2.             {
  3.                 character->DelItem(id, 1);
  4.                  if (id == YOUR_ITEM_ID) character->title = "This is a cool title";
  5.  
  6.                 reply.ReserveMore(8);
  7.                 reply.AddInt(character->HasItem(id));
  8.                 reply.AddChar(character->weight);
  9.                 reply.AddChar(character->maxweight);
  10.                 reply.AddShort(item.effect);
  11.  
  12.                 character->Effect(item.effect, false);
  13.  
  14.                 character->Send(reply);
  15.  
  16.                 QuestUsedItems(character, id);
  17.             }
  18.             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
Post #203913 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
Post #203915 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 

  1. case EIF::EffectPotion:
  2.             {
  3.                 character->DelItem(id, 1);
  4.                  if (id == YOUR_ITEM_ID) character->title = "This is a cool title";
  5.  
  6.                 reply.ReserveMore(8);
  7.                 reply.AddInt(character->HasItem(id));
  8.                 reply.AddChar(character->weight);
  9.                 reply.AddChar(character->maxweight);
  10.                 reply.AddShort(item.effect);
  11.  
  12.                 character->Effect(item.effect, false);
  13.  
  14.                 character->Send(reply);
  15.  
  16.                 QuestUsedItems(character, id);
  17.             }
  18.             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
Post #203964 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 

  1. case EIF::EffectPotion:
  2.             {
  3.                 character->DelItem(id, 1);
  4.                  if (id == YOUR_ITEM_ID) character->title = "This is a cool title";
  5.  
  6.                 reply.ReserveMore(8);
  7.                 reply.AddInt(character->HasItem(id));
  8.                 reply.AddChar(character->weight);
  9.                 reply.AddChar(character->maxweight);
  10.                 reply.AddShort(item.effect);
  11.  
  12.                 character->Effect(item.effect, false);
  13.  
  14.                 character->Send(reply);
  15.  
  16.                 QuestUsedItems(character, id);
  17.             }
  18.             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
Post #203974 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 

  1. case EIF::EffectPotion:
  2.             {
  3.                 character->DelItem(id, 1);
  4.                  if (id == YOUR_ITEM_ID) character->title = "This is a cool title";
  5.  
  6.                 reply.ReserveMore(8);
  7.                 reply.AddInt(character->HasItem(id));
  8.                 reply.AddChar(character->weight);
  9.                 reply.AddChar(character->maxweight);
  10.                 reply.AddShort(item.effect);
  11.  
  12.                 character->Effect(item.effect, false);
  13.  
  14.                 character->Send(reply);
  15.  
  16.                 QuestUsedItems(character, id);
  17.             }
  18.             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
Page: << 1 >>

EOSERV Forum > EO Server Building > Item to Change Title