Advertisement
Sehrentos

rAthena diff patch - Costume NPC and @costumeitem

Apr 30th, 2015
1,653
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 9.75 KB | None | 0 0
  1. diff --git a/conf/battle/battle.conf b/conf/battle/battle.conf
  2. index 593d4e9..74c35e2 100644
  3. --- a/conf/battle/battle.conf
  4. +++ b/conf/battle/battle.conf
  5. @@ -158,3 +158,10 @@ warg_can_falcon: no
  6.  // Should the target be able of dodging damage by snapping away to the edge of the screen?
  7.  // Official behavior is "no"
  8.  snap_dodge: no
  9. +
  10. +// Costume item edit
  11. +// Reserved Char ID for costume converted items.
  12. +// 0 = Disable
  13. +// If you change this later, then all converted/created costumeitem's will
  14. +// turn back to normal items with a 'Unknown's ...' name and no socket in it.
  15. +reserved_costume_id: 1
  16. \ No newline at end of file
  17. diff --git a/npc/custom/sehrentos/costumer.txt b/npc/custom/sehrentos/costumer.txt
  18. new file mode 100644
  19. index 0000000..803a9be
  20. --- /dev/null
  21. +++ b/npc/custom/sehrentos/costumer.txt
  22. @@ -0,0 +1,43 @@
  23. +// ======================================
  24. +// Costumer npc
  25. +// 27-04-2015
  26. +// Convert headgear into costume items.
  27. +// refine & cards will be lost!
  28. +// ======================================
  29. +prontera,149,214,4 script  Costumer#cs_0   421,{
  30. +   mes "[ "+strnpcinfo(1)+" ]";
  31. +   mes "What headgear would you like to convert into costume?";
  32. +   mes "^ff0000Warning!^000000";
  33. +   mes "Converted item will lose all refine and cards compounded in them.";
  34. +   next;
  35. +   setarray .@Position$[1],"Top","Mid","Low";
  36. +   setarray .@Position[1],     1,    9,   10;
  37. +   set .@Menu$,"";
  38. +   for( set .@i, 1; .@i < 5; set .@i, .@i + 1 )
  39. +   {
  40. +       if( getequipisequiped(.@Position[.@i]) )
  41. +       set .@Menu$, .@Menu$ + .@Position$[.@i] + "-" + "[" + getequipname(.@Position[.@i]) + "]";
  42. +       set .@Menu$, .@Menu$ + ":";
  43. +   }
  44. +   set .@Part, .@Position[ select(.@Menu$) ];
  45. +   if( !getequipisequiped(.@Part) )
  46. +   {
  47. +       mes "[ " + strnpcinfo(1) + " ]";
  48. +       mes "Your not wearing anything there...";
  49. +       close;
  50. +   }
  51. +   mes "[ "+strnpcinfo(1)+" ]";
  52. +   mes "You want to Costume your " + getitemname(getequipid(.@Part)) + "?";
  53. +   next;
  54. +   if( select("Yes, proceed:No, I am sorry.") == 2 )
  55. +   {
  56. +       mes "[ "+strnpcinfo(1)+" ]";
  57. +       mes "Need some time to think about it, huh?";
  58. +       mes "Alright, I can understand.";
  59. +       close;
  60. +   }
  61. +   costume .@Part; // Convert the Headgear
  62. +   mes "[ "+strnpcinfo(1)+" ]";
  63. +   mes "Done, enjoy your costume headgear.";
  64. +   close;
  65. +}
  66. \ No newline at end of file
  67. diff --git a/src/map/atcommand.c b/src/map/atcommand.c
  68. index d7e318a..f0d5247 100644
  69. --- a/src/map/atcommand.c
  70. +++ b/src/map/atcommand.c
  71. @@ -1198,7 +1198,7 @@ static void warp_get_suggestions(struct map_session_data* sd, const char *name)
  72.  ACMD_FUNC(item)
  73.  {
  74.     char item_name[100];
  75. -   int number = 0, bound = BOUND_NONE;
  76. +   int number = 0, bound = BOUND_NONE, costume = 0; // Costume item edit
  77.     char flag = 0;
  78.     struct item item_tmp;
  79.     struct item_data *item_data[10];
  80. @@ -1237,6 +1237,24 @@ static void warp_get_suggestions(struct map_session_data* sd, const char *name)
  81.             clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  82.             return -1;
  83.         }
  84. +       // Costume item edit
  85. +       if (!strcmpi(command + 1, "costumeitem")) {
  86. +           if (!battle_config.reserved_costume_id) {
  87. +               clif_displaymessage(fd, "Costume convertion is disabled.");
  88. +               return -1;
  89. +           }
  90. +           if (!(item_data[j]->equip&EQP_HEAD_LOW) &&
  91. +               !(item_data[j]->equip&EQP_HEAD_MID) &&
  92. +               !(item_data[j]->equip&EQP_HEAD_TOP) &&
  93. +               !(item_data[j]->equip&EQP_COSTUME_HEAD_LOW) &&
  94. +               !(item_data[j]->equip&EQP_COSTUME_HEAD_MID) &&
  95. +               !(item_data[j]->equip&EQP_COSTUME_HEAD_TOP))
  96. +           {
  97. +               clif_displaymessage(fd, "You cannot costume this item. Costume only work for headgears.");
  98. +               return -1;
  99. +           }
  100. +           costume = 1;
  101. +       } // end edit
  102.         itemlist = strtok(NULL, ":"); //next itemline
  103.         j++;
  104.     }
  105. @@ -1258,6 +1276,14 @@ static void warp_get_suggestions(struct map_session_data* sd, const char *name)
  106.                 item_tmp.nameid = item_id;
  107.                 item_tmp.identify = 1;
  108.                 item_tmp.bound = bound;
  109. +
  110. +               // Costume item edit
  111. +               if (costume == 1) {
  112. +                   item_tmp.card[0] = CARD0_CREATE;
  113. +                   item_tmp.card[2] = GetWord(battle_config.reserved_costume_id, 0);
  114. +                   item_tmp.card[3] = GetWord(battle_config.reserved_costume_id, 1);
  115. +               } // End edit
  116. +
  117.                 if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  118.                     clif_additem(sd, 0, 0, flag);
  119.             }
  120. @@ -9994,6 +10020,7 @@ void atcommand_basecommands(void) {
  121.         ACMD_DEF(costume),
  122.         ACMD_DEF(cloneequip),
  123.         ACMD_DEF(clonestat),
  124. +       ACMD_DEF2("costumeitem", item) // Costume item edit
  125.     };
  126.     AtCommandInfo* atcommand;
  127.     int i;
  128. diff --git a/src/map/battle.c b/src/map/battle.c
  129. index ecb15fc..e94fb86 100644
  130. --- a/src/map/battle.c
  131. +++ b/src/map/battle.c
  132. @@ -8015,6 +8015,7 @@ bool battle_check_range(struct block_list *src, struct block_list *bl, int range
  133.     { "homunculus_evo_intimacy_need",       &battle_config.homunculus_evo_intimacy_need,    91100,  0,      INT_MAX,        },
  134.     { "homunculus_evo_intimacy_reset",      &battle_config.homunculus_evo_intimacy_reset,   1000,   0,      INT_MAX,        },
  135.     { "monster_loot_search_type",           &battle_config.monster_loot_search_type,        1,      0,      1,              },
  136. +   { "reserved_costume_id", &battle_config.reserved_costume_id, 1, 0, INT_MAX, }, // Costume item edit
  137.  };
  138.  
  139.  #ifndef STATS_OPT_OUT
  140. diff --git a/src/map/battle.h b/src/map/battle.h
  141. index a880661..3cffbc5 100644
  142. --- a/src/map/battle.h
  143. +++ b/src/map/battle.h
  144. @@ -589,6 +589,7 @@ extern struct Battle_Config
  145.     int homunculus_evo_intimacy_need;
  146.     int homunculus_evo_intimacy_reset;
  147.     int monster_loot_search_type;
  148. +   int reserved_costume_id; // Costume item edit
  149.  } battle_config;
  150.  
  151.  void do_init_battle(void);
  152. diff --git a/src/map/map.c b/src/map/map.c
  153. index d9c0b0b..0f383b6 100644
  154. --- a/src/map/map.c
  155. +++ b/src/map/map.c
  156. @@ -1644,6 +1644,13 @@ void map_reqnickdb(struct map_session_data * sd, int charid)
  157.  
  158.     nullpo_retv(sd);
  159.  
  160. +   // Costume item edit
  161. +   if (battle_config.reserved_costume_id && battle_config.reserved_costume_id == charid)
  162. +   {
  163. +       clif_solved_charname(sd->fd, charid, "Costume");
  164. +       return;
  165. +   } //end
  166. +
  167.     tsd = map_charid2sd(charid);
  168.     if( tsd )
  169.     {
  170. diff --git a/src/map/pc.c b/src/map/pc.c
  171. index da9285c..54f7a79 100755
  172. --- a/src/map/pc.c
  173. +++ b/src/map/pc.c
  174. @@ -678,7 +678,7 @@ void pc_setnewpc(struct map_session_data *sd, uint32 account_id, uint32 char_id,
  175.  * @param n Equip index in inventory
  176.  */
  177.  int pc_equippoint(struct map_session_data *sd,int n){
  178. -   int ep = 0;
  179. +   int ep = 0, char_id = 0; // Costume item edit
  180.  
  181.     nullpo_ret(sd);
  182.  
  183. @@ -696,6 +696,17 @@ int pc_equippoint(struct map_session_data *sd,int n){
  184.             (sd->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO))//Kagerou and Oboro can dual wield daggers. [Rytech]
  185.             return EQP_ARMS;
  186.     }
  187. +
  188. +   // Costume item edit
  189. +   if (battle_config.reserved_costume_id &&
  190. +       sd->status.inventory[n].card[0] == CARD0_CREATE &&
  191. +       (char_id = MakeDWord(sd->status.inventory[n].card[2], sd->status.inventory[n].card[3])) == battle_config.reserved_costume_id)
  192. +   { // Costume Item - Converted
  193. +       if (ep&EQP_HEAD_TOP) { ep &= ~EQP_HEAD_TOP; ep |= EQP_COSTUME_HEAD_TOP; }
  194. +       if (ep&EQP_HEAD_LOW) { ep &= ~EQP_HEAD_LOW; ep |= EQP_COSTUME_HEAD_LOW; }
  195. +       if (ep&EQP_HEAD_MID) { ep &= ~EQP_HEAD_MID; ep |= EQP_COSTUME_HEAD_MID; }
  196. +   } // End edit
  197. +
  198.     return ep;
  199.  }
  200.  
  201. diff --git a/src/map/script.c b/src/map/script.c
  202. index d6a72a0..2baa114 100644
  203. --- a/src/map/script.c
  204. +++ b/src/map/script.c
  205. @@ -20096,6 +20096,51 @@ static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  206.     return SCRIPT_CMD_SUCCESS;
  207.  }
  208.  
  209. +/**
  210. + * Costume item edit
  211. + **/
  212. +BUILDIN_FUNC(costume) {
  213. +   int i = -1, num, ep;
  214. +   TBL_PC *sd;
  215. +
  216. +   num = script_getnum(st, 2); // Equip Slot
  217. +   sd = script_rid2sd(st);
  218. +
  219. +   if (sd == NULL)
  220. +       return 0;
  221. +   if (num > 0 && num <= ARRAYLENGTH(equip))
  222. +       i = pc_checkequip(sd, equip[num - 1]);
  223. +   if (i < 0)
  224. +       return 0;
  225. +
  226. +   ep = sd->status.inventory[i].equip;
  227. +   if (!(ep&EQP_HEAD_LOW) && !(ep&EQP_HEAD_MID) && !(ep&EQP_HEAD_TOP))
  228. +       return 0;
  229. +
  230. +   log_pick_pc(sd, LOG_TYPE_SCRIPT, -1, &sd->status.inventory[i]);
  231. +   pc_unequipitem(sd, i, 2);
  232. +   clif_delitem(sd, i, 1, 3);
  233. +   // --------------------------------------------------------------------
  234. +   sd->status.inventory[i].refine = 0;
  235. +   sd->status.inventory[i].attribute = 0;
  236. +   sd->status.inventory[i].card[0] = CARD0_CREATE;
  237. +   sd->status.inventory[i].card[1] = 0;
  238. +   sd->status.inventory[i].card[2] = GetWord(battle_config.reserved_costume_id, 0);
  239. +   sd->status.inventory[i].card[3] = GetWord(battle_config.reserved_costume_id, 1);
  240. +
  241. +   if (ep&EQP_HEAD_TOP) { ep &= ~EQP_HEAD_TOP; ep |= EQP_COSTUME_HEAD_TOP; }
  242. +   if (ep&EQP_HEAD_LOW) { ep &= ~EQP_HEAD_LOW; ep |= EQP_COSTUME_HEAD_LOW; }
  243. +   if (ep&EQP_HEAD_MID) { ep &= ~EQP_HEAD_MID; ep |= EQP_COSTUME_HEAD_MID; }
  244. +   // --------------------------------------------------------------------
  245. +   log_pick_pc(sd, LOG_TYPE_SCRIPT, 1, &sd->status.inventory[i]);
  246. +
  247. +   clif_additem(sd, i, 1, 0);
  248. +   pc_equipitem(sd, i, ep);
  249. +   clif_misceffect(&sd->bl, 3);
  250. +
  251. +   return 0;
  252. +}
  253. +
  254.  #include "../custom/script.inc"
  255.  
  256.  // declarations that were supposed to be exported from npc_chat.c
  257. @@ -20648,6 +20693,8 @@ struct script_function buildin_func[] = {
  258.     BUILDIN_DEF(npcshopupdate,"sii?"),
  259.     BUILDIN_DEF(getattachedrid,""),
  260.  
  261. +   BUILDIN_DEF(costume, "i"), // Costume item edit
  262. +
  263.  #include "../custom/script_def.inc"
  264.  
  265.     {NULL,NULL,NULL},
  266. diff --git a/src/map/status.c b/src/map/status.c
  267. index 3e78166..e249c2c 100644
  268. --- a/src/map/status.c
  269. +++ b/src/map/status.c
  270. @@ -3095,7 +3095,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
  271.         current_equip_combo_pos = 0;
  272.         if (index < 0)
  273.             continue;
  274. -       if (i == EQI_AMMO)
  275. +       if (i == EQI_AMMO || i == EQI_COSTUME_TOP || i == EQI_COSTUME_MID || i == EQI_COSTUME_LOW) // Costume item edit
  276.             continue;
  277.         if (pc_is_same_equip_index((enum equip_index)i, sd->equip_index, index))
  278.             continue;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement