From fdf1d34fdc53bb28625669ead2b812f6dcb47337 Mon Sep 17 00:00:00 2001 From: Matheus Macabu Date: Sat, 18 May 2013 18:17:38 -0300 Subject: Some type conversion warnings fixed. If this breaks anything create a bug report ASAP and I will revert it gladly. Signed-off-by: Matheus Macabu --- src/char/char.c | 4 ++-- src/common/des.c | 10 ++++------ src/common/grfio.c | 14 +++++++------- src/common/malloc.c | 6 +++--- src/login/account_sql.c | 4 ++-- src/login/login.c | 4 ++-- src/map/searchstore.c | 4 +++- 7 files changed, 23 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/char/char.c b/src/char/char.c index 00fc633df..f4212a076 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -1171,13 +1171,13 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything p->save_point.map = mapindex_name2id(save_map); if( p->last_point.map == 0 ) { - p->last_point.map = strdb_iget(mapindex_db, MAP_DEFAULT); + p->last_point.map = (unsigned short)strdb_iget(mapindex_db, MAP_DEFAULT); p->last_point.x = MAP_DEFAULT_X; p->last_point.y = MAP_DEFAULT_Y; } if( p->save_point.map == 0 ) { - p->save_point.map = strdb_iget(mapindex_db, MAP_DEFAULT); + p->save_point.map = (unsigned short)strdb_iget(mapindex_db, MAP_DEFAULT); p->save_point.x = MAP_DEFAULT_X; p->save_point.y = MAP_DEFAULT_Y; } diff --git a/src/common/des.c b/src/common/des.c index 917fc33e0..ed6d098dc 100644 --- a/src/common/des.c +++ b/src/common/des.c @@ -78,8 +78,8 @@ static void E(BIT64* src) { BIT64 tmp = {{0}}; -if( false ) -{// original +#if 0 + // original static const uint8_t expand_table[48] = { 32, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, @@ -98,9 +98,8 @@ if( false ) if( src->b[j / 8 + 4] & mask[j % 8] ) tmp .b[i / 6 + 0] |= mask[i % 6]; } -} -else -{// optimized +#endif + // optimized tmp.b[0] = ((src->b[7]<<5) | (src->b[4]>>3)) & 0x3f; // ..0 vutsr tmp.b[1] = ((src->b[4]<<1) | (src->b[5]>>7)) & 0x3f; // ..srqpo n tmp.b[2] = ((src->b[4]<<5) | (src->b[5]>>3)) & 0x3f; // ..o nmlkj @@ -109,7 +108,6 @@ else tmp.b[5] = ((src->b[6]<<1) | (src->b[7]>>7)) & 0x3f; // ..cba98 7 tmp.b[6] = ((src->b[6]<<5) | (src->b[7]>>3)) & 0x3f; // ..8 76543 tmp.b[7] = ((src->b[7]<<1) | (src->b[4]>>7)) & 0x3f; // ..43210 v -} *src = tmp; } diff --git a/src/common/grfio.c b/src/common/grfio.c index bf66dba52..77b976926 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -171,7 +171,7 @@ static void grf_decode_full(unsigned char* buf, size_t len, int cycle) scycle = 7; // so decrypt/de-shuffle periodically - j = -1; // 0, adjusted to fit the ++j step + j = (size_t)-1; // 0, adjusted to fit the ++j step for( i = 20; i < nblocks; ++i ) { if( i % dcycle == 0 ) @@ -408,7 +408,7 @@ void* grfio_reads(const char* fname, int* size) declen = ftell(in); fseek(in,0,SEEK_SET); buf2 = (unsigned char *)aMalloc(declen+1); // +1 for resnametable zero-termination - if(fread(buf2, 1, declen, in) != declen) ShowError("An error occured in fread grfio_reads, fname=%s \n",fname); + if(fread(buf2, 1, declen, in) != (size_t)declen) ShowError("An error occured in fread grfio_reads, fname=%s \n",fname); fclose(in); if( size ) @@ -430,7 +430,7 @@ void* grfio_reads(const char* fname, int* size) int fsize = entry->srclen_aligned; unsigned char *buf = (unsigned char *)aMalloc(fsize); fseek(in, entry->srcpos, 0); - if(fread(buf, 1, fsize, in) != fsize) ShowError("An error occured in fread in grfio_reads, grfname=%s\n",grfname); + if(fread(buf, 1, fsize, in) != (size_t)fsize) ShowError("An error occured in fread in grfio_reads, grfname=%s\n",grfname); fclose(in); buf2 = (unsigned char *)aMalloc(entry->declen+1); // +1 for resnametable zero-termination @@ -526,7 +526,7 @@ static int grfio_entryread(const char* grfname, int gentry) long list_size; list_size = grf_size - ftell(fp); grf_filelist = (unsigned char *) aMalloc(list_size); - if(fread(grf_filelist,1,list_size,fp) != list_size) { ShowError("Couldn't read all grf_filelist element of %s \n", grfname); } + if(fread(grf_filelist,1,list_size,fp) != (size_t)list_size) { ShowError("Couldn't read all grf_filelist element of %s \n", grfname); } fclose(fp); entrys = getlong(grf_header+0x26) - getlong(grf_header+0x22) - 7; @@ -559,7 +559,7 @@ static int grfio_entryread(const char* grfname, int gentry) #ifdef GRFIO_LOCAL aentry.gentry = -(gentry+1); // As Flag for making it a negative number carrying out the first time LocalFileCheck #else - aentry.gentry = gentry+1; // With no first time LocalFileCheck + aentry.gentry = (char)(gentry+1); // With no first time LocalFileCheck #endif filelist_modify(&aentry); } @@ -611,13 +611,13 @@ static int grfio_entryread(const char* grfname, int gentry) aentry.srclen_aligned = getlong(grf_filelist+ofs2+4); aentry.declen = getlong(grf_filelist+ofs2+8); aentry.srcpos = getlong(grf_filelist+ofs2+13)+0x2e; - aentry.type = type; + aentry.type = (char)type; safestrncpy(aentry.fn, fname, sizeof(aentry.fn)); aentry.fnd = NULL; #ifdef GRFIO_LOCAL aentry.gentry = -(gentry+1); // As Flag for making it a negative number carrying out the first time LocalFileCheck #else - aentry.gentry = gentry+1; // With no first time LocalFileCheck + aentry.gentry = (char)(gentry+1); // With no first time LocalFileCheck #endif filelist_modify(&aentry); } diff --git a/src/common/malloc.c b/src/common/malloc.c index 4874aa0f4..592027f56 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -250,7 +250,7 @@ void* _mmalloc(size_t size, const char *file, int line, const char *func ) p->unit_head.block = NULL; p->unit_head.size = 0; p->unit_head.file = file; - p->unit_head.line = line; + p->unit_head.line = (unsigned short)line; p->prev = NULL; if (unit_head_large_first == NULL) p->next = NULL; @@ -324,7 +324,7 @@ void* _mmalloc(size_t size, const char *file, int line, const char *func ) head->block = block; head->file = file; - head->line = line; + head->line = (unsigned short)line; head->size = (unsigned short)size; *(long*)((char*)head + sizeof(struct unit_head) - sizeof(long) + size) = 0xdeadbeaf; return (char *)head + sizeof(struct unit_head) - sizeof(long); @@ -422,7 +422,7 @@ void _mfree(void *ptr, const char *file, int line, const char *func ) #ifdef DEBUG_MEMMGR memset(ptr, 0xfd, block->unit_size - sizeof(struct unit_head) + sizeof(long) ); head->file = file; - head->line = line; + head->line = (unsigned short)line; #endif memmgr_assert( block->unit_used > 0 ); if(--block->unit_used == 0) { diff --git a/src/login/account_sql.c b/src/login/account_sql.c index 565dd0460..d3a7aafff 100644 --- a/src/login/account_sql.c +++ b/src/login/account_sql.c @@ -315,7 +315,7 @@ static bool account_db_sql_set_property(AccountDB* self, const char* key, const safestrncpy(db->codepage, value, sizeof(db->codepage)); else if( strcmpi(key, "case_sensitive") == 0 ) - db->case_sensitive = config_switch(value); + db->case_sensitive = (bool)config_switch(value); else if( strcmpi(key, "account_db") == 0 ) safestrncpy(db->account_db, value, sizeof(db->account_db)); @@ -549,7 +549,7 @@ static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int acc SQL->GetData(sql_handle, 10, &data, NULL); safestrncpy(acc->lastlogin, data, sizeof(acc->lastlogin)); SQL->GetData(sql_handle, 11, &data, NULL); safestrncpy(acc->last_ip, data, sizeof(acc->last_ip)); SQL->GetData(sql_handle, 12, &data, NULL); safestrncpy(acc->birthdate, data, sizeof(acc->birthdate)); - SQL->GetData(sql_handle, 13, &data, NULL); acc->char_slots = atoi(data); + SQL->GetData(sql_handle, 13, &data, NULL); acc->char_slots = (uint8)atoi(data); SQL->GetData(sql_handle, 14, &data, NULL); safestrncpy(acc->pincode, data, sizeof(acc->pincode)); SQL->GetData(sql_handle, 15, &data, NULL); acc->pincode_change = atol(data); diff --git a/src/login/login.c b/src/login/login.c index 8dd5ce20a..2bfb9c730 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -467,7 +467,7 @@ int parse_fromchar(int fd) { ShowStatus("set users %s : %d\n", server[id].name, users); - server[id].users = users; + server[id].users = (uint16)users; } } break; @@ -1083,7 +1083,7 @@ int mmo_auth(struct login_session_data* sd, bool isServer) { sd->login_id2 = rnd() + 1; safestrncpy(sd->lastlogin, acc.lastlogin, sizeof(sd->lastlogin)); sd->sex = acc.sex; - sd->group_id = acc.group_id; + sd->group_id = (uint8)acc.group_id; // update account data timestamp2string(acc.lastlogin, sizeof(acc.lastlogin), time(NULL), "%Y-%m-%d %H:%M:%S"); diff --git a/src/map/searchstore.c b/src/map/searchstore.c index 7e1ee3e84..a9e82f847 100644 --- a/src/map/searchstore.c +++ b/src/map/searchstore.c @@ -150,7 +150,9 @@ void searchstore_query(struct map_session_data* sd, unsigned char type, unsigned } if( max_price < min_price ) { - swap(min_price, max_price); + __asm xor min_price, max_price + __asm xor max_price, min_price + __asm xor min_price, max_price } sd->searchstore.uses--; -- cgit v1.2.3-70-g09d2 From 6d527e5d6a76fbf5f0a6440d74971977b5a37e03 Mon Sep 17 00:00:00 2001 From: Matheus Macabu Date: Sat, 18 May 2013 18:21:08 -0300 Subject: This wasn't supposed to happen. God almighty damn. Signed-off-by: Matheus Macabu --- src/map/searchstore.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/map/searchstore.c b/src/map/searchstore.c index a9e82f847..7e1ee3e84 100644 --- a/src/map/searchstore.c +++ b/src/map/searchstore.c @@ -150,9 +150,7 @@ void searchstore_query(struct map_session_data* sd, unsigned char type, unsigned } if( max_price < min_price ) { - __asm xor min_price, max_price - __asm xor max_price, min_price - __asm xor min_price, max_price + swap(min_price, max_price); } sd->searchstore.uses--; -- cgit v1.2.3-70-g09d2 From c7a830bce88df87d3a91d60e67fece1e49cfb18f Mon Sep 17 00:00:00 2001 From: Mysteries Date: Sun, 19 May 2013 11:20:59 -0400 Subject: Little changes --- npc/mapflag/battleground.txt | 2 +- npc/mapflag/gvg.txt | 2 +- npc/mapflag/jail.txt | 2 +- npc/mapflag/night.txt | 2 +- npc/mapflag/nightmare.txt | 2 +- npc/mapflag/nobranch.txt | 2 +- npc/mapflag/noexp.txt | 2 +- npc/mapflag/noicewall.txt | 2 +- npc/mapflag/noloot.txt | 2 +- npc/mapflag/nomemo.txt | 2 +- npc/mapflag/nopenalty.txt | 2 +- npc/mapflag/nopvp.txt | 2 +- npc/mapflag/noreturn.txt | 2 +- npc/mapflag/nosave.txt | 2 +- npc/mapflag/noskill.txt | 2 +- npc/mapflag/noteleport.txt | 2 +- npc/mapflag/novending.txt | 2 +- npc/mapflag/nowarp.txt | 2 +- npc/mapflag/nowarpto.txt | 2 +- npc/mapflag/partylock.txt | 2 +- npc/mapflag/pvp.txt | 2 +- npc/mapflag/pvp_noguild.txt | 2 +- npc/mapflag/pvp_noparty.txt | 2 +- npc/mapflag/reset.txt | 2 +- npc/mapflag/town.txt | 2 +- src/common/mapindex.h | 2 +- src/common/mmo.h | 63 ++++++++++++++++++++++---------------------- 27 files changed, 58 insertions(+), 57 deletions(-) (limited to 'src') diff --git a/npc/mapflag/battleground.txt b/npc/mapflag/battleground.txt index f7404c139..736ce6215 100644 --- a/npc/mapflag/battleground.txt +++ b/npc/mapflag/battleground.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Battleground map setting. //===== By: ================================================== //= Epoque diff --git a/npc/mapflag/gvg.txt b/npc/mapflag/gvg.txt index 055a1d733..0cd7a3219 100644 --- a/npc/mapflag/gvg.txt +++ b/npc/mapflag/gvg.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Guild versus Guild mode. //===== By: ================================================== //= Hercules Dev Team diff --git a/npc/mapflag/jail.txt b/npc/mapflag/jail.txt index 0a8b00846..c2dd16688 100644 --- a/npc/mapflag/jail.txt +++ b/npc/mapflag/jail.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Jail. //===== By: ================================================== //= Hercules Dev Team diff --git a/npc/mapflag/night.txt b/npc/mapflag/night.txt index c3e8a47fe..aa12815b3 100644 --- a/npc/mapflag/night.txt +++ b/npc/mapflag/night.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Night mode. //===== By: ================================================== //= Skotlex diff --git a/npc/mapflag/nightmare.txt b/npc/mapflag/nightmare.txt index 106ee665a..22c08b263 100644 --- a/npc/mapflag/nightmare.txt +++ b/npc/mapflag/nightmare.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Nightmare mode. //===== By: ================================================== //= Hercules Dev Team diff --git a/npc/mapflag/nobranch.txt b/npc/mapflag/nobranch.txt index 0c96bf896..5717fb166 100644 --- a/npc/mapflag/nobranch.txt +++ b/npc/mapflag/nobranch.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Disable Dead Branch use. //===== By: ================================================== //= HerculesDev Team diff --git a/npc/mapflag/noexp.txt b/npc/mapflag/noexp.txt index 0b6fe20c6..0cc4279ca 100644 --- a/npc/mapflag/noexp.txt +++ b/npc/mapflag/noexp.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Disable EXP gain. //===== By: ================================================== //= Hercules Dev Team diff --git a/npc/mapflag/noicewall.txt b/npc/mapflag/noicewall.txt index 5b6e6ad12..8711ea45d 100644 --- a/npc/mapflag/noicewall.txt +++ b/npc/mapflag/noicewall.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Disable Ice Wall. //===== By: ================================================== //= Hercules Dev Team diff --git a/npc/mapflag/noloot.txt b/npc/mapflag/noloot.txt index 380dc506c..43089ed31 100644 --- a/npc/mapflag/noloot.txt +++ b/npc/mapflag/noloot.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Disable monster drops. //===== By: ================================================== //= Epoque diff --git a/npc/mapflag/nomemo.txt b/npc/mapflag/nomemo.txt index f6628bf46..158982e2c 100644 --- a/npc/mapflag/nomemo.txt +++ b/npc/mapflag/nomemo.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Disable Warp Portal memory. //===== By: ================================================== //= Hercules Dev Team diff --git a/npc/mapflag/nopenalty.txt b/npc/mapflag/nopenalty.txt index 083d86105..b29d4d4a7 100644 --- a/npc/mapflag/nopenalty.txt +++ b/npc/mapflag/nopenalty.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Disable death penalty. //===== By: ================================================== //= Hercules Dev Team diff --git a/npc/mapflag/nopvp.txt b/npc/mapflag/nopvp.txt index 9f876c49b..4eb4831b8 100644 --- a/npc/mapflag/nopvp.txt +++ b/npc/mapflag/nopvp.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Disable Player versus Player mode. //===== By: ================================================== //= Hercules Dev Team diff --git a/npc/mapflag/noreturn.txt b/npc/mapflag/noreturn.txt index 696d81460..d5b94f458 100644 --- a/npc/mapflag/noreturn.txt +++ b/npc/mapflag/noreturn.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Disable return warp. //===== By: ================================================== //= Hercules Dev Team diff --git a/npc/mapflag/nosave.txt b/npc/mapflag/nosave.txt index 59a59fcae..1035d2a77 100644 --- a/npc/mapflag/nosave.txt +++ b/npc/mapflag/nosave.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Disable auto-save. //===== By: ================================================== //= Hercules Dev Team diff --git a/npc/mapflag/noskill.txt b/npc/mapflag/noskill.txt index 81540b45a..ec66f27d3 100644 --- a/npc/mapflag/noskill.txt +++ b/npc/mapflag/noskill.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Disable skill use. //===== By: ================================================== //= Hercules Dev Team diff --git a/npc/mapflag/noteleport.txt b/npc/mapflag/noteleport.txt index df25145d8..d969c5522 100644 --- a/npc/mapflag/noteleport.txt +++ b/npc/mapflag/noteleport.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Disable teleportation. //===== By: ================================================== //= Hercules Dev Team diff --git a/npc/mapflag/novending.txt b/npc/mapflag/novending.txt index 5f7ef8e82..4205d9d6a 100644 --- a/npc/mapflag/novending.txt +++ b/npc/mapflag/novending.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Disable vending. //===== By: ================================================== //= Epoque diff --git a/npc/mapflag/nowarp.txt b/npc/mapflag/nowarp.txt index cfeb938a2..304cebf2f 100644 --- a/npc/mapflag/nowarp.txt +++ b/npc/mapflag/nowarp.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Disable warping. //===== By: ================================================== //= Hercules Dev Team diff --git a/npc/mapflag/nowarpto.txt b/npc/mapflag/nowarpto.txt index 2490b8e61..f54dc785f 100644 --- a/npc/mapflag/nowarpto.txt +++ b/npc/mapflag/nowarpto.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Disable warpto. //===== By: ================================================== //= Hercules Dev Team diff --git a/npc/mapflag/partylock.txt b/npc/mapflag/partylock.txt index e8d7051f2..ba0014026 100644 --- a/npc/mapflag/partylock.txt +++ b/npc/mapflag/partylock.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Party lock. //===== By: ================================================== //= Hercules Dev Team diff --git a/npc/mapflag/pvp.txt b/npc/mapflag/pvp.txt index 4e3ca5762..d72e45a98 100644 --- a/npc/mapflag/pvp.txt +++ b/npc/mapflag/pvp.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Player versus Player mode. //===== By: ================================================== //= Hercules Dev Team diff --git a/npc/mapflag/pvp_noguild.txt b/npc/mapflag/pvp_noguild.txt index 166b65764..fe61a3097 100644 --- a/npc/mapflag/pvp_noguild.txt +++ b/npc/mapflag/pvp_noguild.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Ignore guilds. //===== By: ================================================== //= Hercules Dev Team diff --git a/npc/mapflag/pvp_noparty.txt b/npc/mapflag/pvp_noparty.txt index bd5e866f6..569a46c2d 100644 --- a/npc/mapflag/pvp_noparty.txt +++ b/npc/mapflag/pvp_noparty.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Ignore parties. //===== By: ================================================== //= Hercules Dev Team diff --git a/npc/mapflag/reset.txt b/npc/mapflag/reset.txt index 5354580b9..7af002f22 100644 --- a/npc/mapflag/reset.txt +++ b/npc/mapflag/reset.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Enable Neuralizer use. //===== By: ================================================== //= Daegaladh diff --git a/npc/mapflag/town.txt b/npc/mapflag/town.txt index 319785524..46331818b 100644 --- a/npc/mapflag/town.txt +++ b/npc/mapflag/town.txt @@ -1,4 +1,4 @@ -//===== Hercules Script ======================================= +//===== Hercules Script ====================================== //= Mapflag: Town. //===== By: ================================================== //= Epoque diff --git a/src/common/mapindex.h b/src/common/mapindex.h index d35d9899c..43953a8e0 100644 --- a/src/common/mapindex.h +++ b/src/common/mapindex.h @@ -7,7 +7,7 @@ #include "../common/db.h" -/* when a map index search fails, return results from what map? default:prontera */ +// When a map index search fails, return results from what map? default:prontera #define MAP_DEFAULT "prontera" #define MAP_DEFAULT_X 150 #define MAP_DEFAULT_Y 150 diff --git a/src/common/mmo.h b/src/common/mmo.h index d45dea212..172b27b15 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -51,13 +51,14 @@ #define PACKETVER 20120418 #endif -/// comment following line if your client is NOT ragexeRE (required because of conflicting packets in ragexe vs ragexeRE) +// Comment the following line if your client is NOT ragexeRE (required because of conflicting packets in ragexe vs ragexeRE). #define PACKETVER_RE -//Remove/Comment this line to disable sc_data saving. [Skotlex] +// Comment the following line to disable sc_data saving. [Skotlex] #define ENABLE_SC_SAVING -//Remove/Comment this line to disable server-side hot-key saving support [Skotlex] -//Note that newer clients no longer save hotkeys in the registry! + +// Comment the following like to disable server-side hot-key saving support. [Skotlex] +// Note that newer clients no longer save hotkeys in the registry! #define HOTKEY_SAVING #if PACKETVER < 20090603 @@ -84,10 +85,10 @@ #define MAX_FAME 1000000000 #define MAX_CART 100 #define MAX_SKILL 1477 -#define MAX_SKILL_ID 10015 //[Ind/Hercules] max used skill id -#define GLOBAL_REG_NUM 256 // max permanent character variables per char -#define ACCOUNT_REG_NUM 64 // max permanent local account variables per account -#define ACCOUNT_REG2_NUM 16 // max permanent global account variables per account +#define MAX_SKILL_ID 10015 // [Ind/Hercules] max used skill ID +#define GLOBAL_REG_NUM 256 // Max permanent character variables per char +#define ACCOUNT_REG_NUM 64 // Max permanent local account variables per account +#define ACCOUNT_REG2_NUM 16 // Max permanent global account variables per account //Should hold the max of GLOBAL/ACCOUNT/ACCOUNT2 (needed for some arrays that hold all three) #define MAX_REG_NUM 256 #define DEFAULT_WALK_SPEED 150 @@ -96,16 +97,16 @@ #define MAX_STORAGE 600 #define MAX_GUILD_STORAGE 600 #define MAX_PARTY 12 -#define MAX_GUILD 16+10*6 // increased max guild members +6 per 1 extension levels [Lupus] -#define MAX_GUILDPOSITION 20 // increased max guild positions to accomodate for all members [Valaris] (removed) [PoW] +#define MAX_GUILD 16+10*6 // Increased max guild members +6 per 1 extension levels [Lupus] +#define MAX_GUILDPOSITION 20 // Increased max guild positions to accomodate for all members [Valaris] (removed) [PoW] #define MAX_GUILDEXPULSION 32 #define MAX_GUILDALLIANCE 16 -#define MAX_GUILDSKILL 15 // increased max guild skills because of new skills [Sara-chan] +#define MAX_GUILDSKILL 15 // Increased max guild skills because of new skills [Sara-chan] #define MAX_GUILDLEVEL 50 -#define MAX_GUARDIANS 8 //Local max per castle. [Skotlex] -#define MAX_QUEST_DB 2400 //Max quests that the server will load -#define MAX_QUEST_OBJECTIVES 3 //Max quest objectives for a quest -#define MAX_START_ITEMS 32 //Max number of items allowed to be given to a char whenever it's created. [mkbu95] +#define MAX_GUARDIANS 8 // Local max per castle. [Skotlex] +#define MAX_QUEST_DB 2400 // Max quests that the server will load +#define MAX_QUEST_OBJECTIVES 3 // Max quest objectives for a quest +#define MAX_START_ITEMS 32 // Max number of items allowed to be given to a char whenever it's created. [mkbu95] // for produce #define MIN_ATTRIBUTE 0 @@ -124,43 +125,43 @@ #define NAME_LENGTH (23 + 1) //For item names, which tend to have much longer names. #define ITEM_NAME_LENGTH 50 -//For Map Names, which the client considers to be 16 in length including the .gat extension +//For Map Names, which the client considers to be 16 in length including the .gat extension. #define MAP_NAME_LENGTH (11 + 1) #define MAP_NAME_LENGTH_EXT (MAP_NAME_LENGTH + 4) #define MAX_FRIENDS 40 #define MAX_MEMOPOINTS 3 -//Size of the fame list arrays. +// Size of the fame list arrays. #define MAX_FAME_LIST 10 -//Limits to avoid ID collision with other game objects +// Limits to avoid ID collision with other game objects #define START_ACCOUNT_NUM 2000000 #define END_ACCOUNT_NUM 100000000 #define START_CHAR_NUM 150000 -//Guilds +// Guilds #define MAX_GUILDMES1 60 #define MAX_GUILDMES2 120 -//Base Homun skill. +// Base Homun skill. #define HM_SKILLBASE 8001 #define MAX_HOMUNSKILL 43 -#define MAX_HOMUNCULUS_CLASS 52 //[orn], Increased to 60 from 16 to allow new Homun-S. +#define MAX_HOMUNCULUS_CLASS 52 // [orn] Increased to 60 from 16 to allow new Homun-S. #define HM_CLASS_BASE 6001 #define HM_CLASS_MAX (HM_CLASS_BASE+MAX_HOMUNCULUS_CLASS-1) -//Mail System +// Mail System #define MAIL_MAX_INBOX 30 #define MAIL_TITLE_LENGTH 40 #define MAIL_BODY_LENGTH 200 -//Mercenary System +// Mercenary System #define MC_SKILLBASE 8201 #define MAX_MERCSKILL 40 #define MAX_MERCENARY_CLASS 61 -//Elemental System +// Elemental System #define MAX_ELEMENTALSKILL 42 #define EL_SKILLBASE 8401 #define MAX_ELESKILLTREE 3 @@ -186,7 +187,7 @@ enum item_types { }; -//Questlog system [Kevin] [Inkfish] +// Questlog system [Kevin] [Inkfish] typedef enum quest_state { Q_INACTIVE, Q_ACTIVE, Q_COMPLETE } quest_state; struct quest { @@ -200,7 +201,7 @@ struct item { int id; short nameid; short amount; - unsigned short equip; // location(s) where item is equipped (using enum equip_pos for bitmasking) + unsigned short equip; // Location(s) where item is equipped (using enum equip_pos for bitmasking). char identify; char refine; char attribute; @@ -220,8 +221,8 @@ enum e_skill_flag SKILL_FLAG_PERMANENT, SKILL_FLAG_TEMPORARY, SKILL_FLAG_PLAGIARIZED, - SKILL_FLAG_REPLACED_LV_0, // temporary skill overshadowing permanent skill of level 'N - SKILL_FLAG_REPLACED_LV_0', - SKILL_FLAG_PERM_GRANTED, // permanent, granted through someway e.g. script + SKILL_FLAG_REPLACED_LV_0, // Temporary skill overshadowing permanent skill of level 'N - SKILL_FLAG_REPLACED_LV_0', + SKILL_FLAG_PERM_GRANTED, // Permanent, granted through someway (e.g. script). //... }; @@ -234,7 +235,7 @@ enum e_mmo_charstatus_opt { struct s_skill { unsigned short id; unsigned char lv; - unsigned char flag; // see enum e_skill_flag + unsigned char flag; // See enum e_skill_flag }; struct global_reg { @@ -242,14 +243,14 @@ struct global_reg { char value[256]; }; -//Holds array of global registries, used by the char server and converter. +// Holds array of global registries, used by the char server and converter. struct accreg { int account_id, char_id; int reg_num; struct global_reg reg[MAX_REG_NUM]; }; -//For saving status changes across sessions. [Skotlex] +// For saving status changes across sessions. [Skotlex] struct status_change_data { unsigned short type; //SC_type long val1, val2, val3, val4, tick; //Remaining duration. -- cgit v1.2.3-70-g09d2 From 2ff4db5f8a441f8c8b9f74dda010b605e6f50d67 Mon Sep 17 00:00:00 2001 From: Matheus Macabu Date: Sun, 19 May 2013 19:38:50 -0300 Subject: Added new packets for 2013-05-15aRagexe (thanks to Shakto!). Signed-off-by: Matheus Macabu --- src/common/cbasetypes.h | 18 ++++++++++++++++++ src/map/packets.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) (limited to 'src') diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 731a8b578..bfe8bf8f8 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -281,6 +281,24 @@ typedef char bool; //#define swap(a,b) ((a == b) || ((a ^= b), (b ^= a), (a ^= b))) // Avoid "value computed is not used" warning and generates the same assembly code #define swap(a,b) if (a != b) ((a ^= b), (b ^= a), (a ^= b)) +#if 0 //to be activated soon, more tests needed on how VS works with the macro above +#ifdef WIN32 +#undef swap +#define swap(a,b)__asm \ +{ \ + __asm mov eax, dword ptr [a] \ + __asm cmp eax, dword ptr [b] \ + __asm je _ret \ + __asm xor eax, dword ptr [b] \ + __asm mov dword ptr [a], eax \ + __asm xor eax, dword ptr [b] \ + __asm mov dword ptr [b], eax \ + __asm xor eax, dword ptr [a] \ + __asm mov dword ptr [a], eax \ + __asm _ret: \ +} +#endif +#endif #ifndef max #define max(a,b) (((a) > (b)) ? (a) : (b)) diff --git a/src/map/packets.h b/src/map/packets.h index 7e14305b7..60ee8c7ca 100644 --- a/src/map/packets.h +++ b/src/map/packets.h @@ -2086,4 +2086,39 @@ packet(0x020d,-1); // New Packets End #endif +//2013-05-15aRagexe (Shakto) +#if PACKETVER >= 20130515 + // Shuffle Start + packet(0x0369,7,clif->pActionRequest,2,6); + packet(0x083C,10,clif->pUseSkillToId,2,4,6); + packet(0x0437,5,clif->pWalkToXY,2); + packet(0x035F,6,clif->pTickSend,2); + packet(0x0362,5,clif->pChangeDir,2,4); + packet(0x08A1,6,clif->pTakeItem,2); + packet(0x0944,6,clif->pDropItem,2,4); + packet(0x0887,8,clif->pMoveToKafra,2,4); + packet(0x08AC,8,clif->pMoveFromKafra,2,4); + packet(0x0438,10,clif->pUseSkillToPos,2,4,6,8); + packet(0x0366,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10); + packet(0x096A,6,clif->pGetCharNameRequest,2); + packet(0x0368,6,clif->pSolveCharName,2); + packet(0x0838,12,clif->pSearchStoreInfoListItemClick,2,6,10); + packet(0x0835,2,clif->pSearchStoreInfoNextPage,0); + packet(0x0819,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15); + packet(0x0811,-1,clif->pReqTradeBuyingStore,2,4,8,12); + packet(0x0360,6,clif->pReqClickBuyingStore,2); + packet(0x0817,2,clif->pReqCloseBuyingStore,0); + packet(0x0815,-1,clif->pReqOpenBuyingStore,2,4,8,9,89); + packet(0x092D,41,clif->pPartyBookingRegisterReq,2,4); + //packet(0x08AA,8); // CZ_JOIN_BATTLE_FIELD + packet(0x0963,-1,clif->pItemListWindowSelected,2,4,8); + packet(0x0943,19,clif->pWantToConnection,2,6,10,14,18); + packet(0x0947,26,clif->pPartyInvite2,2); + //packet(0x0862,4); // CZ_GANGSI_RANK + packet(0x0962,26,clif->pFriendsListAdd,2); + packet(0x0931,5,clif->pHomMenu,2,4); + packet(0x093E,36,clif->pStoragePassword,0); + // Shuffle End +#endif + #endif /* _PACKETS_H_ */ -- cgit v1.2.3-70-g09d2 From c1dbdcbe3edee8ecdf259ea77f26ae02338a0903 Mon Sep 17 00:00:00 2001 From: Mysteries Date: Sun, 19 May 2013 21:17:12 -0400 Subject: Slight adjustments --- conf/channels.conf | 42 +++++++++++++++++++++++------------------- conf/map-server.conf | 2 +- conf/messages.conf | 16 +++++++++++----- conf/packet.conf | 10 ++++++---- doc/atcommands.txt | 2 +- doc/ea_job_system.txt | 2 +- doc/effect_list.txt | 2 +- doc/item_bonus.txt | 2 +- doc/item_db.txt | 2 +- doc/map_cache.txt | 2 +- doc/md5_hashcheck.txt | 2 +- doc/mob_db_mode_list.txt | 2 +- doc/packet_struct_notation.txt | 2 +- doc/permissions.txt | 2 +- doc/quest_variables.txt | 2 +- doc/script_commands.txt | 2 +- doc/whisper_sys.txt | 2 +- doc/woe_time_explanation.txt | 2 +- src/map/map.h | 34 +++++++++++++++++----------------- src/map/skill.h | 30 +++++++++++++++--------------- 20 files changed, 87 insertions(+), 75 deletions(-) (limited to 'src') diff --git a/conf/channels.conf b/conf/channels.conf index 3584fc2ea..f17d2aed1 100644 --- a/conf/channels.conf +++ b/conf/channels.conf @@ -8,21 +8,23 @@ //= //= http://hercules.ws/board/ //==================================================== -//= http://hercules.ws/board/topic/316-introducing-hercules-channel-system/ +//================= More Information ================= +// http://hercules.ws/board/topic/316-introducing-hercules-channel-system/ +//==================================================== chsys: ( { - /* default channels (available on boot) */ + /* Default Channels (available on boot) */ default_channels: { /* channel_name : channel_messages_color */ - main: "Orange" /* available as #main */ - support: "Blue" /* available as #support */ - trade: "Red" /* available as #trade */ - offtopic: "Cyan" /* available as #offtopic */ - /* as many channels as you like */ + main: "Orange" /* Available as #main */ + support: "Blue" /* Available as #support */ + trade: "Red" /* Available as #trade */ + offtopic: "Cyan" /* Available as #offtopic */ + /* You may add as many channels as you like */ } - /* colors available */ + /* Colors Available */ colors: { - Default: "0xffffff" /* custom channels will use the first in the list unless a font is selected thru @channel */ + Default: "0xffffff" /* Custom channels use the first color listed unless a font is selected through @channel. */ Red: "0xff0000" Blue: "0x83cfe9" Orange: "0xe57c00" @@ -31,22 +33,25 @@ chsys: ( Green: "0x28bf00" Light_Green: "0x3dff98" Normal: "0x00ff00" - /* as many colors as you like */ + /* As many colors as you like */ } - /* allow users to create their own (private) channels through @channels command? */ + /* Allow users to create their own (private) channels through @channels command? */ /* (must also allow players to use @channels in groups.conf) */ allow_user_channel_creation: true - /* "map_local_channel" is a instanced channel unique to each map */ + + /* "map_local_channel" is a instanced channel unique to each map. */ map_local_channel: true - map_local_channel_name: "map" /* available as #map */ + map_local_channel_name: "map" /* Available as #map */ map_local_channel_color: "Yellow" - map_local_channel_autojoin: true /* can disable autojoin in specific maps through a mapflag or zone */ + map_local_channel_autojoin: true /* You can disable autojoin in specific maps through a mapflag or zone. */ + /* "ally_channel" is a channel shared by all your guild allies */ ally_channel_enabled: true - ally_channel_name: "ally" /* available as #ally */ + ally_channel_name: "ally" /* Available as #ally */ ally_channel_color: "Green" - ally_channel_autojoin: true /* will members autojoin to their respective #ally chats when they log-in? */ - /* "irc_channel" is a special channel connected to a specific chat room in any irc network */ + ally_channel_autojoin: true /* Will members autojoin to their respective #ally chats when they log-in? */ + + /* "irc_channel" is a special channel connected to a specific chat room in any irc network. */ irc_channel_enabled: false irc_channel_name: "irc" /* available as #irc */ irc_channel_color: "Light_Green" @@ -55,5 +60,4 @@ chsys: ( irc_channel_nick: "Hercules_chSysBot" /* nick the bot will use */ irc_channel_nick_pw: "" /* password to this nick (if any) to identify to nick server on the irc network */ } -) - +) \ No newline at end of file diff --git a/conf/map-server.conf b/conf/map-server.conf index d15ef8fa5..446bb0d0e 100644 --- a/conf/map-server.conf +++ b/conf/map-server.conf @@ -1,5 +1,5 @@ //-------------------------------------------------------------- -//Hercules Map-Server Configuration File +// Hercules Map-Server Configuration File //-------------------------------------------------------------- // Note: "Comments" are all text on the right side of a double slash "//" diff --git a/conf/messages.conf b/conf/messages.conf index ac2be835a..e2886a57d 100644 --- a/conf/messages.conf +++ b/conf/messages.conf @@ -1,12 +1,18 @@ -// Hercules messages.conf -// Message Configuration -// For translation, just change msg here (second line), no need to modify source code, -// or alternatively, use conf/import/msg_conf.txt +//===== Hercules Message Configuration ======================= +//= Hercules messages.conf +//===== Description: ========================================= +//= This file handles all messages set throughout the server. +//============================================================ +// For translation, just change msg here (second line), +// no need to modify source code or alternatively, +// use conf/import/msg_conf.txt. +//============================================================ // Format: // // English message // msg_number: translated message +//============================================================ -// 0-410: reserved for GM commands +// 0-410: reserved for GM commands // 500-900 reserved for others // 900-1300: @atcommand diff --git a/conf/packet.conf b/conf/packet.conf index 3528d73bb..85996f4e3 100644 --- a/conf/packet.conf +++ b/conf/packet.conf @@ -1,11 +1,13 @@ -// Hercules Sockets Configuration file -// translated (davidsiaw) - +//===== Hercules Sockets Configuration ======================= +//= Hercules Sockets Configuration File +//===== Translated by: ======================================= +// Davidsiaw +//============================================================ // Display debug reports (When something goes wrong during the report, the report is saved.) debug: no -// How long can a socket stall before closing the connection (in seconds) +// How long can a socket stall before closing the connection (in seconds)? stall_time: 60 // Maximum allowed size for clients packets in bytes (default: 24576). diff --git a/doc/atcommands.txt b/doc/atcommands.txt index b31fe4cef..1e2985f66 100644 --- a/doc/atcommands.txt +++ b/doc/atcommands.txt @@ -1,4 +1,4 @@ -//===== Hercules Documentation ================================ +//===== Hercules Documentation =============================== //= Atcommand List //===== By: ================================================== //= Hercules Dev Team diff --git a/doc/ea_job_system.txt b/doc/ea_job_system.txt index 034b4a617..997debf4d 100644 --- a/doc/ea_job_system.txt +++ b/doc/ea_job_system.txt @@ -1,4 +1,4 @@ -//===== Hercules Documentation ================================ +//===== Hercules Documentation =============================== //= eAthena Job System //===== By: ================================================== //= Skotlex diff --git a/doc/effect_list.txt b/doc/effect_list.txt index 19b323cc6..01ea2753b 100644 --- a/doc/effect_list.txt +++ b/doc/effect_list.txt @@ -1,4 +1,4 @@ -//===== Hercules Documentation ================================ +//===== Hercules Documentation =============================== //= Client Effects List //===== By: ================================================== //= Hercules Dev Team diff --git a/doc/item_bonus.txt b/doc/item_bonus.txt index 559e49414..fce54b24e 100644 --- a/doc/item_bonus.txt +++ b/doc/item_bonus.txt @@ -1,4 +1,4 @@ -//===== Hercules Documentation ================================ +//===== Hercules Documentation =============================== //= Hercules Item Bonuses List //===== By: ================================================== //= Hercules Dev Team diff --git a/doc/item_db.txt b/doc/item_db.txt index 742a27089..01c9cc011 100644 --- a/doc/item_db.txt +++ b/doc/item_db.txt @@ -1,4 +1,4 @@ -//===== Hercules Documentation ================================ +//===== Hercules Documentation =============================== //= Item Database //===== By: ================================================== //= Hercules Dev Team diff --git a/doc/map_cache.txt b/doc/map_cache.txt index 99e54ef06..19ab92a4d 100644 --- a/doc/map_cache.txt +++ b/doc/map_cache.txt @@ -1,4 +1,4 @@ -//===== Hercules Documentation ================================ +//===== Hercules Documentation =============================== //= Hercules Map Cache Builder and Format Documentation //===== By: ================================================== //= DracoRPG diff --git a/doc/md5_hashcheck.txt b/doc/md5_hashcheck.txt index 12681f367..a2dbf42fa 100644 --- a/doc/md5_hashcheck.txt +++ b/doc/md5_hashcheck.txt @@ -1,4 +1,4 @@ -//===== Hercules Documentation ================================ +//===== Hercules Documentation =============================== //= MD5 Hash Check //===== By: ================================================== //= Hercules Dev Team diff --git a/doc/mob_db_mode_list.txt b/doc/mob_db_mode_list.txt index f747e38b0..08abf800d 100644 --- a/doc/mob_db_mode_list.txt +++ b/doc/mob_db_mode_list.txt @@ -1,4 +1,4 @@ -//===== Hercules Documentation ================================ +//===== Hercules Documentation =============================== //= Hercules Monster Modes Reference //===== By: ================================================== //= Hercules Dev Team diff --git a/doc/packet_struct_notation.txt b/doc/packet_struct_notation.txt index c1598f3be..0e9c5d055 100644 --- a/doc/packet_struct_notation.txt +++ b/doc/packet_struct_notation.txt @@ -1,4 +1,4 @@ -//===== Hercules Documentation ================================ +//===== Hercules Documentation =============================== //= Packet Structure Notation //===== By: ================================================== //= Ai4rei diff --git a/doc/permissions.txt b/doc/permissions.txt index 1dbfd0056..be51a1821 100644 --- a/doc/permissions.txt +++ b/doc/permissions.txt @@ -1,4 +1,4 @@ -//===== Hercules Documentation ================================ +//===== Hercules Documentation =============================== //= Permission List //===== By: ================================================== //= Hercules Dev Team diff --git a/doc/quest_variables.txt b/doc/quest_variables.txt index 556210dca..0be144183 100644 --- a/doc/quest_variables.txt +++ b/doc/quest_variables.txt @@ -1,4 +1,4 @@ -//===== Hercules Documentation ================================ +//===== Hercules Documentation =============================== //= Permanent Quest Variables //===== By: ================================================== //= Lupus diff --git a/doc/script_commands.txt b/doc/script_commands.txt index a908b338b..269e02745 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -1,4 +1,4 @@ -//===== Hercules Documentation ================================ +//===== Hercules Documentation =============================== //= Hercules Script Commands //===== By: ================================================== //= Hercules Dev Team diff --git a/doc/whisper_sys.txt b/doc/whisper_sys.txt index c5c042f4d..3c870b543 100644 --- a/doc/whisper_sys.txt +++ b/doc/whisper_sys.txt @@ -1,4 +1,4 @@ -//===== Hercules Documentation ================================ +//===== Hercules Documentation =============================== //= NPC Whisper System //===== By: ================================================== //= lordalfa diff --git a/doc/woe_time_explanation.txt b/doc/woe_time_explanation.txt index 2b645118e..9f288eae7 100644 --- a/doc/woe_time_explanation.txt +++ b/doc/woe_time_explanation.txt @@ -1,4 +1,4 @@ -//===== Hercules Documentation ================================ +//===== Hercules Documentation =============================== //= WoE Time Explanation //===== By: ================================================== //= erKURITA diff --git a/src/map/map.h b/src/map/map.h index f524e8840..751cf62f6 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -32,7 +32,7 @@ enum E_MAPSERVER_ST { #define AREA_SIZE battle_config.area_size #define DAMAGELOG_SIZE 30 #define LOOTITEM_SIZE 10 -#define MAX_MOBSKILL 50 //Max 128, see mob skill_idx type if need this higher +#define MAX_MOBSKILL 50 // Max 128 - See mob skill_idx type if you need this higher. #define MAX_MOB_LIST_PER_MAP 128 #define MAX_EVENTQUEUE 2 #define MAX_EVENTTIMER 32 @@ -63,10 +63,10 @@ enum MOBID { MOBID_MAGICDECOY_WIND = 2046, }; -//The following system marks a different job ID system used by the map server, -//which makes a lot more sense than the normal one. [Skotlex] +// The following system marks a different job ID system used by the map server, +// which makes a lot more sense than the normal one. [Skotlex] // -//These marks the "level" of the job. +// These marks the "level" of the job. #define JOBL_2_1 0x100 //256 #define JOBL_2_2 0x200 //512 #define JOBL_2 0x300 @@ -75,13 +75,13 @@ enum MOBID { #define JOBL_BABY 0x2000 //8192 #define JOBL_THIRD 0x4000 //16384 -//for filtering and quick checking. +// For filtering and quick checking. #define MAPID_BASEMASK 0x00ff #define MAPID_UPPERMASK 0x0fff #define MAPID_THIRDMASK (JOBL_THIRD|MAPID_UPPERMASK) //First Jobs //Note the oddity of the novice: -//Super Novices are considered the 2-1 version of the novice! Novices are considered a first class type, too... +//Super Novices are considered the 2-1 version of the novice! Novices are considered a first class type. enum { //Novice And 1-1 Jobs MAPID_NOVICE = 0x0, @@ -209,31 +209,31 @@ enum { MAPID_BABY_CHASER, }; -//Max size for inputs to Graffiti, Talkie Box and Vending text prompts +// Max size for inputs to Graffiti, Talkie Box and Vending text prompts #define MESSAGE_SIZE (79 + 1) -//String length you can write in the 'talking box' +// String length you can write in the 'talking box' #define CHATBOX_SIZE (70 + 1) -//Chatroom-related string sizes +// Chatroom-related string sizes #define CHATROOM_TITLE_SIZE (36 + 1) #define CHATROOM_PASS_SIZE (8 + 1) -//Max allowed chat text length +// Max allowed chat text length #define CHAT_SIZE_MAX (255 + 1) -//24 for npc name + 24 for label + 2 for a "::" and 1 for EOS +// 24 for npc name + 24 for label + 2 for a "::" and 1 for EOS #define EVENT_NAME_LENGTH ( NAME_LENGTH * 2 + 3 ) #define DEFAULT_AUTOSAVE_INTERVAL 5*60*1000 -//Specifies maps where players may hit each other +// Specifies maps where players may hit each other #define map_flag_vs(m) (map[m].flag.pvp || map[m].flag.gvg_dungeon || map[m].flag.gvg || ((agit_flag || agit2_flag) && map[m].flag.gvg_castle) || map[m].flag.battleground) -//Specifies maps that have special GvG/WoE restrictions +// Specifies maps that have special GvG/WoE restrictions #define map_flag_gvg(m) (map[m].flag.gvg || ((agit_flag || agit2_flag) && map[m].flag.gvg_castle)) -//Specifies if the map is tagged as GvG/WoE (regardless of agit_flag status) +// Specifies if the map is tagged as GvG/WoE (regardless of agit_flag status) #define map_flag_gvg2(m) (map[m].flag.gvg || map[m].flag.gvg_castle) // No Kill Steal Protection #define map_flag_ks(m) (map[m].flag.town || map[m].flag.pvp || map[m].flag.gvg || map[m].flag.battleground) -//This stackable implementation does not means a BL can be more than one type at a time, but it's -//meant to make it easier to check for multiple types at a time on invocations such as map_foreach* calls [Skotlex] +//This stackable implementation does not mean a BL can be more than one type at a time, but it's +// meant to make it easier to check for multiple types at a time on invocations such as map_foreach* calls. [Skotlex] enum bl_type { BL_NUL = 0x000, BL_PC = 0x001, @@ -250,7 +250,7 @@ enum bl_type { BL_ALL = 0xFFF, }; -//For common mapforeach calls. Since pets cannot be affected, they aren't included here yet. +// For common mapforeach calls. Since pets cannot be affected, they aren't included here yet. #define BL_CHAR (BL_PC|BL_MOB|BL_HOM|BL_MER|BL_ELEM) enum npc_subtype { WARP, SHOP, SCRIPT, CASHSHOP, TOMB }; diff --git a/src/map/skill.h b/src/map/skill.h index 553dabd6d..c585bbb3a 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -81,14 +81,14 @@ enum e_skill_nk { //Constants to identify a skill's inf2 value. enum e_skill_inf2 { INF2_QUEST_SKILL = 0x0001, - INF2_NPC_SKILL = 0x0002, //NPC skills are those that players can't have in their skill tree. + INF2_NPC_SKILL = 0x0002, // NPC skills are those that players can't have in their skill tree. INF2_WEDDING_SKILL = 0x0004, INF2_SPIRIT_SKILL = 0x0008, INF2_GUILD_SKILL = 0x0010, INF2_SONG_DANCE = 0x0020, INF2_ENSEMBLE_SKILL = 0x0040, INF2_TRAP = 0x0080, - INF2_TARGET_SELF = 0x0100, //Refers to ground placed skills that will target the caster as well (like Grandcross) + INF2_TARGET_SELF = 0x0100, // Refers to ground placed skills that will target the caster as well (like Grandcross) INF2_NO_TARGET_SELF = 0x0200, INF2_PARTY_ONLY = 0x0400, INF2_GUILD_ONLY = 0x0800, @@ -107,19 +107,19 @@ enum e_skill_display { }; enum { - UF_DEFNOTENEMY = 0x0001, // If 'defunit_not_enemy' is set, the target is changed to 'friend' - UF_NOREITERATION = 0x0002, // Spell cannot be stacked - UF_NOFOOTSET = 0x0004, // Spell cannot be cast near/on targets - UF_NOOVERLAP = 0x0008, // Spell effects do not overlap - UF_PATHCHECK = 0x0010, // Only cells with a shootable path will be placed - UF_NOPC = 0x0020, // May not target players - UF_NOMOB = 0x0040, // May not target mobs - UF_SKILL = 0x0080, // May target skills - UF_DANCE = 0x0100, // Dance - UF_ENSEMBLE = 0x0200, // Duet - UF_SONG = 0x0400, // Song - UF_DUALMODE = 0x0800, // Spells should trigger both ontimer and onplace/onout/onleft effects. - UF_RANGEDSINGLEUNIT = 0x2000 // hack for ranged layout, only display center + UF_DEFNOTENEMY = 0x0001, // If 'defunit_not_enemy' is set, the target is changed to 'friend' + UF_NOREITERATION = 0x0002, // Spell cannot be stacked + UF_NOFOOTSET = 0x0004, // Spell cannot be cast near/on targets + UF_NOOVERLAP = 0x0008, // Spell effects do not overlap + UF_PATHCHECK = 0x0010, // Only cells with a shootable path will be placed + UF_NOPC = 0x0020, // May not target players + UF_NOMOB = 0x0040, // May not target mobs + UF_SKILL = 0x0080, // May target skills + UF_DANCE = 0x0100, // Dance + UF_ENSEMBLE = 0x0200, // Duet + UF_SONG = 0x0400, // Song + UF_DUALMODE = 0x0800, // Spells should trigger both ontimer and onplace/onout/onleft effects. + UF_RANGEDSINGLEUNIT = 0x2000 // Hack for ranged layout, only display center }; //Returns the cast type of the skill: ground cast, castend damage, castend no damage -- cgit v1.2.3-70-g09d2 From cc6defd0abcf3a544489732255c96efdde781550 Mon Sep 17 00:00:00 2001 From: Shaktoh Date: Wed, 22 May 2013 17:25:46 +0300 Subject: Update packet.h (Ragexe ver 2013 05 22) Thx to Yommy for the packet extractor tool --- src/map/packets.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src') diff --git a/src/map/packets.h b/src/map/packets.h index 60ee8c7ca..555f45c19 100644 --- a/src/map/packets.h +++ b/src/map/packets.h @@ -2121,4 +2121,39 @@ packet(0x020d,-1); // Shuffle End #endif +//2013-05-22Ragexe (Shakto) +#if PACKETVER >= 20130522 + // Shuffle Start + packet(0x08A2,7,clif->pActionRequest,2,6); + packet(0x095C,10,clif->pUseSkillToId,2,4,6); + packet(0x0360,5,clif->pWalkToXY,2); + packet(0x07EC,6,clif->pTickSend,2); + packet(0x0925,5,clif->pChangeDir,2,4); + packet(0x095E,6,clif->pTakeItem,2); + packet(0x089C,6,clif->pDropItem,2,4); + packet(0x08A3,8,clif->pMoveToKafra,2,4); + packet(0x087E,8,clif->pMoveFromKafra,2,4); + packet(0x0811,10,clif->pUseSkillToPos,2,4,6,8); + packet(0x0964,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10); + packet(0x08A6,6,clif->pGetCharNameRequest,2); + packet(0x0369,6,clif->pSolveCharName,2); + packet(0x093E,12,clif->pSearchStoreInfoListItemClick,2,6,10); + packet(0x08AA,2,clif->pSearchStoreInfoNextPage,0); + packet(0x095B,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15); + packet(0x0952,-1,clif->pReqTradeBuyingStore,2,4,8,12); + packet(0x0368,6,clif->pReqClickBuyingStore,2); + packet(0x086E,2,clif->pReqCloseBuyingStore,0); + packet(0x0874,-1,clif->pReqOpenBuyingStore,2,4,8,9,89); + packet(0x089B,41,clif->pPartyBookingRegisterReq,2,4); + //packet(0x0965,8); // CZ_JOIN_BATTLE_FIELD + packet(0x086A,-1,clif->pItemListWindowSelected,2,4,8); + packet(0x08A9,19,clif->pWantToConnection,2,6,10,14,18); + packet(0x0950,26,clif->pPartyInvite2,2); + //packet(0x08AC,4); // CZ_GANGSI_RANK + packet(0x0362,26,clif->pFriendsListAdd,2); + packet(0x0926,5,clif->pHomMenu,2,4); + packet(0x088E,36,clif->pStoragePassword,0); + // Shuffle End +#endif + #endif /* _PACKETS_H_ */ -- cgit v1.2.3-70-g09d2 From d0c501816214cd604e7f7efddb8debff03c514e8 Mon Sep 17 00:00:00 2001 From: jaBote Date: Fri, 24 May 2013 00:55:00 +0200 Subject: Edited doc/script_commands.txt: - Now lines will have up to 75 characters, no more (this does not affect functions or example codes, except most comments). - Some random lines have been shortened up a bit in order to fit wherever possible, in a way that doesn't affect quality of explanation. - Removed any references to past eA/rA revisions, changed SVN references to Git (except in get_revision), and removed most references to past devs of *Athena: this text is informative, not for credits. - Removed any references to TXT servers. - Removed any references to mob control suite. - Improved a bit the part on how to obtain a GID. - Slight improvements on some commands explanations. - Corrected mes script command definition as it can show more than 1 string at once. - Improved set script command to tell the abridged method: a = 7; - Removed reference to an unused parameter (flag) in source, in guildskill script command. - Corrected an error in the rate of autobonus command (100% is 10000, not 1000 as it was before). - Added ways to get a monster's GID through 'monster' and 'areamonster' script commands. - rAthena reference removed in sprintf and sscanf functions. - Please remove cell_basilica references in sercell function if it doesn't work anymore, as said in http://hercules.ws/board/topic/546-how-to-put-safe-zone-on-some-pvp-map/?hl=cell_basilica - Removed "Whew. That's about all of them." at end of the document. Edited src/map/script.c: - Added modification to 'monster' and 'areamonster' to return GID of summoned monster. Signed-off-by: jaBote --- doc/script_commands.txt | 5000 +++++++++++++++++++++++++---------------------- src/map/script.c | 9 +- 2 files changed, 2657 insertions(+), 2352 deletions(-) (limited to 'src') diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 269e02745..c5212d4d1 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -1,4 +1,4 @@ -//===== Hercules Documentation =============================== +//===== Hercules Documentation =============================== //= Hercules Script Commands //===== By: ================================================== //= Hercules Dev Team @@ -7,22 +7,24 @@ //= Commands are sorted depending on their functionality. //============================================================ -This document is a reference manual for all the scripting commands and functions -available in current Hercules GIT. It is not a simple tutorial. When people tell -you to "Read The F***ing Manual", they mean this. - -The information was mostly acquired through looking up how things actually work -in the source code of the server, which was written by many people over time, -and lots of them don't speak English and never left any notes - or are otherwise -not available for comments. As such, anything written in here might not be -correct, it is only correct to the best of our knowledge, which is limited. - -This is not a place to teach you basic programming. This document will not teach -you basic programming by itself. It's more of a reference for those who have at -least a vague idea of what they want to do and want to know what tools they have -available to do it. We've tried to keep it as simple as feasible, but if you -don't understand it, getting a clear book on programming in general will help -better than yelling around the forum for help. +This document is a reference manual for all the scripting commands and +functions available in current Hercules GIT. It is not a simple tutorial. +When people tell you to "Read The F***ing Manual", they mean this. + +The information was mostly acquired through looking up how things actually +work in the source code of the server, which was written by many people +over time, and lots of them don't speak English and never left any notes - +or are otherwise not available for comments. As such, anything written in +here might not be correct, it is only correct to the best of our +knowledge, which is limited. + +This is not a place to teach you basic programming. This document will not +teach you basic programming by itself. It's more of a reference for those +who have at least a vague idea of what they want to do and want to know +what tools they have available to do it. We've tried to keep it as simple +as feasible, but if you don't understand it, getting a clear book on +programming in general will help better than yelling around the forum for +help. A little learning never caused anyone's head to explode. @@ -35,53 +37,55 @@ The commands and functions are listed in no particular order: Descriptive text - Small example if possible. Will usually be incomplete, it's there just to - give you an idea of how it works in practice. + Small example if possible. Will usually be incomplete, it's there just + to give you an idea of how it works in practice. To find a specific command, use Ctrl+F, (or whatever keys call up a search -function in whatever you're reading this with) put an * followed by the command -name, and it should find the command description for you. +function in whatever you're reading this with) put an * followed by the +command name, and it should find the command description for you. -If you find anything omitted, please respond. :) +If you find anything omitted, please tell us. :) Syntax ------ -Throughout this document, wherever a command wants an argument, it is given in -. This doesn't mean you should type the angle brackets. :) If an -argument of a command is optional, it is given in {curly brackets}. You've -doubtlessly seen this convention somewhere, if you didn't, get used to it, -that's how big boys do it. If a command can optionally take an unspecified -number of arguments, you'll see a list like this: +Throughout this document, wherever a command wants an argument, it is +given in . This doesn't mean you should type the angle +brackets. :) If an argument of a command is optional, it is given in +{curly brackets}. You've doubtlessly seen this convention somewhere, if +you didn't, get used to it, that's how big boys do it. If a command can +optionally take an unspecified number of arguments, you'll see a list like +this: command {,...} This still means they will want to be separated by commas. -Where a command wants a string, it will be given in "quotes", if it's a number, -it will be given without them. Normally, you can put an expression, like a bunch -of functions or operators returning a value, in (round brackets) instead of most -numbers. Round brackets will not always be required, but they're often a good -idea. +Where a command wants a string, it will be given in "quotes", if it's a +number, it will be given without them. Normally, you can put an +expression, like a bunch of functions or operators returning a value, in +(round brackets) instead of most numbers. Round brackets will not always +be required, but they're often a good idea. -Wherever you refer to a map name, it's always 'mapname' or 'mapname.gat' +Wherever you refer to a map name, it's always 'mapname' or 'mapname.gat' (Please, don't use .gat suffix anymore. It's useless.) Script loading structure ------------------------ -Scripts are loaded by the map server as referenced in the 'conf/map-server.conf' -configuration file, but in the default configuration, it doesn't load any script -files itself. Instead, it loads the file 'npc/scripts_main.conf' which itself -contains references to other files. The actual scripts are loaded from txt -files, which are linked up like this: +Scripts are loaded by the map server as referenced in the +'conf/map-server.conf' configuration file, but in the default +configuration, it doesn't load any script files itself. Instead, it loads +the file 'npc/scripts_main.conf' which itself contains references to other +files. The actual scripts are loaded from txt files, which are linked up +like this: npc: -Any line like this, invoked, ultimately, by 'map-server.conf' will load up the -script contained in this file, which will make the script available. No file -will get loaded twice, to prevent possible errors. +Any line like this, invoked, ultimately, by 'map-server.conf' will load up +the script contained in this file, which will make the script available. +No file will get loaded twice, to prevent possible errors. Another configuration file option of relevance is: @@ -90,14 +94,14 @@ delnpc: This will unload a specified script filename from memory, which, while seemingly useless, may sometimes be required. -Whenever '//' is encountered in a line upon reading, everything beyond this on -that line is considered to be a comment and is ignored. This works wherever you -place it. +Whenever '//' is encountered in a line upon reading, everything beyond +this on that line is considered to be a comment and is ignored. This works +wherever you place it. // This line will be ignored when processing the script. -Block comments can also be used, where you can place /* and */ between any text you -wish Hercules to ignore. +Block comments can also be used, where you can place /* and */ between any +text you wish Hercules to ignore. Example: /* This text, @@ -105,23 +109,25 @@ Example: * is ignored, until the following * symbol is encountered: */ -The asterisks (*) in front of each line is a personal preference, and is not required. - -Upon loading all the files, the server will execute all the top-level commands -in them. No variables exist yet at this point, no commands can be called other -than those given in this section. These commands set up the basic server script -structure - create NPC objects, spawn monster objects, set map flags, etc. No -code is actually executed at this point except them. The top-level commands the -scripting are pretty confusing, since they aren't structured like you would -expect commands, command name first, but rather, normally start with a map name. - -What's more confusing about the top-level commands is that most of them use a -tab symbol to divide their arguments. - -To prevent problems and confusion, the tab symbols are written as '%TAB%' or '' -throughout this document, even though this makes the text a bit less readable. -Using an invisible symbol to denote arguments is one of the bad things about -this language, but we're stuck with it for now. :) +The asterisks (*) in front of each line is a personal preference, and is +not required. + +Upon loading all the files, the server will execute all the top-level +commands in them. No variables exist yet at this point, no commands can be +called other than those given in this section. These commands set up the +basic server script structure - create NPC objects, spawn monster objects, +set map flags, etc. No code is actually executed at this point except +them. The top-level commands the scripting are pretty confusing, since +they aren't structured like you would expect commands, command name first, +but rather, normally start with a map name. + +What's more confusing about the top-level commands is that most of them +use a tab symbol to divide their arguments. + +To prevent problems and confusion, the tab symbols are written as '%TAB%' +or '' throughout this document, even though this makes the text a bit +less readable. Using an invisible symbol to denote arguments is one of the +bad things about this language, but we're stuck with it for now. :) Here is a list of valid top-level commands: @@ -129,55 +135,57 @@ Here is a list of valid top-level commands: %TAB%mapflag%TAB% -This will, upon loading, set a specified map flag on a map you like. These are -normally in files inside 'conf/mapflag' and are loaded first, so by the time the -server's up, all the maps have the flags they should have. Map flags determine -the behavior of the map regarding various common problems, for a better -explanation, see 'setmapflag'. +This will, upon loading, set a specified map flag on a map you like. These +are normally in files inside 'npc/mapflag' and are loaded first, so by the +time the server's up, all the maps have the flags they should have. Map +flags determine the behavior of the map regarding various common problems, +for a better explanation, see 'setmapflag'. ** Create a permanent monster spawn: ,,,,%TAB%monster%TAB%%TAB%,,,,{,,} -Map name is the name of the map the monsters will spawn on. x,y are the -coordinates where the mob should spawn. If xs and ys are non-zero, they -specify the 'radius' of a spawn-rectangle area centered at x,y. -Putting zeros instead of these coordinates will spawn the monsters randomly. -Note this is only the initial spawn zone, as mobs random-walk, they are free -to move away from their specified spawn region. - -Monster name is the name the monsters will have on screen, and has no relation -whatsoever to their names anywhere else. It's the mob id that counts, which -identifies monster record in 'mob_db.txt' database of monsters. If the mob name -is given as "--ja--", the 'japanese name' field from the monster database is -used, (which, in Hercules, actually contains an English name) if it's "--en--", -it's the 'english name' from the monster database (which contains an uppercase -name used to summon the monster with a GM command). +Map name is the name of the map the monsters will spawn on. x,y are the +coordinates where the mob should spawn. If xs and ys are non-zero, they +specify the 'radius' of a spawn-rectangle area centered at x,y. Putting +zeros instead of these coordinates will spawn the monsters randomly. Note +this is only the initial spawn zone, as mobs random-walk, they are free to +move away from their specified spawn region. + +Monster name is the name the monsters will have on screen, and has no +relation whatsoever to their names anywhere else. It's the mob id that +counts, which identifies monster record in 'mob_db.txt' database of +monsters. If the mob name is given as "--ja--", the 'japanese name' field +from the monster database is used, (which, in Hercules, actually contains +an English name) if it's "--en--", it's the 'english name' from the +monster database (which contains an uppercase name used to summon the +monster with a GM command). Amount is the amount of monsters that will be spawned when this command is executed, it is affected by spawn rates in 'battle.conf'. -Delay1 and delay2 control monster respawn delays - the first one is the fixed -base respawn time, and the second is random variance on top of the base time. -Both values are given in milliseconds (1000 = 1 second). -Note that the server also enforces a minimum respawn delay of 5 seconds. +Delay1 and delay2 control monster respawn delays - the first one is the +fixed base respawn time, and the second is random variance on top of the +base time. Both values are given in milliseconds (1000 = 1 second). Note +that the server also enforces a minimum respawn delay of 5 seconds. -You can specify a custom level to use for the mob different from the one of -the database by adjoining the level after the name with a comma. eg: +You can specify a custom level to use for the mob different from the one +of the database by adjoining the level after the name with a comma. eg: "Poring,50" for a name will spawn a monster with name Poring and level 50. -Event is a script event to be executed when the mob is killed. The event must -be in the form "NPCName::OnEventName" to execute, and the event name label -should start with "On". As with all events, if the NPC is an on-touch NPC, the -player who triggers the script must be within 'trigger' range for the event to -work. +Event is a script event to be executed when the mob is killed. The event +must be in the form "NPCName::OnEventName" to execute, and the event name +label should start with "On". As with all events, if the NPC is an +on-touch NPC, the player who triggers the script must be within 'trigger' +range for the event to work. -There are two optional fields for monster size and AI. Size can be 0 (medium), -1 (small), or 2 (big). AI can be 0 (default), 1 (attack/friendly), 2 (sphere), -3 (flora), or 4 (zanzou). +There are two optional fields for monster size and AI. Size can be 0 +(medium), 1 (small), or 2 (big). AI can be 0 (default), 1 +(attack/friendly), 2 (sphere), 3 (flora), or 4 (zanzou). -Alternately, a monster spawned using 'boss_monster' instead of 'monster' is able -to be detected on the map with the SC_BOSSMAPINFO status (used by Convex Mirror). +Alternately, a monster spawned using 'boss_monster' instead of 'monster' +is able to be detected on the map with the SC_BOSSMAPINFO status (used by +Convex Mirror, item ID# 12214). ** NPC names @@ -187,13 +195,14 @@ NPC names are kinda special and are formatted this way: {::} -All NPCs need to have a unique name that is used for identification purposes. -When you have to identify a NPC by it's name, you should use . -If is not provided, use instead. +All NPCs need to have a unique name that is used for identification +purposes. When you have to identify a NPC by it's name, you should use +. If is not provided, use +instead. -The client has a special feature when displaying names: -if the display name contains a '#' character, it hides that part of the name. -ex: if your NPC is named 'Hunter#hunter1', it will be displayed as 'Hunter' +The client has a special feature when displaying names: if the display +name contains a '#' character, it hides that part of the name. +Ex: if your NPC is named 'Hunter#hunter1', it will be displayed as 'Hunter' must be at most 24 characters in length. must be at most 24 characters in length. @@ -202,16 +211,16 @@ ex: if your NPC is named 'Hunter#hunter1', it will be displayed as 'Hunter' ,,,%TAB%warp%TAB%%TAB%,,,, -This will define a warp NPC that will warp a player between maps, and while most -arguments of that are obvious, some deserve special mention. +This will define a warp NPC that will warp a player between maps, and +while most arguments of that are obvious, some deserve special mention. -SpanX and SpanY will make the warp sensitive to a character who didn't step -directly on it, but walked into a zone which is centered on the warp from -coordinates and is SpanX in each direction across the X axis and SpanY in each -direction across the Y axis. +SpanX and SpanY will make the warp sensitive to a character who didn't +step directly on it, but walked into a zone which is centered on the warp +from coordinates and is SpanX in each direction across the X axis and +SpanY in each direction across the Y axis. -Warp NPC objects also have a name, because you can use it to refer to them later -with 'enablenpc'/'disablenpc' +Warp NPC objects also have a name, because you can use it to refer to them +later with 'enablenpc'/'disablenpc'. Facing of a warp object is irrelevant, it is not used in the code and all current scripts have a zero in there. @@ -221,41 +230,42 @@ current scripts have a zero in there. ,,,%TAB%script%TAB%%TAB%,{} ,,,%TAB%script%TAB%%TAB%,,,{} -This will place an NPC object on a specified map at the specified location, and -is a top-level command you will use the most in your custom scripting. The NPCs -are triggered by clicking on them, and/or by walking in their trigger area, if -defined, see that below. - -Facing is a direction the NPC sprite will face in. Not all NPC sprites have -different images depending on the direction you look from, so for some facing -will be meaningless. Facings are counted counterclockwise in increments of 45 -degrees, where 0 means facing towards the top of the map. (So to turn the sprite -towards the bottom of the map, you use facing 4, and to make it look southeast -it's facing 5.) - -Sprite id is the sprite number used to display this particular NPC. For a full -list of sprite id numbers see http://kalen.s79.xrea.com/npc/npce.shtml You may -also use a monster's ID number instead to display a monster sprite for this NPC. -It is possible to use a job sprite as well, but you must first define it as a -monster sprite in 'mob_avail.txt', a full description on how to do this is not -in the scope of this manual. +This will place an NPC object on a specified map at the specified +location, and is a top-level command you will use the most in your custom +scripting. The NPCs are triggered by clicking on them, and/or by walking +in their trigger area, if defined. See that below. + +Facing is a direction the NPC sprite will face in. Not all NPC sprites +have different images depending on the direction you look from, so for +some facing will be meaningless. Facings are counted counterclockwise in +increments of 45 degrees, where 0 means facing towards the top of the map. +(So to turn the sprite towards the bottom of the map, you use facing 4, +and to make it look southeast it's facing 5.) + +Sprite id is the sprite number used to display this particular NPC. For a +full list of sprite id numbers see http://kalen.s79.xrea.com/npc/npce.shtml +You may also use a monster's ID number instead to display a monster sprite +for this NPC. It is possible to use a job sprite as well, but you must +first define it as a monster sprite in 'mob_avail.txt', a full description +on how to do this is not in the scope of this manual. A '-1' sprite id will make the NPC invisible (and unclickable). -A '111' sprite id will make an NPC which does not have a sprite, but is still -clickable, which is useful if you want to make a clickable object of the 3D -terrain. +A '111' sprite id will make an NPC which does not have a sprite, but is +still clickable, which is useful if you want to make a clickable object of +the 3D terrain. TriggerX and triggerY, if given, will define an area, centered on NPC and spanning triggerX cells in every direction across X and triggerY in every direction across Y. Walking into that area will trigger the NPC. If no -'OnTouch:' special label is present in the NPC code, the execution will start -from the beginning of the script, otherwise, it will start from the 'OnTouch:' -label. Monsters can also trigger the NPC, though the label 'OnTouchNPC:' is -used in this case. +'OnTouch:' special label is present in the NPC code, the execution will +start from the beginning of the script, otherwise, it will start from the +'OnTouch:' label. Monsters can also trigger the NPC, though the label +'OnTouchNPC:' is used in this case. The code part is the script code that will execute whenever the NPC is -triggered. It may contain commands and function calls, descriptions of which -compose most of this document. It has to be in curly brackets, unlike elsewhere -where we use curly brackets, these do NOT signify an optional parameter. +triggered. It may contain commands and function calls, descriptions of +which compose most of this document. It has to be in curly brackets, +unlike elsewhere where we use curly brackets, these do NOT signify an +optional parameter. ** Define a 'floating' NPC object. @@ -263,30 +273,30 @@ where we use curly brackets, these do NOT signify an optional parameter. This will define an NPC object not triggerable by normal means. This would normally mean it's pointless since it can't do anything, but there are -exceptions, mostly related to running scripts at specified time, which is what -these floating NPC objects are for. More on that below. +exceptions, mostly related to running scripts at specified time, which is +what these floating NPC objects are for. More on that below. ** Define a shop/cashshop NPC. -%TAB%shop%TAB%%TAB%,:{,:...} ,,,%TAB%shop%TAB%%TAB%,:{,:...} -This will define a shop NPC, which, when triggered (which can only be done by -clicking) will cause a shop window to come up. No code whatsoever runs in shop -NPCs and you can't change the prices otherwise than by editing the script -itself. (No variables even exist at this point of scripting, so don't even -bother trying to use them.) - -The item id is the number of item in the 'item_db.txt' database. If Price is set -to -1, the 'buy price' given in the item database will be used. Otherwise, the -price you gave will be used for this item, which is how you create differing -prices for items in different shops. - -You can alternatively use "cashshop" in place of "shop" to use the Cash Shop -interface, allowing you to buy items with special points (Currently stored as -account vars in global_reg #CASHPOINTS and #KAFRAPOINTS). -This type of shop will not allow you to sell items at it, you may only -purchase items here. The layout used to define sale items still count, and +This will define a shop NPC, which, when triggered (which can only be done +by clicking) will cause a shop window to come up. No code whatsoever runs +in shop NPCs and you can't change the prices otherwise than by editing the +script itself (no variables even exist at this point of scripting, so +don't even bother trying to use them). + +The item id is the number of item in the 'item_db.txt' database. If Price +is set to -1, the 'buy price' given in the item database will be used. +Otherwise, the price you gave will be used for this item, which is how you +create differing prices for items in different shops. + +You can alternatively use "cashshop" in place of "shop" to use the Cash +Shop interface, allowing you to buy items with special points (Currently +stored as account vars in global_reg #CASHPOINTS and #KAFRAPOINTS). This +type of shop will not allow you to sell items at it, you may only purchase +items here. The layout used to define sale items still count, and "" refers to how many points will be spent purchasing the them. ** Define an warp/shop/cashshop/NPC duplicate. @@ -301,25 +311,25 @@ This will duplicate an warp/shop/cashshop/NPC referred to by 'label'. Warp duplicates inherit the target location. Shop/cashshop duplicates inherit the item list. NPC duplicates inherit the script code. -The rest (name, location, facing, sprite ID, span/trigger area) -is obtained from the definition of the duplicate (not inherited). +The rest (name, location, facing, sprite ID, span/trigger area) is +obtained from the definition of the duplicate (not inherited). ** Define a function object function%TAB%script%TAB%%TAB%{} -This will define a function object, callable with the 'callfunc' command (see -below). This object will load on every map server separately, so you can get at -it from anywhere. It's not possible to call the code in this object by -anything other than the 'callfunc' script command. - -The code part is the script code that will execute whenever the function is -called with 'callfunc'. It has to be in curly brackets, unlike elsewhere where -we use curly brackets, these do NOT signify an optional parameter. +This will define a function object, callable with the 'callfunc' command +(see below). This object will load on every map server separately, so you +can get at it from anywhere. It's not possible to call the code in this +object by anything other than the 'callfunc' script command. +The code part is the script code that will execute whenever the function +is called with 'callfunc'. It has to be in curly brackets, unlike +elsewhere where we use curly brackets, these do NOT signify an optional +parameter. Once an object is defined which has a 'code' field to it's definition, it -contains script commands which can actually be triggered and executed. +contains script commands which can actually be triggered and executed. ~ RID? GID? ~ @@ -328,82 +338,83 @@ What a RID is and why do you need to know Most scripting commands and functions will want to request data about a character, store variables referenced to that character, send stuff to the -client connected to that specific character. Whenever a script is invoked by a -character, it is passed a so-called RID - this is the account ID number of a -character that caused the code to execute by clicking on it, walking into it's -OnTouch zone, or otherwise. - -If you are only writing common NPCs, you don't need to bother with it. However, -if you use functions, if you use timers, if you use clock-based script -activation, you need to be aware of all cases when a script execution can be -triggered without a RID attached. This will make a lot of commands and functions -unusable, since they want data from a specific character, want to send stuff to -a specific client, want to store variables specific to that character, and they -would not know what character to work on if there's no RID. - -Unless you use 'attachrid' to explicitly attach a character to the script first. +client connected to that specific character. Whenever a script is invoked +by a character, it is passed a so-called RID - this is the account ID +number of a character that caused the code to execute by clicking on it, +walking into it's OnTouch zone, or otherwise. + +If you are only writing common NPCs, you don't need to bother with it. +However, if you use functions, if you use timers, if you use clock-based +script activation, you need to be aware of all cases when a script +execution can be triggered without a RID attached. This will make a lot of +commands and functions unusable, since they want data from a specific +character, want to send stuff to a specific client, want to store +variables specific to that character, and they would not know what +character to work on if there's no RID. + +Unless you use 'attachrid' to explicitly attach a character to the script +first (see player-related commands). Whenever we say 'invoking character', we mean 'the character who's RID is -attached to the running script. The script function "playerattached" can be -used to check which is the currently attached player to the script (it will -return 0 if the there is no player attached or the attached player no longer -is logged on to the map-server). +attached to the running script. The script function "playerattached" can +be used to check which is the currently attached player to the script (it +will return 0 if the there is no player attached or the attached player no +longer is logged on to the map-server). But what about GID? --- ---- ----- ---- -GID stands for the Game ID of something, this can either be the GID obtained -through mobspawn (mob control commands) or the account ID of a character. -Another way would be to right click on a mob, -NPC or char as GM sprited char to view the GID. - -This is mostly used for the new version of skill and the mob control commands -implemented (but NEVER documented by Lance. Shame on you...). +GID stands for the Game ID of something, this can either be the GID of a +mob obtained through the monster script command (if only summoned one), +the GID of a NPC obtained through the getnpcid script command or the +account ID of a character (same as its RID). Another way would be to right +click on a mob, NPC or char as GM sprited char to view its GID. Item and pet scripts -------------------- -Each item in the item database has three special fields - Script , OnEquip_Script -and OnUnequip_Script. The first is script code run every time a character equips the item, -with the RID of the equipping character. Every time they unequip an item, all -temporary bonuses given by the script commands are cleared, and all the scripts -are executed once again to rebuild them. This also happens in several other -situations (like upon login) but the full list is currently unknown. +Each item in the item database has three special fields - Script, +OnEquip_Script and OnUnequip_Script. The first is script code run every +time a character equips the item, with the RID of the equipping character. +Every time they unequip an item, all temporary bonuses given by the script +commands are cleared, and all the scripts are executed once again to +rebuild them. This also happens in several other situations (like upon +login) but the full list is currently unknown. -OnEquip_Script is a piece of script code run whenever the item is used by a character -by double-clicking on it. OnUnequip_Script runs whenever the -equipment is unequip by a character +OnEquip_Script is a piece of script code run whenever the item is used by +a character by double-clicking on it. OnUnequip_Script runs whenever the +equipment is unequipped by a character. -Not all script commands work properly in the item scripts. Where commands and -functions are known to be meant specifically for use in item scripts, they are -described as such. +Not all script commands work properly in the item scripts. Where commands +and functions are known to be meant specifically for use in item scripts, +they are described as such. Every pet in the pet database has a PetScript field, which determines pet -behavior. It is invoked wherever a pet of the specified type is spawned. -(hatched from an egg, or loaded from the char server when a character who had -that pet following them connects) This may occur in some other situations as -well. Don't expect anything other than commands definitely marked as usable in -pet scripts to work in there reliably. +behavior. It is invoked wherever a pet of the specified type is spawned +(hatched from an egg, or loaded from the char server when a character who +had that pet following them connects). This may occur in some other +situations as well. Don't expect anything other than commands definitely +marked as usable in pet scripts to work in there reliably. Numbers ------- -Beside the common decimal numbers, which are nothing special whatsoever (though -do not expect to use fractions, since ALL numbers are integer in this language), -the script engine also handles hexadecimal numbers, which are otherwise -identical. Writing a number like '0x' will make it recognized as a -hexadecimal value. Notice that 0x10 is equal to 16. Also notice that if you try -to 'mes 0x10' it will print '16'. +Beside the common decimal numbers, which are nothing special whatsoever +(though do not expect to use fractions, since ALL numbers are integer in +this language), the script engine also handles hexadecimal numbers, which +are otherwise identical. Writing a number like '0x' will make +it recognized as a hexadecimal value. Notice that 0x10 is equal to 16. +Also notice that if you try to 'mes 0x10' it will print '16'. This is not used much, but it pays to know about it. Variables --------- -The meat of every programming language is variables - places where you store -data. +The meat of every programming language is variables - places where you +store data. -In the Hercules scripting language, variable names are not case sensitive. +In Hercules scripting language, variable names are not case sensitive. Variables are divided into and uniquely identified by the combination of: prefix - determines the scope and extent (or lifetime) of the variable @@ -423,51 +434,45 @@ permanent - They still exist when the server resets. temporary - They cease to exist when the server resets. Prefix: scope and extent -nothing - A permanent variable attached to the character, the default variable - type. They are stored with all the account data in "save\athena.txt" - in TXT versions and in the SQL versions in the `global_reg_value` - table using type 3. -"@" - A temporary variable attached to the character. - SVN versions before 2094 revision and RC5 version will also treat - 'l' as a temporary variable prefix, so beware of having variable - names starting with 'l' if you want full backward compatibility. -"$" - A global permanent variable. - They are stored in "save\mapreg.txt" or database table `mapreg`, - depending on server type. +nothing - A permanent variable attached to the character, the default + variable type. They are stored with all the account data in the + `global_reg_value` table using type 3. +"@" - A temporary variable attached to the character. + They disappear when the character logs out. +"$" - A global permanent variable. + They are stored in database table `mapreg`. "$@" - A global temporary variable. - This is important for scripts which are called with no RID + Thhey are important for scripts which are called with no RID attached, that is, not triggered by a specific character object. "." - A NPC variable. - They exist in the NPC and disappear when the server restarts or the - NPC is reloaded. Can be accessed from inside the NPC or by calling - 'getvariableofnpc'. Function objects can also have .variables which - are accessible from inside the function, however 'getvariableofnpc' - does NOT work on function objects. + They exist in the NPC and disappear when the server restarts or + the NPC is reloaded. Can be accessed from inside the NPC or by + calling 'getvariableofnpc'. Function objects can also have + .variables which are accessible from inside the function, + however 'getvariableofnpc' does NOT work on function objects. ".@" - A scope variable. - They are unique to the instance and scope. Each instance has it's - own scope that ends when the script ends. Calling a function with - callsub/callfunc starts a new scope, returning from the function - ends it. When a scope ends, it's variables are converted to values - ('return .@var;' returns a value, not a reference). -"'" - An instance variable - These are used with the instancing system, and are unique to each - party's instance. + They are unique to the instance and scope. Each instance has + its own scope that ends when the script ends. Calling a + function with callsub/callfunc starts a new scope, returning + from the function ends it. When a scope ends, it's variables + are converted to values ('return .@var;' returns a value, not a + reference). +"'" - An instance variable. + These are used with the instancing system, and are unique to + each party's instance. "#" - A permanent local account variable. - They are stored with all the account data in "save\accreg.txt" in - TXT versions and in the SQL versions in the 'global_reg_value' - table using type 2. -"##" - A permanent global account variable stored by the login server. - They are stored in "save\account.txt" and in the SQL versions in the - 'global_reg_value' table, using type 1. The only difference you will - note from normal # variables is when you have multiple char-servers - connected to the same login server. The # variables are unique to - each char-server, while the ## variables are shared by all these - char-servers. + They are stored in the 'global_reg_value' table using type 2. +"##" - A permanent global account variable stored by the login server. + They are stored in the 'global_reg_value' table, using type 1. + The only difference you will note from normal # variables is + when you have multiple char-servers connected to the same + login-server. The # variables are unique to each char-server, + while the ## variables are shared by all these char-servers. Postfix: integer or string -nothing - integer variable, can store positive and negative numbers, but only - whole numbers (so don't expect to do any fractional math) -'$' - string variable, can store text +nothing - integer variable, can store positive and negative numbers, but + only whole numbers (so don't expect to do any fractional math). +'$' - string variable, can store text. Examples: name - permanent character integer variable @@ -490,14 +495,15 @@ $@name$ - temporary global string variable If a variable was never set, it is considered to equal zero for integer variables or an empty string ("", nothing between the quotes) for string variables. Once you set it to that, the variable is as good as forgotten -forever, and no trace remains of it even if it was stored with character or -account data. +forever, and no trace remains of it even if it was stored with character +or account data. -Some variables are special, that is, they are already defined for you by the -scripting engine. You can see the full list somewhere in 'db/const.txt', which -is a file you should read, since it also allows you to replace lots of numbered -arguments for many commands with easier to read text. The special variables most -commonly used are all permanent character-based variables: +Some variables are special, that is, they are already defined for you by +the scripting engine. You can see the full list somewhere in +'db/const.txt', which is a file you should read, since it also allows you +to replace lots of numbered arguments for many commands with easier to +read text. The special variables most commonly used are all permanent +character-based variables: Zeny - Amount of Zeny. Hp - Current amount of hit points. @@ -510,48 +516,51 @@ BaseLevel - Character's base level. JobLevel - Character's job level. BaseExp - Amount of base experience points. JobExp - Amount of job experience points. -NextBaseExp - Amount of base experience points needed to reach the next level. -NextJobExp - Amount of job experience points needed to reach the next level. +NextBaseExp - Amount of base experience points needed to reach next level. +NextJobExp - Amount of job experience points needed to reach next level. Weight - Amount of weight the character currently carries. MaxWeight - Maximum weight the character can carry. Sex - 0 if female, 1 if male. Class - Character's job. -Upper - 0 if the character is a normal class, 1 if advanced, 2 if baby. +Upper - 0 if the character is normal class, 1 if advanced, 2 if baby. BaseClass - The character's 1-1 'normal' job, regardless of Upper value. - For example, this will return Job_Acolyte for Acolyte, Priest/Monk, - High Priest/Champion, and Arch Bishop/Sura. If the character has not - reached a 1-1 class, it will return Job_Novice. + For example, this will return Job_Acolyte for Acolyte, + Priest/Monk, High Priest/Champion, and Arch Bishop/Sura. + If the character has not reached a 1-1 class, it will return + Job_Novice. BaseJob - The character's 'normal' job, regardless of Upper value. For example, this will return Job_Acolyte for Acolyte, Baby Acolyte, and High Acolyte. -Karma - The character's karma. Karma system is not fully functional, but - this doesn't mean this doesn't work at all. Not tested. -Manner - The character's manner rating. Becomes negative if the player - utters words forbidden through the use of 'manner.txt' client-side - file. - -While these behave as variables, do not always expect to just set them - it is -not certain whether this will work for all of them. Whenever there is a command -or a function to set something, it's usually preferable to use that instead. The -notable exception is Zeny, which you can and often will address directly - -setting it will make the character own this number of Zeny. -If you try to set Zeny to a negative number, the script will be terminated with an error. +Karma - The character's karma. Karma system is not fully functional, + but this doesn't mean this doesn't work at all. Not tested. +Manner - The character's manner rating. Becomes negative if the + player utters words forbidden through the use of + 'manner.txt' client-side file. + +While these behave as variables, do not always expect to just set them - +it is not certain whether this will work for all of them. Whenever there +is a command or a function to set something, it's usually preferable to +use that instead. The notable exception is Zeny, which you can and often +will address directly - setting it will make the character own this number +of Zeny. If you try to set Zeny to a negative number, the script will be +terminated with an error. Assigning variables --------- --------- -Variables can be accessed and assigned values directly without the use of the built-in -'set' function. This means that variables can be accessed and modified much like other -programming languages. +Variables can be accessed and assigned values directly without the use of +the built-in 'set' function. This means that variables can be accessed and +modified much like other programming languages. @x = 100; @x = @y = 100; -Support for modifying variable values using 'set' is still supported (and required -to exist for this new method to work) so previous scripts will continue to work. +Support for modifying variable values using 'set' is still supported (and +required to exist for this method to work) so previous scripts will +continue working. -When assigning values, all operator methods are supported which exist in the below -'Operators' section. For instance: +When assigning values, all operator methods are supported which exist in +the below 'Operators' section. For instance: @x += 100; @x -= 100; @@ -561,58 +570,59 @@ When assigning values, all operator methods are supported which exist in the bel @x >>= 2; @x <<= 2; -Will all work. For more information on available operators, see the Operators section -described below. All operators listed there may be placed in-front of the '=' sign -when modifying variables to perform the action as required. +Will all work. For more information on available operators, see the +Operators section described below. All operators listed there may be +placed in-front of the '=' sign when modifying variables to perform the +action as required. Note: - !! Currently the scripting engine does not support directly copying array variables. - !! In order to copy arrays between variables the use of 'copyarray' function is still - !! required. + !! Currently the scripting engine does not support directly copying array + !! variables. In order to copy arrays between variables the use of + !! 'copyarray' function is still required. Strings ------- -To include symbol '"' in a string you should use prefix '\"' +To include symbol '"' in a string you should use prefix '\"'. Arrays ------ -Arrays (in Hercules at least) are essentially a set of variables going under the -same name. You can tell between the specific variables of an array with an -'array index', a number of a variable in that array: +Arrays (in Hercules at least) are essentially a set of variables going +under the same name. You can tell between the specific variables of an +array with an 'array index', a number of a variable in that array: [] -Variables stored in this way, inside an array, are also called 'array elements'. -Arrays are specifically useful for storing a set of similar data (like several -item IDs for example) and then looping through it. You can address any array -variable as if it was a normal variable: +Variables stored in this way, inside an array, are also called 'array +elements'. Arrays are specifically useful for storing a set of similar +data (like several item IDs for example) and then looping through it. You +can address any array variable as if it was a normal variable: set @arrayofnumbers[0],1; -You can also do sneaky things like using a variable (or an expression, or even a -value from an another array) to get at an array value: +You can also do sneaky things like using a variable (or an expression, or +even a value from an another array) to get at an array value: set @x,100; set @arrayofnumbers[@x],10; This will make @arrayofnumbers[100] equal to 10. -Notice that index numbering always starts with 0. Arrays cannot hold more than -128 variables. (So the last one can't have a number higher than 127) +Notice that index numbering always starts with 0. Arrays cannot hold more +than 128 variables (so the last one can't have a number higher than 127). -And array indexes probably can't be negative. Nobody tested what happens when -you try to get a negatively numbered variable from an array, but it's not going -to be pretty. :) +And array indexes probably can't be negative. Nobody tested what happens +when you try to get a negatively numbered variable from an array, but it's +not going to be pretty. :) Arrays can naturally store strings: -@menulines$[0] is the 0th element of the @menulines$ array of strings. Notice -the '$', normally denoting a string variable, before the square brackets that -denotes an array index. +@menulines$[0] is the 0th element of the @menulines$ array of strings. +Notice the '$', normally denoting a string variable, before the square +brackets that denotes an array index. Resume of the allowed variable and array scopes ------ -- --- ------- -------- --- ----- ------ @@ -659,12 +669,13 @@ Variable References Operators --------- -Operators are things you can do to variables and numbers. They are either the -common mathematical operations or conditional operators +Operators are things you can do to variables and numbers. They are either +the common mathematical operations or conditional operators: -+ - will add two numbers. If you try to add two strings, the result will be a - string glued together at the +. You can add a number to a string, and the - result will be a string. No other math operators work with strings. ++ - will add two numbers. If you try to add two strings, the result will + be a string glued together at the +. You can add a number to a string, + and the result will be a string. No other math operators work with + strings. - - will subtract two numbers. * - will multiply two numbers. / - will divide two numbers. Note that this is an integer division, i.e. @@ -672,20 +683,22 @@ common mathematical operations or conditional operators % - will give you the remainder of the division. 7%2 is equal to 1. There are also conditional operators. This has to do with the conditional -command 'if' and they are meant to return either 1 if the condition is satisfied -and 0 if it isn't. (That's what they call 'boolean' variables. 0 means 'False'. -Anything except the zero is 'True' Odd as it is, -1 and -5 and anything below -zero will also be True.) - -You can compare numbers to each other and you compare strings to each other, but -you can not compare numbers to strings. - - == - Is true if both sides are equal. For strings, it means they are the same. - >= - True if the first value is equal to, or greater than, the second value. - <= - True if the first value is equal to, or less than, the second value - > - True if the first value greater than the second value - < - True if the first value is less than the second value - != - True if the first value IS NOT equal to the second one +command 'if' and they are meant to return either 1 if the condition is +satisfied and 0 if it isn't. That's what they call 'boolean' variables. 0 +means 'False'. Anything except the zero is 'True'. Odd as it is, -1 and -5 +and anything below zero will also be True.) + +You can compare numbers to each other and you compare strings to each +other, but you can not compare numbers to strings. + + == - Is true if both sides are equal. For strings, it means they contain + the same value. + >= - True if the first value is equal to, or greater than, the second + value. + <= - True if the first value is equal to, or less than, the second value. + > - True if the first value greater than the second value. + < - True if the first value is less than the second value. + != - True if the first value IS NOT equal to the second one. Examples: @@ -693,9 +706,9 @@ Examples: 1<2 is True while 1>2 is False. @x>2 is True if @x is equal to 3. But it isn't true if @x is 2. -Only '==' and '!=' have been tested for comparing strings. Since there's no way -to code a seriously complex data structure in this language, trying to sort -strings by alphabet would be pointless anyway. +Only '==' and '!=' have been tested for comparing strings. Since there's +no way to code a seriously complex data structure in this language, trying +to sort strings by alphabet would be pointless anyway. Comparisons can be stacked in the same condition: @@ -711,34 +724,38 @@ Logical bitwise operators work only on numbers, and they are the following: << - Left shift. >> - Right shift. - Left shift moves the binary 1(s) of a number n positions to the left, - which is the same as multiplying by 2, n times. - In the other hand, Right shift moves the binary 1(s) of a number n positions - to the right, which is the same as dividing by 2, n times. + Left shift moves the binary 1(s) of a number n positions to the left, + which is the same as multiplying by 2, n times. + In the other hand, Right shift moves the binary 1(s) of a number n + positions to the right, which is the same as dividing by 2, n times. Example: set b,2; set a, b << 3; mes a; set a, a >> 2; mes a; - The first mes command would display 16, which is the same as 2 x (2 x 2 x 2) = 16. - The second mes command would display 4, which is the same as 16 / 2 = 8. 8 / 2 = 4. + The first mes command would display 16, which is the same as: + 2 x (2 x 2 x 2) = 16. + The second mes command would display 4, which is the same as: + 16 / 2 = 8; 8 / 2 = 4. & - And. | - Or. - The bitwise operator AND (&) is used to test two values against each other, - and results in setting bits which are active in both arguments. This can - be used for a few things, but in Hercules this operator is usually used to - create bit-masks in scripts. + The bitwise operator AND (&) is used to test two values against each + other, and results in setting bits which are active in both arguments. + This can be used for a few things, but in Hercules this operator is + usually used to create bit-masks in scripts. - The bitwise operator OR (|)sets to 1 a binary position if the binary position - of one of the numbers is 1. This way a variable can hold several values we can check, - known as bit-mask. A variable currently can hold up to 32 bit-masks (from position 0 - to position 1). This is a cheap(skate) and easy way to avoid using arrays to store several checks - that a player can have. + The bitwise operator OR (|) sets to 1 a binary position if the binary + position of one of the numbers is 1. This way a variable can hold + several values we can check, known as bit-mask. A variable currently + can hold up to 32 bit-masks (from position 0 to position 1). This is a + cheap(skate) and easy way to avoid using arrays to store several + checks that a player can have. - A bit-mask basically is (ab)using the variables bits to set various options in - one variable. With the current limit if variables it is possible to store 32 - different options in one variable (by using the bits on position 0 to 31). + A bit-mask basically is (ab)using the variables bits to set various + options in one variable. With the current limit in variables it is + possible to store 32 different options in one variable (by using the + bits on position 0 to 31). Example(s): - Basic example of the & operator, bit example: @@ -746,56 +763,60 @@ Logical bitwise operators work only on numbers, and they are the following: Why? : 10 = 2^1 + 2^3 (2 + 8), so in bits, it would be 1010 2 = 2^1 (2), so in bits (same size) it would be 0010 - The & (AND) operator sets bits which are active (1) in both arguments, so in the - example 1010 & 0010, only the 2^1 bit is active (1) in both. Resulting in the bit - 0010, which is 2. + The & (AND) operator sets bits which are active (1) in both + arguments, so in the example 1010 & 0010, only the 2^1 bit is + active (1) in both. Resulting in the bit 0010, which is 2. - Basic example of creating and using a bit-mask: - set @options,2|4|16; //(note: this is the same as 2+4+16, or 22) - if (@options & 1) mes "Option 1 is activated"; + set @options,2|4|16; // (note: this is the same as 2+4+16, or 22) + if (@options & 1) mes "Option 1 is activated"; if (@options & 2) mes "Option 2 is activated"; if (@options & 4) mes "Option 3 is activated"; if (@options & 8) mes "Option 4 is activated"; if (@options & 16) mes "Options 5 is activated"; - This would return the messages about option 2, 3 and 5 being shown (since we've set - the 2,4 and 16 bit to 1). + This would return the messages about option 2, 3 and 5 being shown + (since we've set the 2,4 and 16 bit to 1). ^ - Xor. - The bitwise operator XOR (eXclusive OR) sets a binary position to 0 if both - numbers have the same value in the said position. On the other hand, it - sets to 1 if they have different values in the said binary position. - This is another way of setting and unsetting bits in bit-masks. + The bitwise operator XOR (eXclusive OR) sets a binary position to 0 if + both numbers have the same value in the said position. On the other + hand, it sets to 1 if they have different values in the said binary + position. This is another way of setting and unsetting bits in + bit-masks. Example: - First let's set the quests that are currently in progress: set inProgress,1|8|16; // quest 1,8 and 16 are in progress - After playing for a bit, the player starts another quest: if( inProgress&2 == 0 ){ - // this will set the bit for quest 2 (inProgress has that bit set to 0) + // this will set the bit for quest 2 (inProgress has that bit + // set to 0) set inProgress,inProgress^2; mes "Quest 2: find a newbie and be helpful to him for an hour."; close; } - - After spending some time reading info on Xor's, the player finally completes quest 1: + - After spending some time reading info on Xor's, the player finally + completes quest 1: if( inProgress&1 && isComplete ){ - // this will unset the bit for quest 1 (inProgress has that bit set to 1) + // this will unset the bit for quest 1 (inProgress has that + // bit set to 1) set inProgress,inProgress^1; mes "Quest 1 complete!! You unlocked the secrets of the Xor dynasty, use them wisely."; close; } -Unary operators with only with a single number, which follows the operator, and -are following: +Unary operators with only with a single number, which follows the +operator, and are the following: - - Negation. - The sign of the number will be reversed. If the number was positive, it will - become negative and vice versa. + The sign of the number will be reversed. If the number was positive, + it will become negative and vice versa. Example: set .@myvar,10; mes "Negative 10 is "+(-.@myvar); ! - Logical Not. - Reverses the boolean result of an expression. True will become false and - false will become true. + Reverses the boolean result of an expression. True will become false + and false will become true. Example: if(!callfunc("F_dosomething")) @@ -805,15 +826,17 @@ are following: } ~ - Bitwise Not. - Reverses each bit in a number, also known as one's complement. Cleared bits - are set, and set bits are cleared. + Reverses each bit in a number, also known as one's complement. Cleared + bits are set, and set bits are cleared. Example: - - Ensure, that quest 2 is disabled, while keeping all other active, if they are. - set inProgress,inProgress&(~2); // same as set inProgress,inProgress&0xfffffffd + - Ensure, that quest 2 is disabled, while keeping all other active, if + they are. + set inProgress,inProgress&(~2); + // same as set inProgress,inProgress&0xfffffffd -Ternary operators take three expressions (numbers, strings or boolean), and are -following: +Ternary operators take three expressions (numbers, strings or boolean), +and are the following: ?: - Conditional operator Very useful e.g. to replace @@ -836,14 +859,14 @@ Within executable script code, some lines can be labels: