charcommand.c 123 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "../common/cbasetypes.h"
  4. #include "../common/mmo.h"
  5. #include "../common/timer.h"
  6. #include "../common/nullpo.h"
  7. #include "../common/showmsg.h"
  8. #include "../common/strlib.h"
  9. #include "../common/utils.h"
  10. #include "atcommand.h" // msg_txt()
  11. #include "charcommand.h"
  12. #include "battle.h"
  13. #include "clif.h"
  14. #include "chrif.h"
  15. #include "intif.h"
  16. #include "itemdb.h"
  17. #include "log.h"
  18. #include "map.h"
  19. #include "pc.h"
  20. #include "status.h"
  21. #include "skill.h"
  22. #include "mob.h"
  23. #include "npc.h"
  24. #include "pet.h"
  25. #include "mercenary.h"
  26. #include "party.h"
  27. #include "guild.h"
  28. #include "script.h"
  29. #include "trade.h"
  30. #include "unit.h"
  31. #include <stdio.h>
  32. #include <stdlib.h>
  33. #include <string.h>
  34. #include <math.h>
  35. char charcommand_symbol = '#';
  36. extern char *msg_table[1000]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  37. #define CCMD_FUNC(x) int charcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  38. typedef struct CharCommandInfo {
  39. const char* command;
  40. int level;
  41. CharCommandFunc func;
  42. } CharCommandInfo;
  43. static CharCommandInfo* get_charcommandinfo_byname(const char* name);
  44. static CharCommandInfo* get_charcommandinfo_byfunc(const CharCommandFunc func);
  45. /*==========================================
  46. * 対象キャラクターを転職させる upper指定で転生や養子も可能
  47. *------------------------------------------*/
  48. int charcommand_jobchange(const int fd, struct map_session_data* sd, const char* command, const char* message)
  49. {
  50. char character[100];
  51. struct map_session_data* pl_sd;
  52. int job = 0, upper = -1;
  53. memset(character, '\0', sizeof(character));
  54. if (!message || !*message || sscanf(message, "%d %23[^\n]", &job, character) < 2) {
  55. clif_displaymessage(fd, "Please, enter a job and a player name (usage: #job/#jobchange <job ID> <player>).");
  56. clif_displaymessage(fd, " 0 Novice 7 Knight 14 Crusader 21 Peco Crusader");
  57. clif_displaymessage(fd, " 1 Swordman 8 Priest 15 Monk 22 N/A");
  58. clif_displaymessage(fd, " 2 Mage 9 Wizard 16 Sage 23 Super Novice");
  59. clif_displaymessage(fd, " 3 Archer 10 Blacksmith 17 Rogue 24 Gunslinger");
  60. clif_displaymessage(fd, " 4 Acolyte 11 Hunter 18 Alchemist 25 Ninja");
  61. clif_displaymessage(fd, " 5 Merchant 12 Assassin 19 Bard 26 N/A");
  62. clif_displaymessage(fd, " 6 Thief 13 Peco Knight 20 Dancer");
  63. clif_displaymessage(fd, "4001 Novice High 4008 Lord Knight 4015 Paladin 4022 Peco Paladin");
  64. clif_displaymessage(fd, "4002 Swordman High 4009 High Priest 4016 Champion");
  65. clif_displaymessage(fd, "4003 Mage High 4010 High Wizard 4017 Professor");
  66. clif_displaymessage(fd, "4004 Archer High 4011 Whitesmith 4018 Stalker");
  67. clif_displaymessage(fd, "4005 Acolyte High 4012 Sniper 4019 Creator");
  68. clif_displaymessage(fd, "4006 Merchant High 4013 Assassin Cross 4020 Clown");
  69. clif_displaymessage(fd, "4007 Thief High 4014 Peco Lord Knight 4021 Gypsy");
  70. clif_displaymessage(fd, "4023 Baby Novice 4030 Baby Knight 4037 Baby Crusader 4044 Baby Peco Crusader");
  71. clif_displaymessage(fd, "4024 Baby Swordsman 4031 Baby Priest 4038 Baby Monk 4045 Super Baby");
  72. clif_displaymessage(fd, "4025 Baby Mage 4032 Baby Wizard 4039 Baby Sage 4046 Taekwon Kid");
  73. clif_displaymessage(fd, "4026 Baby Archer 4033 Baby Blacksmith 4040 Baby Rogue 4047 Taekwon Master");
  74. clif_displaymessage(fd, "4027 Baby Acolyte 4034 Baby Hunter 4041 Baby Alchemist 4048 N/A");
  75. clif_displaymessage(fd, "4028 Baby Merchant 4035 Baby Assassin 4042 Baby Bard 4049 Soul Linker");
  76. clif_displaymessage(fd, "4029 Baby Thief 4036 Baby Peco-Knight 4043 Baby Dancer");
  77. return -1;
  78. }
  79. if ((pl_sd = map_nick2sd(character)) == NULL) {
  80. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  81. return -1;
  82. }
  83. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  84. {
  85. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  86. return -1;
  87. }
  88. if (!pcdb_checkid(job)) {
  89. clif_displaymessage(fd, msg_txt(49)); // Invalid job ID.
  90. return -1;
  91. }
  92. if (pc_jobchange(pl_sd, job, upper) != 0) {
  93. clif_displaymessage(fd, msg_txt(192)); // Impossible to change the character's job.
  94. return -1;
  95. }
  96. clif_displaymessage(fd, msg_txt(48)); // Character's job changed.
  97. return 0;
  98. }
  99. /*==========================================
  100. *
  101. *------------------------------------------*/
  102. int charcommand_petrename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  103. {
  104. char character[NAME_LENGTH];
  105. struct map_session_data *pl_sd;
  106. struct pet_data *pd;
  107. memset(character, '\0', sizeof(character));
  108. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  109. clif_displaymessage(fd, "Please, enter a player name (usage: #petrename <player>).");
  110. return -1;
  111. }
  112. if ((pl_sd = map_nick2sd(character)) == NULL) {
  113. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  114. return -1;
  115. }
  116. if (!pl_sd->status.pet_id || !pl_sd->pd) {
  117. clif_displaymessage(fd, msg_txt(191)); // Sorry, but this player has no pet.
  118. return -1;
  119. }
  120. pd = pl_sd->pd;
  121. if (pd->pet.rename_flag) {
  122. clif_displaymessage(fd, msg_txt(190)); // This player can already rename his/her pet.
  123. return -1;
  124. }
  125. pd->pet.rename_flag = 0;
  126. intif_save_petdata(pl_sd->status.account_id, &pd->pet);
  127. clif_send_petstatus(pl_sd);
  128. clif_displaymessage(fd, msg_txt(189)); // This player can now rename his/her pet.
  129. return 0;
  130. }
  131. /*==========================================
  132. *
  133. *------------------------------------------*/
  134. int charcommand_petfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  135. {
  136. int friendly = 0;
  137. char character[NAME_LENGTH];
  138. struct map_session_data *pl_sd;
  139. struct pet_data *pd;
  140. memset(character, '\0', sizeof(character));
  141. if (!message || !*message || sscanf(message,"%d %23s",&friendly,character) < 2) {
  142. clif_displaymessage(fd, "Please, enter a valid value (usage: #petfriendly <0-1000> <player>).");
  143. return -1;
  144. }
  145. if ( (pl_sd = map_nick2sd(character)) == NULL )
  146. {
  147. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  148. return -1;
  149. }
  150. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  151. {
  152. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  153. return -1;
  154. }
  155. if (!pl_sd->status.pet_id || !pl_sd->pd) {
  156. clif_displaymessage(fd, msg_txt(191)); // Sorry, but this player has no pet.
  157. return -1;
  158. }
  159. friendly = cap_value(friendly, 0, 1000);
  160. pd = pl_sd->pd;
  161. if (friendly == pd->pet.intimate) {
  162. clif_displaymessage(fd, msg_txt(183)); // Pet friendly is already the good value.
  163. return -1;
  164. }
  165. pd->pet.intimate = friendly;
  166. clif_send_petstatus(pl_sd);
  167. clif_pet_emotion(pd,0);
  168. clif_displaymessage(pl_sd->fd, msg_txt(182)); // Pet friendly value changed!
  169. clif_displaymessage(sd->fd, msg_txt(182)); // Pet friendly value changed!
  170. return 0;
  171. }
  172. /*==========================================
  173. *
  174. *------------------------------------------*/
  175. int charcommand_stats(const int fd, struct map_session_data* sd, const char* command, const char* message)
  176. {
  177. char character[NAME_LENGTH];
  178. char job_jobname[100];
  179. char output[200];
  180. struct map_session_data *pl_sd;
  181. int i;
  182. struct {
  183. const char* format;
  184. int value;
  185. } output_table[] = {
  186. { "Base Level - %d", 0 },
  187. { NULL, 0 },
  188. { "Hp - %d", 0 },
  189. { "MaxHp - %d", 0 },
  190. { "Sp - %d", 0 },
  191. { "MaxSp - %d", 0 },
  192. { "Str - %3d", 0 },
  193. { "Agi - %3d", 0 },
  194. { "Vit - %3d", 0 },
  195. { "Int - %3d", 0 },
  196. { "Dex - %3d", 0 },
  197. { "Luk - %3d", 0 },
  198. { "Zeny - %d", 0 },
  199. { "Free SK Points - %d", 0 },
  200. { "JobChangeLvl - %d", 0 },
  201. { NULL, 0 }
  202. };
  203. memset(character, '\0', sizeof(character));
  204. memset(job_jobname, '\0', sizeof(job_jobname));
  205. memset(output, '\0', sizeof(output));
  206. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  207. clif_displaymessage(fd, "Please, enter a player name (usage: #stats <player>).");
  208. return -1;
  209. }
  210. if ( (pl_sd = map_nick2sd(character)) == NULL )
  211. {
  212. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  213. return -1;
  214. }
  215. //direct array initialization with variables is not standard C compliant.
  216. output_table[0].value = pl_sd->status.base_level;
  217. output_table[1].format = job_jobname;
  218. output_table[1].value = pl_sd->status.job_level;
  219. output_table[2].value = pl_sd->status.hp;
  220. output_table[3].value = pl_sd->status.max_hp;
  221. output_table[4].value = pl_sd->status.sp;
  222. output_table[5].value = pl_sd->status.max_sp;
  223. output_table[6].value = pl_sd->status.str;
  224. output_table[7].value = pl_sd->status.agi;
  225. output_table[8].value = pl_sd->status.vit;
  226. output_table[9].value = pl_sd->status.int_;
  227. output_table[10].value = pl_sd->status.dex;
  228. output_table[11].value = pl_sd->status.luk;
  229. output_table[12].value = pl_sd->status.zeny;
  230. output_table[13].value = pl_sd->status.skill_point;
  231. output_table[14].value = pl_sd->change_level;
  232. sprintf(job_jobname, "Job - %s %s", job_name(pl_sd->status.class_), "(level %d)");
  233. sprintf(output, msg_txt(53), pl_sd->status.name); // '%s' stats:
  234. clif_displaymessage(fd, output);
  235. for (i = 0; output_table[i].format != NULL; i++) {
  236. sprintf(output, output_table[i].format, output_table[i].value);
  237. clif_displaymessage(fd, output);
  238. }
  239. return 0;
  240. }
  241. /*==========================================
  242. * Character Reset
  243. *------------------------------------------*/
  244. int charcommand_reset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  245. {
  246. char character[NAME_LENGTH];
  247. char output[200];
  248. struct map_session_data *pl_sd;
  249. memset(character, '\0', sizeof(character));
  250. memset(output, '\0', sizeof(output));
  251. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  252. clif_displaymessage(fd, "Please, enter a player name (usage: #reset <player>).");
  253. return -1;
  254. }
  255. if ( (pl_sd = map_nick2sd(character)) == NULL )
  256. {
  257. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  258. return -1;
  259. }
  260. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  261. {
  262. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  263. return -1;
  264. }
  265. pc_resetstate(pl_sd);
  266. pc_resetskill(pl_sd,1);
  267. sprintf(output, msg_txt(208), character); // '%s' skill and stats points reseted!
  268. clif_displaymessage(fd, output);
  269. return 0;
  270. }
  271. /*==========================================
  272. *
  273. *------------------------------------------*/
  274. int charcommand_option(const int fd, struct map_session_data* sd, const char* command, const char* message)
  275. {
  276. char character[NAME_LENGTH];
  277. int opt1 = 0, opt2 = 0, opt3 = 0;
  278. struct map_session_data* pl_sd;
  279. memset(character, '\0', sizeof(character));
  280. if (!message || !*message ||
  281. sscanf(message, "%d %d %d %23[^\n]", &opt1, &opt2, &opt3, character) < 4 ||
  282. opt1 < 0 || opt2 < 0 || opt3 < 0) {
  283. clif_displaymessage(fd, "Please, enter valid options and a player name (usage: #option <param1> <param2> <param3> <player>).");
  284. return -1;
  285. }
  286. if ( (pl_sd = map_nick2sd(character)) == NULL )
  287. {
  288. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  289. return -1;
  290. }
  291. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  292. {
  293. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  294. return -1;
  295. }
  296. pl_sd->sc.opt1 = opt1;
  297. pl_sd->sc.opt2 = opt2;
  298. pc_setoption(pl_sd, opt3);
  299. clif_displaymessage(fd, msg_txt(58)); // Character's options changed.
  300. return 0;
  301. }
  302. /*==========================================
  303. *
  304. *------------------------------------------*/
  305. int charcommand_save(const int fd, struct map_session_data* sd, const char* command, const char* message)
  306. {
  307. char map_name[MAP_NAME_LENGTH_EXT];
  308. char character[NAME_LENGTH];
  309. struct map_session_data* pl_sd;
  310. int x = 0, y = 0;
  311. int m;
  312. memset(map_name, '\0', sizeof(map_name));
  313. memset(character, '\0', sizeof(character));
  314. if (!message || !*message || sscanf(message, "%15s %d %d %23[^\n]", map_name, &x, &y, character) < 4 || x < 0 || y < 0) {
  315. clif_displaymessage(fd, "Please, enter a valid save point and a player name (usage: #save <map> <x> <y> <player>).");
  316. return -1;
  317. }
  318. if ( (pl_sd = map_nick2sd(character)) == NULL )
  319. {
  320. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  321. return -1;
  322. }
  323. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  324. {
  325. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  326. return -1;
  327. }
  328. m = map_mapname2mapid(map_name);
  329. if (m < 0 && !mapindex_name2id(map_name)) {
  330. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  331. return -1;
  332. }
  333. //FIXME: What do you do if the map is in another map server with the nowarpto flag?
  334. if (m>=0 && map[m].flag.nosave && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  335. clif_displaymessage(fd, "You are not authorised to set this map as a save map.");
  336. return -1;
  337. }
  338. if (m>=0)
  339. pc_setsavepoint(pl_sd, map[m].index, x, y);
  340. else
  341. pc_setsavepoint(pl_sd, mapindex_name2id(map_name), x, y);
  342. clif_displaymessage(fd, msg_txt(57)); // Character's respawn point changed.
  343. return 0;
  344. }
  345. /*==========================================
  346. * CharSpiritBall Function by PalasX
  347. *------------------------------------------*/
  348. int charcommand_spiritball(const int fd, struct map_session_data* sd,const char* command, const char* message)
  349. {
  350. struct map_session_data *pl_sd;
  351. char character[NAME_LENGTH];
  352. int spirit = 0;
  353. memset(character, '\0', sizeof(character));
  354. if(!message || !*message || sscanf(message, "%d %23[^\n]", &spirit, character) < 2 || spirit < 0 || spirit > 1000) {
  355. clif_displaymessage(fd, "Usage: @spiritball <number: 0-1000> <player>.");
  356. return -1;
  357. }
  358. if ( (pl_sd = map_nick2sd(character)) == NULL )
  359. {
  360. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  361. return -1;
  362. }
  363. if (spirit >= 0 && spirit <= 0x7FFF) {
  364. if (pl_sd->spiritball != spirit || spirit > 999) {
  365. if (pl_sd->spiritball > 0)
  366. pc_delspiritball(pl_sd, pl_sd->spiritball, 1);
  367. }
  368. pl_sd->spiritball = spirit;
  369. clif_spiritball(pl_sd);
  370. // no message, player can look the difference
  371. if (spirit > 1000)
  372. clif_displaymessage(fd, msg_txt(204)); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  373. } else {
  374. clif_displaymessage(fd, msg_txt(205)); // You already have this number of spiritballs.
  375. return -1;
  376. }
  377. return 0;
  378. }
  379. /*==========================================
  380. * #itemlist <character>: Displays the list of a player's items.
  381. *------------------------------------------*/
  382. int charcommand_itemlist(const int fd, struct map_session_data* sd, const char* command, const char* message)
  383. {
  384. struct map_session_data *pl_sd;
  385. struct item_data *item_data, *item_temp;
  386. int i, j, equip, count, counter, counter2;
  387. char character[NAME_LENGTH], output[200], equipstr[100], outputtmp[200];
  388. struct item *i_item; //Current inventory item.
  389. nullpo_retr(-1, sd);
  390. memset(character, '\0', sizeof(character));
  391. memset(output, '\0', sizeof(output));
  392. memset(equipstr, '\0', sizeof(equipstr));
  393. memset(outputtmp, '\0', sizeof(outputtmp));
  394. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  395. clif_displaymessage(fd, "Please, enter a player name (usage: #itemlist <player>).");
  396. return -1;
  397. }
  398. if ( (pl_sd = map_nick2sd(character)) == NULL )
  399. {
  400. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  401. return -1;
  402. }
  403. counter = 0;
  404. count = 0;
  405. for (i = 0; i < MAX_INVENTORY; i++) {
  406. i_item = &pl_sd->status.inventory[i];
  407. if (pl_sd->status.inventory[i].nameid > 0 && (item_data = itemdb_exists(i_item->nameid)) != NULL) {
  408. counter = counter + i_item->amount;
  409. count++;
  410. if (count == 1) {
  411. sprintf(output, "------ Items list of '%s' ------", pl_sd->status.name);
  412. clif_displaymessage(fd, output);
  413. }
  414. if ((equip = i_item->equip)) {
  415. strcpy(equipstr, "| equiped: ");
  416. if (equip & EQP_GARMENT)
  417. strcat(equipstr, "robe/gargment, ");
  418. if (equip & EQP_ACC_L)
  419. strcat(equipstr, "left accessory, ");
  420. if (equip & EQP_ARMOR)
  421. strcat(equipstr, "body/armor, ");
  422. if ((equip & EQP_ARMS) == EQP_HAND_R)
  423. strcat(equipstr, "right hand, ");
  424. if ((equip & EQP_ARMS) == EQP_HAND_L)
  425. strcat(equipstr, "left hand, ");
  426. if ((equip & EQP_ARMS) == EQP_ARMS)
  427. strcat(equipstr, "both hands, ");
  428. if (equip & EQP_SHOES)
  429. strcat(equipstr, "feet, ");
  430. if (equip & EQP_ACC_R)
  431. strcat(equipstr, "right accessory, ");
  432. if ((equip & EQP_HELM) == EQP_HEAD_LOW)
  433. strcat(equipstr, "lower head, ");
  434. if ((equip & EQP_HELM) == EQP_HEAD_TOP)
  435. strcat(equipstr, "top head, ");
  436. if ((equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP))
  437. strcat(equipstr, "lower/top head, ");
  438. if ((equip & EQP_HELM) == EQP_HEAD_MID)
  439. strcat(equipstr, "mid head, ");
  440. if ((equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID))
  441. strcat(equipstr, "lower/mid head, ");
  442. if ((equip & EQP_HELM) == EQP_HELM)
  443. strcat(equipstr, "lower/mid/top head, ");
  444. // remove final ', '
  445. equipstr[strlen(equipstr) - 2] = '\0';
  446. } else
  447. memset(equipstr, '\0', sizeof(equipstr));
  448. if (i_item->refine)
  449. sprintf(output, "%d %s %+d (%s %+d, id: %d) %s", i_item->amount, item_data->name, i_item->refine, item_data->jname, i_item->refine, i_item->nameid, equipstr);
  450. else
  451. sprintf(output, "%d %s (%s, id: %d) %s", i_item->amount, item_data->name, item_data->jname, i_item->nameid, equipstr);
  452. clif_displaymessage(fd, output);
  453. memset(output, '\0', sizeof(output));
  454. counter2 = 0;
  455. if(i_item->card[0]==CARD0_PET) { //pet eggs
  456. if (i_item->card[3])
  457. sprintf(outputtmp, " -> (pet egg, pet id: %u, named)", (unsigned int)MakeDWord(i_item->card[1], i_item->card[2]));
  458. else
  459. sprintf(outputtmp, " -> (pet egg, pet id: %u, unnamed)", (unsigned int)MakeDWord(i_item->card[1], i_item->card[2]));
  460. strcat(output, outputtmp);
  461. } else
  462. if(i_item->card[0]==CARD0_FORGE) { //forged items.
  463. sprintf(outputtmp, " -> (crafted item, creator id: %u, star crumbs %d, element %d)", (unsigned int)MakeDWord(i_item->card[2], i_item->card[3]), i_item->card[1]>>8, i_item->card[1]&0x0f);
  464. } else
  465. if(i_item->card[0]==CARD0_CREATE) { //created items.
  466. sprintf(outputtmp, " -> (produced item, creator id: %u)", (unsigned int)MakeDWord(i_item->card[2], i_item->card[3]));
  467. strcat(output, outputtmp);
  468. } else //Normal slots
  469. for (j = 0; j < item_data->slot; j++) {
  470. if (pl_sd->status.inventory[i].card[j]) {
  471. if ((item_temp = itemdb_exists(i_item->card[j])) != NULL) {
  472. if (output[0] == '\0')
  473. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  474. else
  475. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  476. strcat(output, outputtmp);
  477. }
  478. }
  479. }
  480. if (output[0] != '\0') {
  481. output[strlen(output) - 2] = ')';
  482. output[strlen(output) - 1] = '\0';
  483. clif_displaymessage(fd, output);
  484. }
  485. }
  486. }
  487. if (count == 0)
  488. {
  489. clif_displaymessage(fd, "No item found on this player.");
  490. return -1;
  491. }
  492. sprintf(output, "%d item(s) found in %d kind(s) of items.", counter, count);
  493. clif_displaymessage(fd, output);
  494. return 0;
  495. }
  496. /*==========================================
  497. * #effect by [MouseJstr]
  498. *
  499. * Create a effect localized on another character
  500. *------------------------------------------*/
  501. int charcommand_effect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  502. {
  503. struct map_session_data *pl_sd = NULL;
  504. char character[NAME_LENGTH];
  505. int type = 0;
  506. nullpo_retr(-1, sd);
  507. if (!message || !*message || sscanf(message, "%d %23[^\n]", &type, character) != 2) {
  508. clif_displaymessage(fd, "usage: #effect <type+> <target>.");
  509. return -1;
  510. }
  511. if ( (pl_sd = map_nick2sd(character)) == NULL )
  512. {
  513. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  514. return -1;
  515. }
  516. clif_specialeffect(&pl_sd->bl, type, AREA);
  517. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  518. return 0;
  519. }
  520. /*==========================================
  521. * #storagelist <character>: Displays the items list of a player's storage.
  522. *------------------------------------------*/
  523. int charcommand_storagelist(const int fd, struct map_session_data* sd, const char* command, const char* message)
  524. {
  525. struct map_session_data *pl_sd;
  526. struct item_data *item_data, *item_temp;
  527. int i, j, count = 0, counter = 0, counter2 = 0;
  528. char character[NAME_LENGTH], output[200], outputtmp[200];
  529. nullpo_retr(-1, sd);
  530. memset(character, '\0', sizeof(character));
  531. memset(output, '\0', sizeof(output));
  532. memset(outputtmp, '\0', sizeof(outputtmp));
  533. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  534. clif_displaymessage(fd, "Please, enter a player name (usage: #itemlist <char name>).");
  535. return -1;
  536. }
  537. if ( (pl_sd = map_nick2sd(character)) == NULL )
  538. {
  539. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  540. return -1;
  541. }
  542. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  543. {
  544. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  545. return -1;
  546. }
  547. for (i = 0; i < MAX_STORAGE; i++)
  548. {
  549. struct item* it = &sd->status.storage.items[i];
  550. if( it->nameid > 0 && (item_data = itemdb_search(it->nameid)) != NULL )
  551. {
  552. counter = counter + it->amount;
  553. count++;
  554. if (count == 1) {
  555. sprintf(output, "------ Storage items list of '%s' ------", pl_sd->status.name);
  556. clif_displaymessage(fd, output);
  557. }
  558. if (it->refine)
  559. sprintf(output, "%d %s %+d (%s %+d, id: %d)", it->amount, item_data->name, it->refine, item_data->jname, it->refine, it->nameid);
  560. else
  561. sprintf(output, "%d %s (%s, id: %d)", it->amount, item_data->name, item_data->jname, it->nameid);
  562. clif_displaymessage(fd, output);
  563. memset(output, '\0', sizeof(output));
  564. counter2 = 0;
  565. for (j = 0; j < item_data->slot; j++) {
  566. if (it->card[j]) {
  567. if ((item_temp = itemdb_search(it->card[j])) != NULL) {
  568. if (output[0] == '\0')
  569. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  570. else
  571. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  572. strcat(output, outputtmp);
  573. }
  574. }
  575. }
  576. if (output[0] != '\0') {
  577. output[strlen(output) - 2] = ')';
  578. output[strlen(output) - 1] = '\0';
  579. clif_displaymessage(fd, output);
  580. }
  581. }
  582. }
  583. if (count == 0)
  584. clif_displaymessage(fd, "No item found in the storage of this player.");
  585. else {
  586. sprintf(output, "%d item(s) found in %d kind(s) of items.", counter, count);
  587. clif_displaymessage(fd, output);
  588. }
  589. return 0;
  590. }
  591. static void charcommand_item_sub(struct map_session_data *sd,struct item_data *item_data,int number)
  592. {
  593. int loop, get_count, pet_id, i;
  594. if( sd == NULL || item_data == NULL )
  595. return;
  596. if( !itemdb_isstackable2(item_data) ) {
  597. loop = number; get_count = 1;
  598. } else {
  599. loop = 1; get_count = number;
  600. }
  601. for (i = 0; i < loop; i++)
  602. {
  603. if( (pet_id = search_petDB_index(item_data->nameid, PET_EGG)) >= 0 )
  604. {// if pet egg
  605. sd->catch_target_class = pet_db[pet_id].class_;
  606. intif_create_pet(sd->status.account_id, sd->status.char_id,
  607. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  608. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  609. 100, 0, 1, pet_db[pet_id].jname);
  610. }
  611. else
  612. {// if not pet egg
  613. int flag = 0;
  614. struct item item_tmp;
  615. memset(&item_tmp, 0, sizeof(item_tmp));
  616. item_tmp.nameid = item_data->nameid;
  617. item_tmp.identify = 1;
  618. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  619. clif_additem(sd, 0, 0, flag);
  620. //Logs (A)dmins items [Lupus]
  621. if(log_config.enable_logs&0x400)
  622. log_pick_pc(sd, "A", item_tmp.nameid, number, &item_tmp);
  623. }
  624. }
  625. }
  626. /*==========================================
  627. * #item command (usage: #item <name/id_of_item> <quantity> <player>)
  628. * by MC Cameri
  629. *------------------------------------------*/
  630. int charcommand_item(const int fd, struct map_session_data* sd, const char* command, const char* message)
  631. {
  632. char item_name[100];
  633. char character[NAME_LENGTH];
  634. struct map_session_data *pl_sd;
  635. int number = 0, item_id;
  636. struct item_data *item_data;
  637. int gmlvl;
  638. char tmp_cmdoutput[1024];
  639. nullpo_retr(-1, sd);
  640. memset(item_name, '\0', sizeof(item_name));
  641. if (!message || !*message || (
  642. sscanf(message, "\"%99[^\"]\" %d %23[^\n]", item_name, &number, character) < 3 &&
  643. sscanf(message, "%99s %d %23[^\n]", item_name, &number, character) < 3
  644. )) {
  645. clif_displaymessage(fd, "Please, enter an item name/id (usage: #item <item name or ID> <quantity> <char name>).");
  646. return -1;
  647. }
  648. if (number <= 0)
  649. number = 1;
  650. item_id = 0;
  651. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  652. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  653. item_id = item_data->nameid;
  654. if (item_id < 500) {
  655. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  656. return -1;
  657. }
  658. gmlvl = pc_isGM(sd);
  659. if( !pc_can_give_items(gmlvl) )
  660. {
  661. clif_displaymessage(fd, msg_txt(246)); // GM is not allowed to trade
  662. return -1;
  663. }
  664. if ((pl_sd = map_nick2sd(character)) != NULL)
  665. {
  666. int pl_gmlvl = pc_isGM(pl_sd);
  667. if( gmlvl < pl_gmlvl || !itemdb_cantrade_sub(item_data, gmlvl, pl_gmlvl) )
  668. {// you can give items only to lower or same level
  669. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  670. return -1;
  671. }
  672. charcommand_item_sub(pl_sd,item_data,number);
  673. clif_displaymessage(fd, msg_txt(18)); // Item created.
  674. }
  675. else if (strcmpi(character,"all")==0 || strcmpi(character,"everyone")==0)
  676. {
  677. struct s_mapiterator* iter = mapit_getallusers();
  678. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  679. {
  680. int pl_gmlvl = pc_isGM(pl_sd);
  681. if( gmlvl < pl_gmlvl || !itemdb_cantrade_sub(item_data, gmlvl, pl_gmlvl) )
  682. continue;
  683. charcommand_item_sub(pl_sd,item_data,number);
  684. clif_displaymessage(pl_sd->fd, msg_txt(18)); // Item created.
  685. }
  686. mapit_free(iter);
  687. snprintf(tmp_cmdoutput, sizeof(tmp_cmdoutput), "Everyone received %s %d.",item_name,number);
  688. clif_displaymessage(fd, tmp_cmdoutput);
  689. }
  690. else
  691. {
  692. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  693. return -1;
  694. }
  695. return 0;
  696. }
  697. /*==========================================
  698. * #warp/#rura/#rura+ <mapname> <x> <y> <char name>
  699. *------------------------------------------*/
  700. int charcommand_warp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  701. {
  702. char map_name[MAP_NAME_LENGTH_EXT];
  703. char character[NAME_LENGTH];
  704. int x = 0, y = 0;
  705. struct map_session_data *pl_sd;
  706. int m;
  707. nullpo_retr(-1, sd);
  708. memset(map_name, '\0', sizeof(map_name));
  709. memset(character, '\0', sizeof(character));
  710. if (!message || !*message || sscanf(message, "%15s %d %d %23[^\n]", map_name, &x, &y, character) < 4) {
  711. clif_displaymessage(fd, "Usage: #warp/#rura/#rura+ <mapname> <x> <y> <char name>");
  712. return -1;
  713. }
  714. if ((pl_sd = map_nick2sd(character)) == NULL) {
  715. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  716. return -1;
  717. }
  718. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can rura+ only lower or same GM level
  719. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  720. return -1;
  721. }
  722. m = map_mapname2mapid(map_name);
  723. if (m < 0) {
  724. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  725. return -1;
  726. }
  727. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOREACH)) {
  728. clif_displaymessage(fd, msg_txt(2)); // Coordinates out of range.
  729. x = y = 0;
  730. }
  731. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  732. clif_displaymessage(fd, "You are not authorised to warp someone to this map.");
  733. return -1;
  734. }
  735. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  736. clif_displaymessage(fd, "You are not authorised to warp this player from its actual map.");
  737. return -1;
  738. }
  739. if (pc_setpos(pl_sd, map[m].index, x, y, 3) == 0) {
  740. clif_displaymessage(pl_sd->fd, msg_txt(0)); // Warped.
  741. if (pl_sd->fd != fd)
  742. clif_displaymessage(fd, msg_txt(15)); // Player warped (message sends to player too).
  743. return 0;
  744. }
  745. //No error message specified...?
  746. return -1;
  747. }
  748. /*==========================================
  749. * #zeny <charname>
  750. *------------------------------------------*/
  751. int charcommand_zeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  752. {
  753. struct map_session_data *pl_sd;
  754. char character[NAME_LENGTH];
  755. int zeny = 0, new_zeny;
  756. nullpo_retr(-1, sd);
  757. memset(character, '\0', sizeof(character));
  758. if (!message || !*message || sscanf(message, "%d %23[^\n]", &zeny, character) < 2 || zeny == 0) {
  759. clif_displaymessage(fd, "Please, enter a number and a player name (usage: #zeny <zeny> <name>).");
  760. return -1;
  761. }
  762. if ((pl_sd = map_nick2sd(character)) != NULL) {
  763. new_zeny = pl_sd->status.zeny + zeny;
  764. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  765. new_zeny = MAX_ZENY;
  766. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  767. new_zeny = 0;
  768. if (new_zeny != pl_sd->status.zeny) {
  769. pl_sd->status.zeny = new_zeny;
  770. clif_updatestatus(pl_sd, SP_ZENY);
  771. clif_displaymessage(fd, msg_txt(211)); // Character's number of zenys changed!
  772. } else {
  773. if (zeny < 0)
  774. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  775. else
  776. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  777. return -1;
  778. }
  779. } else {
  780. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  781. return -1;
  782. }
  783. return 0;
  784. }
  785. /*==========================================
  786. * #cash or #points <amount> <charname>
  787. *------------------------------------------*/
  788. int charcommand_cash(const int fd, struct map_session_data* sd, const char* command, const char* message)
  789. {
  790. struct map_session_data *pl_sd;
  791. char character[NAME_LENGTH];
  792. int value = 0;
  793. nullpo_retr(-1, sd);
  794. memset(character, '\0', sizeof(character));
  795. if( !message || !*message || sscanf(message, "%d %23[^\n]", &value, character) < 2 || value == 0 )
  796. {
  797. clif_displaymessage(fd, "Please, enter a number and a player name (usage: #cash|#points <points> <name>).");
  798. return -1;
  799. }
  800. if( (pl_sd = map_nick2sd(character)) != NULL )
  801. {
  802. if( !strcmpi(command+1,"cash") )
  803. {
  804. if( value > 0 )
  805. pc_getcash(pl_sd, value, 0);
  806. else
  807. pc_paycash(pl_sd, value, 0);
  808. clif_displaymessage(fd, "Character's Cash Points changed!.");
  809. }
  810. else
  811. { // @points
  812. if( value > 0 )
  813. pc_getcash(pl_sd, 0, value);
  814. else
  815. pc_paycash(pl_sd, value, value);
  816. clif_displaymessage(fd, "Character's Kafra Points changed!.");
  817. }
  818. }
  819. else
  820. {
  821. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  822. return -1;
  823. }
  824. return 0;
  825. }
  826. /*==========================================
  827. * #fakename <char name> <fake name>
  828. *------------------------------------------*/
  829. int charcommand_fakename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  830. {
  831. struct map_session_data *pl_sd;
  832. char name[NAME_LENGTH];
  833. char char_name[NAME_LENGTH];
  834. nullpo_retr(-1, sd);
  835. name[0] = '\0'; //If you don't pass a second word, name is left as garbage, most definitely not a blank name! [Skotlex]
  836. if (!message || !*message || sscanf(message, "%23s %23[^\n]", char_name, name) < 1) {
  837. clif_displaymessage(sd->fd,"Usage: #fakename <char name> <fake name>.");
  838. clif_displaymessage(sd->fd,"Or: #fakename <char name> to disable.");
  839. return 0;
  840. }
  841. if(!(pl_sd = map_nick2sd(char_name))) {
  842. clif_displaymessage(sd->fd,"Character not found.");
  843. return -1;
  844. }
  845. if(!name[0]) {
  846. if(strlen(pl_sd->fakename) > 1) {
  847. pl_sd->fakename[0]='\0';
  848. clif_charnameack(0, &pl_sd->bl);
  849. clif_displaymessage(sd->fd,"Returned to real name.");
  850. } else {
  851. clif_displaymessage(sd->fd,"Character does not has a fake name.");
  852. }
  853. return 0;
  854. }
  855. if(strlen(name) < 2) {
  856. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  857. return 0;
  858. }
  859. memcpy(pl_sd->fakename, name, NAME_LENGTH);
  860. clif_charnameack(0, &pl_sd->bl);
  861. clif_displaymessage(sd->fd,"Fake name enabled.");
  862. return 0;
  863. }
  864. /*==========================================
  865. * #baselvl <#> <nickname>
  866. * Transferred by: Kevin
  867. *------------------------------------------*/
  868. int charcommand_baselevel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  869. {
  870. struct map_session_data *pl_sd;
  871. char player[NAME_LENGTH];
  872. int level = 0, i, status_point=0;
  873. nullpo_retr(-1, sd);
  874. if (!message || !*message || sscanf(message, "%d %23[^\n]", &level, player) < 2 || level == 0) {
  875. clif_displaymessage(fd, "Please, enter a level adjustment and a player name (usage: #baselvl <#> <nickname>).");
  876. return -1;
  877. }
  878. if ((pl_sd = map_nick2sd(player)) == NULL) {
  879. clif_displaymessage(fd, msg_table[3]); // Character not found.
  880. return -1;
  881. }
  882. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can change base level only lower or same gm level
  883. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  884. return -1;
  885. }
  886. if (level > 0) {
  887. if (pl_sd->status.base_level == pc_maxbaselv(pl_sd)) { // check for max level by Valaris
  888. clif_displaymessage(fd, msg_table[91]); // Character's base level can't go any higher.
  889. return 0;
  890. } // End Addition
  891. if ((unsigned int)level > pc_maxbaselv(pl_sd) ||
  892. pl_sd->status.base_level > pc_maxbaselv(pl_sd) -level)
  893. level = pc_maxbaselv(pl_sd) - pl_sd->status.base_level;
  894. for (i = 1; i <= level; i++)
  895. status_point += (pl_sd->status.base_level + i + 14) / 5;
  896. if (pl_sd->status.status_point > USHRT_MAX - status_point)
  897. pl_sd->status.status_point = USHRT_MAX;
  898. else
  899. pl_sd->status.status_point += status_point;
  900. pl_sd->status.base_level += (unsigned int)level;
  901. status_percent_heal(&pl_sd->bl, 100, 100);
  902. clif_misceffect(&pl_sd->bl, 0);
  903. clif_displaymessage(fd, msg_table[65]); // Character's base level raised.
  904. } else {
  905. if (pl_sd->status.base_level == 1) {
  906. clif_displaymessage(fd, msg_table[193]); // Character's base level can't go any lower.
  907. return -1;
  908. }
  909. level *= -1;
  910. if ((unsigned int)level >= pl_sd->status.base_level)
  911. level = pl_sd->status.base_level -1;
  912. for (i = 0; i > -level; i--)
  913. status_point += (pl_sd->status.base_level +i + 14) / 5;
  914. if (pl_sd->status.status_point < status_point)
  915. pc_resetstate(pl_sd);
  916. if (pl_sd->status.status_point < status_point)
  917. pl_sd->status.status_point = 0;
  918. else
  919. pl_sd->status.status_point -= status_point;
  920. pl_sd->status.base_level -= (unsigned int)level;
  921. clif_displaymessage(fd, msg_table[66]); // Character's base level lowered.
  922. }
  923. clif_updatestatus(pl_sd, SP_BASELEVEL);
  924. clif_updatestatus(pl_sd, SP_NEXTBASEEXP);
  925. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  926. status_calc_pc(pl_sd, 0);
  927. if(pl_sd->status.party_id)
  928. party_send_levelup(pl_sd);
  929. return 0; //正常終了
  930. }
  931. /*==========================================
  932. * #jlvl <#> <nickname>
  933. * Transferred by: Kevin
  934. *------------------------------------------*/
  935. int charcommand_joblevel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  936. {
  937. struct map_session_data *pl_sd;
  938. char player[NAME_LENGTH];
  939. int level = 0;
  940. //転生や養子の場合の元の職業を算出する
  941. nullpo_retr(-1, sd);
  942. if (!message || !*message || sscanf(message, "%d %23[^\n]", &level, player) < 2 || level == 0) {
  943. clif_displaymessage(fd, "Please, enter a level adjustment and a player name (usage: #joblvl <#> <nickname>).");
  944. return -1;
  945. }
  946. if ((pl_sd = map_nick2sd(player)) != NULL) {
  947. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change job level only lower or same gm level
  948. if (level > 0) {
  949. if (pl_sd->status.job_level == pc_maxjoblv(pl_sd)) {
  950. clif_displaymessage(fd, msg_txt(67)); // Character's job level can't go any higher.
  951. return -1;
  952. }
  953. if ((unsigned int)level > pc_maxjoblv(pl_sd) ||
  954. pl_sd->status.job_level > pc_maxjoblv(pl_sd) -level)
  955. level = pc_maxjoblv(pl_sd) - pl_sd->status.job_level;
  956. pl_sd->status.job_level += (unsigned int)level;
  957. clif_updatestatus(pl_sd, SP_JOBLEVEL);
  958. clif_updatestatus(pl_sd, SP_NEXTJOBEXP);
  959. if (pl_sd->status.skill_point > USHRT_MAX - level)
  960. pl_sd->status.skill_point = USHRT_MAX;
  961. else
  962. pl_sd->status.skill_point += level;
  963. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  964. status_calc_pc(pl_sd, 0);
  965. clif_misceffect(&pl_sd->bl, 1);
  966. clif_displaymessage(fd, msg_txt(68)); // character's job level raised.
  967. } else {
  968. if (pl_sd->status.job_level == 1) {
  969. clif_displaymessage(fd, msg_txt(194)); // Character's job level can't go any lower.
  970. return -1;
  971. }
  972. level*=-1;
  973. if ((unsigned int)level >= pl_sd->status.job_level)
  974. level = pl_sd->status.job_level-1;
  975. pl_sd->status.job_level -= (unsigned int)level;
  976. clif_updatestatus(pl_sd, SP_JOBLEVEL);
  977. clif_updatestatus(pl_sd, SP_NEXTJOBEXP);
  978. if (pl_sd->status.skill_point < level)
  979. pc_resetskill(pl_sd, 0); //Need more skill points to substract
  980. if (pl_sd->status.skill_point < level)
  981. pl_sd->status.skill_point = 0;
  982. else
  983. pl_sd->status.skill_point -= level;
  984. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  985. status_calc_pc(pl_sd, 0);
  986. clif_displaymessage(fd, msg_txt(69)); // Character's job level lowered.
  987. }
  988. } else {
  989. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  990. return -1;
  991. }
  992. } else {
  993. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  994. return -1;
  995. }
  996. return 0;
  997. }
  998. /*==========================================
  999. * #questskill <skill_#> <nickname>
  1000. * Transferred by: Kevin
  1001. *------------------------------------------*/
  1002. int charcommand_questskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1003. {
  1004. struct map_session_data *pl_sd;
  1005. char player[NAME_LENGTH];
  1006. int skill_id = 0;
  1007. nullpo_retr(-1, sd);
  1008. if (!message || !*message || sscanf(message, "%d %23[^\n]", &skill_id, player) < 2 || skill_id < 0) {
  1009. clif_displaymessage(fd, "Please, enter a quest skill number and a player name (usage: #questskill <#:0+> <nickname>).");
  1010. return -1;
  1011. }
  1012. if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
  1013. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  1014. return -1;
  1015. }
  1016. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  1017. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  1018. return -1;
  1019. }
  1020. if ((pl_sd = map_nick2sd(player)) == NULL) {
  1021. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1022. return -1;
  1023. }
  1024. if (pc_checkskill(pl_sd, skill_id) > 0) {
  1025. clif_displaymessage(fd, msg_txt(200)); // This player already has this quest skill.
  1026. return -1;
  1027. }
  1028. pc_skill(pl_sd, skill_id, 1, 0);
  1029. clif_displaymessage(fd, msg_txt(199)); // This player has learned the skill.
  1030. return 0;
  1031. }
  1032. /*==========================================
  1033. * #lostskill <skill_#> <nickname>
  1034. * Transferred by: Kevin
  1035. *------------------------------------------*/
  1036. int charcommand_lostskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1037. {
  1038. struct map_session_data *pl_sd;
  1039. char player[NAME_LENGTH];
  1040. int skill_id = 0;
  1041. nullpo_retr(-1, sd);
  1042. if (!message || !*message || sscanf(message, "%d %23[^\n]", &skill_id, player) < 2 || skill_id < 0) {
  1043. clif_displaymessage(fd, "Please, enter a quest skill number and a player name (usage: @charlostskill <#:0+> <char_name>).");
  1044. return -1;
  1045. }
  1046. if (skill_id < 0 && skill_id >= MAX_SKILL) {
  1047. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  1048. return -1;
  1049. }
  1050. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  1051. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  1052. return -1;
  1053. }
  1054. if ((pl_sd = map_nick2sd(player)) == NULL) {
  1055. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1056. return -1;
  1057. }
  1058. if (pc_checkskill(pl_sd, skill_id) == 0) {
  1059. clif_displaymessage(fd, msg_txt(203)); // This player doesn't have this quest skill.
  1060. return -1;
  1061. }
  1062. pl_sd->status.skill[skill_id].lv = 0;
  1063. pl_sd->status.skill[skill_id].flag = 0;
  1064. clif_skillinfoblock(pl_sd);
  1065. clif_displaymessage(fd, msg_txt(202)); // This player has forgotten the skill.
  1066. return 0;
  1067. }
  1068. /*==========================================
  1069. * Character Skill Reset
  1070. *------------------------------------------*/
  1071. int charcommand_skreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1072. {
  1073. struct map_session_data *pl_sd;
  1074. char player[NAME_LENGTH];
  1075. char tmp_cmdoutput[1024];
  1076. nullpo_retr(-1, sd);
  1077. if (!message || !*message || sscanf(message, "%23[^\n]", player) < 1) {
  1078. clif_displaymessage(fd, "Please, enter a player name (usage: @charskreset <charname>).");
  1079. return -1;
  1080. }
  1081. if ((pl_sd = map_nick2sd(player)) != NULL) {
  1082. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset skill points only lower or same gm level
  1083. pc_resetskill(pl_sd,1);
  1084. sprintf(tmp_cmdoutput, msg_txt(206), player); // '%s' skill points reseted!
  1085. clif_displaymessage(fd, tmp_cmdoutput);
  1086. } else {
  1087. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1088. return -1;
  1089. }
  1090. } else {
  1091. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1092. return -1;
  1093. }
  1094. return 0;
  1095. }
  1096. /*==========================================
  1097. * Character Stat Reset
  1098. *------------------------------------------*/
  1099. int charcommand_streset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1100. {
  1101. struct map_session_data *pl_sd;
  1102. char player[NAME_LENGTH];
  1103. char tmp_cmdoutput[1024];
  1104. nullpo_retr(-1, sd);
  1105. if (!message || !*message || sscanf(message, "%23[^\n]", player) < 1) {
  1106. clif_displaymessage(fd, "Please, enter a player name (usage: @charstreset <charname>).");
  1107. return -1;
  1108. }
  1109. if ((pl_sd = map_nick2sd(player)) != NULL) {
  1110. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset stats points only lower or same gm level
  1111. pc_resetstate(pl_sd);
  1112. sprintf(tmp_cmdoutput, msg_txt(207), player); // '%s' stats points reseted!
  1113. clif_displaymessage(fd, tmp_cmdoutput);
  1114. } else {
  1115. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1116. return -1;
  1117. }
  1118. } else {
  1119. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1120. return -1;
  1121. }
  1122. return 0;
  1123. }
  1124. /*==========================================
  1125. * Character Model by chbrules
  1126. *------------------------------------------*/
  1127. int charcommand_model(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1128. {
  1129. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1130. struct map_session_data *pl_sd;
  1131. char player[NAME_LENGTH];
  1132. char tmp_cmdoutput[1024];
  1133. nullpo_retr(-1, sd);
  1134. if (!message || !*message || sscanf(message, "%d %d %d %23[^\n]", &hair_style, &hair_color, &cloth_color, player) < 4 || hair_style < 0 || hair_color < 0 || cloth_color < 0) {
  1135. sprintf(tmp_cmdoutput, "Please, enter a valid model and a player name (usage: @charmodel <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d> <name>).",
  1136. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1137. clif_displaymessage(fd, tmp_cmdoutput);
  1138. return -1;
  1139. }
  1140. if ((pl_sd = map_nick2sd(player)) != NULL) {
  1141. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1142. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1143. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1144. pc_changelook(pl_sd, LOOK_HAIR, hair_style);
  1145. pc_changelook(pl_sd, LOOK_HAIR_COLOR, hair_color);
  1146. pc_changelook(pl_sd, LOOK_CLOTHES_COLOR, cloth_color);
  1147. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1148. } else {
  1149. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1150. return -1;
  1151. }
  1152. } else {
  1153. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1154. return -1;
  1155. }
  1156. return 0;
  1157. }
  1158. /*==========================================
  1159. * Character Skill Point (Rewritten by [Yor])
  1160. *------------------------------------------*/
  1161. int charcommand_skpoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1162. {
  1163. struct map_session_data *pl_sd;
  1164. char player[NAME_LENGTH];
  1165. int new_skill_point;
  1166. int point = 0;
  1167. nullpo_retr(-1, sd);
  1168. if (!message || !*message || sscanf(message, "%d %23[^\n]", &point, player) < 2 || point == 0) {
  1169. clif_displaymessage(fd, "Please, enter a number and a player name (usage: @charskpoint <amount> <name>).");
  1170. return -1;
  1171. }
  1172. if ((pl_sd = map_nick2sd(player)) != NULL) {
  1173. if (point > 0 && pl_sd->status.skill_point > USHRT_MAX - point)
  1174. new_skill_point = USHRT_MAX;
  1175. else if (point < 0 && pl_sd->status.skill_point < -point)
  1176. new_skill_point = 0;
  1177. else
  1178. new_skill_point = pl_sd->status.skill_point + point;
  1179. if (new_skill_point != (int)pl_sd->status.skill_point) {
  1180. pl_sd->status.skill_point = new_skill_point;
  1181. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  1182. clif_displaymessage(fd, msg_txt(209)); // Character's number of skill points changed!
  1183. } else {
  1184. if (point < 0)
  1185. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  1186. else
  1187. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  1188. return -1;
  1189. }
  1190. } else {
  1191. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1192. return -1;
  1193. }
  1194. return 0;
  1195. }
  1196. /*==========================================
  1197. * Character Status Point (rewritten by [Yor])
  1198. *------------------------------------------*/
  1199. int charcommand_stpoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1200. {
  1201. struct map_session_data *pl_sd;
  1202. char player[NAME_LENGTH];
  1203. int new_status_point;
  1204. int point = 0;
  1205. nullpo_retr(-1, sd);
  1206. if (!message || !*message || sscanf(message, "%d %23[^\n]", &point, player) < 2 || point == 0) {
  1207. clif_displaymessage(fd, "Please, enter a number and a player name (usage: @charstpoint <amount> <name>).");
  1208. return -1;
  1209. }
  1210. if ((pl_sd = map_nick2sd(player)) != NULL) {
  1211. if (point > 0 && pl_sd->status.status_point > USHRT_MAX - point)
  1212. new_status_point = USHRT_MAX;
  1213. else if (point < 0 && pl_sd->status.status_point < -point)
  1214. new_status_point = 0;
  1215. else
  1216. new_status_point = pl_sd->status.status_point + point;
  1217. if (new_status_point != (int)pl_sd->status.status_point) {
  1218. pl_sd->status.status_point = new_status_point;
  1219. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  1220. clif_displaymessage(fd, msg_txt(210)); // Character's number of status points changed!
  1221. } else {
  1222. if (point < 0)
  1223. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  1224. else
  1225. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  1226. return -1;
  1227. }
  1228. } else {
  1229. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1230. return -1;
  1231. }
  1232. return 0;
  1233. }
  1234. /*==========================================
  1235. * charchangesex command (usage: charchangesex <player_name>)
  1236. *------------------------------------------*/
  1237. int charcommand_changesex(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1238. {
  1239. struct map_session_data *pl_sd;
  1240. char player[NAME_LENGTH];
  1241. nullpo_retr(-1, sd);
  1242. if (!message || !*message || sscanf(message, "%23[^\n]", player) < 1) {
  1243. clif_displaymessage(fd, "Please, enter a player name (usage: @charchangesex <name>).");
  1244. return -1;
  1245. }
  1246. if ((pl_sd = map_nick2sd(player)) == NULL)
  1247. {
  1248. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1249. return -1;
  1250. }
  1251. if (pc_isGM(sd) < pc_isGM(pl_sd)) {
  1252. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1253. return -1;
  1254. }
  1255. clif_displaymessage(fd, msg_table[88]); // Character name sent to char-server to ask it.
  1256. chrif_changesex(pl_sd);
  1257. return 0;
  1258. }
  1259. /*==========================================
  1260. * Feel (SG save map) Reset
  1261. *------------------------------------------*/
  1262. int charcommand_feelreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1263. {
  1264. char character[NAME_LENGTH];
  1265. char output[200];
  1266. struct map_session_data *pl_sd;
  1267. memset(character, '\0', sizeof(character));
  1268. memset(output, '\0', sizeof(output));
  1269. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  1270. clif_displaymessage(fd, "Please, enter a player name (usage: #feelreset <charname>).");
  1271. return -1;
  1272. }
  1273. if ((pl_sd = map_nick2sd(character)) != NULL) {
  1274. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset a character only for lower or same GM level
  1275. pc_resetfeel(pl_sd);
  1276. sprintf(output, msg_txt(267), character); // '%s' designated maps reseted!
  1277. clif_displaymessage(fd, output);
  1278. } else {
  1279. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1280. return -1;
  1281. }
  1282. } else {
  1283. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1284. return -1;
  1285. }
  1286. return 0;
  1287. }
  1288. /*==========================================
  1289. * #help - Char commands [Kayla]
  1290. *------------------------------------------*/
  1291. int charcommand_help(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1292. {
  1293. char buf[2048], w1[2048], w2[2048];
  1294. int i, gm_level;
  1295. FILE* fp;
  1296. nullpo_retr(-1, sd);
  1297. memset(buf, '\0', sizeof(buf));
  1298. if ((fp = fopen(charhelp_txt, "r")) != NULL) {
  1299. clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
  1300. gm_level = pc_isGM(sd);
  1301. while(fgets(buf, sizeof(buf), fp) != NULL)
  1302. {
  1303. if (buf[0] == '/' && buf[1] == '/')
  1304. continue;
  1305. for (i = 0; buf[i] != '\0'; i++) {
  1306. if (buf[i] == '\r' || buf[i] == '\n') {
  1307. buf[i] = '\0';
  1308. break;
  1309. }
  1310. }
  1311. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1312. clif_displaymessage(fd, buf);
  1313. else if (gm_level >= atoi(w1))
  1314. clif_displaymessage(fd, w2);
  1315. }
  1316. fclose(fp);
  1317. } else {
  1318. clif_displaymessage(fd, msg_txt(27)); /* File help.txt not found. */
  1319. return -1;
  1320. }
  1321. return 0;
  1322. }
  1323. /*==========================================
  1324. * Loads a character back to their save point [HiddenDragon]
  1325. *------------------------------------------*/
  1326. int charcommand_load(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1327. {
  1328. int m;
  1329. char character[NAME_LENGTH];
  1330. struct map_session_data *pl_sd;
  1331. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  1332. clif_displaymessage(fd, "Please, enter a player name (usage: #load <player>).");
  1333. return -1;
  1334. }
  1335. if ( (pl_sd = map_nick2sd(character)) == NULL )
  1336. {
  1337. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1338. return -1;
  1339. }
  1340. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  1341. {
  1342. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1343. return -1;
  1344. }
  1345. m = map_mapindex2mapid(pl_sd->status.save_point.map);
  1346. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(pl_sd)) {
  1347. clif_displaymessage(fd, "Not authorized to warp to target map.");
  1348. return -1;
  1349. }
  1350. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(pl_sd)) {
  1351. clif_displaymessage(fd, "Not authorized to warp from current map.");
  1352. return -1;
  1353. }
  1354. pc_setpos(pl_sd, pl_sd->status.save_point.map, pl_sd->status.save_point.x, pl_sd->status.save_point.y, 0);
  1355. clif_displaymessage(pl_sd->fd, msg_txt(7)); // Warping to respawn point.
  1356. if (pl_sd->fd != fd)
  1357. clif_displaymessage(fd, msg_txt(7)); // Warping to respawn point.
  1358. return 0;
  1359. }
  1360. /*==========================================
  1361. * Changes the targets speed [HiddenDragon]
  1362. *------------------------------------------*/
  1363. int charcommand_speed(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1364. {
  1365. int speed;
  1366. char character[NAME_LENGTH];
  1367. char output[200];
  1368. struct map_session_data *pl_sd;
  1369. if (!message || !*message || sscanf(message, "%d %23[^\n]", &speed, character) < 2) {
  1370. sprintf(output, "Please, enter proper values (usage: #speed <%d-%d> <player>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1371. clif_displaymessage(fd, output);
  1372. return -1;
  1373. }
  1374. if ( (pl_sd = map_nick2sd(character)) == NULL )
  1375. {
  1376. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1377. return -1;
  1378. }
  1379. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  1380. {
  1381. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1382. return -1;
  1383. }
  1384. pl_sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  1385. status_calc_bl(&pl_sd->bl, SCB_SPEED);
  1386. clif_displaymessage(pl_sd->fd, msg_txt(8)); // Speed changed.
  1387. if (pl_sd->fd != fd)
  1388. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  1389. return 0;
  1390. }
  1391. /*==========================================
  1392. * Opens their storage [HiddenDragon]
  1393. *------------------------------------------*/
  1394. int charcommand_storage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1395. {
  1396. char character[NAME_LENGTH];
  1397. struct map_session_data *pl_sd;
  1398. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  1399. clif_displaymessage(fd, "Please, enter a player name (usage: #storage <player>).");
  1400. return -1;
  1401. }
  1402. if ( (pl_sd = map_nick2sd(character)) == NULL )
  1403. {
  1404. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1405. return -1;
  1406. }
  1407. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  1408. {
  1409. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1410. return -1;
  1411. }
  1412. if (pl_sd->npc_id || pl_sd->vender_id || pl_sd->state.trading || pl_sd->state.storage_flag)
  1413. return -1;
  1414. if (storage_storageopen(pl_sd) == 1)
  1415. { //Already open.
  1416. clif_displaymessage(fd, "Players storage already open.");
  1417. return -1;
  1418. }
  1419. clif_displaymessage(pl_sd->fd, "Storage opened.");
  1420. if (pl_sd->fd != fd)
  1421. clif_displaymessage(fd, "Player's storage opened.");
  1422. return 0;
  1423. }
  1424. /*==========================================
  1425. * Opens their guild storage
  1426. *------------------------------------------*/
  1427. int charcommand_guildstorage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1428. {
  1429. char character[NAME_LENGTH];
  1430. struct map_session_data *pl_sd;
  1431. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  1432. clif_displaymessage(fd, "Please, enter a player name (usage: #gstorage <player>).");
  1433. return -1;
  1434. }
  1435. if ( (pl_sd = map_nick2sd(character)) == NULL )
  1436. {
  1437. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1438. return -1;
  1439. }
  1440. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  1441. {
  1442. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1443. return -1;
  1444. }
  1445. if (pl_sd->npc_id || pl_sd->vender_id || pl_sd->state.trading)
  1446. return -1;
  1447. if (pl_sd->status.guild_id == 0) {
  1448. clif_displaymessage(fd, "Target player is not in a guild.");
  1449. return -1;
  1450. }
  1451. if (pl_sd->state.storage_flag) {
  1452. clif_displaymessage(fd, "Guild storage is currently in use.");
  1453. return -1;
  1454. }
  1455. storage_guild_storageopen(pl_sd);
  1456. clif_displaymessage(pl_sd->fd, "Guild storage opened.");
  1457. if (pl_sd->fd != fd)
  1458. clif_displaymessage(fd, "Player's guild storage opened.");
  1459. return 0;
  1460. }
  1461. /*==========================================
  1462. * Applies GM Hide to a character [HiddenDragon]
  1463. *------------------------------------------*/
  1464. int charcommand_hide(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1465. {
  1466. char character[NAME_LENGTH];
  1467. struct map_session_data *pl_sd;
  1468. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  1469. clif_displaymessage(fd, "Please, enter a player name (usage: #hide <player>).");
  1470. return -1;
  1471. }
  1472. if ( (pl_sd = map_nick2sd(character)) == NULL )
  1473. {
  1474. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1475. return -1;
  1476. }
  1477. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  1478. {
  1479. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1480. return -1;
  1481. }
  1482. if (pl_sd->sc.option & OPTION_INVISIBLE) {
  1483. pl_sd->sc.option &= ~OPTION_INVISIBLE;
  1484. if (pl_sd->disguise)
  1485. status_set_viewdata(&pl_sd->bl, pl_sd->disguise);
  1486. else
  1487. status_set_viewdata(&pl_sd->bl, pl_sd->status.class_);
  1488. clif_changeoption(&pl_sd->bl);
  1489. clif_displaymessage(pl_sd->fd, msg_txt(10)); // Invisible: Off
  1490. if (pl_sd->fd != fd)
  1491. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  1492. } else {
  1493. pl_sd->sc.option |= OPTION_INVISIBLE;
  1494. pl_sd->vd.class_ = INVISIBLE_CLASS;
  1495. clif_changeoption(&pl_sd->bl);
  1496. clif_displaymessage(pl_sd->fd, msg_txt(11)); // Invisible: On
  1497. if (pl_sd->fd != fd)
  1498. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  1499. }
  1500. return 0;
  1501. }
  1502. /*==========================================
  1503. * Resurrects a dead character [HiddenDragon]
  1504. *------------------------------------------*/
  1505. int charcommand_alive(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1506. {
  1507. char character[NAME_LENGTH];
  1508. struct map_session_data *pl_sd;
  1509. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  1510. clif_displaymessage(fd, "Please, enter a player name (usage: #alive <player>).");
  1511. return -1;
  1512. }
  1513. if ( (pl_sd = map_nick2sd(character)) == NULL )
  1514. {
  1515. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1516. return -1;
  1517. }
  1518. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  1519. {
  1520. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1521. return -1;
  1522. }
  1523. if (!status_revive(&pl_sd->bl, 100, 100))
  1524. {
  1525. clif_displaymessage(fd, "Target player is not dead.");
  1526. return -1;
  1527. }
  1528. clif_skill_nodamage(&pl_sd->bl,&pl_sd->bl,ALL_RESURRECTION,4,1);
  1529. clif_displaymessage(pl_sd->fd, msg_txt(16)); // You've been revived! It's a miracle!
  1530. return 0;
  1531. }
  1532. /*==========================================
  1533. * Heals someone's HP and SP [HiddenDragon]
  1534. *------------------------------------------*/
  1535. int charcommand_heal(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1536. {
  1537. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1538. char character[NAME_LENGTH];
  1539. struct map_session_data *pl_sd;
  1540. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &hp, &sp, character) < 3) {
  1541. clif_displaymessage(fd, "Please, enter proper values (usage: #heal <hp> <sp> <player>).");
  1542. return -1;
  1543. }
  1544. if ( (pl_sd = map_nick2sd(character)) == NULL )
  1545. {
  1546. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1547. return -1;
  1548. }
  1549. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  1550. {
  1551. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1552. return -1;
  1553. }
  1554. if (hp == 0 && sp == 0) {
  1555. if (!status_percent_heal(&pl_sd->bl, 100, 100))
  1556. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1557. else
  1558. {
  1559. clif_displaymessage(pl_sd->fd, msg_txt(17)); // HP, SP recovered.
  1560. if (pl_sd->fd != fd)
  1561. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1562. }
  1563. return 0;
  1564. }
  1565. if(hp > 0 && sp >= 0) {
  1566. if(!status_heal(&pl_sd->bl, hp, sp, 2))
  1567. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1568. else
  1569. {
  1570. clif_displaymessage(pl_sd->fd, msg_txt(17)); // HP, SP recovered.
  1571. if (pl_sd->fd != fd)
  1572. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1573. }
  1574. return 0;
  1575. }
  1576. if(hp < 0 && sp <= 0) {
  1577. status_damage(NULL, &pl_sd->bl, -hp, -sp, 0, 0);
  1578. clif_damage(&pl_sd->bl,&pl_sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  1579. clif_displaymessage(pl_sd->fd, msg_txt(156)); // HP or/and SP modified.
  1580. if (pl_sd->fd != fd)
  1581. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1582. return 0;
  1583. }
  1584. //Opposing signs.
  1585. if (hp) {
  1586. if (hp > 0)
  1587. status_heal(&pl_sd->bl, hp, 0, 2);
  1588. else {
  1589. status_damage(NULL, &pl_sd->bl, -hp, 0, 0, 0);
  1590. clif_damage(&pl_sd->bl,&pl_sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  1591. }
  1592. }
  1593. if (sp) {
  1594. if (sp > 0)
  1595. status_heal(&pl_sd->bl, 0, sp, 2);
  1596. else
  1597. status_damage(NULL, &pl_sd->bl, 0, -sp, 0, 0);
  1598. }
  1599. clif_displaymessage(pl_sd->fd, msg_txt(156)); // HP or/and SP modified.
  1600. if (pl_sd->fd != fd)
  1601. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1602. return 0;
  1603. }
  1604. /*==========================================
  1605. * Creates items as specified [HiddenDragon]
  1606. *------------------------------------------*/
  1607. int charcommand_item2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1608. {
  1609. struct item item_tmp;
  1610. struct item_data *item_data;
  1611. char item_name[100];
  1612. int item_id, number = 0;
  1613. int identify = 0, refine = 0, attr = 0;
  1614. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1615. int flag;
  1616. int loop, get_count, i;
  1617. char character[NAME_LENGTH];
  1618. struct map_session_data *pl_sd;
  1619. if (!message || !*message || (
  1620. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d %23[^\n]", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, character) < 10 &&
  1621. sscanf(message, "%99s %d %d %d %d %d %d %d %d %23[^\n]", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, character) < 10
  1622. )) {
  1623. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  1624. clif_displaymessage(fd, " <Identify_flag[1|0]> <refine> <attribut> <Card1> <Card2> <Card3> <Card4> <player>).");
  1625. return -1;
  1626. }
  1627. if ( (pl_sd = map_nick2sd(character)) == NULL )
  1628. {
  1629. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1630. return -1;
  1631. }
  1632. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  1633. {
  1634. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1635. return -1;
  1636. }
  1637. if (number <= 0)
  1638. number = 1;
  1639. item_id = 0;
  1640. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1641. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1642. item_id = item_data->nameid;
  1643. if (item_id > 500) {
  1644. loop = 1;
  1645. get_count = number;
  1646. if (item_data->type == 4 || item_data->type == 5 ||
  1647. item_data->type == 7 || item_data->type == 8) {
  1648. loop = number;
  1649. get_count = 1;
  1650. if (item_data->type == 7) {
  1651. identify = 1;
  1652. refine = 0;
  1653. }
  1654. if (item_data->type == 8)
  1655. refine = 0;
  1656. if (refine > 10)
  1657. refine = 10;
  1658. } else {
  1659. identify = 1;
  1660. refine = attr = 0;
  1661. }
  1662. for (i = 0; i < loop; i++) {
  1663. memset(&item_tmp, 0, sizeof(item_tmp));
  1664. item_tmp.nameid = item_id;
  1665. item_tmp.identify = identify;
  1666. item_tmp.refine = refine;
  1667. item_tmp.attribute = attr;
  1668. item_tmp.card[0] = c1;
  1669. item_tmp.card[1] = c2;
  1670. item_tmp.card[2] = c3;
  1671. item_tmp.card[3] = c4;
  1672. if ((flag = pc_additem(pl_sd, &item_tmp, get_count)))
  1673. clif_additem(pl_sd, 0, 0, flag);
  1674. }
  1675. //Logs (A)dmins items [Lupus]
  1676. if(log_config.enable_logs&0x400)
  1677. log_pick_pc(pl_sd, "A", item_tmp.nameid, number, &item_tmp);
  1678. clif_displaymessage(pl_sd->fd, msg_txt(18)); // Item created.
  1679. if (pl_sd->fd != fd)
  1680. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1681. } else {
  1682. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1683. return -1;
  1684. }
  1685. return 0;
  1686. }
  1687. /*==========================================
  1688. * Reset a character's items [HiddenDragon]
  1689. *------------------------------------------*/
  1690. int charcommand_itemreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1691. {
  1692. int i, count = 0;
  1693. char character[NAME_LENGTH];
  1694. char output[200];
  1695. struct map_session_data *pl_sd;
  1696. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  1697. clif_displaymessage(fd, "Please, enter a player name (usage: #itemreset <player>).");
  1698. return -1;
  1699. }
  1700. if ( (pl_sd = map_nick2sd(character)) == NULL )
  1701. {
  1702. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1703. return -1;
  1704. }
  1705. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  1706. {
  1707. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1708. return -1;
  1709. }
  1710. for (i = 0; i < MAX_INVENTORY; i++) {
  1711. if (pl_sd->status.inventory[i].amount && pl_sd->status.inventory[i].equip == 0) {
  1712. //Logs (A)dmins items [Lupus]
  1713. if(log_config.enable_logs&0x400)
  1714. log_pick_pc(pl_sd, "A", pl_sd->status.inventory[i].nameid, -pl_sd->status.inventory[i].amount, &pl_sd->status.inventory[i]);
  1715. pc_delitem(pl_sd, i, pl_sd->status.inventory[i].amount, 0);
  1716. count++;
  1717. }
  1718. }
  1719. sprintf(output, msg_txt(114), count);
  1720. if (pl_sd->fd != fd)
  1721. clif_displaymessage(pl_sd->fd, output); // %d item(s) removed from the player.
  1722. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  1723. return 0;
  1724. }
  1725. /*==========================================
  1726. * Refine their items [HiddenDragon]
  1727. *------------------------------------------*/
  1728. int charcommand_refine(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1729. {
  1730. int i,j, position = 0, refine = 0, current_position, final_refine;
  1731. int count;
  1732. char character[NAME_LENGTH];
  1733. char output[200];
  1734. struct map_session_data *pl_sd;
  1735. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &position, &refine, character) < 3) {
  1736. clif_displaymessage(fd, "Please, enter a position and a amount (usage: #refine <equip position> <+/- amount> <player>).");
  1737. sprintf(output, "%d: Left Accessory", EQI_ACC_L);
  1738. clif_displaymessage(fd, output);
  1739. sprintf(output, "%d: Right Accessory", EQI_ACC_R);
  1740. clif_displaymessage(fd, output);
  1741. sprintf(output, "%d: Shoes", EQI_SHOES);
  1742. clif_displaymessage(fd, output);
  1743. sprintf(output, "%d: Garment", EQI_GARMENT);
  1744. clif_displaymessage(fd, output);
  1745. sprintf(output, "%d: Lower Headgear", EQI_HEAD_LOW);
  1746. clif_displaymessage(fd, output);
  1747. sprintf(output, "%d: Mid Headgear", EQI_HEAD_MID);
  1748. clif_displaymessage(fd, output);
  1749. sprintf(output, "%d: Top Headgear", EQI_HEAD_TOP);
  1750. clif_displaymessage(fd, output);
  1751. sprintf(output, "%d: Body Armor", EQI_ARMOR);
  1752. clif_displaymessage(fd, output);
  1753. sprintf(output, "%d: Left Hand", EQI_HAND_L);
  1754. clif_displaymessage(fd, output);
  1755. sprintf(output, "%d: Right Hand", EQI_HAND_R);
  1756. clif_displaymessage(fd, output);
  1757. return -1;
  1758. }
  1759. if ( (pl_sd = map_nick2sd(character)) == NULL )
  1760. {
  1761. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1762. return -1;
  1763. }
  1764. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  1765. {
  1766. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1767. return -1;
  1768. }
  1769. if (refine < -MAX_REFINE)
  1770. refine = -MAX_REFINE;
  1771. else if (refine > MAX_REFINE)
  1772. refine = MAX_REFINE;
  1773. else if (refine == 0)
  1774. refine = 1;
  1775. count = 0;
  1776. for (j = 0; j < EQI_MAX-1; j++) {
  1777. if ((i = pl_sd->equip_index[j]) < 0)
  1778. continue;
  1779. if(j == EQI_HAND_R && pl_sd->equip_index[EQI_HAND_L] == i)
  1780. continue;
  1781. if(j == EQI_HEAD_MID && pl_sd->equip_index[EQI_HEAD_LOW] == i)
  1782. continue;
  1783. if(j == EQI_HEAD_TOP && (pl_sd->equip_index[EQI_HEAD_MID] == i || pl_sd->equip_index[EQI_HEAD_LOW] == i))
  1784. continue;
  1785. if(position && !(pl_sd->status.inventory[i].equip & position))
  1786. continue;
  1787. final_refine = pl_sd->status.inventory[i].refine + refine;
  1788. if (final_refine > MAX_REFINE)
  1789. final_refine = MAX_REFINE;
  1790. else if (final_refine < 0)
  1791. final_refine = 0;
  1792. if (pl_sd->status.inventory[i].refine != final_refine) {
  1793. pl_sd->status.inventory[i].refine = final_refine;
  1794. current_position = pl_sd->status.inventory[i].equip;
  1795. pc_unequipitem(pl_sd, i, 3);
  1796. clif_refine(fd, 0, i, pl_sd->status.inventory[i].refine);
  1797. clif_delitem(pl_sd, i, 1);
  1798. clif_additem(pl_sd, i, 1, 0);
  1799. pc_equipitem(pl_sd, i, current_position);
  1800. clif_misceffect(&pl_sd->bl, 3);
  1801. count++;
  1802. }
  1803. }
  1804. if (count == 0)
  1805. clif_displaymessage(fd, msg_txt(166)); // No item has been refined!
  1806. else if (count == 1)
  1807. {
  1808. clif_displaymessage(pl_sd->fd, msg_txt(167)); // 1 item has been refined!
  1809. if (pl_sd->fd != fd)
  1810. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined!
  1811. }
  1812. else {
  1813. sprintf(output, msg_txt(168), count); // %d items have been refined!
  1814. clif_displaymessage(pl_sd->fd, output);
  1815. if (pl_sd->fd != fd)
  1816. clif_displaymessage(fd, output);
  1817. }
  1818. return 0;
  1819. }
  1820. /*==========================================
  1821. * Produce a manufactured item in their inventory [HiddenDragon]
  1822. *------------------------------------------*/
  1823. int charcommand_produce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1824. {
  1825. char item_name[100];
  1826. int item_id, attribute = 0, star = 0;
  1827. int flag = 0;
  1828. struct item_data *item_data;
  1829. struct item tmp_item;
  1830. char character[NAME_LENGTH];
  1831. char output[200];
  1832. struct map_session_data *pl_sd;
  1833. nullpo_retr(-1, sd);
  1834. if (!message || !*message || (
  1835. sscanf(message, "\"%99[^\"]\" %d %d %23[^\n]", item_name, &attribute, &star, character) < 4 &&
  1836. sscanf(message, "%99s %d %d %23[^\n]", item_name, &attribute, &star, character) < 4
  1837. )) {
  1838. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: #produce <equip name or equip ID> <element> <# of very's> <player>).");
  1839. return -1;
  1840. }
  1841. if ( (pl_sd = map_nick2sd(character)) == NULL )
  1842. {
  1843. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1844. return -1;
  1845. }
  1846. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  1847. {
  1848. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1849. return -1;
  1850. }
  1851. item_id = 0;
  1852. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  1853. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  1854. {
  1855. sprintf(output, msg_txt(170)); // This item is not an equipment.
  1856. clif_displaymessage(fd, output);
  1857. return -1;
  1858. }
  1859. item_id = item_data->nameid;
  1860. if (itemdb_isequip2(item_data)) {
  1861. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  1862. attribute = ATTRIBUTE_NORMAL;
  1863. if (star < MIN_STAR || star > MAX_STAR)
  1864. star = 0;
  1865. memset(&tmp_item, 0, sizeof tmp_item);
  1866. tmp_item.nameid = item_id;
  1867. tmp_item.amount = 1;
  1868. tmp_item.identify = 1;
  1869. tmp_item.card[0] = CARD0_FORGE;
  1870. tmp_item.card[1] = item_data->type==IT_WEAPON?
  1871. ((star*5) << 8) + attribute:0;
  1872. tmp_item.card[2] = GetWord(pl_sd->status.char_id, 0);
  1873. tmp_item.card[3] = GetWord(pl_sd->status.char_id, 1);
  1874. clif_produceeffect(pl_sd, 0, item_id);
  1875. clif_misceffect(&pl_sd->bl, 3);
  1876. //Logs (A)dmins items [Lupus]
  1877. if(log_config.enable_logs&0x400)
  1878. log_pick_pc(pl_sd, "A", tmp_item.nameid, 1, &tmp_item);
  1879. if ((flag = pc_additem(pl_sd, &tmp_item, 1)))
  1880. {
  1881. clif_additem(pl_sd, 0, 0, flag);
  1882. clif_displaymessage(fd, msg_txt(18));
  1883. }
  1884. } else {
  1885. sprintf(output, msg_txt(169), item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  1886. clif_displaymessage(fd, output);
  1887. return -1;
  1888. }
  1889. return 0;
  1890. }
  1891. /*==========================================
  1892. * Changes a character's stats [HiddenDragon
  1893. *------------------------------------------*/
  1894. int charcommand_param(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1895. {
  1896. int index, value = 0, new_value;
  1897. char character[NAME_LENGTH];
  1898. char output[200];
  1899. struct map_session_data *pl_sd;
  1900. const char* param[] = { "#str", "#agi", "#vit", "#int", "#dex", "#luk", NULL };
  1901. short* status[6];
  1902. if (!message || !*message || sscanf(message, "%d %s", &value, character) < 2 || value == 0) {
  1903. sprintf(output, "Please, enter a valid value (usage: #str,#agi,#vit,#int,#dex,#luk <+/-adjustment> <player>).");
  1904. clif_displaymessage(fd, output);
  1905. return -1;
  1906. }
  1907. if ( (pl_sd = map_nick2sd(character)) == NULL )
  1908. {
  1909. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1910. return -1;
  1911. }
  1912. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  1913. {
  1914. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1915. return -1;
  1916. }
  1917. status[0] = &pl_sd->status.str;
  1918. status[1] = &pl_sd->status.agi;
  1919. status[2] = &pl_sd->status.vit;
  1920. status[3] = &pl_sd->status.int_;
  1921. status[4] = &pl_sd->status.dex;
  1922. status[5] = &pl_sd->status.luk;
  1923. index = -1;
  1924. for (index = 0; index < ARRAYLENGTH(param); index++) {
  1925. if (strcmpi(command, param[index]) == 0)
  1926. break;
  1927. }
  1928. if (index == ARRAYLENGTH(param) || index > MAX_STATUS_TYPE) {
  1929. // normaly impossible...
  1930. sprintf(output, "Please, enter a valid value (usage: #str,#agi,#vit,#int,#dex,#luk <+/-adjustment> <player>).");
  1931. clif_displaymessage(fd, output);
  1932. return -1;
  1933. }
  1934. if (value > 0 && *status[index] > 999 - value)
  1935. new_value = 999;
  1936. else if (value < 0 && *status[index] <= -value)
  1937. new_value = 1;
  1938. else
  1939. new_value = *status[index] + value;
  1940. if (new_value != (int)*status[index]) {
  1941. *status[index] = new_value;
  1942. clif_updatestatus(pl_sd, SP_STR + index);
  1943. clif_updatestatus(pl_sd, SP_USTR + index);
  1944. status_calc_pc(pl_sd, 0);
  1945. clif_displaymessage(pl_sd->fd, msg_txt(42)); // Stat changed.
  1946. if (pl_sd->fd != fd)
  1947. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  1948. } else {
  1949. if (value < 0)
  1950. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  1951. else
  1952. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  1953. return -1;
  1954. }
  1955. return 0;
  1956. }
  1957. /*==========================================
  1958. * Levels up a character's guild [HiddenDragon]
  1959. *------------------------------------------*/
  1960. int charcommand_guildlevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1961. {
  1962. int level = 0;
  1963. short added_level;
  1964. struct guild *guild_info;
  1965. char character[NAME_LENGTH];
  1966. struct map_session_data *pl_sd;
  1967. nullpo_retr(-1, sd);
  1968. if (!message || !*message || sscanf(message, "%d %s", &level, character) < 2 || level == 0) {
  1969. clif_displaymessage(fd, "Please, enter a valid level and player (usage: #guildlvup/@guildlvlup <# of levels> <player>).");
  1970. return -1;
  1971. }
  1972. if ( (pl_sd = map_nick2sd(character)) == NULL )
  1973. {
  1974. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1975. return -1;
  1976. }
  1977. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  1978. {
  1979. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1980. return -1;
  1981. }
  1982. if (pl_sd->status.guild_id <= 0 || (guild_info = guild_search(pl_sd->status.guild_id)) == NULL) {
  1983. clif_displaymessage(fd, "Target player is not in a guild"); // You're not in a guild.
  1984. return -1;
  1985. }
  1986. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  1987. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  1988. // return -1;
  1989. //}
  1990. added_level = (short)level;
  1991. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  1992. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  1993. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  1994. added_level = 1 - guild_info->guild_lv;
  1995. if (added_level != 0) {
  1996. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  1997. clif_displaymessage(pl_sd->fd, msg_txt(179)); // Guild level changed.
  1998. if (pl_sd->fd != fd)
  1999. clif_displaymessage(fd, msg_txt(179));
  2000. } else {
  2001. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  2002. return -1;
  2003. }
  2004. return 0;
  2005. }
  2006. /*==========================================
  2007. * Opens a hatch window for them [HiddenDragon]
  2008. *------------------------------------------*/
  2009. int charcommand_hatch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2010. {
  2011. char character[NAME_LENGTH];
  2012. struct map_session_data *pl_sd;
  2013. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  2014. clif_displaymessage(fd, "Please, enter a player name (usage: #hatch <player>).");
  2015. return -1;
  2016. }
  2017. if ( (pl_sd = map_nick2sd(character)) == NULL )
  2018. {
  2019. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2020. return -1;
  2021. }
  2022. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2023. {
  2024. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2025. return -1;
  2026. }
  2027. if (pl_sd->status.pet_id <= 0)
  2028. clif_sendegg(sd);
  2029. else {
  2030. clif_displaymessage(fd, "Target player already has a pet"); // You already have a pet.
  2031. return -1;
  2032. }
  2033. return 0;
  2034. }
  2035. /*==========================================
  2036. * Change target pet's hunger [HiddenDragon]
  2037. *------------------------------------------*/
  2038. int charcommand_pethungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2039. {
  2040. int hungry;
  2041. struct pet_data *pd;
  2042. char character[NAME_LENGTH];
  2043. struct map_session_data *pl_sd;
  2044. nullpo_retr(-1, sd);
  2045. if (!message || !*message || sscanf(message, "%d %23[^\n]", &hungry, character) < 2) {
  2046. clif_displaymessage(fd, "Please, enter a valid number and player (usage: #pethungry <0-100> <player>).");
  2047. return -1;
  2048. }
  2049. if ( (pl_sd = map_nick2sd(character)) == NULL )
  2050. {
  2051. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2052. return -1;
  2053. }
  2054. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2055. {
  2056. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2057. return -1;
  2058. }
  2059. pd = pl_sd->pd;
  2060. if (!pl_sd->status.pet_id || !pd) {
  2061. clif_displaymessage(fd, "Target has no pet"); // Sorry, but you have no pet.
  2062. return -1;
  2063. }
  2064. if (hungry < 0 || hungry > 100) {
  2065. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2066. return -1;
  2067. }
  2068. if (hungry == pd->pet.hungry) {
  2069. clif_displaymessage(fd, msg_txt(186)); // Pet hungry is already the good value.
  2070. return -1;
  2071. }
  2072. pd->pet.hungry = hungry;
  2073. clif_send_petstatus(pl_sd);
  2074. clif_displaymessage(pl_sd->fd, msg_txt(185)); // Pet hungry value changed!
  2075. if (pl_sd->fd != fd)
  2076. clif_displaymessage(fd, msg_txt(185)); // Pet hungry value changed!
  2077. return 0;
  2078. }
  2079. /*==========================================
  2080. * Give all skills to target [HiddenDragon]
  2081. *------------------------------------------*/
  2082. int charcommand_allskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2083. {
  2084. char character[NAME_LENGTH];
  2085. struct map_session_data *pl_sd;
  2086. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  2087. clif_displaymessage(fd, "Please, enter a player name (usage: #allskill <player>).");
  2088. return -1;
  2089. }
  2090. if ( (pl_sd = map_nick2sd(character)) == NULL )
  2091. {
  2092. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2093. return -1;
  2094. }
  2095. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2096. {
  2097. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2098. return -1;
  2099. }
  2100. pc_allskillup(pl_sd); // all skills
  2101. pl_sd->status.skill_point = 0; // 0 skill points
  2102. clif_updatestatus(pl_sd, SP_SKILLPOINT); // update
  2103. clif_displaymessage(pl_sd->fd, msg_txt(76)); // You have received all skills.
  2104. if (pl_sd->fd != fd)
  2105. clif_displaymessage(fd, "Player has received all skills for his/her class.");
  2106. return 0;
  2107. }
  2108. /*==========================================
  2109. * Change target's clothing color [HiddenDragon]
  2110. *------------------------------------------*/
  2111. int charcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2112. {
  2113. int cloth_color = 0;
  2114. char character[NAME_LENGTH];
  2115. char output[200];
  2116. struct map_session_data *pl_sd;
  2117. if (!message || !*message || sscanf(message, "%d %23[^\n]", &cloth_color, character) < 2) {
  2118. sprintf(output, "Please, enter a clothes color (usage: #dye/@ccolor <clothes color: %d-%d> <player>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2119. clif_displaymessage(fd,output);
  2120. return -1;
  2121. }
  2122. if ( (pl_sd = map_nick2sd(character)) == NULL )
  2123. {
  2124. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2125. return -1;
  2126. }
  2127. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2128. {
  2129. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2130. return -1;
  2131. }
  2132. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2133. pc_changelook(pl_sd, LOOK_CLOTHES_COLOR, cloth_color);
  2134. clif_displaymessage(pl_sd->fd, msg_txt(36)); // Appearence changed.
  2135. if (pl_sd->fd != fd)
  2136. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2137. } else {
  2138. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2139. return -1;
  2140. }
  2141. return 0;
  2142. }
  2143. /*==========================================
  2144. * Change target's hair style [HiddenDragon]
  2145. *------------------------------------------*/
  2146. int charcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2147. {
  2148. int hair_style = 0;
  2149. char character[NAME_LENGTH];
  2150. char output[200];
  2151. struct map_session_data *pl_sd;
  2152. nullpo_retr(-1, sd);
  2153. if (!message || !*message || sscanf(message, "%d %23[^\n]", &hair_style, character) < 2) {
  2154. sprintf(output, "Please, enter a hair style (usage: #hairstyle/#hstyle <hair ID: %d-%d> <player>.", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2155. clif_displaymessage(fd, output);
  2156. return -1;
  2157. }
  2158. if ( (pl_sd = map_nick2sd(character)) == NULL )
  2159. {
  2160. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2161. return -1;
  2162. }
  2163. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2164. {
  2165. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2166. return -1;
  2167. }
  2168. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2169. pc_changelook(pl_sd, LOOK_HAIR, hair_style);
  2170. clif_displaymessage(pl_sd->fd, msg_txt(36)); // Appearence changed.
  2171. if (pl_sd->fd != fd)
  2172. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2173. } else {
  2174. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2175. return -1;
  2176. }
  2177. return 0;
  2178. }
  2179. /*==========================================
  2180. * Change target's hair color [HiddenDragon]
  2181. *------------------------------------------*/
  2182. int charcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2183. {
  2184. int hair_color = 0;
  2185. char character[NAME_LENGTH];
  2186. char output[200];
  2187. struct map_session_data *pl_sd;
  2188. nullpo_retr(-1, sd);
  2189. memset(output, '\0', sizeof(output));
  2190. if (!message || !*message || sscanf(message, "%d %23[^\n]", &hair_color, character) < 2) {
  2191. sprintf(output, "Please, enter a hair color (usage: #haircolor/#hcolor <hair color: %d-%d> <player>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2192. clif_displaymessage(fd, output);
  2193. return -1;
  2194. }
  2195. if ( (pl_sd = map_nick2sd(character)) == NULL )
  2196. {
  2197. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2198. return -1;
  2199. }
  2200. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2201. {
  2202. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2203. return -1;
  2204. }
  2205. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2206. pc_changelook(pl_sd, LOOK_HAIR_COLOR, hair_color);
  2207. clif_displaymessage(pl_sd->fd, msg_txt(36)); // Appearence changed.
  2208. if (pl_sd->fd != fd)
  2209. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2210. } else {
  2211. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2212. return -1;
  2213. }
  2214. return 0;
  2215. }
  2216. /*==========================================
  2217. * Change all target's stats [HiddenDragon]
  2218. *------------------------------------------*/
  2219. int charcommand_allstats(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2220. {
  2221. int index, count, value = 0, max, new_value;
  2222. short* status[6];
  2223. char character[NAME_LENGTH];
  2224. struct map_session_data *pl_sd;
  2225. //we don't use direct initialization because it isn't part of the c standard.
  2226. nullpo_retr(-1, sd);
  2227. memset(character, '\0', sizeof(character));
  2228. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  2229. clif_displaymessage(fd, "Please, enter a player name (usage: #statall/#statsall/#allstat/#allstats <player>).");
  2230. return -1;
  2231. }
  2232. if ( (pl_sd = map_nick2sd(character)) == NULL )
  2233. {
  2234. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2235. return -1;
  2236. }
  2237. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2238. {
  2239. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2240. return -1;
  2241. }
  2242. status[0] = &pl_sd->status.str;
  2243. status[1] = &pl_sd->status.agi;
  2244. status[2] = &pl_sd->status.vit;
  2245. status[3] = &pl_sd->status.int_;
  2246. status[4] = &pl_sd->status.dex;
  2247. status[5] = &pl_sd->status.luk;
  2248. count = 0;
  2249. max = pc_maxparameter(pl_sd);
  2250. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2251. if (value > 0 && *status[index] > max - value)
  2252. new_value = max;
  2253. else if (value < 0 && *status[index] <= -value)
  2254. new_value = 1;
  2255. else
  2256. new_value = *status[index] +value;
  2257. if (new_value != (int)*status[index]) {
  2258. *status[index] = new_value;
  2259. clif_updatestatus(pl_sd, SP_STR + index);
  2260. clif_updatestatus(pl_sd, SP_USTR + index);
  2261. status_calc_pc(pl_sd, 0);
  2262. count++;
  2263. }
  2264. }
  2265. if (count > 0) // if at least 1 stat modified
  2266. {
  2267. clif_displaymessage(pl_sd->fd, msg_txt(84)); // All stats changed!
  2268. if (fd != pl_sd->fd)
  2269. clif_displaymessage(fd, "Player's stats changed"); // All stats changed!
  2270. }
  2271. else {
  2272. if (value < 0)
  2273. clif_displaymessage(fd, msg_txt(177)); // Impossible to decrease a stat.
  2274. else
  2275. clif_displaymessage(fd, msg_txt(178)); // Impossible to increase a stat.
  2276. return -1;
  2277. }
  2278. return 0;
  2279. }
  2280. /*==========================================
  2281. * Gives/Removes a peco from a player [HiddenDragon]
  2282. *------------------------------------------*/
  2283. int charcommand_mount_peco(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2284. {
  2285. struct map_session_data *pl_sd;
  2286. char character[NAME_LENGTH];
  2287. nullpo_retr(-1, sd);
  2288. memset(character, '\0', sizeof(character));
  2289. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  2290. clif_displaymessage(fd, "Please, enter a player name (usage: #mount/#mountpeco <player>).");
  2291. return -1;
  2292. }
  2293. if ( (pl_sd = map_nick2sd(character)) == NULL )
  2294. {
  2295. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2296. return -1;
  2297. }
  2298. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2299. {
  2300. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2301. return -1;
  2302. }
  2303. if (!pc_isriding(pl_sd))
  2304. { // if actually no peco
  2305. if (!pc_checkskill(pl_sd, KN_RIDING))
  2306. {
  2307. clif_displaymessage(fd, msg_txt(217)); // Player cannot mount a PecoePeco with his/her job.
  2308. return -1;
  2309. }
  2310. if (pl_sd->disguise)
  2311. {
  2312. clif_displaymessage(fd, msg_txt(215)); // Player cannot mount a PecoPeco while in disguise.
  2313. return -1;
  2314. }
  2315. pc_setoption(pl_sd, pl_sd->sc.option | OPTION_RIDING);
  2316. if (pl_sd->fd != fd)
  2317. clif_displaymessage(fd, "Player mounted a peco.");
  2318. clif_displaymessage(pl_sd->fd, msg_txt(216)); // Mounted Peco.
  2319. }
  2320. else
  2321. { //Dismount
  2322. pc_setoption(pl_sd, pl_sd->sc.option & ~OPTION_RIDING);
  2323. clif_displaymessage(pl_sd->fd, msg_txt(218)); // Unmounted Peco.
  2324. if (pl_sd->fd != fd)
  2325. clif_displaymessage(fd, "Player unmounted a peco.");
  2326. }
  2327. return 0;
  2328. }
  2329. /*==========================================
  2330. * Remove items from a player (now a char command) [HiddenDragon]
  2331. *------------------------------------------*/
  2332. int charcommand_delitem(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2333. {
  2334. struct map_session_data *pl_sd;
  2335. char item_name[100];
  2336. int i, number = 0, item_id, item_position, count;
  2337. struct item_data *item_data;
  2338. char character[NAME_LENGTH];
  2339. char output[200];
  2340. nullpo_retr(-1, sd);
  2341. memset(character, '\0', sizeof(character));
  2342. memset(item_name, '\0', sizeof(item_name));
  2343. memset(output, '\0', sizeof(output));
  2344. if (!message || !*message || (
  2345. sscanf(message, "\"%99[^\"]\" %d %23[^\n]", item_name, &number, character) < 3 &&
  2346. sscanf(message, "%s %d %23[^\n]", item_name, &number, character) < 3
  2347. ) || number < 1) {
  2348. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: #delitem <item_name_or_ID> <quantity> <player>).");
  2349. return -1;
  2350. }
  2351. if ( (pl_sd = map_nick2sd(character)) == NULL )
  2352. {
  2353. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2354. return -1;
  2355. }
  2356. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2357. {
  2358. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2359. return -1;
  2360. }
  2361. item_id = 0;
  2362. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2363. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2364. item_id = item_data->nameid;
  2365. if (item_id > 500) {
  2366. item_position = pc_search_inventory(pl_sd, item_id);
  2367. if (item_position >= 0) {
  2368. count = 0;
  2369. for(i = 0; i < number && item_position >= 0; i++) {
  2370. //Logs (A)dmins items [Lupus]
  2371. if(log_config.enable_logs&0x400)
  2372. log_pick_pc(pl_sd, "A", pl_sd->status.inventory[item_position].nameid, -1, &pl_sd->status.inventory[item_position]);
  2373. pc_delitem(pl_sd, item_position, 1, 0);
  2374. count++;
  2375. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  2376. }
  2377. sprintf(output, msg_txt(113), count); // %d item(s) removed by a GM.
  2378. clif_displaymessage(pl_sd->fd, output);
  2379. if (number == count)
  2380. sprintf(output, msg_txt(114), count); // %d item(s) removed from the player.
  2381. else
  2382. sprintf(output, msg_txt(115), count, count, number); // %d item(s) removed. Player had only %d on %d items.
  2383. clif_displaymessage(fd, output);
  2384. } else {
  2385. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  2386. return -1;
  2387. }
  2388. }
  2389. else
  2390. {
  2391. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  2392. return -1;
  2393. }
  2394. return 0;
  2395. }
  2396. //Added by Coltaro
  2397. //We're using this function here instead of using time_t so that it only counts player's jail time when he/she's online (and since the idea is to reduce the amount of minutes one by one in status_change_timer...).
  2398. //Well, using time_t could still work but for some reason that looks like more coding x_x
  2399. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute) {
  2400. const int factor_year = 518400; //12*30*24*60 = 518400
  2401. const int factor_month = 43200; //30*24*60 = 43200
  2402. const int factor_day = 1440; //24*60 = 1440
  2403. const int factor_hour = 60;
  2404. *year = jailtime/factor_year;
  2405. jailtime -= *year*factor_year;
  2406. *month = jailtime/factor_month;
  2407. jailtime -= *month*factor_month;
  2408. *day = jailtime/factor_day;
  2409. jailtime -= *day*factor_day;
  2410. *hour = jailtime/factor_hour;
  2411. jailtime -= *hour*factor_hour;
  2412. *minute = jailtime;
  2413. *year = *year > 0? *year : 0;
  2414. *month = *month > 0? *month : 0;
  2415. *day = *day > 0? *day : 0;
  2416. *hour = *hour > 0? *hour : 0;
  2417. *minute = *minute > 0? *minute : 0;
  2418. return;
  2419. }
  2420. /*==========================================
  2421. * Jail a player for a certain amount of time [Coltaro]
  2422. *------------------------------------------*/
  2423. int charcommand_jailtime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2424. {
  2425. struct map_session_data* pl_sd;
  2426. int year, month, day, hour, minute;
  2427. char character[NAME_LENGTH];
  2428. char output[200];
  2429. memset(character, '\0', sizeof(character));
  2430. nullpo_retr(-1, sd);
  2431. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  2432. clif_displaymessage(fd, "Please, enter a player name (usage: #jailtime <player>).");
  2433. return -1;
  2434. }
  2435. if ( (pl_sd = map_nick2sd(character)) == NULL )
  2436. {
  2437. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2438. return -1;
  2439. }
  2440. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2441. {
  2442. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2443. return -1;
  2444. }
  2445. if (!pl_sd->sc.data[SC_JAILED]) {
  2446. clif_displaymessage(fd, "This player is not in jail.");
  2447. return -1;
  2448. }
  2449. if (pl_sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  2450. clif_displaymessage(fd, "This player has been jailed indefinitely.");
  2451. return 0;
  2452. }
  2453. if (pl_sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  2454. clif_displaymessage(fd, "This player has been jailed for an unknown amount of time.");
  2455. return -1;
  2456. }
  2457. //Get remaining jail time
  2458. get_jail_time(pl_sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  2459. sprintf(output,msg_txt(402),"This player will remain",year,month,day,hour,minute);
  2460. clif_displaymessage(fd, output);
  2461. return 0;
  2462. }
  2463. /*==========================================
  2464. * Disguises a player [HiddenDragon]
  2465. *------------------------------------------*/
  2466. int charcommand_disguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2467. {
  2468. int mob_id;
  2469. char mob_name[NAME_LENGTH];
  2470. struct map_session_data* pl_sd;
  2471. char character[NAME_LENGTH];
  2472. nullpo_retr(-1, sd);
  2473. memset(character, '\0', sizeof(character));
  2474. memset(mob_name, '\0', sizeof(mob_name));
  2475. if (!message || !*message || sscanf(message, "%s %23[^\n]", mob_name, character) < 2) {
  2476. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: #disguise <monster_name_or_monster_ID> <player>).");
  2477. return -1;
  2478. }
  2479. if ( (pl_sd = map_nick2sd(character)) == NULL )
  2480. {
  2481. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2482. return -1;
  2483. }
  2484. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2485. {
  2486. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2487. return -1;
  2488. }
  2489. if ((mob_id = atoi(mob_name)) > 0)
  2490. { //Acquired an ID
  2491. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id))
  2492. mob_id = 0; //Invalid id for either mobs or npcs.
  2493. } else { //Acquired a Name
  2494. if ((mob_id = mobdb_searchname(mob_name)) == 0)
  2495. {
  2496. struct npc_data* nd = npc_name2id(mob_name);
  2497. if (nd != NULL)
  2498. mob_id = nd->class_;
  2499. }
  2500. }
  2501. if (mob_id == 0)
  2502. {
  2503. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
  2504. return -1;
  2505. }
  2506. if(pc_isriding(pl_sd))
  2507. {
  2508. //FIXME: wrong message [ultramage]
  2509. //clif_displaymessage(fd, msg_txt(228)); // Character cannot wear disguise while riding a PecoPeco.
  2510. return -1;
  2511. }
  2512. pc_disguise(pl_sd, mob_id);
  2513. clif_displaymessage(pl_sd->fd, msg_txt(122)); // Disguise applied.
  2514. if (pl_sd->fd != fd)
  2515. clif_displaymessage(fd, msg_txt(140)); // Character's disguise applied.
  2516. return 0;
  2517. }
  2518. /*==========================================
  2519. * Undisguises a player [HiddenDragon]
  2520. *------------------------------------------*/
  2521. int charcommand_undisguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2522. {
  2523. char character[NAME_LENGTH];
  2524. struct map_session_data* pl_sd;
  2525. nullpo_retr(-1, sd);
  2526. memset(character, '\0', sizeof(character));
  2527. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  2528. clif_displaymessage(fd, "Please, enter a player name (usage: #undisguise <player>).");
  2529. return -1;
  2530. }
  2531. if ( (pl_sd = map_nick2sd(character)) == NULL )
  2532. {
  2533. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2534. return -1;
  2535. }
  2536. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2537. {
  2538. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2539. return -1;
  2540. }
  2541. if (pl_sd->disguise)
  2542. {
  2543. pc_disguise(pl_sd, 0);
  2544. clif_displaymessage(pl_sd->fd, msg_txt(124)); // Disguise removed from character
  2545. if (pl_sd->fd != fd)
  2546. clif_displaymessage(fd, msg_txt(141)); // Undisguise applied
  2547. }
  2548. else {
  2549. clif_displaymessage(fd, msg_txt(142)); // Character is not disguised.
  2550. return -1;
  2551. }
  2552. return 0;
  2553. }
  2554. /*==========================================
  2555. * Displays contents of target's cart [HiddenDragon]
  2556. *------------------------------------------*/
  2557. int charcommand_cart_list(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2558. {
  2559. char outputtmp[200];
  2560. char output[200];
  2561. char character[NAME_LENGTH];
  2562. struct map_session_data *pl_sd;
  2563. struct item_data *item_data, *item_temp;
  2564. int i, j, count = 0, counter = 0, counter2;
  2565. nullpo_retr(-1, sd);
  2566. memset(character, '\0', sizeof(character));
  2567. memset(output, '\0', sizeof(output));
  2568. memset(outputtmp, '\0', sizeof(outputtmp));
  2569. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  2570. clif_displaymessage(fd, "Please, enter a player name (usage: #cartlist <player>).");
  2571. return -1;
  2572. }
  2573. if ( (pl_sd = map_nick2sd(character)) == NULL )
  2574. {
  2575. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2576. return -1;
  2577. }
  2578. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2579. {
  2580. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2581. return -1;
  2582. }
  2583. for (i = 0; i < MAX_CART; i++) {
  2584. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  2585. counter = counter + pl_sd->status.cart[i].amount;
  2586. count++;
  2587. if (count == 1) {
  2588. sprintf(output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  2589. clif_displaymessage(fd, output);
  2590. }
  2591. if (pl_sd->status.cart[i].refine)
  2592. sprintf(output, "%d %s %+d (%s %+d, id: %d)", pl_sd->status.cart[i].amount, item_data->name, pl_sd->status.cart[i].refine, item_data->jname, pl_sd->status.cart[i].refine, pl_sd->status.cart[i].nameid);
  2593. else
  2594. sprintf(output, "%d %s (%s, id: %d)", pl_sd->status.cart[i].amount, item_data->name, item_data->jname, pl_sd->status.cart[i].nameid);
  2595. clif_displaymessage(fd, output);
  2596. memset(output, '\0', sizeof(output));
  2597. counter2 = 0;
  2598. for (j = 0; j < item_data->slot; j++) {
  2599. if (pl_sd->status.cart[i].card[j]) {
  2600. if ( (item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  2601. if (output[0] == '\0')
  2602. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  2603. else
  2604. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  2605. strcat(output, outputtmp);
  2606. }
  2607. }
  2608. }
  2609. if (output[0] != '\0') {
  2610. output[strlen(output) - 2] = ')';
  2611. output[strlen(output) - 1] = '\0';
  2612. clif_displaymessage(fd, output);
  2613. }
  2614. }
  2615. }
  2616. if (count == 0)
  2617. clif_displaymessage(fd, "No item found in the cart of this player.");
  2618. else {
  2619. sprintf(output, "%d item(s) found in %d kind(s) of items.", counter, count);
  2620. clif_displaymessage(fd, output);
  2621. }
  2622. return 0;
  2623. }
  2624. static int charcommand_stopattack(struct block_list *bl,va_list ap)
  2625. {
  2626. struct unit_data *ud = unit_bl2ud(bl);
  2627. int id = va_arg(ap, int);
  2628. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  2629. {
  2630. unit_stop_attack(bl);
  2631. return 1;
  2632. }
  2633. return 0;
  2634. }
  2635. /*==========================================
  2636. * Enable a player to kill players even when not in pvp [HiddenDragon]
  2637. *------------------------------------------*/
  2638. int charcommand_killer(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2639. {
  2640. char character[NAME_LENGTH];
  2641. struct map_session_data *pl_sd;
  2642. memset(character, '\0', sizeof(character));
  2643. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  2644. clif_displaymessage(fd, "Please, enter a player name (usage: #killer <player>).");
  2645. return -1;
  2646. }
  2647. if ( (pl_sd = map_nick2sd(character)) == NULL )
  2648. {
  2649. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2650. return -1;
  2651. }
  2652. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2653. {
  2654. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2655. return -1;
  2656. }
  2657. pl_sd->state.killer = !pl_sd->state.killer;
  2658. if(pl_sd->state.killer)
  2659. {
  2660. clif_displaymessage(pl_sd->fd, msg_txt(241));
  2661. if (pl_sd->fd != fd)
  2662. clif_displaymessage(fd, "Target player can now kill anybody.");
  2663. }
  2664. else
  2665. {
  2666. clif_displaymessage(pl_sd->fd, msg_txt(287));
  2667. if (pl_sd->fd != fd)
  2668. clif_displaymessage(fd, msg_txt(287));
  2669. pc_stop_attack(pl_sd);
  2670. }
  2671. return 0;
  2672. }
  2673. /*==========================================
  2674. * Enable other players to kill target even when not in pvp [HiddenDragon]
  2675. *------------------------------------------*/
  2676. int charcommand_killable(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2677. {
  2678. char character[NAME_LENGTH];
  2679. struct map_session_data *pl_sd;
  2680. memset(character, '\0', sizeof(character));
  2681. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  2682. clif_displaymessage(fd, "Please, enter a player name (usage: #killable <player>).");
  2683. return -1;
  2684. }
  2685. if ( (pl_sd = map_nick2sd(character)) == NULL )
  2686. {
  2687. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2688. return -1;
  2689. }
  2690. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2691. {
  2692. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2693. return -1;
  2694. }
  2695. pl_sd->state.killable = !pl_sd->state.killable;
  2696. if(pl_sd->state.killable)
  2697. {
  2698. clif_displaymessage(pl_sd->fd, msg_txt(242));
  2699. if (pl_sd->fd != fd)
  2700. clif_displaymessage(fd, msg_txt(289));
  2701. }
  2702. else
  2703. {
  2704. clif_displaymessage(pl_sd->fd, msg_txt(288));
  2705. if (pl_sd->fd != fd)
  2706. clif_displaymessage(fd, msg_txt(290));
  2707. map_foreachinrange(charcommand_stopattack,&pl_sd->bl, AREA_SIZE, BL_CHAR, pl_sd->bl.id);
  2708. }
  2709. return 0;
  2710. }
  2711. /*==========================================
  2712. * Drop all of the target's possessions on the ground
  2713. *------------------------------------------*/
  2714. int charcommand_dropall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2715. {
  2716. int i;
  2717. struct map_session_data *pl_sd = NULL;
  2718. nullpo_retr(-1, sd);
  2719. if (!message || !*message)
  2720. return -1;
  2721. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  2722. return -1;
  2723. for (i = 0; i < MAX_INVENTORY; i++) {
  2724. if (pl_sd->status.inventory[i].amount) {
  2725. if(pl_sd->status.inventory[i].equip != 0)
  2726. pc_unequipitem(pl_sd, i, 3);
  2727. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  2728. }
  2729. }
  2730. clif_displaymessage(pl_sd->fd, "All items dropped");
  2731. clif_displaymessage(fd, "It is done");
  2732. return 0;
  2733. }
  2734. /*==========================================
  2735. * Put all of the target's possessions into storage
  2736. *------------------------------------------*/
  2737. int charcommand_storeall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2738. {
  2739. int i;
  2740. struct map_session_data *pl_sd = NULL;
  2741. nullpo_retr(-1, sd);
  2742. if (!message || !*message)
  2743. return -1;
  2744. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  2745. return -1;
  2746. if (pl_sd->state.storage_flag != 1)
  2747. { //Open storage.
  2748. if( storage_storageopen(pl_sd) == 1 ) {
  2749. clif_displaymessage(fd, "The character currently can't use the storage.");
  2750. return 1;
  2751. }
  2752. }
  2753. for (i = 0; i < MAX_INVENTORY; i++) {
  2754. if (pl_sd->status.inventory[i].amount) {
  2755. if(pl_sd->status.inventory[i].equip != 0)
  2756. pc_unequipitem(pl_sd, i, 3);
  2757. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  2758. }
  2759. }
  2760. storage_storageclose(pl_sd);
  2761. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  2762. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  2763. clif_displaymessage(pl_sd->fd, " -- the management");
  2764. clif_displaymessage(fd, "It is done");
  2765. return 0;
  2766. }
  2767. /*==========================================
  2768. * Refreshes target [HiddenDragon]
  2769. *------------------------------------------*/
  2770. int charcommand_refresh(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2771. {
  2772. char character[NAME_LENGTH];
  2773. struct map_session_data *pl_sd;
  2774. memset(character, '\0', sizeof(character));
  2775. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  2776. clif_displaymessage(fd, "Please, enter a player name (usage: #refresh <player>).");
  2777. return -1;
  2778. }
  2779. if ( (pl_sd = map_nick2sd(character)) == NULL )
  2780. {
  2781. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2782. return -1;
  2783. }
  2784. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2785. {
  2786. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2787. return -1;
  2788. }
  2789. clif_refresh(pl_sd);
  2790. return 0;
  2791. }
  2792. /*==========================================
  2793. * View target's exp [HiddenDragon]
  2794. *------------------------------------------*/
  2795. int charcommand_exp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2796. {
  2797. char output[200];
  2798. double nextb, nextj;
  2799. char character[NAME_LENGTH];
  2800. struct map_session_data *pl_sd;
  2801. memset(character, '\0', sizeof(character));
  2802. memset(output, '\0', sizeof(output));
  2803. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  2804. clif_displaymessage(fd, "Please, enter a player name (usage: #exp <player>).");
  2805. return -1;
  2806. }
  2807. if ( (pl_sd = map_nick2sd(character)) == NULL )
  2808. {
  2809. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2810. return -1;
  2811. }
  2812. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2813. {
  2814. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2815. return -1;
  2816. }
  2817. nextb = pc_nextbaseexp(pl_sd);
  2818. if (nextb)
  2819. nextb = pl_sd->status.base_exp*100.0/nextb;
  2820. nextj = pc_nextjobexp(pl_sd);
  2821. if (nextj)
  2822. nextj = pl_sd->status.job_exp*100.0/nextj;
  2823. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", pl_sd->status.base_level, nextb, pl_sd->status.job_level, nextj);
  2824. clif_displaymessage(fd, output);
  2825. return 0;
  2826. }
  2827. /*==========================================
  2828. * Makes monsters ignore target [HiddenDragon]
  2829. *------------------------------------------*/
  2830. int charcommand_monsterignore(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2831. {
  2832. char character[NAME_LENGTH];
  2833. struct map_session_data *pl_sd;
  2834. memset(character, '\0', sizeof(character));
  2835. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  2836. clif_displaymessage(fd, "Please, enter a player name (usage: #monsterignore/#battleignore <player>).");
  2837. return -1;
  2838. }
  2839. if ( (pl_sd = map_nick2sd(character)) == NULL )
  2840. {
  2841. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2842. return -1;
  2843. }
  2844. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2845. {
  2846. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2847. return -1;
  2848. }
  2849. if (!pl_sd->state.monster_ignore) {
  2850. pl_sd->state.monster_ignore = 1;
  2851. clif_displaymessage(pl_sd->fd, "You are now immune to attacks.");
  2852. if (fd != pl_sd->fd)
  2853. clif_displaymessage(pl_sd->fd, "Target player is now immune to attacks.");
  2854. } else {
  2855. sd->state.monster_ignore = 0;
  2856. clif_displaymessage(sd->fd, "You are no longer immune to attacks.");
  2857. if (fd != pl_sd->fd)
  2858. clif_displaymessage(pl_sd->fd, "Target player is no longer immune to attacks.");
  2859. }
  2860. return 0;
  2861. }
  2862. /*==========================================
  2863. * Change target's size [HiddenDragon]
  2864. *------------------------------------------*/
  2865. int charcommand_size(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2866. {
  2867. int size=0;
  2868. char character[NAME_LENGTH];
  2869. struct map_session_data *pl_sd;
  2870. memset(character, '\0', sizeof(character));
  2871. if (!message || !*message || sscanf(message, "%d %23[^\n]", &size, character) < 2) {
  2872. clif_displaymessage(fd, "Please, enter a player name (usage: #size <0-2> <player>).");
  2873. return -1;
  2874. }
  2875. if ( (pl_sd = map_nick2sd(character)) == NULL )
  2876. {
  2877. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2878. return -1;
  2879. }
  2880. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2881. {
  2882. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2883. return -1;
  2884. }
  2885. if(pl_sd->state.size) {
  2886. pl_sd->state.size=0;
  2887. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  2888. }
  2889. if(size==1) {
  2890. pl_sd->state.size=1;
  2891. clif_specialeffect(&pl_sd->bl,420,AREA);
  2892. clif_displaymessage(fd, "Size changed.");
  2893. if (fd != pl_sd->fd)
  2894. clif_displaymessage(pl_sd->fd, "Size changed.");
  2895. } else if(size==2) {
  2896. pl_sd->state.size=2;
  2897. clif_specialeffect(&pl_sd->bl,422,AREA);
  2898. clif_displaymessage(fd, "Size changed.");
  2899. if (fd != pl_sd->fd)
  2900. clif_displaymessage(pl_sd->fd, "Size changed.");
  2901. }
  2902. else
  2903. {
  2904. clif_displaymessage(fd, "Size restored.");
  2905. if (fd != pl_sd->fd)
  2906. clif_displaymessage(pl_sd->fd, "Size restored.");
  2907. }
  2908. return 0;
  2909. }
  2910. /*==========================================
  2911. * Level up target's homunculus [HiddenDragon]
  2912. *------------------------------------------*/
  2913. int charcommand_homlevel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2914. {
  2915. TBL_HOM * hd;
  2916. int level = 0, i = 0;
  2917. char character[NAME_LENGTH];
  2918. struct map_session_data *pl_sd;
  2919. memset(character, '\0', sizeof(character));
  2920. if (!message || !*message || sscanf(message, "%d %23[^\n]", &level, character) < 2) {
  2921. clif_displaymessage(fd, "Please, enter a player name and level (usage: #homlevel <# of levels> <player>).");
  2922. return -1;
  2923. }
  2924. if ( (pl_sd = map_nick2sd(character)) == NULL )
  2925. {
  2926. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2927. return -1;
  2928. }
  2929. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2930. {
  2931. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2932. return -1;
  2933. }
  2934. if ( !merc_is_hom_active(pl_sd->hd) )
  2935. {
  2936. clif_displaymessage(fd, "Target player does not have a homunculus.");
  2937. return 1;
  2938. }
  2939. hd = pl_sd->hd;
  2940. for (i = 1; i <= level && hd->exp_next; i++){
  2941. hd->homunculus.exp += hd->exp_next;
  2942. merc_hom_levelup(hd);
  2943. }
  2944. status_calc_homunculus(hd,0);
  2945. status_percent_heal(&hd->bl, 100, 100);
  2946. clif_misceffect2(&hd->bl,568);
  2947. clif_displaymessage(pl_sd->fd, "Homunculus level changed.");
  2948. if (pl_sd->fd != fd)
  2949. clif_displaymessage(fd, "Player's homunculus level changed.");
  2950. return 0;
  2951. }
  2952. /*==========================================
  2953. * Evolve target's homunculus [HiddenDragon]
  2954. *------------------------------------------*/
  2955. int charcommand_homevolution(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2956. {
  2957. char character[NAME_LENGTH];
  2958. struct map_session_data *pl_sd;
  2959. memset(character, '\0', sizeof(character));
  2960. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  2961. clif_displaymessage(fd, "Please, enter a player name (usage: #homevolution <player>).");
  2962. return -1;
  2963. }
  2964. if ( (pl_sd = map_nick2sd(character)) == NULL )
  2965. {
  2966. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2967. return -1;
  2968. }
  2969. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2970. {
  2971. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2972. return -1;
  2973. }
  2974. if ( !merc_is_hom_active(pl_sd->hd) ) {
  2975. clif_displaymessage(fd, "Target player does not have a homunculus.");
  2976. return -1;
  2977. }
  2978. if ( !merc_hom_evolution(pl_sd->hd) ) {
  2979. clif_displaymessage(fd, "Target homunculus cannot evolve.");
  2980. return -1;
  2981. }
  2982. clif_displaymessage(pl_sd->fd, "Homunculus evolution initiated.");
  2983. if (pl_sd->fd != fd)
  2984. clif_displaymessage(fd, "Homunculus evolution initiated.");
  2985. return 0;
  2986. }
  2987. /*==========================================
  2988. * Create a homunculus for target [HiddenDragon]
  2989. *------------------------------------------*/
  2990. int charcommand_makehomun(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2991. {
  2992. int homunid;
  2993. char character[NAME_LENGTH];
  2994. char output[200];
  2995. struct map_session_data *pl_sd;
  2996. memset(character, '\0', sizeof(character));
  2997. memset(output, '\0', sizeof(output));
  2998. if (!message || !*message || sscanf(message, "%d %23[^\n]", &homunid, character) < 2) {
  2999. sprintf(output, "Please, enter a player name (usage: #makehomun <homunculus id: %d-%d> <player>).", HM_CLASS_BASE, HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1);
  3000. clif_displaymessage(fd, output);
  3001. return -1;
  3002. }
  3003. if ( (pl_sd = map_nick2sd(character)) == NULL )
  3004. {
  3005. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3006. return -1;
  3007. }
  3008. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3009. {
  3010. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3011. return -1;
  3012. }
  3013. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  3014. {
  3015. clif_displaymessage(fd, "Invalid homunculus ID.");
  3016. return -1;
  3017. }
  3018. if(pl_sd->status.hom_id == 0)
  3019. {
  3020. merc_create_homunculus_request(pl_sd,homunid);
  3021. }
  3022. else
  3023. {
  3024. clif_displaymessage(fd, "Target player already has a homunculus.");
  3025. }
  3026. return 0;
  3027. }
  3028. /*==========================================
  3029. * Change Target's homunculus' friendlyness [HiddenDragon]
  3030. *------------------------------------------*/
  3031. int charcommand_homfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3032. {
  3033. int friendly = 0;
  3034. char character[NAME_LENGTH];
  3035. struct map_session_data *pl_sd;
  3036. memset(character, '\0', sizeof(character));
  3037. if (!message || !*message || sscanf(message, "%d %23[^\n]", &friendly, character) < 2) {
  3038. clif_displaymessage(fd, "Please, enter a player name and friendly value (usage: #homfriendly <0-1000> <player>).");
  3039. return -1;
  3040. }
  3041. if ( (pl_sd = map_nick2sd(character)) == NULL )
  3042. {
  3043. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3044. return -1;
  3045. }
  3046. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3047. {
  3048. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3049. return -1;
  3050. }
  3051. if (merc_is_hom_active(pl_sd->hd)) {
  3052. if (friendly > 0 && friendly <= 1000) {
  3053. pl_sd->hd->homunculus.intimacy = friendly * 100 ;
  3054. clif_send_homdata(pl_sd,SP_INTIMATE,friendly);
  3055. clif_displaymessage(pl_sd->fd, "Homunculus friendly value changed.");
  3056. if (fd != pl_sd->fd)
  3057. clif_displaymessage(fd, "Homunculus friendly value changed.");
  3058. } else {
  3059. clif_displaymessage(fd, "Invalid friendly value.");
  3060. }
  3061. }
  3062. else
  3063. {
  3064. clif_displaymessage(fd, "Target player's homunculus does not exist.");
  3065. return -1;
  3066. }
  3067. return 0;
  3068. }
  3069. /*==========================================
  3070. * Modify target's homunculus hunger [HiddenDragon]
  3071. *------------------------------------------*/
  3072. int charcommand_homhungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3073. {
  3074. int hungry = 0;
  3075. char character[NAME_LENGTH];
  3076. struct map_session_data *pl_sd;
  3077. memset(character, '\0', sizeof(character));
  3078. if (!message || !*message || sscanf(message, "%d %23[^\n]", &hungry, character) < 2) {
  3079. clif_displaymessage(fd, "Please, enter a player name (usage: #homhungry <0-100> <player>).");
  3080. return -1;
  3081. }
  3082. if ( (pl_sd = map_nick2sd(character)) == NULL )
  3083. {
  3084. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3085. return -1;
  3086. }
  3087. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3088. {
  3089. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3090. return -1;
  3091. }
  3092. if (pl_sd->status.hom_id > 0 && pl_sd->hd) {
  3093. struct homun_data *hd = pl_sd->hd;
  3094. if (hungry >= 0 && hungry <= 100) {
  3095. hd->homunculus.hunger = hungry;
  3096. clif_send_homdata(pl_sd,SP_HUNGRY,hd->homunculus.hunger);
  3097. clif_displaymessage(pl_sd->fd, "Homunculus hungry value changed.");
  3098. if (fd != pl_sd->fd)
  3099. clif_displaymessage(fd, "Homunculus hungry value changed.");
  3100. } else {
  3101. clif_displaymessage(fd, "Invalid hungry value.");
  3102. return -1;
  3103. }
  3104. }
  3105. else
  3106. {
  3107. clif_displaymessage(fd, "Target player does not have a homunculus.");
  3108. return -1;
  3109. }
  3110. return 0;
  3111. }
  3112. /*==========================================
  3113. * Show target's homunculus stats [HiddenDragon]
  3114. *------------------------------------------*/
  3115. int charcommand_hominfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3116. {
  3117. struct homun_data *hd;
  3118. struct status_data *status;
  3119. char output[200];
  3120. char character[NAME_LENGTH];
  3121. struct map_session_data *pl_sd;
  3122. memset(character, '\0', sizeof(character));
  3123. memset(output, '\0', sizeof(output));
  3124. if (!message || !*message || sscanf(message, "%23[^\n]", character) < 1) {
  3125. clif_displaymessage(fd, "Please, enter a player name (usage: #hominfo <player>).");
  3126. return -1;
  3127. }
  3128. if ( (pl_sd = map_nick2sd(character)) == NULL )
  3129. {
  3130. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3131. return -1;
  3132. }
  3133. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3134. {
  3135. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3136. return -1;
  3137. }
  3138. if(!merc_is_hom_active(pl_sd->hd))
  3139. return -1;
  3140. hd = pl_sd->hd;
  3141. status = status_get_status_data(&hd->bl);
  3142. clif_displaymessage(fd, "Homunculus stats :");
  3143. snprintf(output, sizeof(output), "HP : %d/%d - SP : %d/%d", status->hp, status->max_hp, status->sp, status->max_sp);
  3144. clif_displaymessage(fd, output);
  3145. snprintf(output, sizeof(output), "ATK : %d - MATK : %d~%d", status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  3146. clif_displaymessage(fd, output);
  3147. snprintf(output, sizeof(output), "Hungry : %d - Intimacy : %u", hd->homunculus.hunger, hd->homunculus.intimacy/100);
  3148. clif_displaymessage(fd, output);
  3149. snprintf(output, sizeof(output), "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d", status->str, status->agi, status->vit, status->int_, status->dex, status->luk);
  3150. clif_displaymessage(fd, output);
  3151. return 0;
  3152. }
  3153. /*==========================================
  3154. * charcommand_info[] structure definition
  3155. *------------------------------------------*/
  3156. CharCommandInfo charcommand_info[] = {
  3157. { "job", 60, charcommand_jobchange },
  3158. { "jobchange", 60, charcommand_jobchange },
  3159. { "petrename", 50, charcommand_petrename },
  3160. { "petfriendly", 50, charcommand_petfriendly },
  3161. { "stats", 40, charcommand_stats },
  3162. { "option", 60, charcommand_option },
  3163. { "reset", 60, charcommand_reset },
  3164. { "save", 60, charcommand_save },
  3165. { "spiritball", 40, charcommand_spiritball },
  3166. { "itemlist", 40, charcommand_itemlist },
  3167. { "effect", 40, charcommand_effect },
  3168. { "storagelist", 40, charcommand_storagelist },
  3169. { "item", 60, charcommand_item },
  3170. { "warp", 60, charcommand_warp },
  3171. { "rura", 60, charcommand_warp },
  3172. { "rura+", 60, charcommand_warp },
  3173. { "zeny", 60, charcommand_zeny },
  3174. { "fakename", 50, charcommand_fakename },
  3175. { "baselvl", 60, charcommand_baselevel },
  3176. { "baselevel", 60, charcommand_baselevel },
  3177. { "blvl", 60, charcommand_baselevel },
  3178. { "blevel", 60, charcommand_baselevel },
  3179. { "joblvl", 60, charcommand_joblevel },
  3180. { "joblevel", 60, charcommand_joblevel },
  3181. { "jlvl", 60, charcommand_joblevel },
  3182. { "jlevel", 60, charcommand_joblevel },
  3183. { "questskill", 60, charcommand_questskill },
  3184. { "lostskill", 60, charcommand_lostskill },
  3185. { "skreset", 60, charcommand_skreset },
  3186. { "streset", 60, charcommand_streset },
  3187. { "model", 50, charcommand_model },
  3188. { "skpoint", 60, charcommand_skpoint },
  3189. { "stpoint", 60, charcommand_stpoint },
  3190. { "changesex", 60, charcommand_changesex },
  3191. { "feelreset", 60, charcommand_feelreset },
  3192. { "help", 20, charcommand_help },
  3193. { "load", 60, charcommand_load },
  3194. { "speed", 60, charcommand_speed },
  3195. { "storage", 60, charcommand_storage },
  3196. { "gstorage", 60, charcommand_guildstorage },
  3197. { "hide", 60, charcommand_hide },
  3198. { "alive", 60, charcommand_alive },
  3199. { "revive", 60, charcommand_alive },
  3200. { "heal", 60, charcommand_heal },
  3201. { "item2", 60, charcommand_item2 },
  3202. { "itemreset", 60, charcommand_itemreset },
  3203. { "refine", 60, charcommand_refine },
  3204. { "produce", 60, charcommand_produce },
  3205. { "str", 60, charcommand_param },
  3206. { "agi", 60, charcommand_param },
  3207. { "vit", 60, charcommand_param },
  3208. { "int", 60, charcommand_param },
  3209. { "dex", 60, charcommand_param },
  3210. { "luk", 60, charcommand_param },
  3211. { "glvl", 60, charcommand_guildlevelup },
  3212. { "glevel", 60, charcommand_guildlevelup },
  3213. { "guildlvl", 60, charcommand_guildlevelup },
  3214. { "guildlevel", 60, charcommand_guildlevelup },
  3215. { "hatch", 50, charcommand_hatch },
  3216. { "pethungry", 60, charcommand_pethungry },
  3217. { "allskill", 60, charcommand_allskill },
  3218. { "allskills", 60, charcommand_allskill },
  3219. { "skillall", 60, charcommand_allskill },
  3220. { "skillsall", 60, charcommand_allskill },
  3221. { "dye", 50, charcommand_dye },
  3222. { "hairstyle", 50, charcommand_hair_style },
  3223. { "hstyle", 50, charcommand_hair_style },
  3224. { "haircolor", 50, charcommand_hair_color },
  3225. { "hcolor", 50, charcommand_hair_color },
  3226. { "allstat", 60, charcommand_allstats },
  3227. { "allstats", 60, charcommand_allstats },
  3228. { "statall", 60, charcommand_allstats },
  3229. { "statsall", 60, charcommand_allstats },
  3230. { "mount", 50, charcommand_mount_peco },
  3231. { "mountpeco", 50, charcommand_mount_peco },
  3232. { "delitem", 60, charcommand_delitem },
  3233. { "jailtime", 40, charcommand_jailtime },
  3234. { "disguise", 60, charcommand_disguise },
  3235. { "undisguise", 60, charcommand_undisguise },
  3236. { "cartlist", 40, charcommand_cart_list },
  3237. { "killer", 60, charcommand_killer },
  3238. { "killable", 60, charcommand_killable },
  3239. { "dropall", 60, charcommand_dropall },
  3240. { "storeall", 60, charcommand_storeall },
  3241. { "refresh", 40, charcommand_refresh },
  3242. { "exp", 1, charcommand_exp },
  3243. { "monsterignore", 60, charcommand_monsterignore },
  3244. { "size", 50, charcommand_size },
  3245. { "hlvl", 60, charcommand_homlevel },
  3246. { "hlevel", 60, charcommand_homlevel },
  3247. { "homlvl", 60, charcommand_homlevel },
  3248. { "homlevel", 60, charcommand_homlevel },
  3249. { "homevolve", 60, charcommand_homevolution },
  3250. { "homevolution", 60, charcommand_homevolution },
  3251. { "homfriendly", 60, charcommand_homfriendly },
  3252. { "homhungry", 60, charcommand_homhungry },
  3253. { "hominfo", 40, charcommand_hominfo },
  3254. { "cash", 60, charcommand_cash },
  3255. { "points", 60, charcommand_cash },
  3256. };
  3257. /*==========================================
  3258. * Command lookup functions
  3259. *------------------------------------------*/
  3260. static CharCommandInfo* get_charcommandinfo_byname(const char* name)
  3261. {
  3262. int i;
  3263. if( *name == charcommand_symbol ) name++; // for backwards compatibility
  3264. ARR_FIND( 0, ARRAYLENGTH(charcommand_info), i, strcmpi(charcommand_info[i].command, name) == 0 );
  3265. return ( i < ARRAYLENGTH(charcommand_info) ) ? &charcommand_info[i] : NULL;
  3266. }
  3267. static CharCommandInfo* get_charcommandinfo_byfunc(const CharCommandFunc func)
  3268. {
  3269. int i;
  3270. ARR_FIND( 0, ARRAYLENGTH(charcommand_info), i, charcommand_info[i].func == func );
  3271. return ( i < ARRAYLENGTH(charcommand_info) ) ? &charcommand_info[i] : NULL;
  3272. }
  3273. /*==========================================
  3274. * Retrieve the command's required gm level
  3275. *------------------------------------------*/
  3276. int get_charcommand_level(const CharCommandFunc func)
  3277. {
  3278. CharCommandInfo* info = get_charcommandinfo_byfunc(func);
  3279. return ( info != NULL ) ? info->level : 100; // 100: command can not be used
  3280. }
  3281. /// Executes a char-command.
  3282. /// To be called by internal server code (bypasses various restrictions).
  3283. bool is_charcommand_sub(const int fd, struct map_session_data* sd, const char* str, int gmlvl)
  3284. {
  3285. CharCommandInfo* info;
  3286. char command[100];
  3287. char args[100];
  3288. char output[200];
  3289. if( !str || !*str )
  3290. return false;
  3291. if( *str != charcommand_symbol ) // check first char
  3292. return false;
  3293. if( sscanf(str, "%99s %99[^\n]", command, args) < 2 )
  3294. args[0] = '\0';
  3295. info = get_charcommandinfo_byname(command);
  3296. if( info == NULL || info->func == NULL || gmlvl < info->level )
  3297. {
  3298. if( gmlvl == 0 )
  3299. return false; // will just display as normal text
  3300. else
  3301. {
  3302. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  3303. clif_displaymessage(fd, output);
  3304. return true;
  3305. }
  3306. }
  3307. if( log_config.gm && info->level >= log_config.gm )
  3308. log_atcommand(sd, str);
  3309. if( info->func(fd, sd, command, args) != 0 )
  3310. {
  3311. sprintf(output, msg_txt(154), command); // "%s failed."
  3312. clif_displaymessage(fd, output);
  3313. }
  3314. return true;
  3315. }
  3316. /// Executes a char-command.
  3317. /// To be used by player-invoked code (restrictions will be applied)
  3318. bool is_charcommand(const int fd, struct map_session_data* sd, const char* message)
  3319. {
  3320. int gmlvl = pc_isGM(sd);
  3321. nullpo_retr(false, sd);
  3322. if( !message || !*message )
  3323. return false;
  3324. if( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  3325. return true; // so that it won't display as normal message
  3326. if( battle_config.atc_gmonly != 0 && gmlvl == 0 )
  3327. return false;
  3328. if( map[sd->bl.m].nocommand && gmlvl < map[sd->bl.m].nocommand )
  3329. {
  3330. clif_displaymessage(fd, msg_txt(143)); // "Commands are disabled on this map."
  3331. return false;
  3332. }
  3333. // skip 10/11-langtype's codepage indicator, if detected
  3334. if( message[0] == '|' && strlen(message) >= 4 && message[3] == charcommand_symbol )
  3335. message += 3;
  3336. return is_charcommand_sub(fd,sd,message,gmlvl);
  3337. }
  3338. /*==========================================
  3339. *
  3340. *------------------------------------------*/
  3341. int charcommand_config_read(const char* cfgName)
  3342. {
  3343. char line[1024], w1[1024], w2[1024];
  3344. CharCommandInfo* p;
  3345. FILE* fp;
  3346. if( (fp = fopen(cfgName, "r")) == NULL )
  3347. {
  3348. ShowError("CharCommand configuration file not found: %s\n", cfgName);
  3349. return 1;
  3350. }
  3351. while( fgets(line, sizeof(line), fp) )
  3352. {
  3353. if( line[0] == '/' && line[1] == '/' )
  3354. continue;
  3355. if( sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2 )
  3356. continue;
  3357. p = get_charcommandinfo_byname(w1);
  3358. if( p != NULL )
  3359. {
  3360. p->level = atoi(w2);
  3361. p->level = cap_value(p->level, 0, 100);
  3362. }
  3363. else
  3364. if( strcmpi(w1, "import") == 0 )
  3365. charcommand_config_read(w2);
  3366. else
  3367. if( strcmpi(w1, "command_symbol") == 0 &&
  3368. w2[0] > 31 && // control characters
  3369. w2[0] != '/' && // symbol of standard ragnarok GM commands
  3370. w2[0] != '%' && // symbol of party chat speaking
  3371. w2[0] != '$' && // symbol of guild chat speaking
  3372. w2[0] != '@' ) // symbol of atcommand
  3373. charcommand_symbol = w2[0];
  3374. else
  3375. ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName);
  3376. }
  3377. fclose(fp);
  3378. return 0;
  3379. }