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ß