Jump to content
Pillows

[Charms] Item's effect to work while in inventory

Recommended Posts

All credit goes to digitalhamster, fixed by ~AnnieRuru~.

Reposting for personal reasons since Ea has been offline and I happen to have saved a web cache of the pages.
The topic is old, so you have to manually add the modifications. Plus, the spacings didn't copy out too well.

The modification works through the item's bonus script in your item_db/db2. Charm's effect don't work if you do not add type (12/etc.), job, upper, and gender in itemdb/db2. Charms will only work with items having type = 12/? on item_db/db2, so your other items won't be affected by this, just the ones you choose.

Make sure type is set according to your mmo.h.
For example:

+++ common/mmo.h (working copy)
@@ -175,6 +175,7 @@
IT_UNKNOWN2,//9
IT_AMMO, //10
IT_DELAYCONSUME,//11
+ IT_CHARM,
IT_CASH = 18,

Looking at IT_CHARM, type is set to 12.

Item stacking

Add this if you want to enable item IDs to stack. It will treat each item as a separate item, in its own item slot. Example: Apple (5) will be in different items slots in your inventory and its effects will stack with each other when the code below is added.

Same item effects on different item IDs will stack regardless of enabling/disabling this modification.

 

Add this if you want items to stack:

 

Go to itemdb.c:

/*==========================================
 * Returns if given item's type is stackable.
 *------------------------------------------*/
int itemdb_isstackable(int nameid)
{
  int type=itemdb_type(nameid);
  switch(type) {
	  case IT_WEAPON:
	  case IT_ARMOR:
	  case IT_PETEGG:
	  case IT_PETARMOR:
+         case IT_CHARM:
		  return 0;

And again, right below it:

/*==========================================
 * Alternate version of itemdb_isstackable
 *------------------------------------------*/
int itemdb_isstackable2(struct item_data *data)
{
  nullpo_retr(0, data);
  switch(data->type) {
	  case IT_WEAPON:
	  case IT_ARMOR:
	  case IT_PETEGG:
	  case IT_PETARMOR:
+         case IT_CHARM:
		  return 0;

Fixed version:
Src for Renewal (manually add): Charms.txt

Edited Annie's fix for older eA revisions: eA_Charms.txt

 

Don't try to update this as a .diff, just a suggestion.

Edited by Pillows
  • Love 1
Link to comment
Share on other sites

thanks for this, i was looking for complete src mods for this charm system but i wasn't able to find one because eA was already down.

 

Tested and worked perfectly!

You just forget to add the correct item_db script so anyone can use this.

#####,Charm,Charm,12,50,,0,,,,,0xFFFFFFFF,15,2,,,60,,,{ bonus bAllStats,100; },{},{}

But still, not working in Gunslinger & Ninja

I wish someone will provide fix for Gunslinger & Ninja problem in Charms Mod

Edited by GodKnows Jhomz
Link to comment
Share on other sites

thanks for this, i was looking for complete src mods for this charm system but i wasn't able to find one because eA was already down.

 

Tested and worked perfectly!

You just forget to add the correct item_db script so anyone can use this.

#####,Charm,Charm,12,50,,0,,,,,0xFFFFFFFF,15,2,,,60,,,{ bonus bAllStats,100; },{},{}

But still, not working in Gunslinger & Ninja

I wish someone will provide fix for Gunslinger & Ninja problem in Charms Mod

Oh, I never noticed. I have no idea why the original modification left out those classes.

I came up with a fix, let me know if there's any more problems.

 

Replace (status.c):

if ( sd->inventory_data[i]->script && sd->inventory_data[i]->elv <= sd->status.base_level && ( 1 << sd->class_ & MAPID_BASEMASK ) & sd->inventory_data[i]->class_base[ sd->class_ & JOBL_2_1? 1: sd->class_ & JOBL_2_2? 2:0 ] && ( 1 << ( sd->class_ & JOBL_UPPER? 1: sd->class_ & JOBL_BABY? 2:0 ) ) & sd->inventory_data[i]->class_upper ) {

With this:

if ( sd->inventory_data[i]->script && sd->inventory_data[i]->elv <= sd->status.base_level && sd->inventory_data[i]->class_upper ) {

Updated original post!

Link to comment
Share on other sites

 

thanks for this, i was looking for complete src mods for this charm system but i wasn't able to find one because eA was already down.

 

Tested and worked perfectly!

You just forget to add the correct item_db script so anyone can use this.

#####,Charm,Charm,12,50,,0,,,,,0xFFFFFFFF,15,2,,,60,,,{ bonus bAllStats,100; },{},{}

But still, not working in Gunslinger & Ninja

I wish someone will provide fix for Gunslinger & Ninja problem in Charms Mod

Oh, I never noticed. I have no idea why the original modification left out those classes.

I came up with a fix, let me know if there's any more problems.

 

Replace (status.c):

if ( sd->inventory_data[i]->script && sd->inventory_data[i]->elv <= sd->status.base_level && ( 1 << sd->class_ & MAPID_BASEMASK ) & sd->inventory_data[i]->class_base[ sd->class_ & JOBL_2_1? 1: sd->class_ & JOBL_2_2? 2:0 ] && ( 1 << ( sd->class_ & JOBL_UPPER? 1: sd->class_ & JOBL_BABY? 2:0 ) ) & sd->inventory_data[i]->class_upper ) {

With this:

if ( sd->inventory_data[i]->script && sd->inventory_data[i]->elv <= sd->status.base_level && sd->inventory_data[i]->class_upper ) {

Updated original post!

 

Thanks for this !

But already fixed mine by getting my old src code for status.c file.

this is the codes that I get somewhere here in rA or in eA forum.

 

From :

if ( sd->inventory_data[i]->script && sd->inventory_data[i]->elv <= sd->status.base_level && ( 1 << sd->class_ & MAPID_BASEMASK ) & sd->inventory_data[i]->class_base[ sd->class_ & JOBL_2_1? 1: sd->class_ & JOBL_2_2? 2:0 ] && ( 1 << ( sd->class_ & JOBL_UPPER? 1: sd->class_ & JOBL_BABY? 2:0 ) ) & sd->inventory_data[i]->class_upper ) {

To :

if ( sd->inventory_data[i]->script && 0 < sd->status.base_level && sd->inventory_data[i]->class_upper ) {
run_script( sd->inventory_data[i]->script, 0, sd->bl.id, 0 );
Link to comment
Share on other sites

 

 

thanks for this, i was looking for complete src mods for this charm system but i wasn't able to find one because eA was already down.

 

Tested and worked perfectly!

You just forget to add the correct item_db script so anyone can use this.

#####,Charm,Charm,12,50,,0,,,,,0xFFFFFFFF,15,2,,,60,,,{ bonus bAllStats,100; },{},{}

But still, not working in Gunslinger & Ninja

I wish someone will provide fix for Gunslinger & Ninja problem in Charms Mod

Oh, I never noticed. I have no idea why the original modification left out those classes.

I came up with a fix, let me know if there's any more problems.

 

Replace (status.c):

if ( sd->inventory_data[i]->script && sd->inventory_data[i]->elv <= sd->status.base_level && ( 1 << sd->class_ & MAPID_BASEMASK ) & sd->inventory_data[i]->class_base[ sd->class_ & JOBL_2_1? 1: sd->class_ & JOBL_2_2? 2:0 ] && ( 1 << ( sd->class_ & JOBL_UPPER? 1: sd->class_ & JOBL_BABY? 2:0 ) ) & sd->inventory_data[i]->class_upper ) {

With this:

if ( sd->inventory_data[i]->script && sd->inventory_data[i]->elv <= sd->status.base_level && sd->inventory_data[i]->class_upper ) {

Updated original post!

 

Thanks for this !

But already fixed mine by getting my old src code for status.c file.

this is the codes that I get somewhere here in rA or in eA forum.

 

From :

if ( sd->inventory_data[i]->script && sd->inventory_data[i]->elv <= sd->status.base_level && ( 1 << sd->class_ & MAPID_BASEMASK ) & sd->inventory_data[i]->class_base[ sd->class_ & JOBL_2_1? 1: sd->class_ & JOBL_2_2? 2:0 ] && ( 1 << ( sd->class_ & JOBL_UPPER? 1: sd->class_ & JOBL_BABY? 2:0 ) ) & sd->inventory_data[i]->class_upper ) {

To :

if ( sd->inventory_data[i]->script && 0 < sd->status.base_level && sd->inventory_data[i]->class_upper ) {
run_script( sd->inventory_data[i]->script, 0, sd->bl.id, 0 );

 

That's the same line of code.

Link to comment
Share on other sites

I change this:

map/pc.cpp

--- map/pc.c (revision 14843)
+++ map/pc.c (working copy)
@@ -3444,6 +3444,7 @@
	clif_updatestatus(sd,SP_WEIGHT);
	//Auto-equip
	if(data->flag.autoequip) pc_equipitem(sd, i, data->equip);
+	if(data->type == IT_CHARM) status_calc_pc(sd,0);//dh
	return 0;

To:

if (id->type == IT_CHARM) status_calc_pc(sd, SCO_NONE); //dh

Now the next part:

@@ -3470,6 +3473,8 @@
	if(!(type&2))
		clif_updatestatus(sd,SP_WEIGHT);

+	if(mem == IT_CHARM) status_calc_pc(sd,0);//dh
+
return 0;

To:

if(mem == IT_CHARM) status_calc_pc(sd, SCO_NONE);//dh

 

map/itemdb.cpp

	id->type = atoi(str[3]);

-	if( id->type < 0 || id->type == IT_UNKNOWN || id->type == IT_UNKNOWN2 || ( id->type > IT_DELAYCONSUME && id->type < IT_CASH ) || id->type >= IT_MAX )
+	if( id->type < 0 || id->type == IT_UNKNOWN || id->type == IT_UNKNOWN2 || ( id->type > IT_CHARM && id->type < IT_CASH ) || id->type >= IT_MAX )
	{// catch invalid item types
		ShowWarning("itemdb_parse_dbrow: Invalid item type %d for item %d. IT_ETC will be used.\n", id->type, nameid);
		id->type = IT_ETC;

TO:

if( id->type < 0 || id->type == IT_UNKNOWN || id->type == IT_UNKNOWN2 || ( id->type > IT_SHADOWGEAR && id->type < IT_CASH && id->type > IT_CHARM ) ||  id->type >= IT_MAX  )

I don't know about this part but... still working. 

 

db/import/itemdb.txt

#####,Charm,Charm,12,50,,0,,,,,0xFFFFFFFF,15,2,,,60,,,{ bonus bAllStats,100; },{},{}

TO:

30050,Charm,Charm,13,6,,0,,,,,0xFFFFFFFF,15,2,,,1,,,{bonus bStr,2; },{},{}

Change to your ID.

 

image.png.e9727dfb5a4c5f5d6a5c8b968e0f1b92.png

  • Like 1
Link to comment
Share on other sites

7 hours ago, Scanty said:

I change this:

map/pc.cpp

--- map/pc.c (revision 14843)
+++ map/pc.c (working copy)
@@ -3444,6 +3444,7 @@
	clif_updatestatus(sd,SP_WEIGHT);
	//Auto-equip
	if(data->flag.autoequip) pc_equipitem(sd, i, data->equip);
+	if(data->type == IT_CHARM) status_calc_pc(sd,0);//dh
	return 0;

To:

if (id->type == IT_CHARM) status_calc_pc(sd, SCO_NONE); //dh

Now the next part:

@@ -3470,6 +3473,8 @@
	if(!(type&2))
		clif_updatestatus(sd,SP_WEIGHT);

+	if(mem == IT_CHARM) status_calc_pc(sd,0);//dh
+
return 0;

To:

if(mem == IT_CHARM) status_calc_pc(sd, SCO_NONE);//dh

 

map/itemdb.cpp

	id->type = atoi(str[3]);

-	if( id->type < 0 || id->type == IT_UNKNOWN || id->type == IT_UNKNOWN2 || ( id->type > IT_DELAYCONSUME && id->type < IT_CASH ) || id->type >= IT_MAX )
+	if( id->type < 0 || id->type == IT_UNKNOWN || id->type == IT_UNKNOWN2 || ( id->type > IT_CHARM && id->type < IT_CASH ) || id->type >= IT_MAX )
	{// catch invalid item types
		ShowWarning("itemdb_parse_dbrow: Invalid item type %d for item %d. IT_ETC will be used.\n", id->type, nameid);
		id->type = IT_ETC;

TO:

if( id->type < 0 || id->type == IT_UNKNOWN || id->type == IT_UNKNOWN2 || ( id->type > IT_SHADOWGEAR && id->type < IT_CASH && id->type > IT_CHARM ) ||  id->type >= IT_MAX  )

I don't know about this part but... still working. 

 

db/import/itemdb.txt

#####,Charm,Charm,12,50,,0,,,,,0xFFFFFFFF,15,2,,,60,,,{ bonus bAllStats,100; },{},{}

TO:

30050,Charm,Charm,13,6,,0,,,,,0xFFFFFFFF,15,2,,,1,,,{bonus bStr,2; },{},{}

Change to your ID.

 

image.png.e9727dfb5a4c5f5d6a5c8b968e0f1b92.png

thx work like a charm 😀

Link to comment
Share on other sites

Hello can anyone help? 

[Warning]: Item 40315 (Lucky Charm of Strength) is an equipment with no equip-field! Making it an etc item.
 

png-transparent-paper-parchment-scroll-others-orange-parchment-scroll.png

Link to comment
Share on other sites

does this work on latest rathena who uses itemdb.yml isntead of text ? im getting the error on the item 

"IInvalid item equip location as it has no equip location, defaulting to IT_ETC"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.