Advertisement
Guest User

Untitled

a guest
Jul 18th, 2016
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.67 KB | None | 0 0
  1. //===== Hercules Plugin ======================================
  2. //= Show Party Buffs
  3. //===== By: ==================================================
  4. //= Samuel [Hercules]
  5. //===== Current Version: =====================================
  6. //= 1.0
  7. //===== Compatible With: =====================================
  8. //= Hercules/RagEmu
  9. //===== Description: =========================================
  10. //= With this plugin, it will show certain buffs that are
  11. //= present with you and your party members in the party
  12. //= window.
  13. //= B - Blessing
  14. //= A - Agility Up
  15. //= F - Full Chemical Protection
  16. //= S - Soul Link
  17. //= + - Devotion
  18. //===== Credits: =============================================
  19. //= AnnieRuru - originally made the plugin
  20. //= Functor - bug fix
  21. //============================================================
  22.  
  23. #include "common/hercules.h"
  24. #include "common/nullpo.h"
  25. #include "common/socket.h"
  26. #include "common/memmgr.h"
  27.  
  28. #include <stdio.h>
  29. #include <string.h>
  30. #include <stdlib.h>
  31.  
  32. #include "map/pc.h"
  33. #include "map/clif.h"
  34. #include "map/party.h"
  35.  
  36. #include "plugins/HPMHooking.h"
  37. #include "common/HPMDataCheck.h" // should always be the last file included! (if you don't make it last, it'll intentionally break compile time)
  38.  
  39. HPExport struct hplugin_info pinfo = {
  40. "partybuff", // Plugin name
  41. SERVER_TYPE_MAP,// Which server types this plugin works with?
  42. "0.0", // Plugin version
  43. HPM_VERSION, // HPM Version (don't change, macro is automatically updated)
  44. };
  45.  
  46. struct player_data {
  47. int buff;
  48. };
  49.  
  50. int status_change_start_post( int retVal___, struct block_list *src, struct block_list *bl, enum sc_type type, int rate, int val1, int val2, int val3, int val4, int tick, int flag)
  51. {
  52. if ( bl->type == BL_PC && retVal___ > 0 ) {
  53. TBL_PC *sd = BL_CAST(BL_PC, bl);
  54. struct party_data *p;
  55. if (( p = party->search(sd->status.party_id ))) {
  56. struct player_data *ssd = getFromMSD( sd, 0 );
  57. int before_buff = ssd->buff;
  58. if ( type == SC_BLESSING )
  59. ssd->buff |= 0x1;
  60. if ( type == SC_INC_AGI )
  61. ssd->buff |= 0x2;
  62. if ( type == SC_PROTECTWEAPON || type == SC_PROTECTSHIELD || type == SC_PROTECTARMOR || type == SC_PROTECTHELM )
  63. if ( sd->sc.data[SC_PROTECTWEAPON] && sd->sc.data[SC_PROTECTSHIELD] && sd->sc.data[SC_PROTECTARMOR] && sd->sc.data[SC_PROTECTHELM] )
  64. ssd->buff |= 0x4;
  65. if ( type == SC_SOULLINK )
  66. ssd->buff |= 0x8;
  67. if ( type == SC_DEVOTION )
  68. ssd->buff |= 0x10;
  69. if ( before_buff != ssd->buff ) // only send the packet if update the status is newly apply, no need to resend if just renew the status
  70. clif->party_info( p, NULL );
  71. }
  72. }
  73. return retVal___;
  74. }
  75.  
  76. int status_change_end_post( int retVal___, struct block_list *bl, enum sc_type type, int tid, const char *file, int line )
  77. {
  78. if ( bl->type == BL_PC && retVal___ > 0 ) {
  79. TBL_PC *sd = BL_CAST(BL_PC, bl);
  80. struct party_data *p;
  81. if ( sd->state.active == 1 ) { // fix map-server crash when player logout
  82. if (( p = party->search(sd->status.party_id ))) {
  83. struct player_data *ssd = getFromMSD( sd, 0 );
  84. int before_buff = ssd->buff;
  85. if ( type == SC_BLESSING )
  86. ssd->buff &= ~0x1;
  87. if ( type == SC_INC_AGI )
  88. ssd->buff &= ~0x2;
  89. if ( type == SC_PROTECTWEAPON || type == SC_PROTECTSHIELD || type == SC_PROTECTARMOR || type == SC_PROTECTHELM )
  90. if ( sd->sc.data[SC_PROTECTWEAPON] && sd->sc.data[SC_PROTECTSHIELD] && sd->sc.data[SC_PROTECTARMOR] && sd->sc.data[SC_PROTECTHELM] )
  91. ssd->buff &= ~0x4;
  92. if ( type == SC_SOULLINK )
  93. ssd->buff &= ~0x8;
  94. if ( type == SC_DEVOTION )
  95. ssd->buff &= ~0x10;
  96. if ( before_buff != ssd->buff ) // only send the packet if update the status is newly apply, no need to resend if just renew the status
  97. clif->party_info( p, NULL );
  98. }
  99. }
  100. }
  101. return retVal___;
  102. }
  103.  
  104. void clif_party_info_overload( struct party_data* p, struct map_session_data *sd ) {
  105. unsigned char buf[2+2+NAME_LENGTH+(4+NAME_LENGTH+MAP_NAME_LENGTH_EXT+1+1)*MAX_PARTY];
  106. struct map_session_data* party_sd = NULL;
  107. int i, c;
  108. nullpo_retv(p);
  109. WBUFW(buf,0) = 0xfb;
  110. memcpy( WBUFP(buf,4), p->party.name, NAME_LENGTH );
  111. for ( i = 0, c = 0; i < MAX_PARTY; i++ ) {
  112. struct party_member* m = &p->party.member[i];
  113. if(!m->account_id) continue;
  114. if(party_sd == NULL) party_sd = p->data[i].sd;
  115. WBUFL(buf,28+c*46) = m->account_id;
  116. if ( m->online && p->data[i].sd != NULL ) {
  117. struct player_data *ssd = getFromMSD( p->data[i].sd, 0 );
  118. char temp[NAME_LENGTH];
  119. safesnprintf( temp, NAME_LENGTH, "[%s%s%s%s%s]%s",
  120. ( ssd->buff & 0x1 )? "B" : "_",
  121. ( ssd->buff & 0x2 )? "A" : "_",
  122. ( ssd->buff & 0x4 )? "F" : "_",
  123. ( ssd->buff & 0x8 )? "S" : "_",
  124. ( ssd->buff & 0x10 )? "+" : "_",
  125. m->name );
  126. memcpy(WBUFP(buf,28+c*46+4), temp, NAME_LENGTH);
  127. } else
  128. memcpy(WBUFP(buf,28+c*46+4), m->name, NAME_LENGTH);
  129. mapindex->getmapname_ext(mapindex_id2name(m->map), (char*)WBUFP(buf,28+c*46+28));
  130. WBUFB(buf,28+c*46+44) = (m->leader) ? 0 : 1;
  131. WBUFB(buf,28+c*46+45) = (m->online) ? 0 : 1;
  132. c++;
  133. }
  134. WBUFW(buf,2) = 28+c*46;
  135. if (sd)
  136. clif->send(buf, WBUFW(buf,2), &sd->bl, SELF);
  137. else if (party_sd)
  138. clif->send(buf, WBUFW(buf,2), &party_sd->bl, PARTY);
  139. return;
  140. }
  141.  
  142. bool pc_authok_pre( struct map_session_data **sd, int *login_id2, time_t *expiration_time, int *group_id, const struct mmo_charstatus **st, bool *changing_mapservers ) {
  143. struct player_data *ssd;
  144. CREATE( ssd, struct player_data, true );
  145. ssd->buff = 0;
  146. addToMSD( *sd, ssd, 0, true );
  147. return true;
  148. }
  149.  
  150. int map_quit_post( int retVal___, struct map_session_data *sd ) {
  151. //struct player_data *ssd = getFromMSD( sd, 0 );
  152. removeFromMSD( sd, 0 );
  153. return retVal___;
  154. }
  155.  
  156. void clif_party_member_info_overload(struct party_data* p, struct map_session_data* sd)
  157. {
  158. return;
  159. }
  160.  
  161. HPExport void plugin_init (void) {
  162. clif->party_member_info = &clif_party_member_info_overload;
  163. addHookPre( pc, authok, pc_authok_pre );
  164. addHookPost( map, quit, map_quit_post );
  165. clif->party_info = &clif_party_info_overload;
  166. addHookPost( status, change_start, status_change_start_post );
  167. addHookPost( status, change_end_, status_change_end_post );
  168. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement