Jump to content

passive Item Script - aus dem Inventar heraus


a7fa7fa

Recommended Posts


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  3
  • Reputation:   0
  • Joined:  02/15/12
  • Last Seen:  

Hallo zusammen,

mein erster Post hier in dem Forum :) Hab hier schon sehr viel Hilfe gefunden, doch zu meinem Problem find ich keinen Threat.

Zu meinem Problem: Ich habe Versucht, dass Items aus dem Inventar heraus ein Script wirken können ohne euipt zu sein.

Hierfür habe ich die src modifiziert und einen neuen Item Typ erstellt(Typ 12). Ich habe mich dafür an diesen Guide hier angelehnt: http://www.eathena.ws/board/index.php?showtopic=246304

Doch der ist noch von eathena und die src von rathena hat sich verändert und ich musste ein par Anpassungen durchführen (Konstantendeklaration in Returnstatement, anstatt eines einfachen Konstantendefiners etc.).

Hier meine kompletten änderungen:

--- src/common/mmo.h 2011-12-27 22:09:51.727946899 +0500
+++ src/common/mmo.h 2011-12-28 15:29:55.193120002 +0500
@@ -178,6 +178,7 @@
 IT_UNKNOWN2,//9
 IT_AMMO,    //10
 IT_DELAYCONSUME,//11
+ IT_PASSEQU,//12
 IT_THROWWEAPON= 17,//17
 IT_CASH = 18,
 IT_MAX
--- src/map/clif.c 2011-12-28 10:44:28.209120003 +0500
+++ src/map/clif.c 2011-12-28 15:39:13.405120002 +0500
@@ -60,7 +60,7 @@
//Converts item type in case of pet eggs.
static inline int itemtype(int type)
{
- return ( type == IT_PETEGG ) ? IT_WEAPON : type;
+ return ( type == IT_PETEGG ) ? IT_WEAPON : ( type == IT_PASSEQU ) ? IT_ETC : type;
}

--- src/map/pc.c 2011-12-26 10:23:31.255420000 +0500
+++ src/map/pc.c 2011-12-28 15:29:55.221120002 +0500
@@ -3457,6 +3457,7 @@
 clif_updatestatus(sd,SP_WEIGHT);
 //Auto-equip
 if(data->flag.autoequip) pc_equipitem(sd, i, data->equip);
+ if(sd->inventory_data[i]->type == IT_PASSEQU) status_calc_pc(sd,0);
 return 0;
}

@@ -3465,6 +3466,7 @@
 *------------------------------------------*/
int pc_delitem(struct map_session_data *sd,int n,int amount,int type, short reason)
{
+ int mem=0;
 nullpo_retr(1, sd);

 if(sd->status.inventory[n].nameid==0 || amount <= 0 || sd->status.inventory[n].amount<amount || sd->inventory_data[n] == NULL)
@@ -3475,6 +3477,7 @@
 if(sd->status.inventory[n].amount<=0){
  if(sd->status.inventory[n].equip)
   pc_unequipitem(sd,n,3);
+  mem = sd->inventory_data[n]->type;
  memset(&sd->status.inventory[n],0,sizeof(sd->status.inventory[0]));
  sd->inventory_data[n] = NULL;
 }
@@ -3483,6 +3486,8 @@
 if(!(type&2))
  clif_updatestatus(sd,SP_WEIGHT);
+ if(mem == IT_PASSEQU) status_calc_pc(sd,0);
 return 0;
}

--- src/map/status.c 2011-12-26 10:23:31.247420000 +0500
+++ src/map/status.c 2011-12-28 15:29:55.225120002 +0500
@@ -2176,6 +2176,18 @@
 pc_delautobonus(sd,sd->autobonus3,ARRAYLENGTH(sd->autobonus3),true);

 // Parse equipment.
+ for(i=0;i<MAX_INVENTORY;i++){
+		    if(!sd->inventory_data[i])
+			    continue;
+	    if(sd->inventory_data[i]->type == IT_PASSEQU){
+			    if(sd->inventory_data[i]->script && sd->inventory_data[i]->elv <=sd->status.base_level) {
+			    if((!((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))) continue;		   
+				    run_script(sd->inventory_data[i]->script,0,sd->bl.id,0);
+			    if (!calculating) //Abort, run_script retriggered this. [skotlex]
+				    return 1;
+			    }}}
+
 for(i=0;i<EQI_MAX-1;i++) {
  current_equip_item_index = index = sd->equip_index[i]; //We pass INDEX to current_equip_item_index - for EQUIP_SCRIPT (new cards solution) [Lupus]
  if(index < 0)

Ich verwende die SQL Item_db und mein Item sieht so aus:

25001,blu,bla,12,50,,70,,,,,4294967295,7,2,,,60,,,{ bonus bDex,2; },{},{}

Der Typ 12 ist in der src von mir neu defiert worden, ansonsten sollten eigentlich alle Attribute klar sein.

Beim compilen und serverstarten treten keine Probleme auf. Auch wirft das Item keinen Fehler, wenn ich es im Spiel, im Inventar habe und es mir ansehe, droppe etc. Das ItemScript wird schlicht weg einfach ignoriert.

Ich hatte schon mit dem gedanken gespielt, alles über einen Script zu laufen zu lassen (Inventar nach Item abfragen und loopen), doch hat man da nicht die Freiheit so Bonus zu vegeben, wie es die ItemBonusCommands hergeben. Höchstens über atcommands, doch diese werden nicht als Bonus gezählt, sondern als absolute Statveränderung. Zudem ist das keine performante Lösung.

Server läuft auf svn 15584. Ich habe ansonsten keine weiteren srcMods eingebaut.

Ich hoffe mir kann jemand helfen

Gruß

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  57
  • Reputation:   15
  • Joined:  12/25/11
  • Last Seen:  

Soweit alles korrekt, aber es scheinen noch ein paar kleine Modifikationen zu fehlen. Versuch die entsprechenden Änderungen aus diesem Posting vorzunehmen: http://www.eathena.ws/board/index.php?s=&showtopic=246304&view=findpost&p=1503344

Sollte dann funktionieren, kann es leider derzeit nicht selbst testen.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  3
  • Reputation:   0
  • Joined:  02/15/12
  • Last Seen:  

Haha, hätte den Thread auch selber weiterlesen können. Aber vielen dank für den Hinweis :D

Es funktioniert jetzt einwandfrei. Falls sich jemand dafür interessiert, hier sind die änderungen für 15584.

--- src/common/mmo.h 2011-12-27 22:09:51.727946899 +0500
+++ src/common/mmo.h 2011-12-28 15:29:55.193120002 +0500
@@ -178,6 +178,7 @@
 IT_UNKNOWN2,//9
 IT_AMMO,    //10
 IT_DELAYCONSUME,//11
+ IT_PASSEQU,//12
 IT_THROWWEAPON= 17,//17
 IT_CASH = 18,
 IT_MAX
--- src/map/clif.c 2011-12-28 10:44:28.209120003 +0500
+++ src/map/clif.c 2011-12-28 15:39:13.405120002 +0500
@@ -60,7 +60,7 @@
//Converts item type in case of pet eggs.
static inline int itemtype(int type)
{
- return ( type == IT_PETEGG ) ? IT_WEAPON : type;
+ return ( type == IT_PETEGG ) ? IT_WEAPON : ( type == IT_PASSEQU ) ? IT_ETC : type;
}[/font][/color]

[color=#282828][font=helvetica, arial, sans-serif]--- src/map/pc.c 2011-12-26 10:23:31.255420000 +0500
+++ src/map/pc.c 2011-12-28 15:29:55.221120002 +0500
@@ -3457,6 +3457,7 @@
 clif_updatestatus(sd,SP_WEIGHT);
 //Auto-equip
 if(data->flag.autoequip) pc_equipitem(sd, i, data->equip);
+ if(data->type == IT_PASSEQU) status_calc_pc(sd,0);//dh
 return 0;
}

@@ -3465,6 +3466,7 @@
 *------------------------------------------*/
int pc_delitem(struct map_session_data *sd,int n,int amount,int type, short reason)
{
+ int mem=0;
 nullpo_retr(1, sd);

 if(sd->status.inventory[n].nameid==0 || amount <= 0 || sd->status.inventory[n].amount<amount || sd->inventory_data[n] == NULL)
@@ -3475,6 +3477,7 @@
 if(sd->status.inventory[n].amount<=0){
  if(sd->status.inventory[n].equip)
   pc_unequipitem(sd,n,3);
+  mem = sd->inventory_data[n]->type;
  memset(&sd->status.inventory[n],0,sizeof(sd->status.inventory[0]));
  sd->inventory_data[n] = NULL;
 }
@@ -3483,6 +3486,8 @@
 if(!(type&2))
  clif_updatestatus(sd,SP_WEIGHT);

+ if(mem == IT_PASSEQU) status_calc_pc(sd,0);
+
 return 0;
}

--- src/map/status.c 2011-12-26 10:23:31.247420000 +0500
+++ src/map/status.c 2011-12-28 15:29:55.225120002 +0500
@@ -2176,6 +2176,18 @@
 pc_delautobonus(sd,sd->autobonus3,ARRAYLENGTH(sd->autobonus3),true);

 // Parse equipment.
+ for ( i=0; i < MAX_INVENTORY; i++ ) {  //dh
+  if ( !sd->inventory_data[i] || sd->inventory_data[i]->type != IT_PASSEQU )
+   continue;
+  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 ) {
+   run_script( sd->inventory_data[i]->script, 0, sd->bl.id, 0 );
+   if ( !calculating ) //Abort, run_script retriggered this. [skotlex]
+    return 1;
+  }
+ }
+
 for(i=0;i<EQI_MAX-1;i++) {
  current_equip_item_index = index = sd->equip_index[i]; //We pass INDEX to current_equip_item_index - for EQUIP_SCRIPT (new cards solution) [Lupus]
  if(index < 0)[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif] 
--- map/itemdb.c 2011-12-26 10:23:31.247420000 +0500
+++ map/itemdb.c 2011-12-28 15:29:55.225120002 +0500
@@ -196,6 +196,7 @@
  case IT_PETARMOR:	   return "Pet Accessory";
  case IT_AMMO:		   return "Arrow/Ammunition";
  case IT_DELAYCONSUME:   return "Delay-Consume Usable";
+  case IT_PASSEQU:		  return "Charms";
  case IT_CASH:		   return "Cash Usable";
 }
 return "Unknown Type";
@@ -371,6 +372,7 @@
   case IT_ARMOR:
   case IT_PETEGG:
   case IT_PETARMOR:
+   case IT_PASSEQU:
 return 0;
   default:
 return 1;
@@ -388,6 +390,7 @@
   case IT_ARMOR:
   case IT_PETEGG:
   case IT_PETARMOR:
+   case IT_PASSEQU:
 return 0;
   default:
 return 1;
@@ -736,7 +739,7 @@

 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_PASSEQU && 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;
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...