Jump to content
  • 0

Costume converter debug.


Question

Posted

I used this script which i got from another topic, but after i apply it,

nothing happens. the npc is there but once i click him nothing happens.

i checked every line to find an unclosed statement but its all good.

would anyone of you know what i can do to get this to work?

 

// -------------------------------------------------------------------------------
// 	Script Name : Headgear to Costume converter >> Costume to Headgear converter
// -------------------------------------------------------------------------------
// Description :
// - Allows a user to convert the equipped headgear (on Top, Mid or Low) into a
//   costume item. It will remove any card and refine of the Item.
// - Allows a user to restore the equipped costume headgear (on Top, Mid or Low)
//   into its original form. It will not return any card or refine of the item.
// -------------------------------------------------------------------------------
prt_in.gat,156,67,5	script	Costume	715,{

		if (countitem(512) >= 1) goto L_Clown; // you need 1 apple to use the clown
	mes "[Clown]";
	mes "You don't have any requirements to use this";
	close;

L_Clown:	
	mes "[Clown]";
	mes "Here you can convert your headgears into a Costume Headgear or restore to its Original form.";
	switch(select("I want to convert.:I want to restore.:No thanks.")) {
	case 1:
			next;
			mes "Please, select what to convert.";
			mes "Remember, cards and refine will be removed.";
			next;
				setarray .@Position$[1],"Top","Mid","Low";
				setarray .@Position[1],     1,    9,   10;
				set .@Menu$,"";
			for( set .@i, 1; .@i < 5; set .@i, .@i + 1 )
			{
				if( getequipisequiped(.@Position[.@i]) )
				set .@Menu$, .@Menu$ + .@Position$[.@i] + "-" + "[" + getequipname(.@Position[.@i]) + "]";
				set .@Menu$, .@Menu$ + ":";
			}
			set .@Part, .@Position[ select(.@Menu$) ];
			if( !getequipisequiped(.@Part) )
			{
				mes "[Clown]";
				mes "Your not wearing anything there...";
				close;
			}
			mes "[Clown]";
			mes "You want to Costume your " + getitemname(getequipid(.@Part)) + "?";
			next;
			if( select("Yes, proceed:No, I am sorry.") == 2 )
			{
				mes "[Clown]";
				mes "Need some time to think about it, huh?";
				mes "Alright, I can understand.";
				close;
			}
			costume .@Part; // Convert the Headgear
			mes "[Clown]";
			mes "Done, enjoy your costume headgear.";
			close;
	case 2:
			next;
			mes "Please, select what to restore.";
			mes "Remember, I will only restore it back without refine and cards.";
			next;
				setarray .@Position$[1],"Top","Mid","Low";
				setarray .@Position[1],     13,    12,   11;
				set .@Menu$,"";
			for( set .@i, 1; .@i < 5; set .@i, .@i + 1 )
			{
				if( getequipisequiped(.@Position[.@i]) )
				set .@Menu$, .@Menu$ + .@Position$[.@i] + "-" + "[" + getequipname(.@Position[.@i]) + "]";
				set .@Menu$, .@Menu$ + ":";
			}
			set .@Part, .@Position[ select(.@Menu$) ];
			if( !getequipisequiped(.@Part) )
			{
				mes "[Clown]";
				mes "Your not wearing anything there...";
				close;
			}
			mes "[Clown]";
			mes "You want to restore your " + getitemname(getequipid(.@Part)) + "?";
			next;
			if( select("Yes, proceed:No, I am sorry.") == 2 )
			{
				mes "[Clown]";
				mes "Need some time to think about it, huh?";
				mes "Alright, I can understand.";
				close;
			}
			a = getequipid(.@Part);			
			delitem a,1;
			getitem a,1;
			delitem 512,1;
			mes "[Clown]";
			mes "Done, enjoy your restored headgear.";
			close;
	case 3:
		mes "[Clown]";
		mes "Very well. Return at once if you seek my services.";
		close;
	}
}

 

8 answers to this question

Recommended Posts

Posted

prt_in.gat,156,67,5    script    Costume    715,{

change it to

prt_in,156,67,5    script    Costume    715,{

 I did this, but still the same thing, nothing happens when i click the npc

Posted (edited)

oh sorry, forget about that one.
 
my map-server says that there's something wrong with this line:

costume .@Part; // Convert the Headgear

you may have a clue there. What exactly you want to do there?
 
also, it's better for you to use
close2;
end;

 
instead of
close;
Edited by Winz
Posted

There is no rAthena script command such as this :

costume .@Part; // Convert the Headgear

 

Apply this patch or download it via the attachment of the topic starter of this link ( http://rathena.org/board/topic/82370-costume-npc-and-costumeitem/ )

Index: atcommand.c
===================================================================
--- atcommand.c    (revision 17306)
+++ atcommand.c    (working copy)
@@ -1117,7 +1117,7 @@
 ACMD_FUNC(item)
 {
     char item_name[100];
-    int number = 0, item_id, flag = 0;
+    int number = 0, item_id, flag = 0, costume = 0;
     struct item item_tmp;
     struct item_data *item_data;
     int get_count, i;
@@ -1142,7 +1142,27 @@
         clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
         return -1;
     }
-
+    
+    if( !strcmpi(command+1,"costumeitem") )
+    {
+        if( !battle_config.reserved_costume_id )
+        {
+            clif_displaymessage(fd, "Costume convertion is disable. Set a value for reserved_cosutme_id on your battle.conf file.");
+            return -1;
+        }
+        if( !(item_data->equip&EQP_HEAD_LOW) &&
+            !(item_data->equip&EQP_HEAD_MID) &&
+            !(item_data->equip&EQP_HEAD_TOP) &&
+            !(item_data->equip&EQP_COSTUME_HEAD_LOW) &&
+            !(item_data->equip&EQP_COSTUME_HEAD_MID) &&
+            !(item_data->equip&EQP_COSTUME_HEAD_TOP) )
+        {
+            clif_displaymessage(fd, "You cannot costume this item. Costume only work for headgears.");
+            return -1;
+        }
+        costume = 1;
+    }
+    
     item_id = item_data->nameid;
     get_count = number;
     //Check if it's stackable.
@@ -1155,7 +1175,13 @@
             memset(&item_tmp, 0, sizeof(item_tmp));
             item_tmp.nameid = item_id;
             item_tmp.identify = 1;
-
+            if( costume == 1 )
+            { // Costume Item
+                item_tmp.card[0] = CARD0_CREATE;
+                item_tmp.card[2] = GetWord(battle_config.reserved_costume_id, 0);
+                item_tmp.card[3] = GetWord(battle_config.reserved_costume_id, 1);
+            }
+            
             if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
                 clif_additem(sd, 0, 0, flag);
         }
@@ -9251,7 +9277,9 @@
         ACMD_DEF(channel),
         ACMD_DEF(fontcolor),
         ACMD_DEF(langtype),
-        ACMD_DEF(reloadmsgconf)
+        ACMD_DEF(reloadmsgconf),
+        ACMD_DEF2("costumeitem", item)
+        
     };
     AtCommandInfo* atcommand;
     int i;
Index: battle.c
===================================================================
--- battle.c    (revision 17306)
+++ battle.c    (working copy)
@@ -5939,6 +5939,7 @@
     { "item_enabled_npc",                   &battle_config.item_enabled_npc,                1,      0,      1,              },
     { "item_flooritem_check",               &battle_config.item_onfloor,                    1,      0,      1,              },
     { "bowling_bash_area",                  &battle_config.bowling_bash_area,               0,      0,      20,             },
+    { "reserved_costume_id",                &battle_config.reserved_costume_id,             999998, 0,      INT_MAX,        },
 };
 #ifndef STATS_OPT_OUT
 /**
Index: battle.h
===================================================================
--- battle.h    (revision 17306)
+++ battle.h    (working copy)
@@ -488,6 +488,10 @@
     int item_enabled_npc;
     int item_onfloor; // Whether to drop an undroppable item on the map or destroy it if inventory is full.
     int bowling_bash_area;
+    
+    // Costume System
+    int reserved_costume_id;
+    
     } battle_config;


 void do_init_battle(void);
Index: map.c
===================================================================
--- map.c    (revision 17306)
+++ map.c    (working copy)
@@ -1537,7 +1537,13 @@
     struct map_session_data* tsd;


     nullpo_retv(sd);
-
+    
+    if( battle_config.reserved_costume_id && battle_config.reserved_costume_id == charid )
+    {
+        clif_solved_charname(sd->fd, charid, "Costume");
+        return;
+    }
+    
     tsd = map_charid2sd(charid);
     if( tsd )
     {
Index: pc.c
===================================================================
--- pc.c    (revision 17306)
+++ pc.c    (working copy)
@@ -66,8 +66,7 @@
 struct fame_list chemist_fame_list[MAX_FAME_LIST];
 struct fame_list taekwon_fame_list[MAX_FAME_LIST];


-static unsigned short equip_pos[EQI_MAX]={EQP_ACC_L,EQP_ACC_R,EQP_SHOES,EQP_GARMENT,EQP_HEAD_LOW,EQP_HEAD_MID,EQP_HEAD_TOP,EQP_ARMOR,EQP_HAND_L,EQP_HAND_R,EQP_COSTUME_HEAD_TOP,EQP_COSTUME_HEAD_MID,EQP_COSTUME_HEAD_LOW,EQP_COSTUME_GARMENT,EQP_AMMO};
-
+static unsigned short equip_pos[EQI_MAX]={EQP_ACC_L,EQP_ACC_R,EQP_SHOES,EQP_GARMENT,EQP_HEAD_LOW,EQP_HEAD_MID,EQP_HEAD_TOP,EQP_ARMOR,EQP_HAND_L,EQP_HAND_R,EQP_AMMO,EQP_COSTUME_HEAD_TOP,EQP_COSTUME_HEAD_MID,EQP_COSTUME_HEAD_LOW,EQP_COSTUME_GARMENT};
 #define MOTD_LINE_SIZE 128
 static char motd_text[MOTD_LINE_SIZE][CHAT_SIZE_MAX]; // Message of the day buffer [Valaris]


@@ -586,7 +585,7 @@


 int pc_equippoint(struct map_session_data *sd,int n)
 {
-    int ep = 0;
+    int ep = 0, char_id = 0;


     nullpo_ret(sd);


@@ -604,6 +603,15 @@
             (sd->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO))//Kagerou and Oboro can dual wield daggers. [Rytech]
             return EQP_ARMS;
     }
+    
+    if( battle_config.reserved_costume_id &&
+        sd->status.inventory[n].card[0] == CARD0_CREATE &&
+        (char_id = MakeDWord(sd->status.inventory[n].card[2],sd->status.inventory[n].card[3])) == battle_config.reserved_costume_id )
+    { // Costume Item - Converted
+        if( ep&EQP_HEAD_TOP ) { ep &= ~EQP_HEAD_TOP; ep |= EQP_COSTUME_HEAD_TOP; }
+        if( ep&EQP_HEAD_LOW ) { ep &= ~EQP_HEAD_LOW; ep |= EQP_COSTUME_HEAD_LOW; }
+        if( ep&EQP_HEAD_MID ) { ep &= ~EQP_HEAD_MID; ep |= EQP_COSTUME_HEAD_MID; }
+    }
     return ep;
 }


@@ -1910,8 +1918,8 @@
                 if( autobonus[i].bonus_script )
                 {
                     int j;
-                    ARR_FIND( 0, EQI_MAX-1, j, sd->equip_index[j] >= 0 && sd->status.inventory[sd->equip_index[j]].equip == autobonus[i].pos );
-                    if( j < EQI_MAX-1 )
+                    ARR_FIND( 0, EQI_MAX_BONUS, j, sd->equip_index[j] >= 0 && sd->status.inventory[sd->equip_index[j]].equip == autobonus[i].pos );
+                    if( j < EQI_MAX_BONUS )
                         script_run_autobonus(autobonus[i].bonus_script,sd->bl.id,sd->equip_index[j]);
                 }
                 continue;
@@ -1941,8 +1949,8 @@
     if( autobonus->other_script )
     {
         int j;
-        ARR_FIND( 0, EQI_MAX-1, j, sd->equip_index[j] >= 0 && sd->status.inventory[sd->equip_index[j]].equip == autobonus->pos );
-        if( j < EQI_MAX-1 )
+        ARR_FIND( 0, EQI_MAX_BONUS, j, sd->equip_index[j] >= 0 && sd->status.inventory[sd->equip_index[j]].equip == autobonus->pos );
+        if( j < EQI_MAX_BONUS )
             script_run_autobonus(autobonus->other_script,sd->bl.id,sd->equip_index[j]);
     }


Index: pc.h
===================================================================
--- pc.h    (revision 17306)
+++ pc.h    (working copy)
@@ -37,11 +37,12 @@
     EQI_ARMOR,
     EQI_HAND_L,
     EQI_HAND_R,
+    EQI_AMMO,
+    EQI_MAX_BONUS = 10,
     EQI_COSTUME_TOP,
     EQI_COSTUME_MID,
     EQI_COSTUME_LOW,
     EQI_COSTUME_GARMENT,
-    EQI_AMMO,
     EQI_MAX
 };


Index: script.c
===================================================================
--- script.c    (revision 17306)
+++ script.c    (working copy)
@@ -17596,6 +17596,52 @@
     return 0;
 }


+/*==========================================
+ * Costume Items
+ *------------------------------------------*/
+BUILDIN_FUNC(costume)
+{
+    int i = -1, num, ep;
+    TBL_PC *sd;
+
+    num = script_getnum(st,2); // Equip Slot
+    sd = script_rid2sd(st);
+
+    if( sd == NULL )
+        return 0;
+    if( num > 0 && num <= ARRAYLENGTH(equip) )
+        i = pc_checkequip(sd, equip[num - 1]);
+    if( i < 0 )
+        return 0;
+
+    ep = sd->status.inventory[i].equip;
+    if( !(ep&EQP_HEAD_LOW) && !(ep&EQP_HEAD_MID) && !(ep&EQP_HEAD_TOP) )
+        return 0;
+
+    log_pick_pc(sd, LOG_TYPE_SCRIPT, -1, &sd->status.inventory[i]);
+    pc_unequipitem(sd,i,2);
+    clif_delitem(sd,i,1,3);
+    // --------------------------------------------------------------------
+    sd->status.inventory[i].refine = 0;
+    sd->status.inventory[i].attribute = 0;
+    sd->status.inventory[i].card[0] = CARD0_CREATE;
+    sd->status.inventory[i].card[1] = 0;
+    sd->status.inventory[i].card[2] = GetWord(battle_config.reserved_costume_id, 0);
+    sd->status.inventory[i].card[3] = GetWord(battle_config.reserved_costume_id, 1);
+
+    if( ep&EQP_HEAD_TOP ) { ep &= ~EQP_HEAD_TOP; ep |= EQP_COSTUME_HEAD_TOP; }
+    if( ep&EQP_HEAD_LOW ) { ep &= ~EQP_HEAD_LOW; ep |= EQP_COSTUME_HEAD_LOW; }
+    if( ep&EQP_HEAD_MID ) { ep &= ~EQP_HEAD_MID; ep |= EQP_COSTUME_HEAD_MID; }
+    // --------------------------------------------------------------------
+    log_pick_pc(sd, LOG_TYPE_SCRIPT, 1, &sd->status.inventory[i]);
+
+    clif_additem(sd,i,1,0);
+    pc_equipitem(sd,i,ep);
+    clif_misceffect(&sd->bl,3);
+
+    return 0;
+}
+
 // declarations that were supposed to be exported from npc_chat.c
 #ifdef PCRE_SUPPORT
 BUILDIN_FUNC(defpattern);
@@ -18060,5 +18106,9 @@
     BUILDIN_DEF(checkquest, "i?"),
     BUILDIN_DEF(changequest, "ii"),
     BUILDIN_DEF(showevent, "ii"),
+    
+    // Costume System
+    BUILDIN_DEF(costume,"i"),
+    
     {NULL,NULL,NULL},
 };
Index: status.c
===================================================================
--- status.c    (revision 17306)
+++ status.c    (working copy)
@@ -2455,7 +2455,7 @@
     pc_delautobonus(sd,sd->autobonus3,ARRAYLENGTH(sd->autobonus3),true);


     // Parse equipment.
-    for(i=0;i<EQI_MAX-1;i++) {
+    for(i=0;i<EQI_MAX_BONUS;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)
             continue;
Index: battle.conf
===================================================================
--- battle.conf    (revision 17306)
+++ battle.conf    (working copy)
@@ -141,3 +141,9 @@
 // range. For example, Sonic Blow requires a 2 cell distance before autocasting is allowed.
 // This setting also affects autospellwhenhit.
 autospell_check_range: no
+
+// ****************************************
+// Reserved Costume ID's
+// ****************************************
+// Reserved Char ID for costume converted items.
+reserved_costume_id: 999998

Join the conversation

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

Guest
Answer this question...

×   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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...